mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-19 18:01:37 +00:00
37 lines
807 B
PHP
37 lines
807 B
PHP
<?php
|
|
|
|
namespace App\Actions\Script;
|
|
|
|
use App\Models\Script;
|
|
use App\Models\User;
|
|
|
|
class CreateScript
|
|
{
|
|
/**
|
|
* @param array<string, mixed> $input
|
|
*/
|
|
public function create(User $user, array $input): Script
|
|
{
|
|
$script = new Script([
|
|
'user_id' => $user->id,
|
|
'name' => $input['name'],
|
|
'content' => $input['content'],
|
|
'project_id' => isset($input['global']) && $input['global'] ? null : $user->current_project_id,
|
|
]);
|
|
$script->save();
|
|
|
|
return $script;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, array<string>>
|
|
*/
|
|
public static function rules(): array
|
|
{
|
|
return [
|
|
'name' => ['required', 'string', 'max:255'],
|
|
'content' => ['required', 'string'],
|
|
];
|
|
}
|
|
}
|