Add card order
This commit is contained in:
@@ -2,6 +2,101 @@
|
||||
|
||||
namespace App\Nova\Resources\Order\Card\Concerns;
|
||||
|
||||
use App\Nova\Resources\Branch\Branch;
|
||||
use App\Nova\Resources\Order\Card\CardState;
|
||||
use App\Nova\Resources\Order\Card\CardType;
|
||||
use App\Nova\User;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use App\Repos\System\Location\CountryRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Laravel\Nova\Fields\Badge;
|
||||
use Laravel\Nova\Fields\BelongsTo;
|
||||
use Laravel\Nova\Fields\Date;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Image;
|
||||
use Laravel\Nova\Fields\Select;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Panel;
|
||||
use Nurmuhammet\NovaInputmask\NovaInputmask;
|
||||
|
||||
class CardOrderFieldsForDetail
|
||||
{
|
||||
/**
|
||||
* Fields for index page
|
||||
*/
|
||||
public static function make($resource): array
|
||||
{
|
||||
return [
|
||||
ID::make()->hide(),
|
||||
Text::make(__('ID'), 'unique_id'),
|
||||
|
||||
Badge::make(__('Status'), 'status')
|
||||
->map(OrderRepo::statusClasses())
|
||||
->addTypes([
|
||||
'primary' => 'dark:bg-gray-900 bg-gray-600 text-white',
|
||||
])
|
||||
->labels(OrderRepo::statusValues())
|
||||
->withIcons()
|
||||
->icons(OrderRepo::statusIcons()),
|
||||
|
||||
Text::make(__('Note'), 'notes'),
|
||||
|
||||
BelongsTo::make(__('Created by').': ', 'user', User::class),
|
||||
|
||||
new Panel(__('Card'), [
|
||||
BelongsTo::make(__('Reason for issuing the card'), 'cardState', CardState::class),
|
||||
BelongsTo::make(__('Card type'), 'cardType', CardType::class),
|
||||
]),
|
||||
|
||||
new Panel(__('Location'), [
|
||||
Select::make(__('Region'), 'region')
|
||||
->displayUsingLabels()
|
||||
->options(RegionRepo::values()),
|
||||
|
||||
BelongsTo::make(__('Branch'), 'branch', Branch::class),
|
||||
]),
|
||||
|
||||
new Panel(__('Personal data'), [
|
||||
Text::make(
|
||||
__('Full Name'),
|
||||
fn ($model) => sprintf(
|
||||
'%s %s%s %s',
|
||||
$model->customer_name,
|
||||
$model->customer_surname,
|
||||
$model->old_surname ? sprintf('(%s)', $model->old_surname) : '',
|
||||
$model->customer_patronic_name
|
||||
)
|
||||
),
|
||||
|
||||
Date::make(__('Date of birth'), 'born_at')
|
||||
->toTurkmenFormat(),
|
||||
|
||||
NovaInputmask::make(__('Phone'), 'phone')
|
||||
->mask('+(\\9\\93)-99-99-99-99')
|
||||
->storeRawValue(),
|
||||
|
||||
NovaInputmask::make(__('Phone additional'), 'phone_additional')
|
||||
->mask('+(\\9\\93)-99-99-99-99')
|
||||
->storeRawValue(),
|
||||
|
||||
Select::make(__('Citizenship'), 'citizenship')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(CountryRepo::values()),
|
||||
|
||||
Text::make(__('Residence (passport)'), 'passport_address'),
|
||||
|
||||
Text::make(__('Current Residence'), 'real_address'),
|
||||
|
||||
Text::make(__('Work location and your position'), 'job_location'),
|
||||
]),
|
||||
|
||||
new Panel(__('Passport files'), [
|
||||
Image::make(__('Passport (page 1)'), 'passport_one'),
|
||||
Image::make(__('Passport (page 2-3)'), 'passport_two'),
|
||||
Image::make(__('Passport (page 8-9)'), 'passport_three'),
|
||||
Image::make(__('Passport (page 32)'), 'passport_four'),
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,61 @@
|
||||
|
||||
namespace App\Nova\Resources\Order\Card\Concerns;
|
||||
|
||||
use App\Nova\Resources\Branch\Branch;
|
||||
use App\Nova\Resources\Order\Card\CardState;
|
||||
use App\Nova\Resources\Order\Card\CardType;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Laravel\Nova\Fields\Badge;
|
||||
use Laravel\Nova\Fields\BelongsTo;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Select;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
|
||||
class CardOrderFieldsForIndex
|
||||
{
|
||||
/**
|
||||
* Fields for index page
|
||||
*/
|
||||
public static function make($resource): array
|
||||
{
|
||||
return [
|
||||
ID::make()->hide(),
|
||||
|
||||
Text::make(__('ID'), 'unique_id')->sortable(),
|
||||
|
||||
BelongsTo::make(__('Reason'), 'cardState', CardState::class)
|
||||
->sortable(),
|
||||
|
||||
BelongsTo::make(__('Type'), 'cardType', CardType::class)
|
||||
->sortable(),
|
||||
|
||||
Select::make(__('Region'), 'region')
|
||||
->displayUsingLabels()
|
||||
->options(RegionRepo::values())
|
||||
->canSeeWhen('isAdmin', $resource)
|
||||
->sortable(),
|
||||
|
||||
BelongsTo::make(__('Branch'), 'branch', Branch::class)
|
||||
->canSeeWhen('isAdmin', $resource)
|
||||
->filterable()
|
||||
->sortable(),
|
||||
|
||||
Text::make(__('Name'), 'customer_name'),
|
||||
|
||||
Text::make(__('Surname'), 'customer_surname'),
|
||||
|
||||
Text::make(__('Phone'), 'phone'),
|
||||
|
||||
Badge::make(__('Status'), 'status')
|
||||
->map(OrderRepo::statusClasses())
|
||||
->addTypes([
|
||||
'primary' => 'dark:bg-gray-900 bg-gray-600 text-white',
|
||||
])
|
||||
->labels(OrderRepo::statusValues())
|
||||
->withIcons()
|
||||
->icons(OrderRepo::statusIcons())
|
||||
->sortable(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,34 +2,6 @@
|
||||
|
||||
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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user