diff --git a/app/Models/Order/Loan/LoanOrder.php b/app/Models/Order/Loan/LoanOrder.php index 24411b8..8da8fe4 100644 --- a/app/Models/Order/Loan/LoanOrder.php +++ b/app/Models/Order/Loan/LoanOrder.php @@ -4,10 +4,64 @@ namespace App\Models\Order\Loan; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; class LoanOrder extends Model { use HasFactory; use SoftDeletes; + + /** + * The attributes that are mass assignable. + * + * @var array + */ + protected $fillable = [ + 'unique_id', + 'loan_type', + 'region', + 'branch_id', + 'customer_name', + 'customer_surname', + 'customer_patronic_name', + 'passport_address', + 'real_address', + 'passport_serie', + 'passport_id', + 'passport_given_at', + 'passport_given_by', + 'born_place', + 'born_at', + 'email', + 'phone', + 'phone_additional', + 'phone_home', + 'work_region', + 'work_province', + 'work_company', + 'work_company_accountant_number', + 'work_started_at', + 'work_salary', + 'work_position', + 'education', + 'marriage_status', + 'passport_one', + 'passport_two', + 'passport_three', + 'passport_four', + 'filled_by', + 'user_id', + 'status', + 'status_reason', + 'notes', + ]; + + /** + * Loan type + */ + public function loanType(): BelongsTo + { + return $this->belongsTo(LoanType::class); + } } diff --git a/app/Nova/Resources/Order/Loan/LoanOrder.php b/app/Nova/Resources/Order/Loan/LoanOrder.php new file mode 100644 index 0000000..ebc5a16 --- /dev/null +++ b/app/Nova/Resources/Order/Loan/LoanOrder.php @@ -0,0 +1,163 @@ + + */ + public static $model = LoanOrderModel::class; + + /** + * The single value that should be used to represent the resource when being displayed. + * + * @var string + */ + public static $title = 'unique_id'; + + /** + * The columns that should be searched. + * + * @var array + */ + public static $search = [ + 'unique_id', + ]; + + /** + * Get the displayable label of the resource. + */ + public static function label(): string + { + return __('Loan orders'); + } + + /** + * Get the displayable singular label of the resource. + */ + public static function singularLabel(): string + { + return __('Loan order'); + } + + /** + * Get the fields displayed by the resource. + */ + public function fields(NovaRequest $request): array + { + return [ + ID::make()->sortable(), + + // $table->string('unique_id')->unique(); + + Select::make(__('Region'), 'region') + ->displayUsingLabels() + ->searchable() + ->options(RegionRepo::values()) + ->default(RegionRepo::default()) + ->rules('required') + ->sortable(), + + Select::make(__('Branch'), 'branch_id') + ->displayUsingLabels() + ->searchable() + ->options(BranchRepo::values()) + ->rules('required') + ->sortable(), + + Select::make(__('Loan type'), 'loan_type') + ->displayUsingLabels() + ->searchable() + ->options(LoanTypeRepo::values()) + ->rules('required') + ->sortable(), + + Text::make(__('Customer name'), 'customer_name') + ->rules('required', 'string', 'max:255'), + + Text::make(__('Customer surname'), 'customer_surname') + ->rules('required', 'string', 'max:255'), + + Text::make(__('Customer patronic name'), 'customer_patronic_name') + ->rules('required', 'string', 'max:255'), + + + // $table->string('passport_address'); + // $table->string('real_address'); + // $table->string('passport_serie')->index(); + // $table->integer('passport_id')->index(); + // $table->date('passport_given_at'); + // $table->string('passport_given_by'); + // $table->string('born_place'); + // $table->date('born_at'); + // $table->string('email')->nullable()->index(); + // $table->string('phone')->index(); + // $table->string('phone_additional')->nullable(); + // $table->string('phone_home')->nullable(); + // $table->string('work_region')->nullable()->index(); + // $table->string('work_province')->nullable(); + // $table->string('work_company')->nullable(); + // $table->string('work_company_accountant_number')->nullable(); + // $table->date('work_started_at')->nullable(); + // $table->string('work_salary')->nullable(); + // $table->string('work_position')->nullable(); + // $table->string('education'); + // $table->string('marriage_status'); + // $table->text('passport_one'); + // $table->text('passport_two'); + // $table->text('passport_three'); + // $table->text('passport_four'); + // $table->foreignId('filled_by')->constrained('users')->restrictOnDelete(); + // $table->foreignId('user_id')->constrained('users')->restrictOnDelete(); + // $table->string('status')->index(); + // $table->string('status_reason')->nullable(); + // $table->string('notes')->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 []; + } +} diff --git a/app/Nova/Resources/Order/Loan/LoanType.php b/app/Nova/Resources/Order/Loan/LoanType.php index 5621fee..3092e49 100644 --- a/app/Nova/Resources/Order/Loan/LoanType.php +++ b/app/Nova/Resources/Order/Loan/LoanType.php @@ -36,6 +36,22 @@ class LoanType extends Resource 'name', ]; + /** + * Get the displayable label of the resource. + */ + public static function label(): string + { + return __('Loan types'); + } + + /** + * Get the displayable singular label of the resource. + */ + public static function singularLabel(): string + { + return __('Loan type'); + } + /** * Get the fields displayed by the resource. */ diff --git a/app/Providers/NovaServiceProvider.php b/app/Providers/NovaServiceProvider.php index 9e6ac98..71d8240 100644 --- a/app/Providers/NovaServiceProvider.php +++ b/app/Providers/NovaServiceProvider.php @@ -3,6 +3,7 @@ namespace App\Providers; use App\Nova\Resources\Branch\Branch; +use App\Nova\Resources\Order\Loan\LoanOrder; use App\Nova\Resources\Order\Loan\LoanType; use App\Nova\Resources\System\Location\Province; use App\Nova\Resources\System\Roles\Permission; @@ -111,6 +112,10 @@ class NovaServiceProvider extends NovaApplicationServiceProvider return [ MenuSection::dashboard(Main::class)->icon('chart-bar'), + MenuSection::make(__('System'), [ + MenuItem::resource(LoanOrder::class), + ])->icon('collection')->collapsable(), + MenuSection::make(__('System'), [ MenuGroup::make(__('User'), [ MenuItem::resource(User::class), diff --git a/app/Repos/Branch/BranchRepo.php b/app/Repos/Branch/BranchRepo.php deleted file mode 100644 index 5b2c829..0000000 --- a/app/Repos/Branch/BranchRepo.php +++ /dev/null @@ -1,7 +0,0 @@ -