芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/qrafiqxcreativeagency.com/accounts/office/app/Console/Commands/SendTaskReminder.php
get(); // Loop through each company foreach ($companies as $company) { // Get current time in company's timezone $now = Carbon::now($company->timezone); // If the company has set "before_days" if ($company->before_days > 0) { $beforeDeadline = $now->clone()->subDays($company->before_days)->format('Y-m-d'); $this->sendReminders($beforeDeadline, $company); } // If the company has set "after_days" if ($company->after_days > 0) { $afterDeadline = $now->clone()->addDays($company->after_days)->format('Y-m-d'); $this->sendReminders($afterDeadline, $company); } // If the company has set "on_deadline" if ($company->on_deadline) { $onDeadline = $now->clone()->format('Y-m-d'); $this->sendReminders($onDeadline, $company); } } } /** * Send task reminders for the given date and company. * * @param string $dueDate * @param \App\Models\Company $company * * @return void */ private function sendReminders(string $dueDate, Company $company) { // Get the "completed" taskboard column for the company $completedTaskColumn = TaskboardColumn::where('company_id', $company->id) ->where('slug', 'completed') ->first(); // Get all tasks for the given date and company that are not in the "completed" column $tasks = Task::select('id') ->where('due_date', $dueDate) ->where('company_id', $company->id) ->where('board_column_id', '<>', $completedTaskColumn->id) ->get(); // Loop through each task foreach ($tasks as $task) { // Fire a TaskReminderEvent for the task event(new TaskReminderEvent($task)); } } }