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
Back To Top
Search