skip to Main Content

Laravel – How to prevent unique error if I have 3 fields in a table/model but need more than 1 item? (factory)

I have a unique index on 3 fields: public function up(): void { Schema::create('items', function (Blueprint $table) { $table->id(); $table->foreignId('points_id'); $table->foreignId('user_id'); $table->unsignedTinyInteger('status'); $table->timestamp('created_at')->useCurrent(); $table->foreign('user_id')->references('id')->on('users'); $table->foreign('points_id')->references('id')->on('points'); $table->unique(['points_id', 'user_id', 'status']); }); } I need to make a factory to create a lot…

VIEW QUESTION

Seed fake images in laravel

I'm trying to generate a fake image to populate seeder data. I created a seeder with this: $this->faker->image(storage_path('app/public/products'), 500, 500) When I try to access them through Laravel Nova to see them, I get this kind of URL: http://localhost/storage/var/www/html/storage/app/public/products/c8831002794cc55fe046c5e2b65794d4.png In…

VIEW QUESTION
Back To Top
Search