ranjith-dev #878
148
app/Filament/Exports/StickerMappingMasterExporter.php
Normal file
148
app/Filament/Exports/StickerMappingMasterExporter.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\StickerMappingMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class StickerMappingMasterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = StickerMappingMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('itemCharacteristic.item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('sticker_structure1_id')
|
||||
->label('STICKER 1')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker1Structure?->sticker_id ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker1_machine_id')
|
||||
->label('WC STICKER 1')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker1Machine?->work_center ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker1_print_ip')
|
||||
->label('STICKER 1 PRINT IP'),
|
||||
ExportColumn::make('sticker_structure2_id')
|
||||
->label('STICKER 2')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker2Structure?->sticker_id ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker2_machine_id')
|
||||
->label('WC STICKER 2')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker2Machine?->work_center ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker2_print_ip')
|
||||
->label('STICKER 2 PRINT IP'),
|
||||
ExportColumn::make('sticker_structure3_id')
|
||||
->label('STICKER 3')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker3Structure?->sticker_id ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker3_machine_id')
|
||||
->label('WC STICKER 3')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker3Machine?->work_center ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker3_print_ip')
|
||||
->label('STICKER 3 PRINT IP'),
|
||||
ExportColumn::make('sticker_structure4_id')
|
||||
->label('STICKER 4')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker4Structure?->sticker_id ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker4_machine_id')
|
||||
->label('WC STICKER 4')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker4Machine?->work_center ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker4_print_ip')
|
||||
->label('STICKER 4 PRINT IP'),
|
||||
ExportColumn::make('sticker_structure5_id')
|
||||
->label('STICKER 5')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker5Structure?->sticker_id ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker5_machine_id')
|
||||
->label('WC STICKER 5')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker5Machine?->work_center ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker5_print_ip')
|
||||
->label('STICKER 5 PRINT IP'),
|
||||
ExportColumn::make('sticker_structure6_id')
|
||||
->label('STICKER 6')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker6Structure?->sticker_id ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker6_machine_id')
|
||||
->label('WC STICKER 6')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker6Machine?->work_center ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker6_print_ip')
|
||||
->label('STICKER 6 PRINT IP'),
|
||||
ExportColumn::make('sticker_structure7_id')
|
||||
->label('STICKER 7')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker7Structure?->sticker_id ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker7_machine_id')
|
||||
->label('WC STICKER 7')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker2Machine?->work_center ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker7_print_ip')
|
||||
->label('STICKER 7 PRINT IP'),
|
||||
ExportColumn::make('sticker_structure8_id')
|
||||
->label('STICKER 8')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker8Structure?->sticker_id ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker8_machine_id')
|
||||
->label('WC STICKER 8')
|
||||
->getStateUsing(function ($record) {
|
||||
return $record->sticker8Machine?->work_center ?? '-';
|
||||
}),
|
||||
ExportColumn::make('sticker8_print_ip')
|
||||
->label('STICKER 8 PRINT IP'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your sticker mapping master export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
55
app/Filament/Imports/StickerMappingMasterImporter.php
Normal file
55
app/Filament/Imports/StickerMappingMasterImporter.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\StickerMappingMaster;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class StickerMappingMasterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = StickerMappingMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant_id')
|
||||
->requiredMapping()
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('sticker1'),
|
||||
ImportColumn::make('sticker2'),
|
||||
ImportColumn::make('sticker3'),
|
||||
ImportColumn::make('sticker4'),
|
||||
ImportColumn::make('sticker5'),
|
||||
ImportColumn::make('created_by'),
|
||||
ImportColumn::make('updated_by'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?StickerMappingMaster
|
||||
{
|
||||
// return StickerMappingMaster::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new StickerMappingMaster();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your sticker mapping master import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
478
app/Filament/Resources/StickerMappingMasterResource.php
Normal file
478
app/Filament/Resources/StickerMappingMasterResource.php
Normal file
@@ -0,0 +1,478 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\StickerMappingMasterExporter;
|
||||
use App\Filament\Imports\StickerMappingMasterImporter;
|
||||
use App\Filament\Resources\StickerMappingMasterResource\Pages;
|
||||
use App\Filament\Resources\StickerMappingMasterResource\RelationManagers;
|
||||
use App\Models\Item;
|
||||
use App\Models\ItemCharacteristic;
|
||||
use App\Models\Machine;
|
||||
use App\Models\StickerMappingMaster;
|
||||
use App\Models\StickerStructureDetail;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
|
||||
class StickerMappingMasterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = StickerMappingMaster::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Customized Sticker Printing';
|
||||
|
||||
// public static function form(Form $form): Form
|
||||
// {
|
||||
// return $form
|
||||
// ->schema([
|
||||
// Forms\Components\TextInput::make('plant_id')
|
||||
// ->required()
|
||||
// ->numeric(),
|
||||
// Forms\Components\TextInput::make('item_id')
|
||||
// ->required()
|
||||
// ->numeric(),
|
||||
// Forms\Components\Textarea::make('sticker1')
|
||||
// ->columnSpanFull(),
|
||||
// Forms\Components\Textarea::make('sticker2')
|
||||
// ->columnSpanFull(),
|
||||
// Forms\Components\Textarea::make('sticker3')
|
||||
// ->columnSpanFull(),
|
||||
// Forms\Components\Textarea::make('sticker4')
|
||||
// ->columnSpanFull(),
|
||||
// Forms\Components\Textarea::make('sticker5')
|
||||
// ->columnSpanFull(),
|
||||
// Forms\Components\Textarea::make('created_by')
|
||||
// ->columnSpanFull(),
|
||||
// Forms\Components\Textarea::make('updated_by')
|
||||
// ->columnSpanFull(),
|
||||
// ]);
|
||||
// }
|
||||
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
/* -------- Basic Mapping -------- */
|
||||
Section::make('Basic Mapping')
|
||||
->schema([
|
||||
Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
|
||||
Select::make('item_characteristic_id')
|
||||
->label('Item Code')
|
||||
->reactive()
|
||||
//->relationship('item', 'code')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return ItemCharacteristic::query()
|
||||
->whereHas('item', function ($query) use ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
})
|
||||
->with('item')
|
||||
->get()
|
||||
->mapWithKeys(fn ($ic) => [
|
||||
$ic->id => $ic->item->code,
|
||||
]);
|
||||
})
|
||||
->searchable()
|
||||
->required(),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
/* -------- Sticker 1 -------- */
|
||||
Section::make('Sticker 1')
|
||||
->schema([
|
||||
Select::make('sticker_structure1_id')
|
||||
->label('Sticker ID')
|
||||
->options(function (callable $get) {
|
||||
return StickerStructureDetail::pluck('sticker_id', 'id');
|
||||
})
|
||||
->searchable(),
|
||||
Select::make('sticker1_machine_id')
|
||||
->label('Work Center')
|
||||
//->relationship('sticker1Machine', 'name')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
||||
})
|
||||
->searchable(),
|
||||
TextInput::make('sticker1_print_ip')
|
||||
->label('Printer IP')
|
||||
->ipv4(),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
/* -------- Sticker 2 -------- */
|
||||
Section::make('Sticker 2')
|
||||
->schema([
|
||||
Select::make('sticker_structure2_id')
|
||||
->label('Sticker ID')
|
||||
->options(function (callable $get) {
|
||||
return StickerStructureDetail::pluck('sticker_id', 'id');
|
||||
})
|
||||
->searchable(),
|
||||
Select::make('sticker2_machine_id')
|
||||
->label('Work Center')
|
||||
// ->relationship('sticker2Machine', 'name')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
||||
})
|
||||
->searchable(),
|
||||
TextInput::make('sticker2_print_ip')
|
||||
->label('Printer IP')
|
||||
->ipv4(),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
/* -------- Sticker 3 -------- */
|
||||
Section::make('Sticker 3')
|
||||
->schema([
|
||||
Select::make('sticker_structure3_id')
|
||||
->label('Sticker ID')
|
||||
->options(function (callable $get) {
|
||||
return StickerStructureDetail::pluck('sticker_id', 'id');
|
||||
})
|
||||
->searchable(),
|
||||
Select::make('sticker3_machine_id')
|
||||
->label('Work Center')
|
||||
//->relationship('sticker3Machine', 'name')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
||||
})
|
||||
->searchable(),
|
||||
TextInput::make('sticker3_print_ip')
|
||||
->label('Printer IP')
|
||||
->ipv4(),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
/* -------- Sticker 4 -------- */
|
||||
Section::make('Sticker 4')
|
||||
->schema([
|
||||
Select::make('sticker_structure4_id')
|
||||
->label('Sticker ID')
|
||||
->options(function (callable $get) {
|
||||
return StickerStructureDetail::pluck('sticker_id', 'id');
|
||||
})
|
||||
->searchable(),
|
||||
Select::make('sticker4_machine_id')
|
||||
->label('Work Center')
|
||||
//->relationship('sticker4Machine', 'name')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
||||
})
|
||||
->searchable(),
|
||||
TextInput::make('sticker4_print_ip')
|
||||
->label('Printer IP')
|
||||
->ipv4(),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
/* -------- Sticker 5 -------- */
|
||||
Section::make('Sticker 5')
|
||||
->schema([
|
||||
Select::make('sticker_structure5_id')
|
||||
->label('Sticker ID')
|
||||
->options(function (callable $get) {
|
||||
return StickerStructureDetail::pluck('sticker_id', 'id');
|
||||
})
|
||||
->searchable(),
|
||||
Select::make('sticker5_machine_id')
|
||||
->label('Work Center')
|
||||
//->relationship('sticker5Machine', 'name')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
||||
})
|
||||
->searchable(),
|
||||
TextInput::make('sticker5_print_ip')
|
||||
->label('Printer IP')
|
||||
->ipv4(),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
/* -------- Sticker 6 -------- */
|
||||
Section::make('Sticker 6')
|
||||
->schema([
|
||||
Select::make('sticker_structure6_id')
|
||||
->label('Sticker ID')
|
||||
->options(function (callable $get) {
|
||||
return StickerStructureDetail::pluck('sticker_id', 'id');
|
||||
})
|
||||
->searchable(),
|
||||
Select::make('sticker6_machine_id')
|
||||
->label('Work Center')
|
||||
//->relationship('sticker6Machine', 'name')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
||||
})
|
||||
->searchable(),
|
||||
TextInput::make('sticker6_print_ip')
|
||||
->label('Printer IP')
|
||||
->ipv4(),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
/* -------- Sticker 7 -------- */
|
||||
Section::make('Sticker 7')
|
||||
->schema([
|
||||
Select::make('sticker_structure7_id')
|
||||
->label('Sticker ID')
|
||||
->options(function (callable $get) {
|
||||
return StickerStructureDetail::pluck('sticker_id', 'id');
|
||||
})
|
||||
->searchable(),
|
||||
Select::make('sticker7_machine_id')
|
||||
->label('Work Center')
|
||||
//->relationship('sticker7Machine', 'name')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
||||
})
|
||||
->searchable(),
|
||||
TextInput::make('sticker7_print_ip')
|
||||
->label('Printer IP')
|
||||
->ipv4(),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
/* -------- Sticker 8 -------- */
|
||||
Section::make('Sticker 8')
|
||||
->schema([
|
||||
Select::make('sticker_structure8_id')
|
||||
->label('Sticker ID')
|
||||
->options(function (callable $get) {
|
||||
return StickerStructureDetail::pluck('sticker_id', 'id');
|
||||
})
|
||||
->searchable(),
|
||||
Select::make('sticker8_machine_id')
|
||||
->label('Work Center')
|
||||
//->relationship('sticker8Machine', 'name')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
||||
})
|
||||
->searchable(),
|
||||
TextInput::make('sticker8_print_ip')
|
||||
->label('Printer IP')
|
||||
->ipv4(),
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
}
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('itemCharacteristic.item.code')
|
||||
->label('Item')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('sticker1Structure.sticker_id')
|
||||
->label('Sticker 1')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker1Machine.work_center')
|
||||
->label('WC 1')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker1_print_ip')
|
||||
->label('Printer IP 1')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker2Structure.sticker_id')
|
||||
->label('Sticker 2')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker2Machine.work_center')
|
||||
->label('WC 2')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker2_print_ip')
|
||||
->label('Printer IP 2')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker3Structure.sticker_id')
|
||||
->label('Sticker 3')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker3Machine.work_center')
|
||||
->label('WC 3')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker3_print_ip')
|
||||
->label('Printer IP 3')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker4Structure.sticker_id')
|
||||
->label('Sticker 4')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker4Machine.work_center')
|
||||
->label('WC 4')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker4_print_ip')
|
||||
->label('Printer IP 4')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker5Structure.sticker_id')
|
||||
->label('Sticker 5')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker5Machine.work_center')
|
||||
->label('WC 5')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker5_print_ip')
|
||||
->label('Printer IP 5')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker6Structure.sticker_id')
|
||||
->label('Sticker 6')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker6Machine.work_center')
|
||||
->label('WC 6')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker6_print_ip')
|
||||
->label('Printer IP 6')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker7Structure.sticker_id')
|
||||
->label('Sticker 7')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker7Machine.work_center')
|
||||
->label('WC 7')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker7_print_ip')
|
||||
->label('Printer IP 7')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker8Structure.sticker_id')
|
||||
->label('Sticker 8')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker8Machine.work_center')
|
||||
->label('WC 8')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('sticker8_print_ip')
|
||||
->label('Printer IP 8')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(StickerMappingMasterImporter::class)
|
||||
->label('Import Sticker Mapping Master')
|
||||
->color('warning')
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import sticker mapping master');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(StickerMappingMasterExporter::class)
|
||||
->label('Export Sticker Mapping Master')
|
||||
->color('warning')
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export sticker mapping master');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListStickerMappingMasters::route('/'),
|
||||
'create' => Pages\CreateStickerMappingMaster::route('/create'),
|
||||
'view' => Pages\ViewStickerMappingMaster::route('/{record}'),
|
||||
'edit' => Pages\EditStickerMappingMaster::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\StickerMappingMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\StickerMappingMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateStickerMappingMaster extends CreateRecord
|
||||
{
|
||||
protected static string $resource = StickerMappingMasterResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\StickerMappingMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\StickerMappingMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditStickerMappingMaster extends EditRecord
|
||||
{
|
||||
protected static string $resource = StickerMappingMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\StickerMappingMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\StickerMappingMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListStickerMappingMasters extends ListRecords
|
||||
{
|
||||
protected static string $resource = StickerMappingMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\StickerMappingMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\StickerMappingMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewStickerMappingMaster extends ViewRecord
|
||||
{
|
||||
protected static string $resource = StickerMappingMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
144
app/Models/StickerMappingMaster.php
Normal file
144
app/Models/StickerMappingMaster.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class StickerMappingMaster extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'item_characteristic_id',
|
||||
|
||||
'sticker_structure1_id',
|
||||
'sticker1_machine_id',
|
||||
'sticker1_print_ip',
|
||||
'sticker_structure2_id',
|
||||
'sticker2_machine_id',
|
||||
'sticker2_print_ip',
|
||||
'sticker_structure3_id',
|
||||
'sticker3_machine_id',
|
||||
'sticker3_print_ip',
|
||||
'sticker_structure4_id',
|
||||
'sticker4_machine_id',
|
||||
'sticker4_print_ip',
|
||||
'sticker_structure5_id',
|
||||
'sticker5_machine_id',
|
||||
'sticker5_print_ip',
|
||||
'sticker_structure6_id',
|
||||
'sticker6_machine_id',
|
||||
'sticker6_print_ip',
|
||||
'sticker_structure7_id',
|
||||
'sticker7_machine_id',
|
||||
'sticker7_print_ip',
|
||||
'sticker_structure8_id',
|
||||
'sticker8_machine_id',
|
||||
'sticker8_print_ip',
|
||||
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function plant()
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function itemCharacteristic()
|
||||
{
|
||||
return $this->belongsTo(ItemCharacteristic::class);
|
||||
}
|
||||
|
||||
public function item(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Item::class, 'item_id');
|
||||
}
|
||||
|
||||
public function sticker1Structure()
|
||||
{
|
||||
return $this->belongsTo(StickerStructureDetail::class, 'sticker_structure1_id');
|
||||
}
|
||||
|
||||
public function sticker2Structure()
|
||||
{
|
||||
return $this->belongsTo(StickerStructureDetail::class, 'sticker_structure2_id');
|
||||
}
|
||||
|
||||
public function sticker3Structure()
|
||||
{
|
||||
return $this->belongsTo(StickerStructureDetail::class, 'sticker_structure3_id');
|
||||
}
|
||||
|
||||
public function sticker4Structure()
|
||||
{
|
||||
return $this->belongsTo(StickerStructureDetail::class, 'sticker_structure4_id');
|
||||
}
|
||||
|
||||
public function sticker5Structure()
|
||||
{
|
||||
return $this->belongsTo(StickerStructureDetail::class, 'sticker_structure5_id');
|
||||
}
|
||||
|
||||
public function sticker6Structure()
|
||||
{
|
||||
return $this->belongsTo(StickerStructureDetail::class, 'sticker_structure6_id');
|
||||
}
|
||||
|
||||
public function sticker7Structure()
|
||||
{
|
||||
return $this->belongsTo(StickerStructureDetail::class, 'sticker_structure7_id');
|
||||
}
|
||||
|
||||
public function sticker8Structure()
|
||||
{
|
||||
return $this->belongsTo(StickerStructureDetail::class, 'sticker_structure8_id');
|
||||
}
|
||||
|
||||
// Machine relationships (per sticker)
|
||||
public function sticker1Machine()
|
||||
{
|
||||
return $this->belongsTo(Machine::class, 'sticker1_machine_id');
|
||||
}
|
||||
|
||||
public function sticker2Machine()
|
||||
{
|
||||
return $this->belongsTo(Machine::class, 'sticker2_machine_id');
|
||||
}
|
||||
|
||||
public function sticker3Machine()
|
||||
{
|
||||
return $this->belongsTo(Machine::class, 'sticker3_machine_id');
|
||||
}
|
||||
|
||||
public function sticker4Machine()
|
||||
{
|
||||
return $this->belongsTo(Machine::class, 'sticker4_machine_id');
|
||||
}
|
||||
|
||||
public function sticker5Machine()
|
||||
{
|
||||
return $this->belongsTo(Machine::class, 'sticker5_machine_id');
|
||||
}
|
||||
|
||||
public function sticker6Machine()
|
||||
{
|
||||
return $this->belongsTo(Machine::class, 'sticker6_machine_id');
|
||||
}
|
||||
|
||||
public function sticker7Machine()
|
||||
{
|
||||
return $this->belongsTo(Machine::class, 'sticker7_machine_id');
|
||||
}
|
||||
|
||||
public function sticker8Machine()
|
||||
{
|
||||
return $this->belongsTo(Machine::class, 'sticker8_machine_id');
|
||||
}
|
||||
}
|
||||
|
||||
106
app/Policies/StickerMappingMasterPolicy.php
Normal file
106
app/Policies/StickerMappingMasterPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\StickerMappingMaster;
|
||||
use App\Models\User;
|
||||
|
||||
class StickerMappingMasterPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any StickerMappingMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, StickerMappingMaster $stickermappingmaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view StickerMappingMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create StickerMappingMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, StickerMappingMaster $stickermappingmaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update StickerMappingMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, StickerMappingMaster $stickermappingmaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete StickerMappingMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any StickerMappingMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, StickerMappingMaster $stickermappingmaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore StickerMappingMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any StickerMappingMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, StickerMappingMaster $stickermappingmaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate StickerMappingMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder StickerMappingMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, StickerMappingMaster $stickermappingmaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete StickerMappingMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any StickerMappingMaster');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE sticker_mapping_masters (
|
||||
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||
plant_id BIGINT NOT NULL,
|
||||
item_characteristic_id BIGINT DEFAULT NULL,
|
||||
sticker_structure1_id BIGINT DEFAULT NULL,
|
||||
sticker1_machine_id BIGINT DEFAULT NULL,
|
||||
sticker1_print_ip TEXT DEFAULT NULL,
|
||||
|
||||
sticker_structure2_id BIGINT DEFAULT NULL,
|
||||
sticker2_machine_id BIGINT DEFAULT NULL,
|
||||
sticker2_print_ip TEXT DEFAULT NULL,
|
||||
|
||||
sticker_structure3_id BIGINT DEFAULT NULL,
|
||||
sticker3_machine_id BIGINT DEFAULT NULL,
|
||||
sticker3_print_ip TEXT DEFAULT NULL,
|
||||
|
||||
sticker_structure4_id BIGINT DEFAULT NULL,
|
||||
sticker4_machine_id BIGINT DEFAULT NULL,
|
||||
sticker4_print_ip TEXT DEFAULT NULL,
|
||||
|
||||
sticker_structure5_id BIGINT DEFAULT NULL,
|
||||
sticker5_machine_id BIGINT DEFAULT NULL,
|
||||
sticker5_print_ip TEXT DEFAULT NULL,
|
||||
|
||||
sticker_structure6_id BIGINT DEFAULT NULL,
|
||||
sticker6_machine_id BIGINT DEFAULT NULL,
|
||||
sticker6_print_ip TEXT DEFAULT NULL,
|
||||
|
||||
sticker_structure7_id BIGINT DEFAULT NULL,
|
||||
sticker7_machine_id BIGINT DEFAULT NULL,
|
||||
sticker7_print_ip TEXT DEFAULT NULL,
|
||||
|
||||
sticker_structure8_id BIGINT DEFAULT NULL,
|
||||
sticker8_machine_id BIGINT DEFAULT NULL,
|
||||
sticker8_print_ip TEXT DEFAULT NULL,
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
created_by TEXT DEFAULT NULL,
|
||||
updated_by TEXT DEFAULT NULL,
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
FOREIGN KEY (plant_id) REFERENCES plants(id),
|
||||
FOREIGN KEY (item_characteristic_id) REFERENCES item_characteristics(id),
|
||||
|
||||
FOREIGN KEY (sticker_structure1_id) REFERENCES sticker_structure_details(id),
|
||||
FOREIGN KEY (sticker_structure2_id) REFERENCES sticker_structure_details(id),
|
||||
FOREIGN KEY (sticker_structure3_id) REFERENCES sticker_structure_details(id),
|
||||
FOREIGN KEY (sticker_structure4_id) REFERENCES sticker_structure_details(id),
|
||||
FOREIGN KEY (sticker_structure5_id) REFERENCES sticker_structure_details(id),
|
||||
FOREIGN KEY (sticker_structure6_id) REFERENCES sticker_structure_details(id),
|
||||
FOREIGN KEY (sticker_structure7_id) REFERENCES sticker_structure_details(id),
|
||||
FOREIGN KEY (sticker_structure8_id) REFERENCES sticker_structure_details(id),
|
||||
|
||||
FOREIGN KEY (sticker1_machine_id) REFERENCES machines(id),
|
||||
FOREIGN KEY (sticker2_machine_id) REFERENCES machines(id),
|
||||
FOREIGN KEY (sticker3_machine_id) REFERENCES machines(id),
|
||||
FOREIGN KEY (sticker4_machine_id) REFERENCES machines(id),
|
||||
FOREIGN KEY (sticker5_machine_id) REFERENCES machines(id),
|
||||
FOREIGN KEY (sticker6_machine_id) REFERENCES machines(id),
|
||||
FOREIGN KEY (sticker7_machine_id) REFERENCES machines(id),
|
||||
FOREIGN KEY (sticker8_machine_id) REFERENCES machines(id)
|
||||
);
|
||||
SQL;
|
||||
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sticker_mapping_masters');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user