Compare commits
3 Commits
94badf95b8
...
de63b29a45
| Author | SHA1 | Date | |
|---|---|---|---|
| de63b29a45 | |||
| e8595117ee | |||
| 92b067b939 |
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Clusters\Cards\CardOrders\Pages;
|
||||
|
||||
use App\Filament\Clusters\Cards\CardOrders\CardOrderResource;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ForceDeleteAction;
|
||||
use Filament\Actions\RestoreAction;
|
||||
@@ -15,6 +16,11 @@ class EditCardOrder extends EditRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('save_top')
|
||||
->label(__('filament-panels::resources/pages/edit-record.form.actions.save.label'))
|
||||
->submit(null)
|
||||
->action('save'),
|
||||
|
||||
DeleteAction::make(),
|
||||
ForceDeleteAction::make(),
|
||||
RestoreAction::make(),
|
||||
|
||||
@@ -2,17 +2,15 @@
|
||||
|
||||
namespace App\Filament\Clusters\Cards\CardOrders\Tables;
|
||||
|
||||
use App\Modules\CardOrder\Filament\Actions\PayCardOrderAction;
|
||||
use App\Modules\CardOrder\Models\CardOrder;
|
||||
use App\Modules\CardOrder\Repositories\CardOrderRepository;
|
||||
use App\Modules\OrderStatus\Repositories\OrderStatusRepository;
|
||||
use App\Modules\Region\Repositories\RegionRepository;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ForceDeleteBulkAction;
|
||||
use Filament\Actions\RestoreBulkAction;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\TrashedFilter;
|
||||
@@ -85,28 +83,8 @@ class CardOrdersTable
|
||||
TrashedFilter::make(),
|
||||
])
|
||||
->recordActions([
|
||||
Action::make('card_order_pay')
|
||||
->label(__('Pay'))
|
||||
->icon('heroicon-o-credit-card')
|
||||
->requiresConfirmation()
|
||||
->action(function (CardOrder $record) {
|
||||
$onlinePayment = CardOrderRepository::make()
|
||||
->createOnlinePaymentOrder($record);
|
||||
|
||||
if ($onlinePayment->successful()) {
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Sending')
|
||||
->send();
|
||||
|
||||
return redirect()->away($onlinePayment->paymentLink());
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Could not send')
|
||||
->send();
|
||||
}),
|
||||
PayCardOrderAction::make()
|
||||
->hidden(fn (CardOrder $record) => $record->paid),
|
||||
|
||||
EditAction::make(),
|
||||
])
|
||||
|
||||
@@ -5,17 +5,15 @@ namespace App\Filament\Clusters\Cards\Cards;
|
||||
use App\Filament\Clusters\Cards\Cards\Pages\ManageCards;
|
||||
use App\Filament\Clusters\Cards\CardsCluster;
|
||||
use App\Modules\AppHelpers\Repositories\DateHelper;
|
||||
use App\Modules\Card\Filament\Actions\CheckCardBalanceAction;
|
||||
use App\Modules\Card\Filament\Actions\DownloadCardRequisteAction;
|
||||
use App\Modules\Card\Filament\Actions\DownloadCardTransactionAction;
|
||||
use App\Modules\Card\Models\Card;
|
||||
use App\Modules\CardBalance\Repositories\CardBalanceRepository;
|
||||
use App\Modules\CardRequisite\Repositories\CardRequisiteRepository;
|
||||
use App\Modules\CardTransaction\Repositories\CardTransactionRepository;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
@@ -24,9 +22,7 @@ use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Livewire\Component;
|
||||
|
||||
class CardResource extends Resource
|
||||
{
|
||||
@@ -127,42 +123,9 @@ class CardResource extends Resource
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
Action::make('card_balance')
|
||||
->label(__('Card balance'))
|
||||
->icon('heroicon-o-credit-card')
|
||||
->requiresConfirmation(false)
|
||||
->modal()
|
||||
->modalContent(fn (Card $record): View => CardBalanceRepository::make()->showCardBalance($record))
|
||||
->modalFooterActions([]),
|
||||
|
||||
Action::make('card_transactions')
|
||||
->label(__('Card transactions'))
|
||||
->icon('heroicon-o-arrows-right-left')
|
||||
->requiresConfirmation()
|
||||
->modalIcon('heroicon-m-arrows-right-left')
|
||||
->schema([
|
||||
DatePicker::make('start_date')
|
||||
->label(__('Start date'))
|
||||
->native(false)
|
||||
->required()
|
||||
->beforeOrEqual('today'),
|
||||
|
||||
DatePicker::make('end_date')
|
||||
->label(__('End date'))
|
||||
->native(false)
|
||||
->required()
|
||||
->beforeOrEqual('today'),
|
||||
])
|
||||
->action(
|
||||
fn (array $data, Card $record, Component $livewire) => CardTransactionRepository::make()->downloadCardTransaction($data, $record, $livewire)
|
||||
),
|
||||
|
||||
Action::make('card_requisite')
|
||||
->label(__('Card requisite'))
|
||||
->icon('heroicon-o-document-text')
|
||||
->requiresConfirmation()
|
||||
->modalIcon('heroicon-o-document-text')
|
||||
->action(fn (Card $record) => CardRequisiteRepository::make()->downloadCardRequisite($record)),
|
||||
CheckCardBalanceAction::make(),
|
||||
DownloadCardTransactionAction::make(),
|
||||
DownloadCardRequisteAction::make(),
|
||||
|
||||
EditAction::make()
|
||||
->label(''),
|
||||
|
||||
@@ -22,6 +22,7 @@ use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Wizard;
|
||||
use Filament\Schemas\Components\Wizard\Step;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@@ -84,7 +85,7 @@ class LoanOrderForm
|
||||
->schema([
|
||||
Select::make('loan_type')
|
||||
->label(__('Loan type'))
|
||||
->relationship('loanType', 'name')
|
||||
->relationship('loanType', 'name', fn (Builder $query) => $query->orderByTranslation('name'))
|
||||
->required(),
|
||||
|
||||
TextInput::make('loan_amount')
|
||||
@@ -109,6 +110,8 @@ class LoanOrderForm
|
||||
Select::make('branch_id')
|
||||
->label(__('Branch'))
|
||||
->relationship('branch', 'name', function ($query, callable $get) {
|
||||
$query->orderByTranslation('name');
|
||||
|
||||
$region = $get('region');
|
||||
if ($region) {
|
||||
$query->where('region', $region);
|
||||
@@ -125,18 +128,21 @@ class LoanOrderForm
|
||||
->columnSpan(2)
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->autocomplete(Str::random(10)),
|
||||
->autocomplete(Str::random(10))
|
||||
->default(user()->first_name),
|
||||
|
||||
TextInput::make('customer_surname')
|
||||
->label(__('Surname'))
|
||||
->columnSpan(2)
|
||||
->required()
|
||||
->maxLength(255),
|
||||
->maxLength(255)
|
||||
->default(user()->last_name),
|
||||
|
||||
TextInput::make('customer_patronic_name')
|
||||
->label(__('Patronic name'))
|
||||
->columnSpan(2)
|
||||
->maxLength(255),
|
||||
->maxLength(255)
|
||||
->default(user()->getOption('patronic_name')),
|
||||
|
||||
DatePicker::make('born_at')
|
||||
->displayFormat('d.m.Y')
|
||||
@@ -144,7 +150,8 @@ class LoanOrderForm
|
||||
->native(false)
|
||||
->columnSpan(2)
|
||||
->required()
|
||||
->beforeOrEqual('today'),
|
||||
->beforeOrEqual('today')
|
||||
->default(user()->getOption('born_at')),
|
||||
|
||||
FusedGroup::make([
|
||||
Select::make('passport_serie')
|
||||
@@ -152,13 +159,15 @@ class LoanOrderForm
|
||||
->options(TurkmenPassportRepository::values())
|
||||
->native(false)
|
||||
->required()
|
||||
->columnSpan(1),
|
||||
->columnSpan(1)
|
||||
->default(user()->getOption('passport_serie')),
|
||||
|
||||
TextInput::make('passport_id')
|
||||
->label(__('Passport number'))
|
||||
->required()
|
||||
->columnSpan(1)
|
||||
->mask('999999'),
|
||||
->mask('999999')
|
||||
->default(user()->getOption('passport_id')),
|
||||
])
|
||||
->columnSpan(3)
|
||||
->label(__('Passport serie and number'))
|
||||
@@ -171,37 +180,43 @@ class LoanOrderForm
|
||||
->native(false)
|
||||
->closeOnDateSelection()
|
||||
->beforeOrEqual('today')
|
||||
->required(),
|
||||
->required()
|
||||
->default(user()->getOption('passport_given_at')),
|
||||
|
||||
TextInput::make('born_place')
|
||||
->columnSpan(3)
|
||||
->label(__('Born place (passport)'))
|
||||
->maxLength(255)
|
||||
->required(),
|
||||
->required()
|
||||
->default(user()->getOption('born_place')),
|
||||
|
||||
TextInput::make('passport_given_by')
|
||||
->label(__('Passport given by'))
|
||||
->columnSpan(4)
|
||||
->maxLength(255)
|
||||
->required(),
|
||||
->required()
|
||||
->default(user()->getOption('passport_given_by')),
|
||||
|
||||
TextInput::make('passport_address')
|
||||
->columnSpan(4)
|
||||
->label(__('Proscription for home'))
|
||||
->maxLength(255)
|
||||
->required(),
|
||||
->required()
|
||||
->default(user()->getOption('passport_address')),
|
||||
|
||||
TextInput::make('real_address')
|
||||
->label(__('Current home address'))
|
||||
->columnSpan(4)
|
||||
->maxLength(255)
|
||||
->required(),
|
||||
->required()
|
||||
->default(user()->getOption('real_address')),
|
||||
|
||||
TextInput::make('email')
|
||||
->label(__('Email'))
|
||||
->email()
|
||||
->maxLength(255)
|
||||
->columnSpan(2),
|
||||
->columnSpan(2)
|
||||
->default(user()->getOption('email')),
|
||||
|
||||
TextInput::make('phone')
|
||||
->label(__('Phone'))
|
||||
@@ -211,7 +226,8 @@ class LoanOrderForm
|
||||
->rules([
|
||||
new PhoneNumberVerificationRule,
|
||||
])
|
||||
->columnSpan(2),
|
||||
->columnSpan(2)
|
||||
->default(user()->phone),
|
||||
|
||||
TextInput::make('phone_additional')
|
||||
->label(__('Additional phone'))
|
||||
@@ -281,12 +297,14 @@ class LoanOrderForm
|
||||
->options(RegionRepository::values())
|
||||
->columnSpan(1)
|
||||
->live()
|
||||
->afterStateUpdated(fn (callable $set) => $set('branch_id', null))
|
||||
->afterStateUpdated(fn (callable $set) => $set('work_province_id', null))
|
||||
->required(),
|
||||
|
||||
Select::make('work_province_id')
|
||||
->label(__('Work province'))
|
||||
->relationship('workProvince', 'name', function ($query, callable $get) {
|
||||
$query->orderByTranslation('name');
|
||||
|
||||
$region = $get('work_region');
|
||||
if ($region) {
|
||||
$query->where('region', $region);
|
||||
|
||||
@@ -23,17 +23,17 @@ class LoanOrdersTable
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('loanType.name')
|
||||
->label('Тип кредита')
|
||||
->label(__('Loan type'))
|
||||
->sortable()
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('region')
|
||||
->label('Регион')
|
||||
->label(__('Region'))
|
||||
->sortable()
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('branch.name')
|
||||
->label('Филиал')
|
||||
->label(__('Branch'))
|
||||
->sortable()
|
||||
->searchable(),
|
||||
|
||||
|
||||
22
app/Modules/Card/Filament/Actions/CheckCardBalanceAction.php
Normal file
22
app/Modules/Card/Filament/Actions/CheckCardBalanceAction.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Card\Filament\Actions;
|
||||
|
||||
use App\Modules\Card\Models\Card;
|
||||
use App\Modules\CardBalance\Repositories\CardBalanceRepository;
|
||||
use Filament\Actions\Action;
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
class CheckCardBalanceAction
|
||||
{
|
||||
public static function make(): Action
|
||||
{
|
||||
return Action::make('card_balance')
|
||||
->label(__('Card balance'))
|
||||
->icon('heroicon-o-credit-card')
|
||||
->requiresConfirmation(false)
|
||||
->modal()
|
||||
->modalContent(fn (Card $record): View => CardBalanceRepository::make()->showCardBalance($record))
|
||||
->modalFooterActions([]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Card\Filament\Actions;
|
||||
|
||||
use App\Modules\Card\Models\Card;
|
||||
use App\Modules\CardRequisite\Repositories\CardRequisiteRepository;
|
||||
use Filament\Actions\Action;
|
||||
|
||||
class DownloadCardRequisteAction
|
||||
{
|
||||
public static function make(): Action
|
||||
{
|
||||
return Action::make('card_requisite')
|
||||
->label(__('Card requisite'))
|
||||
->icon('heroicon-o-document-text')
|
||||
->requiresConfirmation()
|
||||
->modalIcon('heroicon-o-document-text')
|
||||
->action(fn (Card $record) => CardRequisiteRepository::make()->downloadCardRequisite($record));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Card\Filament\Actions;
|
||||
|
||||
use App\Modules\Card\Models\Card;
|
||||
use App\Modules\CardTransaction\Repositories\CardTransactionRepository;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Livewire\Component;
|
||||
|
||||
class DownloadCardTransactionAction
|
||||
{
|
||||
public static function make(): Action
|
||||
{
|
||||
return Action::make('card_transactions')
|
||||
->label(__('Card transactions'))
|
||||
->icon('heroicon-o-arrows-right-left')
|
||||
->requiresConfirmation()
|
||||
->modalIcon('heroicon-m-arrows-right-left')
|
||||
->schema([
|
||||
DatePicker::make('start_date')
|
||||
->label(__('Start date'))
|
||||
->native(false)
|
||||
->required()
|
||||
->beforeOrEqual('today'),
|
||||
|
||||
DatePicker::make('end_date')
|
||||
->label(__('End date'))
|
||||
->native(false)
|
||||
->required()
|
||||
->beforeOrEqual('today'),
|
||||
])
|
||||
->action(
|
||||
fn (array $data, Card $record, Component $livewire) => CardTransactionRepository::make()->downloadCardTransaction($data, $record, $livewire)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\CardOrder\Filament\Actions;
|
||||
|
||||
use App\Modules\CardOrder\Models\CardOrder;
|
||||
use App\Modules\CardOrder\Repositories\CardOrderRepository;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
|
||||
class PayCardOrderAction
|
||||
{
|
||||
public static function make(): Action
|
||||
{
|
||||
return Action::make('card_order_pay')
|
||||
->label(__('Pay'))
|
||||
->icon('heroicon-o-credit-card')
|
||||
->requiresConfirmation()
|
||||
->action(function (CardOrder $record) {
|
||||
$onlinePayment = CardOrderRepository::make()
|
||||
->createOnlinePaymentOrder($record);
|
||||
|
||||
if ($onlinePayment->successful()) {
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Sending')
|
||||
->send();
|
||||
|
||||
return redirect()->away($onlinePayment->paymentLink());
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Could not send')
|
||||
->send();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user