Skip to content

Instantly share code, notes, and snippets.

@czemu

czemu/ActiveUsers.php Secret

Created Mar 4, 2020
Embed
What would you like to do?
<?php
namespace App\Nova\Filters;
use Illuminate\Http\Request;
use Laravel\Nova\Filters\Filter;
class ActiveUsers extends Filter
{
/**
* The filter's component.
*
* @var string
*/
public $component = 'select-filter';
/**
* Apply the filter to the given query.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Database\Eloquent\Builder $query
* @param mixed $value
* @return \Illuminate\Database\Eloquent\Builder
*/
public function apply(Request $request, $query, $value)
{
return $query->where('is_active', $value);
}
/**
* Get the filter's available options.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function options(Request $request)
{
return [
'Only Active Users' => 1,
'Only Inactive Users' => 0
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment