for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Observers;
use App\Src\UseCases\Infra\Sql\Model\CharacteristicsModel;
use App\Src\UseCases\Infra\Sql\Model\PageModel;
use App\Src\UseCases\Infra\Sql\Model\UserCharacteristicsModel;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class PageObserver
{
public function created(PageModel $pageModel)
$pageModel
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function created(/** @scrutinizer ignore-unused */ PageModel $pageModel)
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(PageModel $pageModel)
public function updated(/** @scrutinizer ignore-unused */ PageModel $pageModel)
public function deleted(PageModel $pageModel)
Log::info('Deleting all data from the page internal id: ' . $pageModel->id);
DB::transaction(function () use($pageModel){
try {
$characteristic = CharacteristicsModel::query()->where('page_id', $pageModel->page_id)->first();
if (isset($characteristic)) {
$characteristic->delete();
if (is_file($characteristic->picturePath())) {
unlink($characteristic->picturePath());
UserCharacteristicsModel::query()->where('characteristic_id', $characteristic->id)->delete();
} catch (\Throwable $e) {
Log::emergency('Error deleting all data from the page internal id: ' . $pageModel->id);
throw $e;
});
public function restored(PageModel $pageModel)
public function restored(/** @scrutinizer ignore-unused */ PageModel $pageModel)
public function forceDeleted(PageModel $pageModel)
public function forceDeleted(/** @scrutinizer ignore-unused */ PageModel $pageModel)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.