nang cap san sang import
This commit is contained in:
@@ -5,6 +5,9 @@ namespace App\Filament\Resources\Products;
|
||||
use App\Filament\Resources\Products\Pages\CreateProduct;
|
||||
use App\Filament\Resources\Products\Pages\EditProduct;
|
||||
use App\Filament\Resources\Products\Pages\ListProducts;
|
||||
use App\Filament\Resources\Products\RelationManagers\ContractsRelationManager;
|
||||
use App\Filament\Resources\Products\RelationManagers\HandoversRelationManager;
|
||||
use App\Filament\Resources\Products\RelationManagers\ProductServicesRelationManager;
|
||||
use App\Filament\Resources\Products\Schemas\ProductForm;
|
||||
use App\Filament\Resources\Products\Tables\ProductsTable;
|
||||
use App\Models\Product;
|
||||
@@ -42,7 +45,9 @@ class ProductResource extends Resource
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
ContractsRelationManager::class,
|
||||
HandoversRelationManager::class,
|
||||
ProductServicesRelationManager::class,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Products\RelationManagers;
|
||||
|
||||
use App\Enums\ContractStatus;
|
||||
use App\Enums\ContractType;
|
||||
use App\Filament\Resources\Contracts\ContractResource;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filter;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ContractsRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'contracts';
|
||||
|
||||
protected static ?string $title = 'Contracts';
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->recordTitleAttribute('type')
|
||||
->columns([
|
||||
TextColumn::make('type')
|
||||
->badge()
|
||||
->formatStateUsing(fn (string $state): string => ContractType::from($state)->label()),
|
||||
TextColumn::make('customer.name')
|
||||
->label('Customer')
|
||||
->searchable(),
|
||||
TextColumn::make('status')
|
||||
->badge()
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'active' => 'success',
|
||||
'expired' => 'warning',
|
||||
'liquidated' => 'danger',
|
||||
default => 'gray',
|
||||
})
|
||||
->formatStateUsing(fn (string $state): string => ContractStatus::from($state)->label()),
|
||||
TextColumn::make('start_date')
|
||||
->date('d/m/Y')
|
||||
->sortable(),
|
||||
TextColumn::make('end_date')
|
||||
->date('d/m/Y')
|
||||
->sortable(),
|
||||
TextColumn::make('signed_status')
|
||||
->label('Signed'),
|
||||
TextColumn::make('feedbacks_count')
|
||||
->counts('feedbacks')
|
||||
->label('Tickets'),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('type')
|
||||
->options(ContractType::options()),
|
||||
SelectFilter::make('status')
|
||||
->options(ContractStatus::ACTIVE->options()),
|
||||
])
|
||||
->defaultSort('created_at', 'desc')
|
||||
->headerActions([])
|
||||
->recordActions([]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Products\RelationManagers;
|
||||
|
||||
use App\Enums\HandoverStatus;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class HandoversRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'handovers';
|
||||
|
||||
protected static ?string $title = 'Handovers';
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->recordTitleAttribute('status')
|
||||
->columns([
|
||||
TextColumn::make('customer.name')
|
||||
->label('Customer')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('handover_date')
|
||||
->label('Ngày BG')
|
||||
->date('d/m/Y')
|
||||
->sortable(),
|
||||
TextColumn::make('status')
|
||||
->badge()
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'da_ban_giao' => 'success',
|
||||
'da_len_lich' => 'info',
|
||||
'du_dieu_kien' => 'warning',
|
||||
'chua_du_dieu_kien' => 'danger',
|
||||
default => 'gray',
|
||||
})
|
||||
->formatStateUsing(fn (string $state): string => HandoverStatus::from($state)->label()),
|
||||
TextColumn::make('remark')
|
||||
->label('Ghi chú')
|
||||
->limit(50)
|
||||
->toggleable(),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime('d/m/Y')
|
||||
->sortable()
|
||||
->toggleable(),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('status')
|
||||
->options(HandoverStatus::NOT_READY->options()),
|
||||
])
|
||||
->defaultSort('handover_date', 'desc')
|
||||
->headerActions([])
|
||||
->recordActions([]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Products\RelationManagers;
|
||||
|
||||
use App\Enums\ServiceType;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ProductServicesRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'productServices';
|
||||
|
||||
protected static ?string $title = 'Services';
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->recordTitleAttribute('service_type')
|
||||
->columns([
|
||||
TextColumn::make('service_type')
|
||||
->badge()
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'management_fee' => 'info',
|
||||
'gratitude' => 'success',
|
||||
'self_business' => 'warning',
|
||||
default => 'gray',
|
||||
})
|
||||
->formatStateUsing(fn (string $state): string => ServiceType::from($state)->label()),
|
||||
TextColumn::make('status')
|
||||
->badge()
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'active' => 'success',
|
||||
'pending' => 'warning',
|
||||
'completed' => 'info',
|
||||
'cancelled' => 'danger',
|
||||
default => 'gray',
|
||||
}),
|
||||
TextColumn::make('actual_collection_date')
|
||||
->label('Ngày thu')
|
||||
->date('d/m/Y')
|
||||
->sortable(),
|
||||
TextColumn::make('remark')
|
||||
->label('Ghi chú')
|
||||
->limit(50)
|
||||
->toggleable(),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime('d/m/Y')
|
||||
->sortable()
|
||||
->toggleable(),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('service_type')
|
||||
->options(ServiceType::MANAGEMENT_FEE->options()),
|
||||
SelectFilter::make('status')
|
||||
->options([
|
||||
'active' => 'Active',
|
||||
'pending' => 'Pending',
|
||||
'completed' => 'Completed',
|
||||
'cancelled' => 'Cancelled',
|
||||
]),
|
||||
])
|
||||
->defaultSort('created_at', 'desc')
|
||||
->headerActions([])
|
||||
->recordActions([]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user