%PDF- %PDF-
Direktori : /var/www/html/workeasy-api/app/Console/Commands/ |
Current File : /var/www/html/workeasy-api/app/Console/Commands/SendEmailForPendingCandidates.php |
<?php namespace Workeasy\Console\Commands; use Carbon\Carbon; use Illuminate\Console\Command; use Illuminate\Http\Request; use Illuminate\Notifications\Notifiable; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Notification; use Workeasy\Models\Interview; use Workeasy\Models\Offer; use Workeasy\Models\User; //use Workeasy\Notifications\PendingCandidate; use Workeasy\Notifications\PendingCandidateNotification; class SendEmailForPendingCandidates extends Command { use Notifiable; /** * The name and signature of the console command. * * @var string */ protected $signature = 'email:send'; /** * The console command description. * * @var string */ protected $description = 'Send email notifications to a company for pending candidates'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return mixed */ public function handle() { $check_time = Carbon::now()->subHour(); $interviews = Interview::query()->where('status', Interview::PENDING)->where('created_at', '<', $check_time)->get(); foreach ($interviews as $interview) { $user = $interview->offer->company->user; $user->notify(new PendingCandidateNotification($interview)); } } }