Hello I have table with events.
In table events I have column status with:
1) 0 - waiting
2) 1 - accepted
And column: date_start.
I need check all responses where status = 0 and send email 30 days before the start event.
Example:
I have event:
1) name street Event
2) status = 0;
3) date_start = 22.06.2018
I need send email when day will be: 22.05.2018 that is tomorrow.
I created mail:
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class NotifyApplication extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct()
{
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('emails.notify');
}
}
And I created job (NotifyJob):
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use App\User;
use Mail;
class NotifyMail implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$users = User::all();
$events = Events::all();
foreach($users as $user) {
Mail::to($request->user())->send(new NotifyApplication());
}
}
}
What I need do, that my task was realized. I need cron?