Files
animethemes-server/app/Actions/Models/BackfillAction.php
T
2025-07-24 01:22:29 -03:00

49 lines
968 B
PHP

<?php
declare(strict_types=1);
namespace App\Actions\Models;
use App\Actions\ActionResult;
use App\Models\BaseModel;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Str;
/**
* Class BackfillAction.
*
* @template TModel of \App\Models\BaseModel
*/
abstract class BackfillAction
{
/**
* @param TModel $model
*/
public function __construct(protected BaseModel $model) {}
/**
* Handle action.
*/
abstract public function handle(): ActionResult;
/**
* Get the model the action is handling.
*
* @return TModel
*/
abstract protected function getModel(): BaseModel;
/**
* Get the relation to resources.
*/
abstract protected function relation(): Relation;
/**
* Get the human-friendly label for the underlying model.
*/
protected function label(): string
{
return Str::headline(class_basename($this->getModel()));
}
}