diff --git a/src/app/Http/Livewire/CardForm.php b/src/app/Http/Livewire/CardForm.php new file mode 100644 index 0000000..bbcc1ca --- /dev/null +++ b/src/app/Http/Livewire/CardForm.php @@ -0,0 +1,85 @@ + 'required', + 'description' => 'required', + 'type' => 'required', + 'value' => 'required', + 'meaning' => 'required', + 'meaning_rev' => 'required', + ]; + + public function storeCard() + { + $this->validate(); + $card = Card::create([ + 'name' => $this->name, + 'description' => $this->description, + 'type' => $this->type, + 'value' => $this->value, + 'meaning' => $this->meaning, + 'meaning_rev' => $this->meaning_rev + ]); + $this->reset(); + } + + public function edit($id) + { + $card = Card::find($id); + $this->card_id = $card->id; + $this->name = $card->name; + $this->description = $card->description; + $this->type = $card->type; + $this->value = $card->value; + $this->meaning = $card->meaning; + $this->meaning_rev = $card->meaning_rev; + } + + public function update() + { + $card = Card::updateOrCreate( + [ + 'id' => $this->card_id, + ], + [ + 'name' => $this->name, + 'description' => $this->description, + 'type' => $this->type, + 'value' => $this->value, + 'meaning' => $this->meaning, + 'meaning_rev' => $this->meaning_rev + ], + + ); + + $this->reset(); + } + + public function destroy($id) + { + Card::destroy($id); + } + + public function render() + { + return view('livewire.card-form', ['cards' => Card::latest()->paginate(10)]); + } +} diff --git a/src/resources/views/cards.blade.php b/src/resources/views/cards.blade.php new file mode 100644 index 0000000..6775b5f --- /dev/null +++ b/src/resources/views/cards.blade.php @@ -0,0 +1,24 @@ + + + + + Karten + +
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+ + diff --git a/src/resources/views/livewire/card-form.blade.php b/src/resources/views/livewire/card-form.blade.php new file mode 100644 index 0000000..01ffdd9 --- /dev/null +++ b/src/resources/views/livewire/card-form.blade.php @@ -0,0 +1,125 @@ +
+

Card

+
+
+
+ @csrf +
+ + + @error('name') + {{ $message }} + @enderror +
+
+ + + @error('description') + {{ $message }} + @enderror +
+
+ + + @error('type') + {{ $message }} + @enderror +
+
+ + + @error('value') + {{ $message }} + @enderror +
+
+ + + @error('meaning') + {{ $message }} + @enderror +
+
+ + + @error('meaning_rev') + {{ $message }} + @enderror +
+ + +
+
+
+
+
+ + + + + + + + + + + + @foreach($cards as $card) + + + + + + + + + + + @endforeach + +
+ Id + + Name + + Edit + + Delete +
+
+
+
+ {{ $card->id }} +
+
+
+
+
+ {{ $card->name }} +
+
+ + + +
+
+ {{ $cards->links() }} +
+
+
+