6 changed files with 70 additions and 93 deletions
-
22app/Entities/Payments/Payment.php
-
23app/Entities/Projects/Project.php
-
19app/Traits/OwnedByAgency.php
-
14tests/Feature/Api/ApiEventsTest.php
-
7tests/Feature/Api/ApiManageProjectsTest.php
-
2tests/Feature/Auth/MemberLoginTest.php
@ -0,0 +1,19 @@ |
|||
<?php |
|||
|
|||
namespace App\Traits; |
|||
|
|||
use Illuminate\Database\Eloquent\Builder; |
|||
|
|||
trait OwnedByAgency |
|||
{ |
|||
public static function bootOwnedByAgency() |
|||
{ |
|||
static::addGlobalScope('by_owner', function (Builder $builder) { |
|||
if ( ! is_null(auth()->user()->agency)) { |
|||
$builder->where('owner_id', auth()->user()->agency->id); |
|||
} else { |
|||
$builder->where('owner_id', 0); |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue