Tweaked the organisations fields to change how is_member behaves and added an is_pending

This commit is contained in:
2022-02-15 16:40:10 +00:00
parent 7e2a6d1379
commit e2180ddff3

View File

@@ -284,7 +284,7 @@ class Organisation extends Model implements OrganisationInterface, TokenOwnerInt
public function scopeWithUser($query, $userId) public function scopeWithUser($query, $userId)
{ {
$membersInner = DB::table('organisation_members') $membersInner = DB::table('organisation_members')
->selectRaw('organisation_id, 1 AS is_member, flag_admin AS is_admin') ->selectRaw('organisation_id, flag_approved = 1 AS is_member, flag_admin AS is_admin, flag_approved = 0 AS is_pending')
->where('user_id', $userId); ->where('user_id', $userId);
return $query return $query
->leftJoinSub($membersInner, 'user_orgs', function ($join) { ->leftJoinSub($membersInner, 'user_orgs', function ($join) {