2021-07-13 02:31:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a ScopeAuthorised to an Eloquent Model
|
|
|
|
* This will help limit the scope of accounts that a user can see.
|
|
|
|
*/
|
|
|
|
namespace App\Traits;
|
|
|
|
|
|
|
|
use App\Models\User;
|
|
|
|
|
|
|
|
trait ScopeServiceUserAuthorised
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Only query records that the user is authorised to see
|
|
|
|
*/
|
|
|
|
public function scopeServiceUserAuthorised($query,User $uo)
|
|
|
|
{
|
|
|
|
return $query
|
2024-07-05 12:56:02 +00:00
|
|
|
->whereIN('services.account_id',$uo->accounts_all->pluck('id'));
|
2021-07-13 02:31:56 +00:00
|
|
|
}
|
2022-04-21 04:41:26 +00:00
|
|
|
}
|