generated from thegrind/laravel-dockerized
34 lines
741 B
PHP
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');
|
|
}
|
|
}
|