card pin order
This commit is contained in:
@@ -122,7 +122,6 @@ class LoginController extends Controller
|
||||
/**
|
||||
* Send the response after the user was authenticated.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function sendLoginResponse(Request $request)
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LocaleController extends Controller
|
||||
{
|
||||
/**
|
||||
|
||||
77
app/Models/Order/Card/CardPin/CardPin.php
Normal file
77
app/Models/Order/Card/CardPin/CardPin.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Order\Card\CardPin;
|
||||
|
||||
use App\Models\Branch\Branch;
|
||||
use App\Models\Order\Card\CardType;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class CardPin extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'unique_id',
|
||||
'card_type_id',
|
||||
'card_number',
|
||||
'region',
|
||||
'branch_id',
|
||||
'customer_name',
|
||||
'customer_surname',
|
||||
'customer_patronic_name',
|
||||
'born_at',
|
||||
'phone',
|
||||
'passport_serie',
|
||||
'passport_id',
|
||||
'status',
|
||||
'passport_one',
|
||||
'passport_two',
|
||||
'passport_three',
|
||||
'passport_four',
|
||||
'notes',
|
||||
'user_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'born_at' => 'date',
|
||||
];
|
||||
|
||||
/**
|
||||
* User
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Card type
|
||||
*/
|
||||
public function cardType(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CardType::class, 'card_type_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Branch
|
||||
*/
|
||||
public function branch(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Branch::class, 'branch_id');
|
||||
}
|
||||
}
|
||||
335
app/Nova/Resources/Order/Card/Pin/CardPin.php
Normal file
335
app/Nova/Resources/Order/Card/Pin/CardPin.php
Normal file
@@ -0,0 +1,335 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova\Resources\Order\Card\Pin;
|
||||
|
||||
use App\Models\Branch\Branch;
|
||||
use App\Models\Order\Card\CardPin\CardPin as CardPinModel;
|
||||
use App\Nova\Filters\RegionFilter;
|
||||
use App\Nova\Filters\StatusFilter;
|
||||
use App\Nova\Nova;
|
||||
use App\Nova\Resource;
|
||||
use App\Repos\Order\Card\CardTypeRepo;
|
||||
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\OnlyLetters;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Laravel\Nova\Fields\Date;
|
||||
use Laravel\Nova\Fields\Hidden;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Image;
|
||||
use Laravel\Nova\Fields\Number;
|
||||
use Laravel\Nova\Fields\Select;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Laravel\Nova\Panel;
|
||||
use Nurmuhammet\NovaInputmask\NovaInputmask;
|
||||
|
||||
class CardPin extends Resource
|
||||
{
|
||||
/**
|
||||
* The model the resource corresponds to.
|
||||
*/
|
||||
public static $model = CardPinModel::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', 'cardType'];
|
||||
|
||||
/**
|
||||
* 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 pins');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the displayable singular label of the resource.
|
||||
*/
|
||||
public static function singularLabel(): string
|
||||
{
|
||||
return __('Card pin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text for the create resource button.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
// public static function createButtonLabel(): string
|
||||
// {
|
||||
// return __('Order a cart requisite');
|
||||
// }
|
||||
|
||||
/**
|
||||
* Get the text for the update resource button.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
// public static function updateButtonLabel(): string
|
||||
// {
|
||||
// return __('Update cart requisite');
|
||||
// }
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* After resource created
|
||||
*
|
||||
* @param Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @param Illuminate\Database\Eloquent\Model $model
|
||||
*/
|
||||
public static function afterCreate(NovaRequest $request, Model $model): void
|
||||
{
|
||||
// CardOrderRepo::created()($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(),
|
||||
|
||||
Hidden::make('user_id')
|
||||
->default(auth()->id())
|
||||
->hideWhenUpdating(),
|
||||
|
||||
Select::make(__('Status'), 'status')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(OrderRepo::statusValues())
|
||||
->default(OrderRepo::defaultStatus())
|
||||
->fullWidth()
|
||||
->rules('required')
|
||||
->canSeeWhen('systemUser', $this),
|
||||
|
||||
Text::make(__('Note'), 'notes')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
|
||||
new Panel(__('Card'), [
|
||||
Select::make(__('Card type'), 'card_type_id')
|
||||
->displayUsingLabels()
|
||||
->fullWidth()
|
||||
->searchable()
|
||||
->options(CardTypeRepo::values())
|
||||
->size('w-1/2')
|
||||
->rules('required'),
|
||||
|
||||
NovaInputmask::make(__('Card number'), 'card_number')
|
||||
->mask('9999 9999 9999 9999')
|
||||
->storeRawValue()
|
||||
->size('w-1/2')
|
||||
->rules('required'),
|
||||
]),
|
||||
|
||||
new Panel(__('Location'), [
|
||||
Select::make(__('Region'), 'region')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(RegionRepo::values())
|
||||
->default(RegionRepo::default())
|
||||
->size('w-1/2')
|
||||
->rules('required'),
|
||||
|
||||
Select::make(__('Branch'), 'branch_id')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->dependsOn('region', NovaRepo::dependsOnRegion('region', Branch::class))
|
||||
->size('w-1/2')
|
||||
->rules('required'),
|
||||
]),
|
||||
|
||||
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/2')
|
||||
->rules('required', 'before_or_equal:today'),
|
||||
|
||||
NovaInputmask::make(__('Phone'), 'phone')
|
||||
->mask('+(\\9\\93)-99-99-99-99')
|
||||
->storeRawValue()
|
||||
->size('w-1/2')
|
||||
->rules('required', 'integer', 'between:61000000, 71999999'),
|
||||
]),
|
||||
|
||||
new Panel(__('Passport'), [
|
||||
Select::make(__('Passport serie'), 'passport_serie')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(PassportRepo::values())
|
||||
->size('w-1/2')
|
||||
->rules('required'),
|
||||
|
||||
Number::make(__('Passport id'), 'passport_id')
|
||||
->size('w-1/2')
|
||||
->rules('required', 'numeric', 'digits:6'),
|
||||
|
||||
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.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function cards(NovaRequest $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filters available for the resource.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function filters(NovaRequest $request)
|
||||
{
|
||||
return [
|
||||
RegionFilter::make()
|
||||
->canSee(fn () => Gate::allows('isAdmin'), auth()->user()),
|
||||
|
||||
new StatusFilter(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 [];
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,6 @@ class CardRequisite extends Resource
|
||||
{
|
||||
/**
|
||||
* The model the resource corresponds to.
|
||||
*
|
||||
*/
|
||||
public static $model = CardRequisiteModel::class;
|
||||
|
||||
@@ -166,9 +165,6 @@ class CardRequisite extends Resource
|
||||
|
||||
/**
|
||||
* Get the fields displayed by the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function fields(NovaRequest $request): array
|
||||
{
|
||||
@@ -295,7 +291,6 @@ class CardRequisite extends Resource
|
||||
/**
|
||||
* Get the cards available for the request.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function cards(NovaRequest $request)
|
||||
@@ -306,7 +301,6 @@ class CardRequisite extends Resource
|
||||
/**
|
||||
* Get the filters available for the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function filters(NovaRequest $request)
|
||||
@@ -322,7 +316,6 @@ class CardRequisite extends Resource
|
||||
/**
|
||||
* Get the lenses available for the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function lenses(NovaRequest $request)
|
||||
@@ -333,7 +326,6 @@ class CardRequisite extends Resource
|
||||
/**
|
||||
* Get the actions available for the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function actions(NovaRequest $request)
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Nova\Resources\Branch\Branch;
|
||||
use App\Nova\Resources\Order\Card\CardOrder;
|
||||
use App\Nova\Resources\Order\Card\CardState;
|
||||
use App\Nova\Resources\Order\Card\CardType;
|
||||
use App\Nova\Resources\Order\Card\Pin\CardPin;
|
||||
use App\Nova\Resources\Order\Card\Requisite\CardRequisite;
|
||||
use App\Nova\Resources\Order\Loan\LoanOrder;
|
||||
use App\Nova\Resources\Order\Loan\LoanType;
|
||||
@@ -117,13 +118,14 @@ class NovaServiceProvider extends NovaApplicationServiceProvider
|
||||
MenuSection::dashboard(Main::class)->icon('chart-bar'),
|
||||
|
||||
MenuSection::make(__('Orders'), [
|
||||
MenuGroup::make(__('Loan department'), [
|
||||
MenuGroup::make(__('Loan department'), [
|
||||
MenuItem::resource(LoanOrder::class),
|
||||
])->collapsedByDefault(),
|
||||
|
||||
MenuGroup::make(__('Card department'), [
|
||||
MenuGroup::make(__('Card department'), [
|
||||
MenuItem::resource(CardOrder::class)->name(__('Order new card')),
|
||||
MenuItem::resource(CardRequisite::class),
|
||||
MenuItem::resource(CardPin::class),
|
||||
])->collapsedByDefault(),
|
||||
])->icon('ticket')->collapsedByDefault(),
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('card_pins', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->string('unique_id')->nullable()->unique();
|
||||
|
||||
$table->foreignId('card_type_id')->constrained()->restrictOnDelete();
|
||||
$table->string('card_number');
|
||||
|
||||
$table->string('region', 2)->index();
|
||||
$table->foreignId('branch_id')->constrained('branches')->restrictOnDelete();
|
||||
|
||||
$table->string('customer_name')->index();
|
||||
$table->string('customer_surname')->index();
|
||||
$table->string('customer_patronic_name')->nullable();
|
||||
$table->date('born_at')->nullable();
|
||||
|
||||
$table->string('phone')->nullable()->index();
|
||||
|
||||
$table->string('passport_serie')->index();
|
||||
$table->string('passport_id')->index();
|
||||
|
||||
$table->string('status')->nullable()->default(OrderRepo::defaultStatus())->index();
|
||||
|
||||
$table->text('passport_one')->nullable();
|
||||
$table->text('passport_two')->nullable();
|
||||
$table->text('passport_three')->nullable();
|
||||
$table->text('passport_four')->nullable();
|
||||
|
||||
$table->text('notes')->nullable();
|
||||
|
||||
$table->foreignId('user_id')->constrained('users')->restrictOnDelete();
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('card_pins');
|
||||
}
|
||||
};
|
||||
@@ -266,5 +266,7 @@
|
||||
"Card requisites": "Kart rekwizitler",
|
||||
"Order a cart requisite": "Kart rekwizitini sargyt ediň",
|
||||
"Update cart requisite": "Üýtget",
|
||||
"Card number": "Kart belgisi"
|
||||
"Card number": "Kart belgisi",
|
||||
"Card pin": "Kart pin bukja",
|
||||
"Card pins": "Kart pin bukjalar"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user