public static function getEloquentQuery(): Builder
{
$operation = last(explode('.', Route::currentRouteName()));
$query = parent::getEloquentQuery();
if ($operation == 'index')
{
$authUser = auth()->user();
if ($authUser->role == 'restaurant-admin') {
$rewardIds = Reward::where('restaurant_id', $authUser->restaurant_id)->pluck('id');
$query = $query->whereIn('reward_id', $rewardIds);
}
}
return $query
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
public static function getEloquentQuery(): Builder
{
$operation = last(explode('.', Route::currentRouteName()));
$query = parent::getEloquentQuery();
if ($operation == 'index')
{
$authUser = auth()->user();
if ($authUser->role == 'restaurant-admin') {
$rewardIds = Reward::where('restaurant_id', $authUser->restaurant_id)->pluck('id');
$query = $query->whereIn('reward_id', $rewardIds);
}
}
return $query
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}