osb/app/Traits/ScopeServiceUserAuthorised.php
Deon George 23f57f684e
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 32s
Create Docker Image / Final Docker Image Manifest (push) Successful in 8s
User optimisation and code cleanup
2024-07-05 22:56:02 +10:00

21 lines
428 B
PHP

<?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
->whereIN('services.account_id',$uo->accounts_all->pluck('id'));
}
}