Hide some administration columns for basic organisation users (Fixes #3)
This commit is contained in:
@@ -68,6 +68,30 @@ class User extends UFUser
|
||||
->wherePivot('flag_approved', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all organisations this user is and administrator for (including pending)
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function adminForOrganisations($excludePending = false)
|
||||
{
|
||||
/** @var \UserFrosting\Sprinkle\Core\Util\ClassMapper $classMapper */
|
||||
$classMapper = static::$ci->classMapper;
|
||||
|
||||
$query = $this->belongsToMany(
|
||||
$classMapper->getClassMapping('organisation'), 'organisation_members', 'user_id', 'organisation_id'
|
||||
)
|
||||
->orderBy('organisations.name', 'asc')
|
||||
->withPivot(['flag_admin', 'flag_approved'])
|
||||
->wherePivot('flag_admin', true);
|
||||
|
||||
if ($excludePending === true) {
|
||||
$query = $query->wherePivot('flag_approved', true);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete this member from the database, along with any links to organisations.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user