public function store(LoginRequest $request)
{
$request->authenticate();
$user = auth()->user();
$user->last_login = Carbon::now();
$user->save();
$request->session()->regenerate();
return redirect()->intended(RouteServiceProvider::HOME);
}
php artisan make:command EmailInactiveUsers
protected $signature = 'email:inactive-users';
protected $description = 'Email Inactive Users';
public function handle()
{
$limit = Carbon::now()->subDay(7);
$inactive_users = User::where('last_login', '<', '2022-02-10 09:00:00')->get();
foreach($inactive_users as $user)
{
$user->notify(new NotifyInactiveUser());
$this->info('Email send to' .$user->email);
}
// $this->info($limit);
// return 0;
}
php artisan make:notification NotifyInactiveUser
now implement (implements ShouldQueue) on Notification class.
protected $commands =[
EmailInactiveUsers::class,
];
protected function schedule(Schedule $schedule)
{
$schedule->command('email:inactive-users')->hourlyAt(17);
}
php artisan schedule:work