WIP on CArd Orders
This commit is contained in:
@@ -15,6 +15,13 @@ abstract class Resource extends NovaResource
|
|||||||
*/
|
*/
|
||||||
public static $trafficCop = false;
|
public static $trafficCop = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the resource should be globally searchable.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public static $globallySearchable = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if the current user can replicate the given resource.
|
* Determine if the current user can replicate the given resource.
|
||||||
*/
|
*/
|
||||||
|
|||||||
333
app/Nova/Resources/Order/Card/CardOrder.php
Normal file
333
app/Nova/Resources/Order/Card/CardOrder.php
Normal file
@@ -0,0 +1,333 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Nova\Resources\Order\Card;
|
||||||
|
|
||||||
|
use App\Models\Branch\Branch;
|
||||||
|
use App\Models\Order\Card\CardOrder as CardOrderModel;
|
||||||
|
use App\Nova\Resource;
|
||||||
|
use App\Nova\Resources\Order\Card\Concerns\CardOrderNovaRepo;
|
||||||
|
use App\Nova\User;
|
||||||
|
use App\Repos\Order\Card\CardStateRepo;
|
||||||
|
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 App\Rules\DowranAgaAllowed;
|
||||||
|
use App\Rules\OnlyLetters;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Laravel\Nova\Fields\BelongsTo;
|
||||||
|
use Laravel\Nova\Fields\Date;
|
||||||
|
use Laravel\Nova\Fields\ID;
|
||||||
|
use Laravel\Nova\Fields\Number;
|
||||||
|
use Laravel\Nova\Fields\Select;
|
||||||
|
use Laravel\Nova\Fields\Text;
|
||||||
|
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||||
|
|
||||||
|
class CardOrder extends Resource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The model the resource corresponds to.
|
||||||
|
*
|
||||||
|
* @var class-string<CardOrderModel>
|
||||||
|
*/
|
||||||
|
public static $model = CardOrderModel::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The single value that should be used to represent the resource when being displayed.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public static $title = 'unique_id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The relationships that should be eager loaded on index queries.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
// public static $with = ['branch', 'loanType'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The columns that should be searched.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $search = [
|
||||||
|
'unique_id', 'customer_name', 'customer_surname', 'phone',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
public static function label(): string
|
||||||
|
{
|
||||||
|
return __('Card orders');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the displayable singular label of the resource.
|
||||||
|
*/
|
||||||
|
public static function singularLabel(): string
|
||||||
|
{
|
||||||
|
return __('Card order');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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, $query)
|
||||||
|
{
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a callback to be called after the resource is created.
|
||||||
|
*/
|
||||||
|
// public static function afterCreate(NovaRequest $request, Model $model): void
|
||||||
|
// {
|
||||||
|
// CardOrderNovaRepo::afterCreate($request, $model);
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the fields for index.
|
||||||
|
*/
|
||||||
|
// public function fieldsForIndex(NovaRequest $request): array
|
||||||
|
// {
|
||||||
|
// return CardOrderFieldsForIndex::make($this);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Get the fields for detail
|
||||||
|
// */
|
||||||
|
// public function fieldsForDetail(): array
|
||||||
|
// {
|
||||||
|
// return CardOrderFieldsForDetail::make($this);
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the fields displayed by the resource.
|
||||||
|
*/
|
||||||
|
public function fields(NovaRequest $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ID::make()->sortable(),
|
||||||
|
|
||||||
|
Select::make(__('Status'), 'status')
|
||||||
|
->displayUsingLabels()
|
||||||
|
->searchable()
|
||||||
|
->options(OrderRepo::statusValues())
|
||||||
|
->default(OrderRepo::defaultStatus())
|
||||||
|
->fullWidth()
|
||||||
|
->rules('required')
|
||||||
|
->canSeeWhen('systemUser', $this),
|
||||||
|
|
||||||
|
Text::make(__('Note'), 'status')
|
||||||
|
->fullWidth()
|
||||||
|
->canSeeWhen('systemUser', $this),
|
||||||
|
|
||||||
|
BelongsTo::make(__('Created by').': ', 'user', User::class)
|
||||||
|
->fullWidth()
|
||||||
|
->canSeeWhen('isMe', $this),
|
||||||
|
|
||||||
|
new Panel(__('Loan'), [
|
||||||
|
Select::make(__('Reason for issuing the card'), 'card_state_id')
|
||||||
|
->displayUsingLabels()
|
||||||
|
->fullWidth()
|
||||||
|
->searchable()
|
||||||
|
->options(CardStateRepo::values())
|
||||||
|
->rules('required')
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
|
Select::make(__('Reason for issuing the card'), 'card_type_id')
|
||||||
|
->displayUsingLabels()
|
||||||
|
->fullWidth()
|
||||||
|
->searchable()
|
||||||
|
->options(CardTypeRepo::values())
|
||||||
|
->rules('required')
|
||||||
|
->sortable(),
|
||||||
|
]),
|
||||||
|
|
||||||
|
new Panel(__('Location'), [
|
||||||
|
Select::make(__('Region'), 'region')
|
||||||
|
->displayUsingLabels()
|
||||||
|
->searchable()
|
||||||
|
->options(RegionRepo::values())
|
||||||
|
->default(RegionRepo::default())
|
||||||
|
->size('w-1/2')
|
||||||
|
->rules('required')
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
|
Select::make(__('Branch'), 'branch_id')
|
||||||
|
->displayUsingLabels()
|
||||||
|
->searchable()
|
||||||
|
->dependsOn('region', NovaRepo::dependsOnRegion('region', Branch::class))
|
||||||
|
->size('w-1/2')
|
||||||
|
->rules('required')
|
||||||
|
->sortable(),
|
||||||
|
]),
|
||||||
|
|
||||||
|
new Panel(__('Personal data'), [
|
||||||
|
Text::make(__('Name'), 'customer_name')
|
||||||
|
->size('w-1/3')
|
||||||
|
->rules('required', 'string', new OnlyLetters(), 'max:255'),
|
||||||
|
|
||||||
|
Text::make(__('Surname'), 'customer_surname')
|
||||||
|
->size('w-1/3')
|
||||||
|
->rules('required', 'string', new OnlyLetters(), 'max:255'),
|
||||||
|
|
||||||
|
Text::make(__('Patronic name'), 'customer_patronic_name')
|
||||||
|
->size('w-1/3')
|
||||||
|
->rules('required', 'string', new OnlyLetters(), 'max:255'),
|
||||||
|
|
||||||
|
Date::make(__('Date of birth'), 'born_at')
|
||||||
|
->size('w-1/3')
|
||||||
|
->rules('required', 'before_or_equal:today'),
|
||||||
|
|
||||||
|
NovaInputmask::make(__('Phone'), 'phone')
|
||||||
|
->mask('+(\\9\\93)-99-99-99-99')
|
||||||
|
->storeRawValue()
|
||||||
|
->size('w-1/4')
|
||||||
|
->rules('required', 'integer', 'between:61000000, 71999999'),
|
||||||
|
|
||||||
|
NovaInputmask::make(__('Phone Additional'), 'phone_additional')
|
||||||
|
->mask('+(\\9\\93)-99-99-99-99')
|
||||||
|
->storeRawValue()
|
||||||
|
->size('w-1/4')
|
||||||
|
->rules('nullable', 'integer', 'between:61000000, 71999999'),
|
||||||
|
|
||||||
|
Text::make(__('Residence (passport)'), 'passport_address')
|
||||||
|
->size('w-1/2')
|
||||||
|
->rules('required', 'string', new DowranAgaAllowed(), 'max:255'),
|
||||||
|
|
||||||
|
Text::make(__('Current Residence'), 'real_address')
|
||||||
|
->size('w-1/2')
|
||||||
|
->rules('required', 'string', new DowranAgaAllowed(), 'max:255'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
// Text::make(__(), 'old_surname'),
|
||||||
|
// Text::make(__(), 'citizenship'),
|
||||||
|
// Text::make(__(), 'job_location'),
|
||||||
|
|
||||||
|
new Panel(__('Passport'), [
|
||||||
|
Select::make(__('Passport serie'), 'passport_serie')
|
||||||
|
->displayUsingLabels()
|
||||||
|
->searchable()
|
||||||
|
->options(PassportRepo::values())
|
||||||
|
->size('w-1/3')
|
||||||
|
->rules('required')
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
|
Number::make(__('Passport id'), 'passport_id')
|
||||||
|
->size('w-1/3')
|
||||||
|
->rules('required', 'numeric', 'digits:6'),
|
||||||
|
|
||||||
|
Date::make(__('Passport date of issue'), 'passport_given_at')
|
||||||
|
->size('w-1/3')
|
||||||
|
->rules('required', 'before_or_equal:today'),
|
||||||
|
|
||||||
|
Text::make(__('Passport given by'), 'passport_given_by')
|
||||||
|
->size('w-1/2')
|
||||||
|
->rules('required', 'string', new DowranAgaAllowed(), 'max:255'),
|
||||||
|
|
||||||
|
Text::make(__('Born place (passport)'), 'born_place')
|
||||||
|
->size('w-1/2')
|
||||||
|
->rules('required', 'string', new DowranAgaAllowed(), 'max:255'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
new Panel(__('Passport files'), [
|
||||||
|
Image::make(__('Passport (page 1)'), 'passport_one')
|
||||||
|
->size('w-1/2')
|
||||||
|
->deletable(false)
|
||||||
|
->rules('max:2048', 'mimes:jpg,png,jpeg')
|
||||||
|
->creationRules('required')
|
||||||
|
->updateRules('nullable'),
|
||||||
|
|
||||||
|
Image::make(__('Passport (page 2-3)'), 'passport_two')
|
||||||
|
->size('w-1/2')
|
||||||
|
->deletable(false)
|
||||||
|
->rules('max:2048', 'mimes:jpg,png,jpeg')
|
||||||
|
->creationRules('required')
|
||||||
|
->updateRules('nullable'),
|
||||||
|
|
||||||
|
Image::make(__('Passport (page 8-9)'), 'passport_three')
|
||||||
|
->size('w-1/2')
|
||||||
|
->deletable(false)
|
||||||
|
->rules('max:2048', 'mimes:jpg,png,jpeg')
|
||||||
|
->creationRules('required')
|
||||||
|
->updateRules('nullable'),
|
||||||
|
|
||||||
|
Image::make(__('Passport (page 32)'), 'passport_four')
|
||||||
|
->size('w-1/2')
|
||||||
|
->deletable(false)
|
||||||
|
->rules('max:2048', 'mimes:jpg,png,jpeg')
|
||||||
|
->creationRules('required')
|
||||||
|
->updateRules('nullable'),
|
||||||
|
]),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the cards available for the request.
|
||||||
|
*/
|
||||||
|
public function cards(NovaRequest $request): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the filters available for the resource.
|
||||||
|
*/
|
||||||
|
public function filters(NovaRequest $request): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the lenses available for the resource.
|
||||||
|
*/
|
||||||
|
public function lenses(NovaRequest $request): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the actions available for the resource.
|
||||||
|
*/
|
||||||
|
public function actions(NovaRequest $request): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
101
app/Nova/Resources/Order/Card/CardState.php
Normal file
101
app/Nova/Resources/Order/Card/CardState.php
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Nova\Resources\Order\Card;
|
||||||
|
|
||||||
|
use App\Models\Order\Card\CardState as CardStateModel;
|
||||||
|
use App\Nova\Resource;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Laravel\Nova\Fields\ID;
|
||||||
|
use Laravel\Nova\Fields\Text;
|
||||||
|
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||||
|
|
||||||
|
class CardState extends Resource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The model the resource corresponds to.
|
||||||
|
*
|
||||||
|
* @var class-string<CardStateModel>
|
||||||
|
*/
|
||||||
|
public static $model = CardStateModel::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 = [
|
||||||
|
'name',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the displayable label of the resource.
|
||||||
|
*/
|
||||||
|
public static function label(): string
|
||||||
|
{
|
||||||
|
return __('Card states');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the displayable singular label of the resource.
|
||||||
|
*/
|
||||||
|
public static function singularLabel(): string
|
||||||
|
{
|
||||||
|
return __('Card state');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the fields displayed by the resource.
|
||||||
|
*/
|
||||||
|
public function fields(NovaRequest $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ID::make()->sortable(),
|
||||||
|
|
||||||
|
Text::make(__('Name'), 'name')
|
||||||
|
->rules('required', 'string', 'max:255')
|
||||||
|
->translatable(),
|
||||||
|
|
||||||
|
Text::make(__('Price'), 'price')
|
||||||
|
->rules('required', 'string', 'max:255'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the cards available for the request.
|
||||||
|
*/
|
||||||
|
public function cards(NovaRequest $request): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the filters available for the resource.
|
||||||
|
*/
|
||||||
|
public function filters(NovaRequest $request): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the lenses available for the resource.
|
||||||
|
*/
|
||||||
|
public function lenses(NovaRequest $request): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the actions available for the resource.
|
||||||
|
*/
|
||||||
|
public function actions(NovaRequest $request): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
91
app/Nova/Resources/Order/Card/CardType.php
Normal file
91
app/Nova/Resources/Order/Card/CardType.php
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Nova\Resources\Order\Card;
|
||||||
|
|
||||||
|
use App\Models\Order\Card\CardType as CardTypeModel;
|
||||||
|
use App\Nova\Resource;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Laravel\Nova\Fields\ID;
|
||||||
|
use Laravel\Nova\Fields\Text;
|
||||||
|
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||||
|
|
||||||
|
class CardType extends Resource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The model the resource corresponds to.
|
||||||
|
*
|
||||||
|
* @var class-string<CardTypeModel>
|
||||||
|
*/
|
||||||
|
public static $model = CardTypeModel::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 = [
|
||||||
|
'name',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the fields displayed by the resource.
|
||||||
|
*/
|
||||||
|
public function fields(NovaRequest $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ID::make()->sortable(),
|
||||||
|
|
||||||
|
Text::make(__('Name'), 'name')
|
||||||
|
->rules('required', 'string', 'max:255')
|
||||||
|
->translatable(),
|
||||||
|
|
||||||
|
Text::make(__('Price'), 'price')
|
||||||
|
->rules('nullable', 'numeric'),
|
||||||
|
|
||||||
|
Text::make(__('Notes'), 'notes')
|
||||||
|
->rules('required', 'string', 'max:255'),
|
||||||
|
|
||||||
|
NovaSwitcher::make(__('Active'), 'active')
|
||||||
|
->default(true),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the cards available for the request.
|
||||||
|
*/
|
||||||
|
public function cards(NovaRequest $request): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the filters available for the resource.
|
||||||
|
*/
|
||||||
|
public function filters(NovaRequest $request): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the lenses available for the resource.
|
||||||
|
*/
|
||||||
|
public function lenses(NovaRequest $request): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the actions available for the resource.
|
||||||
|
*/
|
||||||
|
public function actions(NovaRequest $request): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Nova\Resources\Order\Card\Concerns;
|
||||||
|
|
||||||
|
class CardOrderFieldsForDetail
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Nova\Resources\Order\Card\Concerns;
|
||||||
|
|
||||||
|
class CardOrderFieldsForIndex
|
||||||
|
{
|
||||||
|
}
|
||||||
35
app/Nova/Resources/Order/Card/Concerns/CardOrderNovaRepo.php
Normal file
35
app/Nova/Resources/Order/Card/Concerns/CardOrderNovaRepo.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Nova\Resources\Order\Card\Concerns;
|
||||||
|
|
||||||
|
use App\Models\Branch\Branch;
|
||||||
|
use App\Repos\Order\OrderRepo;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||||
|
|
||||||
|
class CardOrderNovaRepo
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Fill unique
|
||||||
|
*/
|
||||||
|
public static function fillUniqueId($request, $model): string
|
||||||
|
{
|
||||||
|
return mb_strtoupper(sprintf(
|
||||||
|
'TB%s-%s',
|
||||||
|
Branch::find($request->branch_id)->unique_code ?? 'TB',
|
||||||
|
$model->id
|
||||||
|
)) ?? uniqid();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* After model has been created
|
||||||
|
*/
|
||||||
|
public static function afterCreate(NovaRequest $request, Model $model): void
|
||||||
|
{
|
||||||
|
$model->update([
|
||||||
|
'unique_id' => static::fillUniqueId($request, $model),
|
||||||
|
'user_id' => auth()->id(),
|
||||||
|
'status' => OrderRepo::defaultStatus(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,7 +29,6 @@ use Laravel\Nova\Fields\Date;
|
|||||||
use Laravel\Nova\Fields\Email;
|
use Laravel\Nova\Fields\Email;
|
||||||
use Laravel\Nova\Fields\ID;
|
use Laravel\Nova\Fields\ID;
|
||||||
use Laravel\Nova\Fields\Image;
|
use Laravel\Nova\Fields\Image;
|
||||||
use Laravel\Nova\Fields\MorphMany;
|
|
||||||
use Laravel\Nova\Fields\Number;
|
use Laravel\Nova\Fields\Number;
|
||||||
use Laravel\Nova\Fields\Select;
|
use Laravel\Nova\Fields\Select;
|
||||||
use Laravel\Nova\Fields\Text;
|
use Laravel\Nova\Fields\Text;
|
||||||
@@ -66,7 +65,7 @@ class LoanOrder extends Resource
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $search = [
|
public static $search = [
|
||||||
'unique_id', 'customer_name', 'customer_surname',
|
'unique_id', 'customer_name', 'customer_surname', 'phone',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -367,9 +366,6 @@ class LoanOrder extends Resource
|
|||||||
->creationRules('required')
|
->creationRules('required')
|
||||||
->updateRules('nullable'),
|
->updateRules('nullable'),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
MorphMany::make(__('Actions'), 'actions', config('nova.actions.resource'))
|
|
||||||
->canSee(fn ($request) => false),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace App\Providers;
|
|||||||
|
|
||||||
use App\Nova\Dashboards\Main;
|
use App\Nova\Dashboards\Main;
|
||||||
use App\Nova\Resources\Branch\Branch;
|
use App\Nova\Resources\Branch\Branch;
|
||||||
|
use App\Nova\Resources\Order\Card\CardState;
|
||||||
use App\Nova\Resources\Order\Loan\LoanOrder;
|
use App\Nova\Resources\Order\Loan\LoanOrder;
|
||||||
use App\Nova\Resources\Order\Loan\LoanType;
|
use App\Nova\Resources\Order\Loan\LoanType;
|
||||||
use App\Nova\Resources\System\Location\Province;
|
use App\Nova\Resources\System\Location\Province;
|
||||||
@@ -127,10 +128,14 @@ class NovaServiceProvider extends NovaApplicationServiceProvider
|
|||||||
MenuItem::resource(Permission::class),
|
MenuItem::resource(Permission::class),
|
||||||
])->collapsable(),
|
])->collapsable(),
|
||||||
|
|
||||||
MenuGroup::make(__('Loan'), [
|
MenuGroup::make(__('Loan orders'), [
|
||||||
MenuItem::resource(LoanType::class),
|
MenuItem::resource(LoanType::class),
|
||||||
])->collapsable(),
|
])->collapsable(),
|
||||||
|
|
||||||
|
MenuGroup::make(__('Card orders'), [
|
||||||
|
MenuItem::resource(CardState::class),
|
||||||
|
]),
|
||||||
|
|
||||||
MenuGroup::make(__('Location'), [
|
MenuGroup::make(__('Location'), [
|
||||||
MenuItem::resource(Province::class),
|
MenuItem::resource(Province::class),
|
||||||
MenuItem::resource(Branch::class),
|
MenuItem::resource(Branch::class),
|
||||||
|
|||||||
17
app/Repos/Order/Card/CardStateRepo.php
Normal file
17
app/Repos/Order/Card/CardStateRepo.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repos\Order\Card;
|
||||||
|
|
||||||
|
use App\Models\Order\Card\CardState;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
class CardStateRepo
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Card state values
|
||||||
|
*/
|
||||||
|
public static function values(): Collection|array
|
||||||
|
{
|
||||||
|
return CardState::where('active', true)->pluck('name', 'id');
|
||||||
|
}
|
||||||
|
}
|
||||||
17
app/Repos/Order/Card/CardTypeRepo.php
Normal file
17
app/Repos/Order/Card/CardTypeRepo.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repos\Order\Card;
|
||||||
|
|
||||||
|
use App\Models\Order\Card\CardType;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
class CardTypeRepo
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Card type values
|
||||||
|
*/
|
||||||
|
public static function values(): Collection|array
|
||||||
|
{
|
||||||
|
return CardType::where('active', true)->pluck('name', 'id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,8 @@ return new class extends Migration
|
|||||||
$table->id();
|
$table->id();
|
||||||
$table->jsonb('name');
|
$table->jsonb('name');
|
||||||
$table->string('price')->nullable();
|
$table->string('price')->nullable();
|
||||||
|
$table->string('notes')->nullable();
|
||||||
|
$table->boolean('active')->default(true);
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ return new class extends Migration
|
|||||||
$table->id();
|
$table->id();
|
||||||
$table->jsonb('name');
|
$table->jsonb('name');
|
||||||
$table->string('price')->nullable();
|
$table->string('price')->nullable();
|
||||||
|
$table->string('notes')->nullable();
|
||||||
|
$table->boolean('active')->default(true);
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,5 +231,10 @@
|
|||||||
"all": "ählisi",
|
"all": "ählisi",
|
||||||
"Created by": "Sargyt eden",
|
"Created by": "Sargyt eden",
|
||||||
"Updated by": "Üýtgeden",
|
"Updated by": "Üýtgeden",
|
||||||
"Passport files": "Pasport faýýlar"
|
"Passport files": "Pasport faýýlar",
|
||||||
|
"Card order": "Kart sargyt",
|
||||||
|
"Card orders": "Kart sargytlary",
|
||||||
|
"Reason for issuing the card": "Kartyň çykarylmagynyň sebäbi",
|
||||||
|
"Card state": "Kartyň çykarylmagynyň sebäbi",
|
||||||
|
"Card states": "Kartyň çykarylmagynyň sebäpleri"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user