mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
70 lines
1.6 KiB
PHP
70 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\HeaderActions\Storage\Wiki\Video\Script;
|
|
|
|
use App\Actions\Storage\Wiki\Video\Script\MoveScriptAction as MoveScript;
|
|
use App\Constants\Config\VideoConstants;
|
|
use App\Models\Wiki\Video\VideoScript;
|
|
use App\Filament\HeaderActions\Storage\Base\MoveHeaderAction;
|
|
use App\Models\BaseModel;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Arr;
|
|
use Illuminate\Support\Facades\Config;
|
|
|
|
/**
|
|
* Class MoveScriptHeaderAction.
|
|
*/
|
|
class MoveScriptHeaderAction extends MoveHeaderAction
|
|
{
|
|
/**
|
|
* Get the underlying storage action.
|
|
*
|
|
* @param VideoScript $script
|
|
* @param array $fields
|
|
* @return MoveScript
|
|
*/
|
|
protected function storageAction(BaseModel $script, array $fields): MoveScript
|
|
{
|
|
/** @var string $path */
|
|
$path = Arr::get($fields, 'path');
|
|
|
|
return new MoveScript($script, $path);
|
|
}
|
|
|
|
/**
|
|
* The name of the disk.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function disk(): string
|
|
{
|
|
return Config::get(VideoConstants::SCRIPT_DISK_QUALIFIED);
|
|
}
|
|
|
|
/**
|
|
* Resolve the default value for the path field.
|
|
*
|
|
* @return string|null
|
|
*/
|
|
protected function defaultPath(): ?string
|
|
{
|
|
$script = $this->getRecord();
|
|
|
|
return $script instanceof VideoScript
|
|
? $script->path
|
|
: null;
|
|
}
|
|
|
|
/**
|
|
* The file extension that the path must end with.
|
|
*
|
|
* @return string
|
|
*/
|
|
protected function allowedFileExtension(): string
|
|
{
|
|
return '.txt';
|
|
}
|
|
}
|