PHP code example of oneduo / laravel-mail-scheduler
1. Go to this page and download the library: Download oneduo/laravel-mail-scheduler 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/ */
oneduo / laravel-mail-scheduler example snippets
use App\Mail\OrderShipped;
use Oneduo\MailScheduler\Support\Facades\ScheduledEmail;
$instance = ScheduledEmail::mailable(new OrderShipped)
->to(['[email protected]'])
->save();
use App\Mail\OrderShipped;
use Oneduo\MailScheduler\Support\Facades\ScheduledEmail;
$instance = ScheduledEmail::mailable(new OrderShipped)
->to(['[email protected]'])
->encrypted() // will encrypt the mailable in database
->save();
use App\Mail\OrderShipped;
use Oneduo\MailScheduler\Support\Facades\ScheduledEmail;
$instance = ScheduledEmail::mailable(new OrderShipped)
->to(['[email protected]'])
->mailer('my_mailer') // mailer defined in config/mail.php
->save();
use App\Mail\OrderShipped;
use App\Models\Product;
use Oneduo\MailScheduler\Support\Facades\ScheduledEmail;
$product = Product::query()->first();
$instance = ScheduledEmail::mailable(new OrderShipped($product))
->to(['[email protected]'])
->encrypted() // will encrypt the mailable in database
->source($product) //
->save();
namespace App\Models\Product;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Oneduo\MailScheduler\Models\ScheduledEmail;
class Product extends Model
{
public function emails(): MorphMany
{
return $this->morphMany(ScheduledEmail::class, 'source');
}
}
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('mail-scheduler:send')
->everyMinute()
->between('08:00', '18:00');
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
sh
php artisan vendor:publish --tag="mail-scheduler-config"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.