1. Go to this page and download the library: Download lopatin96/laravel-campaign library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Atin\LaravelCampaign\Traits\HasCampaign;
class User extends Authenticatable
{
use HasCampaign;
protected $casts = [
'campaign_unsubscribed_at' => 'datetime',
];
}
php artisan make:mail TestMail
use Atin\LaravelMail\Mail\Mailable;
class TestMail extends Mailable
{
public function build()
{
// Build email
}
}
use Atin\LaravelCampaign\Campaigns\Campaign;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Builder;
class TestCampaign extends Campaign
{
protected string $mailable = '\App\Mail\TestMail';
protected function buildQuery(): Builder
{
return \App\Models\User::where(function($query) {
$query->whereDate('users.trial_ends_at', '>=', now())
->whereDate('users.trial_ends_at', '<', now()->addDay());
});
}
}