Add active filter
This commit is contained in:
47
app/Nova/Filters/ActiveFilter.php
Normal file
47
app/Nova/Filters/ActiveFilter.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova\Filters;
|
||||
|
||||
use Laravel\Nova\Filters\Filter;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
|
||||
class ActiveFilter extends Filter
|
||||
{
|
||||
/**
|
||||
* The filter's component.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $component = 'select-filter';
|
||||
|
||||
/**
|
||||
* Get the displayable name of the filter.
|
||||
*/
|
||||
public function name(): string
|
||||
{
|
||||
return __('Activity');
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the filter to the given query.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param mixed $value
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function apply(NovaRequest $request, $query, $value)
|
||||
{
|
||||
return $value ? $query->where('active', $value) : $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filter's available options.
|
||||
*/
|
||||
public function options(NovaRequest $request): array
|
||||
{
|
||||
return [
|
||||
__('Active') => true,
|
||||
__('Inactive') => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,6 @@ class RegionFilter extends Filter
|
||||
|
||||
/**
|
||||
* Get the displayable name of the filter.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function name(): string
|
||||
{
|
||||
@@ -28,7 +26,6 @@ class RegionFilter extends Filter
|
||||
/**
|
||||
* Apply the filter to the given query.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param mixed $value
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
@@ -40,9 +37,6 @@ class RegionFilter extends Filter
|
||||
|
||||
/**
|
||||
* Get the filter's available options.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function options(NovaRequest $request): array
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Nova\Resources\Branch;
|
||||
|
||||
use App\Models\Branch\Branch as BranchModel;
|
||||
use App\Nova\Filters\ActiveFilter;
|
||||
use App\Nova\Filters\RegionFilter;
|
||||
use App\Repos\System\Nova\NovaRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
@@ -99,42 +100,35 @@ class Branch extends Resource
|
||||
|
||||
/**
|
||||
* Get the cards available for the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function cards(NovaRequest $request)
|
||||
public function cards(NovaRequest $request): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filters available for the resource.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function filters(NovaRequest $request)
|
||||
public function filters(NovaRequest $request): array
|
||||
{
|
||||
return [
|
||||
new RegionFilter(),
|
||||
new ActiveFilter(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the lenses available for the resource.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function lenses(NovaRequest $request)
|
||||
public function lenses(NovaRequest $request): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actions available for the resource.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function actions(NovaRequest $request)
|
||||
public function actions(NovaRequest $request): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Nova\Resources\Order\Loan;
|
||||
use App\Models\Branch\Branch;
|
||||
use App\Models\Order\Loan\LoanOrder as LoanOrderModel;
|
||||
use App\Models\System\Location\Province;
|
||||
use App\Nova\Filters\ActiveFilter;
|
||||
use App\Nova\Filters\RegionFilter;
|
||||
use App\Nova\Resource;
|
||||
use App\Nova\Resources\Order\Loan\Concerns\LoanOrderEvents;
|
||||
@@ -20,7 +21,6 @@ use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use App\Rules\DowranAgaAllowed;
|
||||
use App\Rules\OnlyLetters;
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Nova\Fields\Badge;
|
||||
use Laravel\Nova\Fields\Date;
|
||||
use Laravel\Nova\Fields\Email;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
@@ -359,6 +359,7 @@ class LoanOrder extends Resource
|
||||
{
|
||||
return [
|
||||
new RegionFilter(),
|
||||
new ActiveFilter(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Nova\Resources\Order\Loan;
|
||||
|
||||
use App\Models\Order\Loan\LoanType as LoanTypeModel;
|
||||
use App\Nova\Filters\ActiveFilter;
|
||||
use App\Nova\Resource;
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
@@ -91,7 +92,9 @@ class LoanType extends Resource
|
||||
*/
|
||||
public function filters(NovaRequest $request): array
|
||||
{
|
||||
return [];
|
||||
return [
|
||||
new ActiveFilter(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Nova\Resources\System\Location;
|
||||
|
||||
use App\Models\System\Location\Province as ProvinceModel;
|
||||
use App\Nova\Filters\ActiveFilter;
|
||||
use App\Nova\Filters\RegionFilter;
|
||||
use App\Nova\Resource;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
@@ -94,6 +95,7 @@ class Province extends Resource
|
||||
{
|
||||
return [
|
||||
new RegionFilter(),
|
||||
new ActiveFilter(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use App\Models\Branch\Branch;
|
||||
use App\Models\Order\Loan\LoanOrder;
|
||||
use App\Models\Order\Loan\LoanType;
|
||||
@@ -17,6 +16,7 @@ use App\Policies\System\Roles\PermissionPolicy;
|
||||
use App\Policies\System\Roles\RolePolicy;
|
||||
use App\Policies\UserPolicy;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
"A fresh verification link has been sent to your email address.": "E-poçta salgyňyza täze tassyklama baglanyşygy iberildi.",
|
||||
"A Timeout Occurred": "Wagt gutardy",
|
||||
"Accepted": "Kabul edildi",
|
||||
"Active": "Işjeň",
|
||||
"Address": "Salgysy",
|
||||
"Ahal": "Ahal",
|
||||
"All rights reserved.": "Rightshli hukuklar goralandyr.",
|
||||
@@ -208,5 +207,8 @@
|
||||
"You are logged in!": "Sessiýa açdyňyz",
|
||||
"You are receiving this email because we received a password reset request for your account.": "Bu e-poçta alýarsyňyz, sebäbi hasabyňyz üçin paroly täzeden düzmek haýyşyny aldyk.",
|
||||
"Write a correct data please": "Dogry maglumat girizmegiňizi Sizden haýyş edýäris.",
|
||||
"Full Name": "Doly ady"
|
||||
"Full Name": "Doly ady",
|
||||
"Activity": "Işjeňlik",
|
||||
"Active": "Işjeň",
|
||||
"Inactive": "Işjeň däl"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user