mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 22:37:28 -08:00
Add global scope to limit template to current user
This commit is contained in:
parent
9c1bea00ad
commit
d72970b5b6
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
@ -31,6 +32,14 @@ class ReportTemplate extends Model
|
|||
'options' => 'array',
|
||||
];
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
// Scope to current user
|
||||
static::addGlobalScope('current_user', function (Builder $builder) {
|
||||
$builder->where('user_id', auth()->id());
|
||||
});
|
||||
}
|
||||
|
||||
public function checkmarkValue(string $property): string
|
||||
{
|
||||
// Assuming we're using the null object pattern,
|
||||
|
|
Loading…
Reference in a new issue