for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Observers;
use App\Task;
use App\TaskEvent;
use App\User;
use Auth;
use Carbon\Carbon;
class TasksObserver
{
/**
* Listen to the Task created event.
*
* @param \App\Task $task
* @return void
*/
public function created(Task $task)
if (Auth::check()) {
$username = Auth::user()->name;
name
App\User
__get
} else {
$username = User::findOrFail($task->user_id)->name;
}
TaskEvent::create([
'time' => Carbon::now(),
'task_name' => $task->name,
'user_name' => $username,
'type' => 'created',
]);
* Listen to the Task deleting event.
public function deleted(Task $task)
'type' => 'deleted',
public function retrieved(Task $task)
$task
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function retrieved(/** @scrutinizer ignore-unused */ Task $task)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
public function updated(Task $task)
'type' => 'updated',
public function saved(Task $task)
public function saved(/** @scrutinizer ignore-unused */ Task $task)