diff --git a/app/Http/Livewire/Form/RaidForm.php b/app/Http/Livewire/Form/RaidForm.php new file mode 100644 index 0000000..92e387b --- /dev/null +++ b/app/Http/Livewire/Form/RaidForm.php @@ -0,0 +1,78 @@ +raid = $raid; + $this->exist = $raid->exists; + } + + /** + * Validation rules + */ + protected function rules() + { + return [ + 'raid.name' => 'required|string|min:2|max:20', + ]; + } + + public function updated($property, $value) + { + $this->validateOnly($property); + } + + /** + * Returns true if this card has not been stored in the database. + */ + public function isNew() : bool + { + return !$this->exist; + } + + /** + * Submit the form, create/update card. + */ + public function submit() + { + $this->validate(); + $this->raid->save(); + + if ($this->isNew()) { + session()->flash('info', 'Raid was successfully created.'); + return redirect()->route('admin.character.index'); + } + + $this->info('Raid was successfully updated.'); + } + + /** + * Render the setup page + */ + public function render() + { + return view('form.raid') + ->layout('layouts.admin'); + } +} diff --git a/resources/views/form/raid.blade.php b/resources/views/form/raid.blade.php new file mode 100644 index 0000000..9a21bdd --- /dev/null +++ b/resources/views/form/raid.blade.php @@ -0,0 +1,17 @@ + +