scripthost/app/Livewire/Forms/NewScript.php
Javier Feliz 74f5dc5db1
Some checks failed
tests / ci (push) Has been cancelled
linter / quality (push) Has been cancelled
Build & Push Docker Image to Registry / build (release) Failing after 3m7s
Initial test
2025-07-22 19:45:33 -04:00

34 lines
741 B
PHP

<?php
namespace App\Livewire\Forms;
use Livewire\Attributes\Validate;
use Livewire\Component;
class NewScript extends Component
{
#[Validate('required')]
public string $name = '';
#[Validate('required')]
public string $path = '';
#[Validate('required')]
public string $content = '';
public function create()
{
$this->validate();
auth()->user()->scripts()->create([
'name' => $this->name,
'path' => str($this->path)->remove('.sh')->lower()->kebab()->toString(),
'content' => $this->content
]);
$this->reset(['name', 'path', 'content']);
}
public function render()
{
return view('livewire.forms.new-script');
}
}