diff --git a/src/app/Http/Controllers/CardController.php b/src/app/Http/Controllers/CardController.php new file mode 100644 index 0000000..b314d17 --- /dev/null +++ b/src/app/Http/Controllers/CardController.php @@ -0,0 +1,18 @@ +belongsToMany(Tag::class, 'cards_tags', 'tags_id', 'cards_id'); + } + + /** + * Get the Deck associated with the Card + * + * @return \Illuminate\Database\Eloquent\Relations\HasOne + */ + public function deck(): HasOne + { + return $this->hasOne(Deck::class, 'decks_id', 'card_id'); + } } diff --git a/src/database/migrations/2023_07_08_152030_create_cards_table.php b/src/database/migrations/2023_07_08_152030_create_cards_table.php index 06eba07..743ff24 100644 --- a/src/database/migrations/2023_07_08_152030_create_cards_table.php +++ b/src/database/migrations/2023_07_08_152030_create_cards_table.php @@ -13,6 +13,16 @@ return new class extends Migration { Schema::create('cards', function (Blueprint $table) { $table->id(); + $table->string('unique_id')->unique(); # Sollte eine Mix-Kennung aus Deck, Type, CardValue sein + $table->string('name'); + $table->string('description'); + $table->unsignedBiginteger('deck_id'); + $table->foreign('deck_id')->references('id')->on('decks')->onDelete('cascade'); + $table->string('type'); + $table->string('value'); + $table->integer('value_int'); + $table->string('meaning'); + $table->string('meaning_rev'); $table->timestamps(); }); }