Skip to content

Commit

Permalink
Add location filter to review resource #8
Browse files Browse the repository at this point in the history
  • Loading branch information
drewroberts committed Mar 24, 2021
1 parent 7b2c920 commit 0ed8c3d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Nova/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,21 @@ class Review extends BaseResource
];

public static $group = 'Reporting';

/** @psalm-suppress UndefinedClass */
protected array $filterClassList = [
Location::class,
\Tipoff\Locations\Nova\Filters\Location::class,
];

public static function indexQuery(NovaRequest $request, $query)
{
if ($request->user()->hasPermissionTo('all locations')) {
return $query;
}

return $query->whereIn('location_id', $request->user()->locations->pluck('id'));
}

public function fieldsForIndex(NovaRequest $request)
{
return array_filter([
Expand Down

0 comments on commit 0ed8c3d

Please sign in to comment.