mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
44 lines
902 B
PHP
44 lines
902 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;
|
|
|
|
/**
|
|
* @template TModel of \App\Models\BaseModel
|
|
*/
|
|
abstract class BackfillAction
|
|
{
|
|
/**
|
|
* @param TModel $model
|
|
*/
|
|
public function __construct(protected BaseModel $model) {}
|
|
|
|
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()));
|
|
}
|
|
}
|