Raphi
Raphi
FFilament
Created by Raphi on 9/12/2024 in #❓┊help
How can I ensure that only the user's data is exported?
That's what I do
class BelongsToUserScope implements Scope
{
/**
* Apply the scope to a given Eloquent query builder.
*/
public function apply(Builder $builder, Model $model): void
{
if (auth()->check() && ! auth()->user()->isAdmin() ||
Filament::getCurrentPanel()->getId() == 'app') {
$builder->where('user_id', auth()->id());
}
}
}
class BelongsToUserScope implements Scope
{
/**
* Apply the scope to a given Eloquent query builder.
*/
public function apply(Builder $builder, Model $model): void
{
if (auth()->check() && ! auth()->user()->isAdmin() ||
Filament::getCurrentPanel()->getId() == 'app') {
$builder->where('user_id', auth()->id());
}
}
}
3 replies