From 8854eeb911d015193881913cbdedda202ff66f20 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Sun, 3 Nov 2024 23:42:00 +0100 Subject: [PATCH] refactor new project --- app/Livewire/Project/AddEmpty.php | 17 ++++------------- .../views/livewire/project/add-empty.blade.php | 3 ++- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/app/Livewire/Project/AddEmpty.php b/app/Livewire/Project/AddEmpty.php index c3353be84..c8c063960 100644 --- a/app/Livewire/Project/AddEmpty.php +++ b/app/Livewire/Project/AddEmpty.php @@ -3,24 +3,17 @@ namespace App\Livewire\Project; use App\Models\Project; +use Livewire\Attributes\Rule; use Livewire\Component; class AddEmpty extends Component { - public string $name = ''; + #[Rule(['required', 'string', 'min:3'])] + public string $name; + #[Rule(['nullable', 'string'])] public string $description = ''; - protected $rules = [ - 'name' => 'required|string|min:3', - 'description' => 'nullable|string', - ]; - - protected $validationAttributes = [ - 'name' => 'Project Name', - 'description' => 'Project Description', - ]; - public function submit() { try { @@ -34,8 +27,6 @@ class AddEmpty extends Component return redirect()->route('project.show', $project->uuid); } catch (\Throwable $e) { return handleError($e, $this); - } finally { - $this->name = ''; } } } diff --git a/resources/views/livewire/project/add-empty.blade.php b/resources/views/livewire/project/add-empty.blade.php index 67953f219..962376df1 100644 --- a/resources/views/livewire/project/add-empty.blade.php +++ b/resources/views/livewire/project/add-empty.blade.php @@ -1,7 +1,8 @@
-
New project will have a default production environment.
+
New project will have a default production + environment.
Continue