diff --git a/src/app/Http/Controllers/DeckController.php b/src/app/Http/Controllers/DeckController.php
new file mode 100644
index 0000000..71e91ce
--- /dev/null
+++ b/src/app/Http/Controllers/DeckController.php
@@ -0,0 +1,28 @@
+ ['required'],
+ 'uname' => ['required', 'unique:App\Models\Deck', 'string', 'size:4'],
+ 'description' => ['nullable'],
+ 'card_count' => ['required', 'numeric'],
+ 'cover_path' => ['required','image'],
+ 'backside_path' => ['required','image'],
+ 'author' => ['nullable'],
+ 'publisher' => ['nullable'],
+ 'type' => ['nullable'],
+ ];
+
+ public function storeDeck()
+ {
+ $this->validate();
+ $deck = Deck::create([
+ 'name' => $this->name,
+ 'uname' =>$this->uname,
+ 'description' => $this->description,
+ 'card_count' => $this->card_count,
+ 'cover_path' => $this->cover_path,
+ 'backside_path' => $this->backside_path,
+ 'author' => $this->author,
+ 'publisher' => $this->publisher,
+ 'type' => $this->type
+ ]);
+ $this->reset();
+ }
+
+ public function edit($id)
+ {
+ $deck = Deck::find($id);
+ $this->deck_id = $deck->id;
+ $this->name = $deck->name;
+ $this->uname = $deck->uname;
+ $this->description = $deck->description;
+ $this->card_count = $deck->card_count;
+ $this->cover_path = $deck->cover_path;
+ $this->backside_path = $deck->backside_path;
+ $this->author = $deck->author;
+ $this->publisher = $deck->publisher;
+ $this->type = $deck->type;
+ }
+
+ public function update()
+ {
+ $deck = Deck::updateOrCreate(
+ [
+ 'id' => $this->deck_id,
+ ],
+ [
+ 'name' => $this->name,
+ 'uname' =>$this->uname,
+ 'description' => $this->description,
+ 'card_count' => $this->card_count,
+ 'cover_path' => $this->cover_path,
+ 'backside_path' => $this->backside_path,
+ 'author' => $this->author,
+ 'publisher' => $this->publisher,
+ 'type' => $this->type
+ ],
+
+ );
+
+ $this->reset();
+ }
+
+ public function destroy($id)
+ {
+ Deck::destroy($id);
+ }
+
+ public function render()
+ {
+ return view('livewire.deck-form', ['decks' => Deck::latest()->paginate(10)]);
+ }
+}
diff --git a/src/app/Models/Deck.php b/src/app/Models/Deck.php
index f42dab4..9288624 100644
--- a/src/app/Models/Deck.php
+++ b/src/app/Models/Deck.php
@@ -9,6 +9,18 @@ class Deck extends Model
{
use HasFactory;
+ protected $fillable = [
+ 'name',
+ 'uname',
+ 'describtion',
+ 'card_count',
+ 'cover_path',
+ 'backside_path',
+ 'author',
+ 'publisher',
+ 'type'
+ ];
+
/**
* The tags that belong to the Deck
*
diff --git a/src/database/migrations/2023_07_08_142515_create_decks_table.php b/src/database/migrations/2023_07_08_142515_create_decks_table.php
index c88888f..286eb4c 100644
--- a/src/database/migrations/2023_07_08_142515_create_decks_table.php
+++ b/src/database/migrations/2023_07_08_142515_create_decks_table.php
@@ -14,10 +14,13 @@ return new class extends Migration
Schema::create('decks', function (Blueprint $table) {
$table->id();
$table->string('name');
+ $table->string('uname');
$table->string('description')->nullable();
$table->integer('card_count');
$table->string('cover_path');
$table->string('backside_path');
+ $table->string('author')->nullable();
+ $table->string('publisher')->nullable();
$table->string('type')->nullable();
$table->timestamps();
});
diff --git a/src/resources/views/decks.blade.php b/src/resources/views/decks.blade.php
new file mode 100644
index 0000000..08398ce
--- /dev/null
+++ b/src/resources/views/decks.blade.php
@@ -0,0 +1,22 @@
+
+ Id + | ++ Name + | ++ U-Name + | ++ Edit + | ++ Delete + | +
---|---|---|---|---|
+
+
+
+
+
+ {{ $deck->id }}
+
+ |
+
+
+
+ {{ $deck->name }}
+
+ |
+
+
+
+ {{ $deck->uname }}
+
+ |
+
+ + + | + ++ + | + +