skip to Main Content

Laravel – How rith belongsToMany relation get number of related rows?

In laravel 11 app User model have defined relation : namespace AppModels; use IlluminateFoundationAuthUser as Authenticatable; ... class User extends Authenticatable { public function uncompletedTasks(): belongsToMany { return $this->belongsToMany(Task::class) ->using(TaskUser::class) ->withPivot('supervisor_id') // Reference to "task_user" table ->where('completed', false) ->orderBy('priority', 'desc')…

VIEW QUESTION
Back To Top
Search