skip to Main Content

Laravel 11 – validated() and related table

I'd like to insert the user-id of the current user into a table in column "user_id". The field is a relation to the user table. Migration / database schema Schema::create('pdlocations', function (Blueprint $table) { $table->id(); $table->timestamps(); $table->decimal('lon', 10, 7); $table->decimal('lat',…

VIEW QUESTION

Grouping returned collection by a date – Laravel

I've got this function: public function getOverdue() { $jobs = Job::where('RequiredTime', '<', Carbon::now()->addDays(10)->endOfDay()) ->where('JobCancelled', '=', 0) ->where('JobCompleted', '=', 0) ->where('Ref9', '=', null) ->where('CreateDateTime', '>=', Carbon::now()->startOfMonth()) //->groupBy('RequiredTime') ->orderBy('RequiredTime', 'asc') ->get(); return view('pages.dispatch.overdue', [ 'title' => 'Overdue', 'page' => 'Overdue', 'js_action' =>…

VIEW QUESTION

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