ldc-legaulois/app/Traits/UpdateModelStatus.php

21 lines
416 B
PHP
Raw Normal View History

2021-04-28 13:57:12 +02:00
<?php
namespace App\Traits;
use Illuminate\Database\Eloquent\Model;
/**
* This trait works with Route::bind in App service provider
* to resolve the model and the DB row
* It does not work with binder Service
*/
trait UpdateModelStatus
{
public function changePublished(Model $model)
{
$model->status = !$model->status;
$model->saveOrFail();
return redirect()->back();
}
}