Loan paid off letter order
This commit is contained in:
68
app/Models/Order/Loan/LoanPaidOffLetterOrder.php
Normal file
68
app/Models/Order/Loan/LoanPaidOffLetterOrder.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Order\Loan;
|
||||
|
||||
use App\Models\Branch\Branch;
|
||||
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;
|
||||
use Laravel\Nova\Actions\Actionable;
|
||||
|
||||
class LoanPaidOffLetterOrder extends Model
|
||||
{
|
||||
use Actionable;
|
||||
use HasFactory;
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'unique_id',
|
||||
'region',
|
||||
'branch_id',
|
||||
'customer_name',
|
||||
'customer_surname',
|
||||
'customer_patronic_name',
|
||||
'born_at',
|
||||
'phone',
|
||||
'passport_serie',
|
||||
'passport_id',
|
||||
'loan_contract_number',
|
||||
'loan_contract_date',
|
||||
'loan_amount',
|
||||
'loan_reason',
|
||||
'status',
|
||||
'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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Branch
|
||||
*/
|
||||
public function branch(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Branch::class, 'branch_id');
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ use App\Nova\Filters\RegionFilter;
|
||||
use App\Nova\Filters\StatusFilter;
|
||||
use App\Nova\Nova;
|
||||
use App\Nova\Resource;
|
||||
use App\Nova\Resources\Order\Card\Concerns\CardOrderFieldsForIndex;
|
||||
use App\Nova\Resources\Order\Card\Requisite\Concerns\CardRequisiteFieldsForDetail;
|
||||
use App\Nova\Resources\Order\Card\Requisite\Concerns\CardRequisiteFieldsForIndex;
|
||||
use App\Repos\Order\Card\CardOrderRepo;
|
||||
|
||||
@@ -11,7 +11,6 @@ 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\File;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Image;
|
||||
use Laravel\Nova\Fields\Number;
|
||||
@@ -24,7 +23,6 @@ class CardRequisiteFieldsForDetail
|
||||
{
|
||||
/**
|
||||
* Fields for index
|
||||
* @param $resource
|
||||
*/
|
||||
public static function make($resource): array
|
||||
{
|
||||
@@ -78,7 +76,7 @@ class CardRequisiteFieldsForDetail
|
||||
NovaInputmask::make(__('Phone'), 'phone')
|
||||
->mask('+(\\9\\93)-99-99-99-99')
|
||||
->storeRawValue(),
|
||||
]),
|
||||
]),
|
||||
|
||||
new Panel(__('Passport'), [
|
||||
Select::make(__('Passport serie'), 'passport_serie')
|
||||
|
||||
@@ -16,8 +16,6 @@ class CardRequisiteFieldsForIndex
|
||||
{
|
||||
/**
|
||||
* Fields for index
|
||||
* @param $resource
|
||||
* @param $request
|
||||
*/
|
||||
public static function make($resource, $request): array
|
||||
{
|
||||
|
||||
254
app/Nova/Resources/Order/Loan/LoanPaidOffLetterOrder.php
Normal file
254
app/Nova/Resources/Order/Loan/LoanPaidOffLetterOrder.php
Normal file
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova\Resources\Order\Loan;
|
||||
|
||||
use App\Models\Branch\Branch;
|
||||
use App\Models\Order\Loan\LoanPaidOffLetterOrder as LoanPaidOffLetterOrderModel;
|
||||
use App\Nova\Filters\RegionFilter;
|
||||
use App\Nova\Filters\StatusFilter;
|
||||
use App\Nova\Resource;
|
||||
use App\Repos\Order\Card\CardOrderRepo;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use App\Repos\System\Nova\NovaRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use App\Rules\OnlyLetters;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Laravel\Nova\Fields\Hidden;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
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 LoanPaidOffLetterOrder extends Resource
|
||||
{
|
||||
/**
|
||||
* The model the resource corresponds to.
|
||||
*/
|
||||
public static $model = LoanPaidOffLetterOrderModel::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'];
|
||||
|
||||
/**
|
||||
* 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 __('Karzyň ýapylandygy barada güwanama almak');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the displayable singular label of the resource.
|
||||
*/
|
||||
public static function singularLabel(): string
|
||||
{
|
||||
return __('Karzyň ýapylandygy barada güwanama almak');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
$model->update(['unique_id' => CardOrderRepo::fillUniqueId($model)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields displayed by the resource.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fields(NovaRequest $request)
|
||||
{
|
||||
return [
|
||||
ID::make()->sortable(),
|
||||
|
||||
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(__('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(__('Karz barada maglumatlar'), [
|
||||
Text::make(__('Karz şertnamanyň belgisi'), 'loan_contract_number')
|
||||
->rules('required', 'string', 'max:255'),
|
||||
|
||||
Text::make(__('Karz şertnamanyň senesi'), 'loan_contract_date')
|
||||
->rules('required', 'string', 'max:255'),
|
||||
|
||||
Text::make(__('Karzyň möçberi'), 'loan_amount')
|
||||
->rules('required', 'string', 'max:255'),
|
||||
|
||||
Text::make(__('Karzyň maksady'), 'loan_reason')
|
||||
->rules('required', 'string', 'max:255'),
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 [];
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ 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\LoanPaidOffLetterOrder;
|
||||
use App\Nova\Resources\Order\Loan\LoanType;
|
||||
use App\Nova\Resources\System\Location\Province;
|
||||
use App\Nova\Resources\System\Roles\Permission;
|
||||
@@ -120,6 +121,7 @@ class NovaServiceProvider extends NovaApplicationServiceProvider
|
||||
MenuSection::make(__('Orders'), [
|
||||
MenuGroup::make(__('Loan department'), [
|
||||
MenuItem::resource(LoanOrder::class),
|
||||
MenuItem::resource(LoanPaidOffLetterOrder::class),
|
||||
])->collapsedByDefault(),
|
||||
|
||||
MenuGroup::make(__('Card department'), [
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?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('loan_paid_off_letter_orders', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->string('unique_id')->nullable()->unique();
|
||||
$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('notes')->nullable();
|
||||
|
||||
$table->foreignId('user_id')->constrained('users')->restrictOnDelete();
|
||||
|
||||
$table->string('loan_contract_number')->nullable();
|
||||
$table->string('loan_contract_date')->nullable();
|
||||
$table->string('loan_amount')->nullable();
|
||||
$table->string('loan_reason')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('loan_paid_off_letter_orders');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user