Change ScopeServiceUserAuthorised to ScopeAccountUserAuthorised. Scope payments to AccountUserAuthorised, and added PaymentPolicy
This commit is contained in:
29
app/Traits/ScopeAccountUserAuthorised.php
Normal file
29
app/Traits/ScopeAccountUserAuthorised.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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 Illuminate\Support\Facades\Auth;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
trait ScopeAccountUserAuthorised
|
||||
{
|
||||
/**
|
||||
* Only query records that the user is authorised to see
|
||||
*/
|
||||
public function scopeAccountUserAuthorised($query,string $table=NULL,User $uo=NULL)
|
||||
{
|
||||
if (! $uo)
|
||||
$uo = Auth::user();
|
||||
|
||||
if (! $table)
|
||||
$table = $this->getTable();
|
||||
|
||||
return $query
|
||||
->whereIN($table.'.account_id',$uo->accounts_all->pluck('id'));
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?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'));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user