ldc-volena/app/Traits/Controllers/UpdateModelPublished.php
Jérémy Munsch f3d79cf7a9
Bump with laravel base controller phpstan and phpcs
Still TODO picture sizes for seeders
2024-02-12 15:51:31 +01:00

25 lines
661 B
PHP

<?php
namespace App\Traits\Controllers;
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 UpdateModelPublished
{
/**
* Change model published.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @return \Illuminate\Http\RedirectResponse
*/
public function changePublished(Model $model)
{
$model->update(['published' => !$model->getOriginal('published')]);
return redirect()->back()->with('success', trans(__('crud.messages.publish_status_saved')));
}
}