Файловый менеджер - Редактировать - /home/clickysoft/public_html/charliapp-v2.clickysoft.net/app/Observers/TaskObserver.php
Назад
<?php namespace App\Observers; use App\Models\Log; use App\Models\Task; class TaskObserver { /** * Handle the Task "created" event. * * @param \App\Models\Task $task * @return void */ public function created(Task $task) { $book_id = null; $task = Task::whereId($task->id)->first(); $chapter = $task->chapterCard; if($chapter){ $book = $chapter->book; $book_id = $book->id; } Log::create([ 'task_id' => $task->id, 'book_id' => $book_id, 'card_id' => $task->chapter_cards_id, 'status' => $task->status, 'action' => 'task is created' ]); } /** * Handle the Task "updated" event. * * @param \App\Models\Task $task * @return void */ public function updated(Task $task) { $book_id = null; $task = Task::whereId($task->id)->first(); $chapter = $task->chapterCard; if($chapter){ $book = $chapter->book; $book_id = $book->id; } Log::create([ 'task_id' => $task->id, 'book_id' => $book_id, 'card_id' => $task->chapter_cards_id, 'status' => $task->status, 'action' => 'task is updated' ]); } /** * Handle the Task "deleted" event. * * @param \App\Models\Task $task * @return void */ public function deleted(Task $task) { $book_id = null; $task = Task::whereId($task->id)->first(); if (!empty($task)){ $chapter = !empty($task->chapterCard)? $task->chapterCard : null; if(!empty($chapter)){ $book = $chapter->book; $book_id = $book->id; } Log::create([ 'task_id' => $task->id, 'book_id' => $book_id, 'card_id' => $task->chapter_cards_id, 'status' => $task->status, 'action' => 'task is deleted' ]); } } /** * Handle the Task "restored" event. * * @param \App\Models\Task $task * @return void */ public function restored(Task $task) { // } /** * Handle the Task "force deleted" event. * * @param \App\Models\Task $task * @return void */ public function forceDeleted(Task $task) { // } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка