mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -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;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Watson\Validating\ValidatingTrait;
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
@ -31,6 +32,14 @@ class ReportTemplate extends Model
|
||||||
'options' => 'array',
|
'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
|
public function checkmarkValue(string $property): string
|
||||||
{
|
{
|
||||||
// Assuming we're using the null object pattern,
|
// Assuming we're using the null object pattern,
|
||||||
|
|
Loading…
Reference in a new issue