nova sber permission

This commit is contained in:
2024-09-18 22:47:32 +05:00
parent f8194453eb
commit 2b3d6fd5da
2 changed files with 45 additions and 0 deletions

View File

@@ -11,6 +11,7 @@ use App\Repos\Order\OrderRepo;
use App\Repos\System\Nova\NovaRepo;
use App\Repos\System\Settings\Legal\PassportRepo;
use App\Repos\System\Settings\Location\RegionRepo;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use Laravel\Nova\Fields\Badge;
@@ -58,6 +59,27 @@ class NovaSberPaymentOrder extends Resource
*/
public static $with = ['branch'];
/**
* Indicates whether the resource should automatically poll for new resources.
*
* @var bool
*/
public static $polling = true;
/**
* The interval at which Nova should poll for new resources.
*
* @var int
*/
public static $pollingInterval = 120;
/**
* Indicates whether to show the polling toggle button inside Nova.
*
* @var bool
*/
public static $showPollingToggle = true;
/**
* Get the displayable label of the resource.
*/
@@ -82,6 +104,27 @@ class NovaSberPaymentOrder extends Resource
);
}
/**
* Build an "index" query for the given resource.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public static function indexQuery(NovaRequest $request, mixed $query): Builder
{
$user = $request->user();
if ($user->isAdmin()) {
return $query;
}
if ($user->isOperator()) {
return $query->whereIn('branch_id', $user->branches()->pluck('branches.id'));
}
return $query->where('user_id', $request->user()->id);
}
/**
* After resource created
*

View File

@@ -45,6 +45,8 @@ class OrderRepo
public static function statusValues(): array
{
return [
'' => '',
null => '',
self::PENDING => __('Pending'),
self::REGISTER => __('Registered'),
self::PROCESSING => __('Processing'),