This commit refactors the import statements in various controllers and jobs to improve code organization and readability. Unused imports were removed, and necessary imports were added to ensure proper functionality.
36 lines
939 B
PHP
36 lines
939 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Traits\Controllers;
|
|
|
|
use App\Contracts\Executor;
|
|
use App\Cqs\Actions\Common\ToggleModelStatus;
|
|
use App\Cqs\Actions\Common\ToggleModelStatusInput;
|
|
use App\Interfaces\ModelWithStatus;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @mixin \Illuminate\Routing\Controller
|
|
*/
|
|
trait TogglesModelStatus
|
|
{
|
|
/**
|
|
* Toggles model status
|
|
*/
|
|
public function toggleStatus(
|
|
Model & ModelWithStatus $model,
|
|
ToggleModelStatus $action,
|
|
Executor $executor
|
|
): RedirectResponse {
|
|
$this->authorize('toggleStatus', $model);
|
|
|
|
$executor->execute($action, new ToggleModelStatusInput($model));
|
|
|
|
return back()->with('success', trans('crud.messages.has_been_updated', [
|
|
'model' => Str::ucfirst(trans_choice('models.classes.' . $model->getTable(), 1)),
|
|
]));
|
|
}
|
|
}
|