Hoan thien core finance v2
This commit is contained in:
42
app/Filament/Resources/Appendices/AppendixResource.php
Normal file
42
app/Filament/Resources/Appendices/AppendixResource.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Appendices;
|
||||
|
||||
use App\Filament\Resources\Appendices\Pages;
|
||||
use App\Models\Appendix;
|
||||
use App\Enums\NavigationGroup;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables\Table;
|
||||
use App\Filament\Resources\Appendices\Schemas\AppendixForm;
|
||||
use App\Filament\Resources\Appendices\Tables\AppendicesTable;
|
||||
|
||||
class AppendixResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Appendix::class;
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-document-text';
|
||||
protected static string | \UnitEnum | null $navigationGroup = NavigationGroup::TRANSACTION->value;
|
||||
protected static ?int $navigationSort = 4;
|
||||
|
||||
protected static ?string $modelLabel = 'Phụ lục';
|
||||
protected static ?string $pluralModelLabel = 'Phụ lục HĐ';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return AppendixForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return AppendicesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListAppendices::route('/'),
|
||||
'create' => Pages\CreateAppendix::route('/create'),
|
||||
'edit' => Pages\EditAppendix::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
11
app/Filament/Resources/Appendices/Pages/CreateAppendix.php
Normal file
11
app/Filament/Resources/Appendices/Pages/CreateAppendix.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Appendices\Pages;
|
||||
|
||||
use App\Filament\Resources\Appendices\AppendixResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateAppendix extends CreateRecord
|
||||
{
|
||||
protected static string $resource = AppendixResource::class;
|
||||
}
|
||||
11
app/Filament/Resources/Appendices/Pages/EditAppendix.php
Normal file
11
app/Filament/Resources/Appendices/Pages/EditAppendix.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Appendices\Pages;
|
||||
|
||||
use App\Filament\Resources\Appendices\AppendixResource;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditAppendix extends EditRecord
|
||||
{
|
||||
protected static string $resource = AppendixResource::class;
|
||||
}
|
||||
11
app/Filament/Resources/Appendices/Pages/ListAppendices.php
Normal file
11
app/Filament/Resources/Appendices/Pages/ListAppendices.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Appendices\Pages;
|
||||
|
||||
use App\Filament\Resources\Appendices\AppendixResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListAppendices extends ListRecords
|
||||
{
|
||||
protected static string $resource = AppendixResource::class;
|
||||
}
|
||||
65
app/Filament/Resources/Appendices/Schemas/AppendixForm.php
Normal file
65
app/Filament/Resources/Appendices/Schemas/AppendixForm.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Appendices\Schemas;
|
||||
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\KeyValue;
|
||||
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 AppendixForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Grid::make(3)
|
||||
->schema([
|
||||
Section::make('Thông tin phụ lục')
|
||||
->columnSpan(2)
|
||||
->columns(2)
|
||||
->schema([
|
||||
Select::make('contract_id')
|
||||
->label('Hợp đồng gốc')
|
||||
->relationship('contract', 'contract_number')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
|
||||
Select::make('product_id')
|
||||
->label('Sản phẩm')
|
||||
->relationship('product', 'code')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
|
||||
TextInput::make('type')
|
||||
->label('Loại phụ lục')
|
||||
->required(),
|
||||
|
||||
TextInput::make('apply_from_order')
|
||||
->label('Áp dụng từ CN thứ')
|
||||
->numeric()
|
||||
->default(0)
|
||||
->required(),
|
||||
|
||||
DatePicker::make('signing_date')
|
||||
->label('Ngày ký phụ lục')
|
||||
->required(),
|
||||
]),
|
||||
|
||||
Section::make('Dữ liệu bổ sung')
|
||||
->columnSpan(1)
|
||||
->schema([
|
||||
KeyValue::make('custom_data')
|
||||
->label('Thông tin bổ sung')
|
||||
->keyLabel('Thông tin')
|
||||
->valueLabel('Giá trị'),
|
||||
]),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
38
app/Filament/Resources/Appendices/Tables/AppendicesTable.php
Normal file
38
app/Filament/Resources/Appendices/Tables/AppendicesTable.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Appendices\Tables;
|
||||
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class AppendicesTable
|
||||
{
|
||||
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('product.code')
|
||||
->label('Sản phẩm')
|
||||
->searchable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('type')
|
||||
->label('Loại phụ lục')
|
||||
->badge(),
|
||||
|
||||
Tables\Columns\TextColumn::make('apply_from_order')
|
||||
->label('Từ CN')
|
||||
->alignCenter(),
|
||||
|
||||
Tables\Columns\TextColumn::make('signing_date')
|
||||
->label('Ngày ký')
|
||||
->date('d/m/Y')
|
||||
->sortable(),
|
||||
])
|
||||
->defaultSort('signing_date', 'desc');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user