複数の画像投稿(Laravel)

実現したいこと

すみません。
テーブルのカラム構成について質問させて頂きます。
出品の画像を3枚投稿出来るようにしたいのですが、カラムがimageの一つで良いのでしょうか?それともimage_2のようなカラムを作成したほうが良いのでしょうか?
また画像の投稿を1投稿3枚までと制限するのはバリデーションで可能でしょうか?

前提

画像投稿は出来るようになっています。
ですが今の所、画像の投稿は一枚だけとなっています。

該当のソースコード

<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. */ public function up(): void { Schema::create('posts', function (Blueprint $table) { $table->id(); $table->unsignedBigInteger('user_id')->constrained(); $table->string('name'); $table->string('antique_type'); $table->string('image'); $table->decimal('price'); $table->string('old'); $table->text('explanation'); $table->boolean('is_finished')->default(false); $table->timestamps(); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('posts'); } };

試したこと

調べていたのですが、複数の画像投稿の参考サイトなどを見ていると、一つのカラムに複数の画像のパスを配列に入れるみたいな感じなのでしょうか?

補足情報(FW/ツールのバージョンなど)

php: 8.1.21

コメントを投稿

0 コメント