PHP code example of nandosr98 / laravel-remarketing

1. Go to this page and download the library: Download nandosr98/laravel-remarketing 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/ */

    

nandosr98 / laravel-remarketing example snippets


return [

    'send_after_hours' => 1, // Número de horas después de las cuales se enviará el correo
    'queue_name' => 'remarketing', // Nombre de la cola
    'queue_connection' => 'redis',
    'model_related' => App\Models\MiProducto::class, // Modelo relacionado
    'model_related_property_name' => 'producto_id', // Nombre del campo de la relación
    'model_related_method_name' => 'producto', // Metodo de la relación para acceder a los datos
    'mailable_class' => RemarketingMessage::class, // Clase utilizada para enviar el correo
    'mail_name' => 'Sender Name', // Nombre del remitente del correo
    'mail_subject' => 'Subject of the email',
    'mail_view' => 'remarketing::default',
];

public function handle()
{
    Mail::send(new RemarketingMessage($this->id));
}

public function build()
{
    $remarketing = BaseRemarketing::where('id', $this->id)
        ->with(config('remarketing.model_related_method_name'))
        ->first();

    if (!$remarketing) {
        return null;
    }

    $remarketing->sent = true;
    $remarketing->save();

    return $this->view(config('remarketing.mail_view'))
                ->subject(config('remarketing.mail_subject'));
}

event(new DeleteRemarketing($remarketingId));

$package
    ->name('laravel-remarketing')
    ->hasConfigFile()
    ->hasViews()
    ->hasMigration('CreateRemarketingTable')
    ->hasCommands();

use LaravelRemarketing\LaravelRemarketing\Models\Remarketing;

BaseRemarketing::create([
    'model' => App\Models\User::class,
    'model_id' => $user->id,
]);

Artisan::call('remarketing:queue');

event(new DeleteRemarketing($remarketingId));
bash
php artisan vendor:publish --tag="remarketing-config"
php artisan vendor:publish --tag="remarketing-views"
php artisan vendor:publish --tag="remarketing-migrations"
bash
php artisan migrate
bash
php artisan remarketing:queue
bash
0 * * * * php /path/to/artisan remarketing:queue >> /dev/null 2>&1