skip to Main Content

Laravel – How in user model with pivot to tasks to restrict to only uncompleted tasks?

On laravel 10 site I have 3 related tables : Schema::create('users', function (Blueprint $table) { $table->id(); $table->string('name'); ... $table->timestamp('created_at')->useCurrent(); }); Schema::create('tasks', function (Blueprint $table) { $table->id(); $table->foreignId('creator_id')->references('id')->on('users')->onUpdate('RESTRICT')->onDelete('CASCADE'); $table->boolean('completed')->default(false); ... $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable(); }); Schema::create('task_user', function (Blueprint $table) { $table->id(); $table->unsignedBigInteger('user_id')->unsigned()->index(); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');…

VIEW QUESTION

Laravel Basic BelongsToMany

I have ProductCollection Model and AttributeValue Model which have a common table product_collection_attributes that has 2 columns: product_collection_id and attribute_value_id that are a foreign key to their respective tables and are both a primary key. In ProductCollection Model relation is:…

VIEW QUESTION
Back To Top
Search