F
Filament15mo ago
saeed

records based on roles

hi i want in resource if user has client role just see the record that belongs to him and if user has the role of operator see all records can any one help me?
6 Replies
Dennis Koch
Dennis Koch15mo ago
Overwrite getEloquentQuery() on the Resource.
saeed
saeedOP15mo ago
Could not check compatibility between App\Filament\Resources\AsnadResource::getEloquentQuery(): App\Filament\Resources\Builder and Filament\Resources\Resource::getEloquentQuery(): Illuminate\Database\Eloquent\Builder, because class App\Filament\Resources\Builder is not available i want to do this but i get this error and when i use use Illuminate\Database\Eloquent\Builder; i get this Class "App\Filament\Resources\AsnadResource\Pages\Actions\CreateAction" not found i'm sorry
Dennis Koch
Dennis Koch15mo ago
You didn't import the builder. You can't just add code. You need to make sure it uses the right classes
saeed
saeedOP15mo ago
is this modifi correct return static::getModel()::query()->where('user_id', Auth::user()->id); you right
Vp
Vp15mo ago
try this
use Illuminate\Database\Eloquent\Builder;

public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->where('your condition');
}
use Illuminate\Database\Eloquent\Builder;

public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->where('your condition');
}
saeed
saeedOP15mo ago
thank you
Want results from more Discord servers?
Add your server