loan order improvemetns

This commit is contained in:
2023-11-27 01:30:49 +05:00
parent 0fcdedbcc7
commit c50aae497e
10 changed files with 104 additions and 92 deletions

View File

@@ -2,7 +2,7 @@
namespace App\Nova\Resources\Branch\Concerns; namespace App\Nova\Resources\Branch\Concerns;
use App\Models\Branch\Branch; use App\Models\System\Location\Province;
use Closure; use Closure;
class BranchNovaRepo class BranchNovaRepo
@@ -15,7 +15,7 @@ class BranchNovaRepo
return function ($field, $request, $formData) use ($attribute) { return function ($field, $request, $formData) use ($attribute) {
$field->options( $field->options(
$formData->{$attribute} $formData->{$attribute}
? Branch::where('region', $formData->{$attribute})->pluck('name', 'id') ? Province::where('region', $formData->{$attribute})->pluck('name', 'id')
: [] : []
); );
}; };

View File

@@ -2,7 +2,6 @@
namespace App\Nova\Resources\Order\Loan\Concerns; namespace App\Nova\Resources\Order\Loan\Concerns;
use App\Nova\Resources\Order\Loan\Concerns\LoanOrderNovaRepo;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Laravel\Nova\Http\Requests\NovaRequest; use Laravel\Nova\Http\Requests\NovaRequest;
@@ -10,9 +9,6 @@ trait LoanOrderEvents
{ {
/** /**
* Register a callback to be called after the resource is created. * Register a callback to be called after the resource is created.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @param \Illuminate\Database\Eloquent\Model $model
*/ */
public static function afterCreate(NovaRequest $request, Model $model): void public static function afterCreate(NovaRequest $request, Model $model): void
{ {

View File

@@ -0,0 +1,57 @@
<?php
namespace App\Nova\Resources\Order\Loan\Concerns;
use App\Repos\Order\Loan\BranchRepo;
use App\Repos\Order\Loan\LoanTypeRepo;
use App\Repos\Order\OrderRepo;
use App\Repos\System\Settings\Location\RegionRepo;
use Laravel\Nova\Fields\Badge;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Text;
class LoanOrderFieldsForIndex
{
/**
* Loan Order fields for "create"
*/
public static function make(): array
{
return [
ID::make()->hide(),
Text::make(__('ID'), 'unique_id')->sortable(),
Select::make(__('Loan type'), 'loan_type')
->displayUsingLabels()
->options(LoanTypeRepo::values())
->sortable(),
Select::make(__('Region'), 'region')
->displayUsingLabels()
->options(RegionRepo::values())
->sortable(),
Select::make(__('Branch'), 'branch_id')
->displayUsingLabels()
->options(BranchRepo::values())
->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()
->sortable(),
];
}
}

View File

@@ -4,7 +4,6 @@ namespace App\Nova\Resources\Order\Loan\Concerns;
use App\Models\Branch\Branch; use App\Models\Branch\Branch;
use App\Repos\Order\OrderRepo; use App\Repos\Order\OrderRepo;
use Closure;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Laravel\Nova\Http\Requests\NovaRequest; use Laravel\Nova\Http\Requests\NovaRequest;

View File

@@ -6,26 +6,20 @@ use App\Models\Order\Loan\LoanOrder as LoanOrderModel;
use App\Nova\Resource; use App\Nova\Resource;
use App\Nova\Resources\Branch\Concerns\BranchNovaRepo; use App\Nova\Resources\Branch\Concerns\BranchNovaRepo;
use App\Nova\Resources\Order\Loan\Concerns\LoanOrderEvents; use App\Nova\Resources\Order\Loan\Concerns\LoanOrderEvents;
use App\Nova\Resources\Order\Loan\Concerns\LoanOrderNovaRepo; use App\Nova\Resources\Order\Loan\Concerns\LoanOrderFieldsForIndex;
use App\Repos\Order\Loan\BranchRepo; use App\Repos\Order\Loan\BranchRepo;
use App\Repos\Order\Loan\LoanTypeRepo; use App\Repos\Order\Loan\LoanTypeRepo;
use App\Repos\Order\OrderRepo;
use App\Repos\System\Settings\Legal\EducationRepo; use App\Repos\System\Settings\Legal\EducationRepo;
use App\Repos\System\Settings\Legal\MarriageRepo; use App\Repos\System\Settings\Legal\MarriageRepo;
use App\Repos\System\Settings\Legal\PassportRepo; use App\Repos\System\Settings\Legal\PassportRepo;
use App\Repos\System\Settings\Location\RegionRepo; use App\Repos\System\Settings\Location\RegionRepo;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Konsulting\NovaTarget\NovaTarget;
use Laravel\Nova\Fields\Badge;
use Laravel\Nova\Fields\Date; use Laravel\Nova\Fields\Date;
use Laravel\Nova\Fields\Email; use Laravel\Nova\Fields\Email;
use Laravel\Nova\Fields\File;
use Laravel\Nova\Fields\Hidden;
use Laravel\Nova\Fields\ID; use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Image; use Laravel\Nova\Fields\Image;
use Laravel\Nova\Fields\Number; use Laravel\Nova\Fields\Number;
use Laravel\Nova\Fields\Select; use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Slug;
use Laravel\Nova\Fields\Text; use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest; use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Panel; use Laravel\Nova\Panel;
@@ -55,7 +49,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',
]; ];
/** /**
@@ -63,21 +57,21 @@ class LoanOrder extends Resource
* *
* @var bool * @var bool
*/ */
// public static $polling = true; public static $polling = true;
// /** /**
// * The interval at which Nova should poll for new resources. * The interval at which Nova should poll for new resources.
// * *
// * @var int * @var int
// */ */
// public static $pollingInterval = 120; public static $pollingInterval = 120;
// /** /**
// * Indicates whether to show the polling toggle button inside Nova. * Indicates whether to show the polling toggle button inside Nova.
// * *
// * @var bool * @var bool
// */ */
// public static $showPollingToggle = true; public static $showPollingToggle = true;
/** /**
* Get the displayable label of the resource. * Get the displayable label of the resource.
@@ -100,41 +94,7 @@ class LoanOrder extends Resource
*/ */
public function fieldsForIndex(NovaRequest $request): array public function fieldsForIndex(NovaRequest $request): array
{ {
return [ return LoanOrderFieldsForIndex::make();
ID::make()->hide(),
Text::make(__('ID'), 'unique_id')->sortable(),
Select::make(__('Loan type'), 'loan_type')
->displayUsingLabels()
->options(LoanTypeRepo::values())
->sortable(),
Select::make(__('Region'), 'region')
->displayUsingLabels()
->options(RegionRepo::values())
->sortable(),
Select::make(__('Branch'), 'branch_id')
->displayUsingLabels()
->options(BranchRepo::values())
->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()
->sortable(),
];
} }
/** /**
@@ -287,8 +247,8 @@ class LoanOrder extends Resource
->displayUsingLabels() ->displayUsingLabels()
->searchable() ->searchable()
->dependsOn('region', BranchNovaRepo::dependsOnRegion('work_region')) ->dependsOn('region', BranchNovaRepo::dependsOnRegion('work_region'))
->size('w-1/2'), ->size('w-1/2')
// ->rules('required'), ->rules('required'),
Text::make(__('Position'), 'work_position') Text::make(__('Position'), 'work_position')
->size('w-1/2') ->size('w-1/2')

View File

@@ -4,7 +4,6 @@ namespace App\Nova;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Validation\Rules; use Illuminate\Validation\Rules;
use Laravel\Nova\Fields\Gravatar;
use Laravel\Nova\Fields\ID; use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Password; use Laravel\Nova\Fields\Password;
use Laravel\Nova\Fields\Text; use Laravel\Nova\Fields\Text;

View File

@@ -12,6 +12,6 @@ class LoanTypeRepo
*/ */
public static function values(): Collection|array public static function values(): Collection|array
{ {
return LoanType::pluck('name', 'id'); return LoanType::where('active', true)->pluck('name', 'id');
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
return [ return [
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@@ -6,8 +7,8 @@ return [
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
*/ */
"paths" => [ 'paths' => [
"lang_folder" => base_path('lang') 'lang_folder' => base_path('lang'),
], ],
/* /*
@@ -16,7 +17,7 @@ return [
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
*/ */
"search" => [ 'search' => [
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@@ -24,9 +25,9 @@ return [
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
*/ */
"folders" => [ 'folders' => [
base_path("app"), base_path('app'),
resource_path("views"), resource_path('views'),
], ],
/* /*
@@ -35,7 +36,7 @@ return [
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
*/ */
"files" => [ 'files' => [
], ],
/* /*
@@ -44,8 +45,8 @@ return [
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
*/ */
"exclude" => [ 'exclude' => [
"storage", 'storage',
], ],
/* /*
@@ -54,10 +55,10 @@ return [
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
*/ */
"file_extension" => [ 'file_extension' => [
'*.php', '*.php',
'*.js', '*.js',
] ],
], ],
/* /*
@@ -66,7 +67,7 @@ return [
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
*/ */
"translation_methods" => [ 'translation_methods' => [
'\$t', '\$t',
'i18n.t', 'i18n.t',
'@lang', '@lang',

View File

@@ -3,7 +3,6 @@
namespace Database\Seeders; namespace Database\Seeders;
use App\Models\System\Location\Province; use App\Models\System\Location\Province;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class ProvinceTableSeeder extends Seeder class ProvinceTableSeeder extends Seeder

View File

@@ -14,9 +14,9 @@
"Completed": "Tamamlanan", "Completed": "Tamamlanan",
"Contact data": "Habarlaşmak üçin maglumatlar", "Contact data": "Habarlaşmak üçin maglumatlar",
"Current Residence": "Häzirki ýaşaýyş ýeri", "Current Residence": "Häzirki ýaşaýyş ýeri",
"Name": "Adyňyz", "Name": "Ady",
"Patronic name": "Ataňyzyň ady", "Patronic name": "Ataňyzyň ady",
"Surname": "Familiýaňyz", "Surname": "Familiýa",
"Dashoguz": "Daşoguz", "Dashoguz": "Daşoguz",
"Date of birth": "Doglan gün", "Date of birth": "Doglan gün",
"Divorced": "Aýrylşan", "Divorced": "Aýrylşan",
@@ -61,9 +61,10 @@
"Phone Additional": "Telefon goşmaça", "Phone Additional": "Telefon goşmaça",
"Position": "Positionerleşişi", "Position": "Positionerleşişi",
"Processing": "Gaýtadan işlemek", "Processing": "Gaýtadan işlemek",
"Province": "Welaýat", "Province": "Etrap",
"Provinces": "Welaýatlar", "Provinces": "Etraplar",
"Region": "Welaýat", "Region": "Welaýat",
"Regions": "Welaýatlar",
"Registered": "Bellige alyndy", "Registered": "Bellige alyndy",
"Residence (passport)": "Ýazgy edilen salgyňyz", "Residence (passport)": "Ýazgy edilen salgyňyz",
"Role": "Rol", "Role": "Rol",