diff --git a/app/Nova/User/Client.php b/app/Nova/User/Client.php new file mode 100644 index 0000000..e9ec3ef --- /dev/null +++ b/app/Nova/User/Client.php @@ -0,0 +1,175 @@ + + */ + public static $model = \App\Models\User::class; + + /** + * The single value that should be used to represent the resource when being displayed. + * + * @var string + */ + public static $title = 'name'; + + /** + * The columns that should be searched. + * + * @var array + */ + public static $search = [ + 'id', 'name', 'email', + ]; + + /** + * Get the displayable label of the resource. + */ + public static function label(): string + { + return __('Clients'); + } + + /** + * Get the displayable singular label of the resource. + */ + public static function singularLabel(): string + { + return __('Client'); + } + + /** + * Build an "index" query for the given resource. + * + * @param \Illuminate\Database\Eloquent\Builder<\Illuminate\Database\Eloquent\Model> $query + * @return \Illuminate\Database\Eloquent\Builder<\Illuminate\Database\Eloquent\Model> + */ + public static function indexQuery(NovaRequest $request, mixed $query): Builder + { + $query->doesntHave('roles'); + + return $query; + } + + /** + * Get the fields displayed by the resource. + * + * @return array + */ + public function fields(NovaRequest $request): array + { + return [ + ID::make()->sortable(), + + Text::make(__('Username'), 'username') + ->sortable() + ->rules('required', 'string', 'alpha_dash:ascii', 'max:250') + ->creationRules('unique:users,username') + ->updateRules('unique:users,username,{{resourceId}}'), + + Text::make(__('Name'), 'name') + ->sortable() + ->rules('required', 'max:255'), + + NovaInputmask::make(__('Phone'), 'phone') + ->mask('+(\\9\\93)-99-99-99-99') + ->storeRawValue() + ->rules('nullable', 'integer', 'between:61000000, 71999999'), + + Text::make(__('Email'), 'email') + ->sortable() + ->rules('nullable', 'email', 'max:254') + ->creationRules('unique:users,email') + ->updateRules('unique:users,email,{{resourceId}}'), + + Password::make(__('Password'), 'password') + ->onlyOnForms() + ->creationRules('required', Rules\Password::defaults()) + ->updateRules('nullable', Rules\Password::defaults()), + + Boolean::make(__('Active'), 'active') + ->default(true) + ->canSeeWhen('isAdmin', $this), + + MorphToMany::make(__('Roles'), 'roles', Role::class) + ->canSeeWhen('isAdmin', $this), + + MorphToMany::make(__('Permissions'), 'permissions', Permission::class) + ->canSeeWhen('isAdmin', $this), + + BelongsToMany::make(__('Branches'), 'branches', Branch::class) + ->canSeeWhen('isAdmin', $this), + + HasMany::make(__('Loan order'), 'loanOrders', LoanOrder::class), + + HasMany::make(__('Card order'), 'cardOrders', CardOrder::class), + ]; + } + + /** + * Get the cards available for the request. + * + * @return array + */ + public function cards(NovaRequest $request) + { + return []; + } + + /** + * Get the filters available for the resource. + * + * @return array + */ + public function filters(NovaRequest $request) + { + return [ + + ]; + } + + /** + * Get the lenses available for the resource. + * + * @return array + */ + public function lenses(NovaRequest $request) + { + return []; + } + + /** + * Get the actions available for the resource. + * + * @return array + */ + public function actions(NovaRequest $request) + { + return []; + } +} diff --git a/app/Nova/User/Operator.php b/app/Nova/User/Operator.php new file mode 100644 index 0000000..e3101d9 --- /dev/null +++ b/app/Nova/User/Operator.php @@ -0,0 +1,187 @@ + + */ + public static $model = \App\Models\User::class; + + /** + * The single value that should be used to represent the resource when being displayed. + * + * @var string + */ + public static $title = 'name'; + + /** + * The columns that should be searched. + * + * @var array + */ + public static $search = [ + 'id', 'name', 'email', + ]; + + /** + * Get the displayable label of the resource. + */ + public static function label(): string + { + return __('Operators'); + } + + /** + * Get the displayable singular label of the resource. + */ + public static function singularLabel(): string + { + return __('Operator'); + } + + /** + * Build an "index" query for the given resource. + * + * @param \Illuminate\Database\Eloquent\Builder<\Illuminate\Database\Eloquent\Model> $query + * @return \Illuminate\Database\Eloquent\Builder<\Illuminate\Database\Eloquent\Model> + */ + public static function indexQuery(NovaRequest $request, mixed $query): Builder + { + $query->role('operator'); + + return $query; + } + + /** + * Register a callback to be called after the resource is created. + * + * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * @param \Illuminate\Database\Eloquent\Model $model + * @return void + */ + public static function afterCreate(NovaRequest $request, Model $model): void + { + $model->assignRole('operator'); + } + + /** + * Get the fields displayed by the resource. + * + * @return array + */ + public function fields(NovaRequest $request): array + { + return [ + ID::make()->sortable(), + + Text::make(__('Username'), 'username') + ->sortable() + ->rules('required', 'string', 'alpha_dash:ascii', 'max:250') + ->creationRules('unique:users,username') + ->updateRules('unique:users,username,{{resourceId}}'), + + Text::make(__('Name'), 'name') + ->sortable() + ->rules('required', 'max:255'), + + NovaInputmask::make(__('Phone'), 'phone') + ->mask('+(\\9\\93)-99-99-99-99') + ->storeRawValue() + ->rules('nullable', 'integer', 'between:61000000, 71999999'), + + Text::make(__('Email'), 'email') + ->sortable() + ->rules('nullable', 'email', 'max:254') + ->creationRules('unique:users,email') + ->updateRules('unique:users,email,{{resourceId}}'), + + Password::make(__('Password'), 'password') + ->onlyOnForms() + ->creationRules('required', Rules\Password::defaults()) + ->updateRules('nullable', Rules\Password::defaults()), + + Boolean::make(__('Active'), 'active') + ->default(true) + ->canSeeWhen('isAdmin', $this), + + MorphToMany::make(__('Roles'), 'roles', Role::class) + ->canSeeWhen('isAdmin', $this), + + MorphToMany::make(__('Permissions'), 'permissions', Permission::class) + ->canSeeWhen('isAdmin', $this), + + BelongsToMany::make(__('Branches'), 'branches', Branch::class) + ->canSeeWhen('isAdmin', $this), + + HasMany::make(__('Loan order'), 'loanOrders', LoanOrder::class), + + HasMany::make(__('Card order'), 'cardOrders', CardOrder::class), + ]; + } + + /** + * Get the cards available for the request. + * + * @return array + */ + public function cards(NovaRequest $request) + { + return []; + } + + /** + * Get the filters available for the resource. + * + * @return array + */ + public function filters(NovaRequest $request) + { + return [ + + ]; + } + + /** + * Get the lenses available for the resource. + * + * @return array + */ + public function lenses(NovaRequest $request) + { + return []; + } + + /** + * Get the actions available for the resource. + * + * @return array + */ + public function actions(NovaRequest $request) + { + return []; + } +} diff --git a/app/Repos/Payment/OnlinePaymentRepo.php b/app/Repos/Payment/OnlinePaymentRepo.php index 888bb4b..7f43f00 100644 --- a/app/Repos/Payment/OnlinePaymentRepo.php +++ b/app/Repos/Payment/OnlinePaymentRepo.php @@ -92,7 +92,7 @@ class OnlinePaymentRepo /** * Generate order number for payment */ - public function generateOrderNumber(mixed $resource): int + public function generateOrderNumber(mixed $resource): string { return date('dmyHis'); } diff --git a/app/Repos/System/Nova/NovaMenuRepo.php b/app/Repos/System/Nova/NovaMenuRepo.php index de36c20..a61adb0 100644 --- a/app/Repos/System/Nova/NovaMenuRepo.php +++ b/app/Repos/System/Nova/NovaMenuRepo.php @@ -17,6 +17,8 @@ use App\Nova\Resources\System\Location\Province; use App\Nova\Resources\System\Roles\Permission; use App\Nova\Resources\System\Roles\Role; use App\Nova\User; +use App\Nova\User\Client; +use App\Nova\User\Operator; use Illuminate\Http\Request; use Laravel\Nova\Menu\MenuGroup; use Laravel\Nova\Menu\MenuItem; @@ -47,9 +49,14 @@ class NovaMenuRepo ])->collapsedByDefault(), ])->icon('ticket')->collapsedByDefault(), + MenuSection::make(__('Users'), [ + MenuItem::resource(Operator::class), + MenuItem::resource(Client::class), + MenuItem::resource(User::class)->name(__('All users')), + ])->icon('user-group'), + MenuSection::make(__('System'), [ MenuGroup::make(__('Users'), [ - MenuItem::resource(User::class), MenuItem::resource(Role::class), MenuItem::resource(Permission::class), ])->collapsedByDefault(), diff --git a/config/backup.php b/config/backup.php index a694f1a..0673fce 100644 --- a/config/backup.php +++ b/config/backup.php @@ -1,5 +1,7 @@ [ @@ -29,6 +31,8 @@ return [ 'exclude' => [ base_path('vendor'), base_path('node_modules'), + storage_path('app/Laravel'), + storage_path('app/backup-temp'), ], /* diff --git a/lang/tk.json b/lang/tk.json index 6dd015a..655439a 100644 --- a/lang/tk.json +++ b/lang/tk.json @@ -279,5 +279,7 @@ "Certificates of loan repayment": "Karzyň ýapylandygy barada güwanamalar", "Ready files": "Taýýar faýllar", "Paid": "Tölenen", - "Unpaid": "Tölenmedik" + "Unpaid": "Tölenmedik", + "Clients": "Müşderiler", + "Client": "Müşderi" }