I am trying to notify the user that enrolled in an event a day before the start date but it shows me a different error in the last line when it comes to notify(). dose anyone can help.
i have user model which contains (first_name,last_name,sex,users_phone,email, users_photo andpassword)
<?php
namespace AppConsoleCommands;
use IlluminateConsoleCommand;
use AppModelsUser;
use AppModelsevent;
use AppModelsEnrollment;
use AppMailSendMail;
use IlluminateSupportFacadesMail;
use IlluminateSupportFacadesDB;
use CarbonCarbon;
use IlluminateSupportFacadesNotification;
use IlluminateNotificationsNotifiable;
class SendNotification extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'send:notification';
/**
* The console command description.
*
* @var string
*/
protected $description = 'send automatic notification to users that enrolled in events a day before the event date';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$events = DB::select('SELECT events.start_date , enrollments.user_id , users.id, users.first_name, users.last_name, users.sex, users.users_phone, users.password, users.email FROM events , enrollments , users where events.id= event_id and enrollments.user_id=users.id');
foreach($events as $event) {
$created = new Carbon($event->start_date);
$now = Carbon::now();
if((($created->diffInHours($now))>=24 )&& (($created->diffInHours($now))<=48) && ($event->user_id == $event->id)){
app(User::class)->fill(['id' =>$event->id, 'first_name' => $event->first_name, 'last_name' => $event->last_name, 'sex' => $event->sex, 'users_phone' => $event->users_phone, 'email' => $event->email,'password' => $event->password])->notify("Your deadline is in day!");
}
}
}
}
class SendNotification extends Command.
event model (id, eventname, eventstartdate)
enrollments user_id , event_id