check if the task is future or ongoing to send email and notification on deletion
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Mail\VolunteerUnassignToTaskMail;
|
||||
use App\Models\Events;
|
||||
use App\Models\Task;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
@@ -147,21 +148,23 @@ class TasksController extends Controller
|
||||
|
||||
$participants = $task->users;
|
||||
|
||||
foreach ($participants as $user) {
|
||||
broadcast(new TaskParticipationCancelled(
|
||||
$user->id,
|
||||
$task,
|
||||
$event
|
||||
));
|
||||
if (Carbon::now()->lessThanOrEqualTo($task->end)) {
|
||||
foreach ($participants as $user) {
|
||||
broadcast(new TaskParticipationCancelled(
|
||||
$user->id,
|
||||
$task,
|
||||
$event
|
||||
));
|
||||
|
||||
$data = [
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
'taskName' => $task->name,
|
||||
'start' => $event->start,
|
||||
'end' => $task->end,
|
||||
];
|
||||
Mail::to($user->email)->send(new TaskParticipationCancelledMail($data));
|
||||
$data = [
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
'taskName' => $task->name,
|
||||
'start' => $event->start,
|
||||
'end' => $task->end,
|
||||
];
|
||||
Mail::to($user->email)->send(new TaskParticipationCancelledMail($data));
|
||||
}
|
||||
}
|
||||
|
||||
$task->delete();
|
||||
|
||||
Reference in New Issue
Block a user