hi everyone, i am having an issue using query builder for a filament table resource on page LearnersRource page generated using filament:
public static function table(Table $table): Table {
return $table
->columns([
//All table columns and data
])
->query(function (Builder $query){
//$user = Auth::user();
$user = auth('web')->user();
if($user->isSuperAdmin()){
return $query;
}
if($user->isEmployer()){
return $query->where('employer_id', $user->employer_id);
}
return Learner::query()->where('1 = 0');
})
}
Note isSuperAdmin & isEmployer method are underlined as undefined methods even when declared in user Model class as
public function isSuperAdmin(): bool
{
return $this->hasRole('super_admin');
}
public function isEmployer(): bool
{
return $this->hasRole('employer');
}
and the learner model class handles the relationship as:
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}