-
app/Console/Commands/SendDueReservationsNotifications.php
Open in GitHubuse App\Models\Reservation; use App\Notifications\HostReservationStarting; use App\Notifications\UserReservationStarting; use Illuminate\Console\Command; use Illuminate\Support\Facades\Notification; class SendDueReservationsNotifications extends Command { protected $signature = 'ergodnc:send-reservations-notifications'; protected $description = 'Command description'; public function __construct() { parent::__construct(); } public function handle() { Reservation::query() ->with('office.user') ->where('status', Reservation::STATUS_ACTIVE) ->where('start_date', now()->toDateString()) ->each(function ($reservation) { Notification::send($reservation->user, new UserReservationStarting($reservation)); Notification::send($reservation->office->user, new HostReservationStarting($reservation)); }); return 0; } }