diff --git a/app/Modules/SberPaymentOrder/Nova/Resources/NovaSberPaymentOrder.php b/app/Modules/SberPaymentOrder/Nova/Resources/NovaSberPaymentOrder.php index 4ba485c..4f5d487 100644 --- a/app/Modules/SberPaymentOrder/Nova/Resources/NovaSberPaymentOrder.php +++ b/app/Modules/SberPaymentOrder/Nova/Resources/NovaSberPaymentOrder.php @@ -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 * diff --git a/app/Repos/Order/OrderRepo.php b/app/Repos/Order/OrderRepo.php index f1f7c6b..094858d 100644 --- a/app/Repos/Order/OrderRepo.php +++ b/app/Repos/Order/OrderRepo.php @@ -45,6 +45,8 @@ class OrderRepo public static function statusValues(): array { return [ + '' => '', + null => '', self::PENDING => __('Pending'), self::REGISTER => __('Registered'), self::PROCESSING => __('Processing'),