21 lines
466 B
PHP
21 lines
466 B
PHP
<?php
|
|
|
|
namespace App\Models\Traits;
|
|
|
|
use App\Models\Organization;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
trait HasOrganization
|
|
{
|
|
public function organization(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Organization::class);
|
|
}
|
|
|
|
public function scopeOrganization(Builder $query, int $organization_id): Builder
|
|
{
|
|
return $query->where('organization_id', $organization_id);
|
|
}
|
|
}
|