wip
This commit is contained in:
@@ -256,7 +256,7 @@ class CardOrderForm
|
||||
->required()
|
||||
->columnSpan(2),
|
||||
])->columnSpan(4),
|
||||
])->columnSpanFull(),
|
||||
])->columnSpanFull()->skippable(fn (string $context) => $context === 'edit'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Clusters\Loans\LoanOrders\Schemas;
|
||||
|
||||
use App\Modules\FilamentPermission\Repositories\FilamentPermissionRepository;
|
||||
use App\Modules\LoanOrder\Models\LoanOrderRequiredDocs;
|
||||
use App\Modules\LoanOrder\Repositories\LoanOrderRepository;
|
||||
use App\Modules\OrderStatus\Repositories\OrderStatusRepository;
|
||||
@@ -39,7 +40,8 @@ class LoanOrderForm
|
||||
Section::make(__('New loan order'))
|
||||
->columnSpan(4)
|
||||
->columns(4)
|
||||
|
||||
->disabled(fn (string $context): bool => FilamentPermissionRepository::forClients())
|
||||
->hidden(fn (string $context) => FilamentPermissionRepository::defaultSystemInput($context))
|
||||
->components([
|
||||
Select::make('status')
|
||||
->label(__('Status'))
|
||||
@@ -343,9 +345,10 @@ class LoanOrderForm
|
||||
->displayFormat('d.m.Y')
|
||||
->beforeOrEqual('today')
|
||||
->required()
|
||||
->native(false)
|
||||
->columnSpan(1),
|
||||
]),
|
||||
])->columnSpan(4),
|
||||
])->columnSpan(4)->skippable(fn (string $context) => $context === 'edit'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,11 @@ class LoansTable
|
||||
{
|
||||
return $table
|
||||
->modifyQueryUsing(function (Builder $query) {
|
||||
DefaultQueryForResourceIndexRepository::make($query);
|
||||
if (user()->isAdmin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$query->where('user_id', user()->id);
|
||||
})
|
||||
->columns([
|
||||
TextColumn::make('account_number')
|
||||
|
||||
@@ -8,7 +8,7 @@ use App\Filament\Clusters\Loans\Resources\LoanOrderMobiles\Pages\EditLoanOrderMo
|
||||
use App\Filament\Clusters\Loans\Resources\LoanOrderMobiles\Pages\ListLoanOrderMobiles;
|
||||
use App\Filament\Clusters\Loans\Resources\LoanOrderMobiles\Schemas\LoanOrderMobileForm;
|
||||
use App\Filament\Clusters\Loans\Resources\LoanOrderMobiles\Tables\LoanOrderMobilesTable;
|
||||
use App\Modules\LoanOrder\Models\LoanOrder;
|
||||
use App\Modules\LoanOrderMobile\Models\LoanOrderMobile;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
@@ -19,7 +19,7 @@ use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class LoanOrderMobileResource extends Resource
|
||||
{
|
||||
protected static ?string $model = LoanOrder::class;
|
||||
protected static ?string $model = LoanOrderMobile::class;
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
|
||||
@@ -453,7 +453,7 @@ class LoanOrderMobileForm
|
||||
Tab::make(__('Guarantor').' 2')
|
||||
->columns(6)
|
||||
->hidden(function (Get $get): bool {
|
||||
$loan_amount = string($get('loan_amount'));
|
||||
$loan_amount = $get('loan_amount') ? string($get('loan_amount')) : 1;
|
||||
|
||||
return ! ($loan_amount && intval($loan_amount) > 20000);
|
||||
})
|
||||
|
||||
64
app/Modules/LoanOrderMobile/LoanOrderMobileModule.php
Normal file
64
app/Modules/LoanOrderMobile/LoanOrderMobileModule.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\LoanOrderMobile;
|
||||
|
||||
use App\Modules\Makeable;
|
||||
use App\Modules\ModuleContract;
|
||||
|
||||
class LoanOrderMobileModule implements ModuleContract
|
||||
{
|
||||
use Makeable;
|
||||
|
||||
/**
|
||||
* Module is enabled
|
||||
*/
|
||||
protected bool $enabled = true;
|
||||
|
||||
/**
|
||||
* Check if is module enabled
|
||||
*/
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable module
|
||||
*/
|
||||
public function disable(): void
|
||||
{
|
||||
$this->enabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable module
|
||||
*/
|
||||
public function enable(): void
|
||||
{
|
||||
$this->enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if module has a filament resource
|
||||
*/
|
||||
public function hasFilamentResource(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get module composer requirements
|
||||
*/
|
||||
public function getComposerRequirements(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get module composer suggestions
|
||||
*/
|
||||
public function getComposerSuggestions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
182
app/Modules/LoanOrderMobile/Models/LoanOrderMobile.php
Normal file
182
app/Modules/LoanOrderMobile/Models/LoanOrderMobile.php
Normal file
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\LoanOrderMobile\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Modules\Branch\Interfaces\BelongsToBranch;
|
||||
use App\Modules\Branch\Models\Branch;
|
||||
use App\Modules\LoanOrder\Models\LoanOrderRequiredDocs;
|
||||
use App\Modules\LoanOrder\Models\LoanType;
|
||||
use App\Modules\LoanOrder\Repositories\LoanOrderRepository;
|
||||
use App\Modules\OrderStatus\Interfaces\HasStatus;
|
||||
use App\Modules\Province\Models\Province;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $unique_id
|
||||
* @property string|null $source
|
||||
* @property int|null $user_id
|
||||
* @property int $loan_type
|
||||
* @property string $region
|
||||
* @property int $branch_id
|
||||
* @property string $customer_name
|
||||
* @property string $customer_surname
|
||||
* @property string|null $customer_patronic_name
|
||||
* @property string $passport_address
|
||||
* @property string $real_address
|
||||
* @property string $passport_serie
|
||||
* @property string $passport_id
|
||||
* @property Carbon $passport_given_at
|
||||
* @property string $passport_given_by
|
||||
* @property string $born_place
|
||||
* @property Carbon $born_at
|
||||
* @property string|null $email
|
||||
* @property string $phone
|
||||
* @property string|null $phone_additional
|
||||
* @property string|null $phone_home
|
||||
* @property string|null $work_region
|
||||
* @property int|null $work_province_id
|
||||
* @property string|null $work_company
|
||||
* @property string|null $work_company_accountant_number
|
||||
* @property Carbon|null $work_started_at
|
||||
* @property string|null $work_salary
|
||||
* @property string|null $work_position
|
||||
* @property string $education
|
||||
* @property string $marriage_status
|
||||
* @property string $passport_one
|
||||
* @property string $passport_two
|
||||
* @property string $passport_three
|
||||
* @property string $passport_four
|
||||
* @property string|null $loan_amount
|
||||
* @property string|null $card_number
|
||||
* @property string|null $card_name
|
||||
* @property string|null $card_month
|
||||
* @property string|null $card_year
|
||||
* @property string $guarantor_name
|
||||
* @property string|null $guarantor_surname
|
||||
* @property string|null $guarantor_patronic_name
|
||||
* @property string|null $guarantor_passport_serie
|
||||
* @property string|null $guarantor_passport_id
|
||||
* @property string|null $guarantor_card_number
|
||||
* @property string|null $guarantor_card_name
|
||||
* @property string|null $guarantor_card_month
|
||||
* @property string|null $guarantor_card_year
|
||||
* @property string|null $guarantor_note
|
||||
* @property string|null $guarantor_2_name
|
||||
* @property string|null $guarantor_2_surname
|
||||
* @property string|null $guarantor_2_patronic_name
|
||||
* @property string|null $guarantor_2_passport_serie
|
||||
* @property string|null $guarantor_2_passport_id
|
||||
* @property string|null $guarantor_2_card_number
|
||||
* @property string|null $guarantor_2_card_name
|
||||
* @property string|null $guarantor_2_card_month
|
||||
* @property string|null $guarantor_2_card_year
|
||||
* @property string|null $guarantor_2_note
|
||||
* @property string|null $loan_card_number
|
||||
* @property string|null $loan_card_name
|
||||
* @property string|null $loan_card_month
|
||||
* @property string|null $loan_card_year
|
||||
* @property int $loan_order_required_doc_id
|
||||
* @property string|null $status
|
||||
* @property string|null $satisfiable
|
||||
* @property string|null $notes
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
*/
|
||||
class LoanOrderMobile extends Model implements BelongsToBranch, HasStatus
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* Table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'loan_orders';
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'passport_given_at' => 'date',
|
||||
'born_at' => 'date',
|
||||
'work_started_at' => 'date',
|
||||
];
|
||||
|
||||
/**
|
||||
* Loan type
|
||||
*
|
||||
* @return BelongsTo<LoanType, $this>
|
||||
*/
|
||||
public function loanType(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(LoanType::class, 'loan_type');
|
||||
}
|
||||
|
||||
/**
|
||||
* Branch
|
||||
*
|
||||
* @return BelongsTo<Branch, $this>
|
||||
*/
|
||||
public function branch(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Branch::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Work province
|
||||
*
|
||||
* @return BelongsTo<Province, $this>
|
||||
*/
|
||||
public function workProvince(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Province::class, 'work_province_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* User (who created order)
|
||||
*
|
||||
* @return BelongsTo<User, $this>
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Required docs
|
||||
*
|
||||
* @return BelongsTo<LoanOrderRequiredDocs, $this>
|
||||
*/
|
||||
public function requiredDocs(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(LoanOrderRequiredDocs::class, 'loan_order_required_doc_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* "boot" method for model
|
||||
*/
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(LoanOrderRepository::creating());
|
||||
static::created(LoanOrderRepository::created());
|
||||
// static::updated(function (LoanOrder $model) {
|
||||
// if ($model->notes && $model->wasChanged('notes')) {
|
||||
// Alert::create([
|
||||
// 'user_id' => $model->user_id,
|
||||
// 'name' => 'Duýdyryş',
|
||||
// 'value' => $model->notes,
|
||||
// ]);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\LoanOrderMobile\Policies;
|
||||
|
||||
use App\Modules\LoanOrderMobile\Models\LoanOrderMobile;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Foundation\Auth\User as AuthUser;
|
||||
|
||||
class LoanOrderMobilePolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function viewAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ViewAny:LoanOrderMobile');
|
||||
}
|
||||
|
||||
public function view(AuthUser $authUser, LoanOrderMobile $loanOrderMobile): bool
|
||||
{
|
||||
return $authUser->can('View:LoanOrderMobile');
|
||||
}
|
||||
|
||||
public function create(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Create:LoanOrderMobile');
|
||||
}
|
||||
|
||||
public function update(AuthUser $authUser, LoanOrderMobile $loanOrderMobile): bool
|
||||
{
|
||||
return $authUser->can('Update:LoanOrderMobile');
|
||||
}
|
||||
|
||||
public function delete(AuthUser $authUser, LoanOrderMobile $loanOrderMobile): bool
|
||||
{
|
||||
return $authUser->can('Delete:LoanOrderMobile');
|
||||
}
|
||||
|
||||
public function restore(AuthUser $authUser, LoanOrderMobile $loanOrderMobile): bool
|
||||
{
|
||||
return $authUser->can('Restore:LoanOrderMobile');
|
||||
}
|
||||
|
||||
public function forceDelete(AuthUser $authUser, LoanOrderMobile $loanOrderMobile): bool
|
||||
{
|
||||
return $authUser->can('ForceDelete:LoanOrderMobile');
|
||||
}
|
||||
|
||||
public function forceDeleteAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('ForceDeleteAny:LoanOrderMobile');
|
||||
}
|
||||
|
||||
public function restoreAny(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('RestoreAny:LoanOrderMobile');
|
||||
}
|
||||
|
||||
public function replicate(AuthUser $authUser, LoanOrderMobile $loanOrderMobile): bool
|
||||
{
|
||||
return $authUser->can('Replicate:LoanOrderMobile');
|
||||
}
|
||||
|
||||
public function reorder(AuthUser $authUser): bool
|
||||
{
|
||||
return $authUser->can('Reorder:LoanOrderMobile');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\LoanOrderMobile\Repositories;
|
||||
|
||||
class LoanOrderMobileRepository {}
|
||||
@@ -59,11 +59,20 @@ function module_exists(string $moduleName): bool
|
||||
*/
|
||||
function string(mixed $value): string
|
||||
{
|
||||
if (! is_string($value)) {
|
||||
throw new Exception('!!!Make it string!!!');
|
||||
if (is_string($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
return $value;
|
||||
if ($value instanceof Stringable) {
|
||||
return (string) $value;
|
||||
}
|
||||
|
||||
// Optionally handle scalar values (int, float, bool) as strings too
|
||||
if (is_scalar($value)) {
|
||||
return (string) $value;
|
||||
}
|
||||
|
||||
throw new Exception('Value is not stringable.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user