Hoan thien core finance v2
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PaymentFines\Pages;
|
||||
|
||||
use App\Filament\Resources\PaymentFines\PaymentFineResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreatePaymentFine extends CreateRecord
|
||||
{
|
||||
protected static string $resource = PaymentFineResource::class;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PaymentFines\Pages;
|
||||
|
||||
use App\Filament\Resources\PaymentFines\PaymentFineResource;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditPaymentFine extends EditRecord
|
||||
{
|
||||
protected static string $resource = PaymentFineResource::class;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PaymentFines\Pages;
|
||||
|
||||
use App\Filament\Resources\PaymentFines\PaymentFineResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListPaymentFines extends ListRecords
|
||||
{
|
||||
protected static string $resource = PaymentFineResource::class;
|
||||
}
|
||||
42
app/Filament/Resources/PaymentFines/PaymentFineResource.php
Normal file
42
app/Filament/Resources/PaymentFines/PaymentFineResource.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PaymentFines;
|
||||
|
||||
use App\Filament\Resources\PaymentFines\Pages;
|
||||
use App\Models\PaymentFine;
|
||||
use App\Enums\NavigationGroup;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables\Table;
|
||||
use App\Filament\Resources\PaymentFines\Schemas\PaymentFineForm;
|
||||
use App\Filament\Resources\PaymentFines\Tables\PaymentFinesTable;
|
||||
|
||||
class PaymentFineResource extends Resource
|
||||
{
|
||||
protected static ?string $model = PaymentFine::class;
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-exclamation-triangle';
|
||||
protected static string | \UnitEnum | null $navigationGroup = NavigationGroup::FINANCE->value;
|
||||
protected static ?int $navigationSort = 6;
|
||||
|
||||
protected static ?string $modelLabel = 'Tiền phạt';
|
||||
protected static ?string $pluralModelLabel = 'Tiền phạt';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return PaymentFineForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return PaymentFinesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListPaymentFines::route('/'),
|
||||
'create' => Pages\CreatePaymentFine::route('/create'),
|
||||
'edit' => Pages\EditPaymentFine::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PaymentFines\Schemas;
|
||||
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class PaymentFineForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Grid::make(3)
|
||||
->schema([
|
||||
Section::make('Thông tin tiền phạt')
|
||||
->columnSpan(2)
|
||||
->columns(2)
|
||||
->schema([
|
||||
Select::make('contract_id')
|
||||
->label('Hợp đồng')
|
||||
->relationship('contract', 'contract_number')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
|
||||
TextInput::make('amount')
|
||||
->label('Số tiền phạt')
|
||||
->numeric()
|
||||
->prefix('VND')
|
||||
->required(),
|
||||
|
||||
TextInput::make('reason')
|
||||
->label('Lý do phạt')
|
||||
->required(),
|
||||
|
||||
DatePicker::make('due_date')
|
||||
->label('Ngày đến hạn nộp phạt')
|
||||
->required(),
|
||||
|
||||
DatePicker::make('paid_date')
|
||||
->label('Ngày thực nộp')
|
||||
->nullable(),
|
||||
]),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\PaymentFines\Tables;
|
||||
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class PaymentFinesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('contract.contract_number')
|
||||
->label('Hợp đồng')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('amount')
|
||||
->label('Số tiền phạt')
|
||||
->money('VND')
|
||||
->sortable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('reason')
|
||||
->label('Lý do')
|
||||
->searchable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('due_date')
|
||||
->label('Hạn nộp')
|
||||
->date('d/m/Y')
|
||||
->sortable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('paid_date')
|
||||
->label('Ngày nộp')
|
||||
->date('d/m/Y')
|
||||
->placeholder('Chưa nộp')
|
||||
->color(fn ($state) => $state ? 'success' : 'danger'),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\Filter::make('unpaid')
|
||||
->label('Chưa nộp')
|
||||
->query(fn ($query) => $query->whereNull('paid_date')),
|
||||
])
|
||||
->defaultSort('due_date', 'desc');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user