-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Description
- Laravel-mongodb Version: Latest
- PHP Version:7.4
- Database Driver & Version:
Monogdb
Description:
$this->getPermissionClass()->with('roles')->get()
My Model Permission is having this function
public function roles(): BelongsToMany
{
return $this->belongsToMany(
config('permission.models.role'),
config('permission.collection_names.role_has_permissions'),
'permission_id',
'role_id'
);
}
it does not work
relation returns empty
namespace Illuminate\Database\Eloquent\Relations\BelongsToMany;
public function get($columns = ['*'])
{
// First we'll add the proper select columns onto the query so it is run with
// the proper columns. Then, we will get the results and hydrate our pivot
// models with the result of those columns as a separate model relation.
$builder = $this->query->applyScopes();
$columns = $builder->getQuery()->columns ? [] : $columns;
$models = $builder->addSelect(
$this->shouldSelect($columns)
)->getModels();
$this->hydratePivotRelation($models);
// If we actually found models we will also eager load any relationships that
// have been specified as needing to be eager loaded. This will solve the
// n + 1 query problem for the developer and also increase performance.
if (count($models) > 0) {
$models = $builder->eagerLoadRelations($models);
}
return $this->related->newCollection($models);
}
This function should return collection model of related but returns empty
Metadata
Metadata
Assignees
Labels
No labels