after production line stop reason column remove
This commit is contained in:
51
app/Filament/Imports/BlockImporter.php
Normal file
51
app/Filament/Imports/BlockImporter.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Imports;
|
||||||
|
|
||||||
|
use App\Models\Block;
|
||||||
|
use Filament\Actions\Imports\ImportColumn;
|
||||||
|
use Filament\Actions\Imports\Importer;
|
||||||
|
use Filament\Actions\Imports\Models\Import;
|
||||||
|
|
||||||
|
class BlockImporter extends Importer
|
||||||
|
{
|
||||||
|
protected static ?string $model = Block::class;
|
||||||
|
|
||||||
|
public static function getColumns(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ImportColumn::make('name')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Block Name')
|
||||||
|
->label('Block Name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('plant')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Plant Name')
|
||||||
|
->label('Plant Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolveRecord(): ?Block
|
||||||
|
{
|
||||||
|
// return Block::firstOrNew([
|
||||||
|
// // Update existing records, matching them by `$this->data['column_name']`
|
||||||
|
// 'email' => $this->data['email'],
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
return new Block();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCompletedNotificationBody(Import $import): string
|
||||||
|
{
|
||||||
|
$body = 'Your block 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
45
app/Filament/Imports/CompanyImporter.php
Normal file
45
app/Filament/Imports/CompanyImporter.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Imports;
|
||||||
|
|
||||||
|
use App\Models\Company;
|
||||||
|
use Filament\Actions\Imports\ImportColumn;
|
||||||
|
use Filament\Actions\Imports\Importer;
|
||||||
|
use Filament\Actions\Imports\Models\Import;
|
||||||
|
|
||||||
|
class CompanyImporter extends Importer
|
||||||
|
{
|
||||||
|
protected static ?string $model = Company::class;
|
||||||
|
|
||||||
|
public static function getColumns(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ImportColumn::make('name')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Company Name')
|
||||||
|
->label('Company Name')
|
||||||
|
->rules(['required']),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolveRecord(): ?Company
|
||||||
|
{
|
||||||
|
// return Company::firstOrNew([
|
||||||
|
// // Update existing records, matching them by `$this->data['column_name']`
|
||||||
|
// 'email' => $this->data['email'],
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
return new Company();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCompletedNotificationBody(Import $import): string
|
||||||
|
{
|
||||||
|
$body = 'Your company 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,6 +30,24 @@ class ItemImporter extends Importer
|
|||||||
->label('Hourly Quantity')
|
->label('Hourly Quantity')
|
||||||
->numeric()
|
->numeric()
|
||||||
->rules(['required', 'integer']),
|
->rules(['required', 'integer']),
|
||||||
|
ImportColumn::make('line')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Line Name')
|
||||||
|
->label('Line Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('block')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Block Name')
|
||||||
|
->label('Block Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('plant')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Plant Name')
|
||||||
|
->label('Plant Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
68
app/Filament/Imports/LineImporter.php
Normal file
68
app/Filament/Imports/LineImporter.php
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Imports;
|
||||||
|
|
||||||
|
use App\Models\Line;
|
||||||
|
use Filament\Actions\Imports\ImportColumn;
|
||||||
|
use Filament\Actions\Imports\Importer;
|
||||||
|
use Filament\Actions\Imports\Models\Import;
|
||||||
|
|
||||||
|
class LineImporter extends Importer
|
||||||
|
{
|
||||||
|
protected static ?string $model = Line::class;
|
||||||
|
|
||||||
|
public static function getColumns(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ImportColumn::make('name')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Line Name')
|
||||||
|
->label('Line Name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('type')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Line Type')
|
||||||
|
->label('Line Type')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('shift')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Shift Name')
|
||||||
|
->label('Shift Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('block')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Block Name')
|
||||||
|
->label('Block Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('plant')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Plant Name')
|
||||||
|
->label('Plant Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolveRecord(): ?Line
|
||||||
|
{
|
||||||
|
// return Line::firstOrNew([
|
||||||
|
// // Update existing records, matching them by `$this->data['column_name']`
|
||||||
|
// 'email' => $this->data['email'],
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
return new Line();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCompletedNotificationBody(Import $import): string
|
||||||
|
{
|
||||||
|
$body = 'Your line 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
68
app/Filament/Imports/LineStopImporter.php
Normal file
68
app/Filament/Imports/LineStopImporter.php
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Imports;
|
||||||
|
|
||||||
|
use App\Models\LineStop;
|
||||||
|
use Filament\Actions\Imports\ImportColumn;
|
||||||
|
use Filament\Actions\Imports\Importer;
|
||||||
|
use Filament\Actions\Imports\Models\Import;
|
||||||
|
|
||||||
|
class LineStopImporter extends Importer
|
||||||
|
{
|
||||||
|
protected static ?string $model = LineStop::class;
|
||||||
|
|
||||||
|
public static function getColumns(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ImportColumn::make('code')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Line Stop Code')
|
||||||
|
->label('Line Stop Code')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('reason')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Line Stop Reason')
|
||||||
|
->label('Line Stop Reason')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('shift')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Shift Name')
|
||||||
|
->label('Shift Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('block')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Block Name')
|
||||||
|
->label('Block Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('plant')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Plant Name')
|
||||||
|
->label('Plant Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolveRecord(): ?LineStop
|
||||||
|
{
|
||||||
|
// return LineStop::firstOrNew([
|
||||||
|
// // Update existing records, matching them by `$this->data['column_name']`
|
||||||
|
// 'email' => $this->data['email'],
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
return new LineStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCompletedNotificationBody(Import $import): string
|
||||||
|
{
|
||||||
|
$body = 'Your line stop 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
62
app/Filament/Imports/PlantImporter.php
Normal file
62
app/Filament/Imports/PlantImporter.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Imports;
|
||||||
|
|
||||||
|
use App\Models\Plant;
|
||||||
|
use Filament\Actions\Imports\ImportColumn;
|
||||||
|
use Filament\Actions\Imports\Importer;
|
||||||
|
use Filament\Actions\Imports\Models\Import;
|
||||||
|
|
||||||
|
class PlantImporter extends Importer
|
||||||
|
{
|
||||||
|
protected static ?string $model = Plant::class;
|
||||||
|
|
||||||
|
public static function getColumns(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ImportColumn::make('code')
|
||||||
|
->requiredMapping()
|
||||||
|
->numeric()
|
||||||
|
->exampleHeader('Plant Code')
|
||||||
|
->label('Plant Code')
|
||||||
|
->rules(['required']), //, 'integer'
|
||||||
|
ImportColumn::make('company')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Company Name')
|
||||||
|
->label('Company Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('name')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Plant Name')
|
||||||
|
->label('Plant Name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('address')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Plant Address')
|
||||||
|
->label('Plant Address')
|
||||||
|
->rules(['required']),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolveRecord(): ?Plant
|
||||||
|
{
|
||||||
|
// return Plant::firstOrNew([
|
||||||
|
// // Update existing records, matching them by `$this->data['column_name']`
|
||||||
|
// 'email' => $this->data['email'],
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
return new Plant();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCompletedNotificationBody(Import $import): string
|
||||||
|
{
|
||||||
|
$body = 'Your plant 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
84
app/Filament/Imports/ProductionLineStopImporter.php
Normal file
84
app/Filament/Imports/ProductionLineStopImporter.php
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Imports;
|
||||||
|
|
||||||
|
use App\Models\ProductionLineStop;
|
||||||
|
use Filament\Actions\Imports\ImportColumn;
|
||||||
|
use Filament\Actions\Imports\Importer;
|
||||||
|
use Filament\Actions\Imports\Models\Import;
|
||||||
|
|
||||||
|
class ProductionLineStopImporter extends Importer
|
||||||
|
{
|
||||||
|
protected static ?string $model = ProductionLineStop::class;
|
||||||
|
|
||||||
|
public static function getColumns(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ImportColumn::make('from_datetime')
|
||||||
|
->requiredMapping()
|
||||||
|
->rules(['required', 'datetime']),
|
||||||
|
ImportColumn::make('to_datetime')
|
||||||
|
->requiredMapping()
|
||||||
|
->rules(['required', 'datetime']),
|
||||||
|
ImportColumn::make('stop_hour')
|
||||||
|
->requiredMapping()
|
||||||
|
->numeric()
|
||||||
|
->rules(['required', 'integer']),
|
||||||
|
ImportColumn::make('stop_min')
|
||||||
|
->requiredMapping()
|
||||||
|
->numeric()
|
||||||
|
->rules(['required', 'integer']),
|
||||||
|
ImportColumn::make('linestop')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Line Stop Code')
|
||||||
|
->label('Line Stop Code')
|
||||||
|
->relationship(resolveUsing:'code')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('line')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Line Name')
|
||||||
|
->label('Line Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('shift')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Shift Name')
|
||||||
|
->label('Shift Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('block')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Block Name')
|
||||||
|
->label('Block Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('plant')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Plant Name')
|
||||||
|
->label('Plant Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolveRecord(): ?ProductionLineStop
|
||||||
|
{
|
||||||
|
// return ProductionLineStop::firstOrNew([
|
||||||
|
// // Update existing records, matching them by `$this->data['column_name']`
|
||||||
|
// 'email' => $this->data['email'],
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
return new ProductionLineStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCompletedNotificationBody(Import $import): string
|
||||||
|
{
|
||||||
|
$body = 'Your production line stop 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
70
app/Filament/Imports/ProductionPlanImporter.php
Normal file
70
app/Filament/Imports/ProductionPlanImporter.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Imports;
|
||||||
|
|
||||||
|
use App\Models\ProductionPlan;
|
||||||
|
use Filament\Actions\Imports\ImportColumn;
|
||||||
|
use Filament\Actions\Imports\Importer;
|
||||||
|
use Filament\Actions\Imports\Models\Import;
|
||||||
|
|
||||||
|
class ProductionPlanImporter extends Importer
|
||||||
|
{
|
||||||
|
protected static ?string $model = ProductionPlan::class;
|
||||||
|
|
||||||
|
public static function getColumns(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ImportColumn::make('plan_quantity')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Plan Quantity')
|
||||||
|
->label('Plan Quantity')
|
||||||
|
->numeric()
|
||||||
|
->rules(['required', 'integer']),
|
||||||
|
ImportColumn::make('production_quantity')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Production Quantity')
|
||||||
|
->label('Production Quantity')
|
||||||
|
->numeric()
|
||||||
|
->rules(['required', 'integer']),
|
||||||
|
ImportColumn::make('line')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Line Name')
|
||||||
|
->label('Line Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('shift')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Shift Name')
|
||||||
|
->label('Shift Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('plant')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Plant Name')
|
||||||
|
->label('Plant Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolveRecord(): ?ProductionPlan
|
||||||
|
{
|
||||||
|
// return ProductionPlan::firstOrNew([
|
||||||
|
// // Update existing records, matching them by `$this->data['column_name']`
|
||||||
|
// 'email' => $this->data['email'],
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
return new ProductionPlan();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCompletedNotificationBody(Import $import): string
|
||||||
|
{
|
||||||
|
$body = 'Your production plan 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,29 +19,24 @@ class ProductionQuantityImporter extends Importer
|
|||||||
->exampleHeader('Created DateTime')
|
->exampleHeader('Created DateTime')
|
||||||
->label('Created DateTime')
|
->label('Created DateTime')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('plan_quantity')
|
// ImportColumn::make('hourly_quantity')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Plan Quantity')
|
// ->exampleHeader('Hourly Quantity')
|
||||||
->label('Plan Quantity')
|
// ->label('Hourly Quantity')
|
||||||
->numeric()
|
// ->numeric()
|
||||||
->rules(['required', 'integer']),
|
// ->rules(['required', 'integer']),
|
||||||
ImportColumn::make('hourly_quantity')
|
ImportColumn::make('item')
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Hourly Quantity')
|
|
||||||
->label('Hourly Quantity')
|
|
||||||
->numeric()
|
|
||||||
->rules(['required', 'integer']),
|
|
||||||
ImportColumn::make('item_code')
|
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Item Code')
|
->exampleHeader('Item Code')
|
||||||
->label('Item Code')
|
->label('Item Code')
|
||||||
|
->relationship(resolveUsing:'code')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('serial_number')
|
ImportColumn::make('serial_number')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Serial Number')
|
->exampleHeader('Serial Number')
|
||||||
->label('Serial Number')
|
->label('Serial Number')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('line')
|
ImportColumn::make('line')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Line Name')
|
->exampleHeader('Line Name')
|
||||||
->label('Line Name')
|
->label('Line Name')
|
||||||
|
|||||||
78
app/Filament/Imports/ShiftImporter.php
Normal file
78
app/Filament/Imports/ShiftImporter.php
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Imports;
|
||||||
|
|
||||||
|
use App\Models\Shift;
|
||||||
|
use Filament\Actions\Imports\ImportColumn;
|
||||||
|
use Filament\Actions\Imports\Importer;
|
||||||
|
use Filament\Actions\Imports\Models\Import;
|
||||||
|
|
||||||
|
class ShiftImporter extends Importer
|
||||||
|
{
|
||||||
|
protected static ?string $model = Shift::class;
|
||||||
|
|
||||||
|
public static function getColumns(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ImportColumn::make('name')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Shift Name')
|
||||||
|
->label('Shift Name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('block')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Block Name')
|
||||||
|
->label('Block Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('plant')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Plant Name')
|
||||||
|
->label('Plant Name')
|
||||||
|
->relationship(resolveUsing:'name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('start_time')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Start Time')
|
||||||
|
->label('Start Time')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('duration')
|
||||||
|
->requiredMapping()
|
||||||
|
->numeric()
|
||||||
|
->exampleHeader('Shift Duration')
|
||||||
|
->label('Shift Duration')
|
||||||
|
->rules(['required', 'integer']),
|
||||||
|
ImportColumn::make('end_time')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('End Time')
|
||||||
|
->label('End Time')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('status')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Active Status')
|
||||||
|
->label('Active Status')
|
||||||
|
->rules(['required']),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolveRecord(): ?Shift
|
||||||
|
{
|
||||||
|
// return Shift::firstOrNew([
|
||||||
|
// // Update existing records, matching them by `$this->data['column_name']`
|
||||||
|
// 'email' => $this->data['email'],
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
return new Shift();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCompletedNotificationBody(Import $import): string
|
||||||
|
{
|
||||||
|
$body = 'Your shift 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,26 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Filament\Pages;
|
namespace App\Filament\Pages;
|
||||||
|
|
||||||
use Filament\Forms\Components\Select;
|
|
||||||
use Filament\Forms\Components\TextInput;
|
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||||
use Filament\Tables\Filters\SelectFilter;
|
use Filament\Pages\Dashboard as BaseDashboard;
|
||||||
|
use App\Models\Line;
|
||||||
|
|
||||||
class Dashboard extends \Filament\Pages\Dashboard
|
class Dashboard extends BaseDashboard
|
||||||
{
|
{
|
||||||
use HasFiltersForm;
|
use HasFiltersForm;
|
||||||
|
|
||||||
public function filtersForm(Form $form): Form
|
public function filtersForm(Form $form): Form
|
||||||
{
|
{
|
||||||
return $form->schema([
|
return $form->schema([
|
||||||
Select::make('Plant')
|
// Select::make('plant_id')
|
||||||
->options(\DB::table('plants')->pluck('name', 'name')) // Fetch plant names
|
// ->relationship('plant', 'name')
|
||||||
->label('Select Plant'),
|
// ->required()
|
||||||
|
// ->reactive(),
|
||||||
|
|
||||||
Select::make('Line')
|
// Select::make('line_id')
|
||||||
->options(\DB::table('lines')->pluck('name', 'name')) // Fetch line names
|
// ->relationship('line', 'name')
|
||||||
->label('Select Line'),
|
// ->required()
|
||||||
]);
|
// ->options(fn (callable $get) =>
|
||||||
}
|
// Line::where('plant_id', $get('plant_id'))->pluck('name', 'id')
|
||||||
|
// )
|
||||||
|
// ->reactive()
|
||||||
|
// ->afterStateUpdated(fn ($set) => $set('line_id', null)),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources;
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Filament\Imports\BlockImporter;
|
||||||
use App\Filament\Resources\BlockResource\Pages;
|
use App\Filament\Resources\BlockResource\Pages;
|
||||||
use App\Models\Block;
|
use App\Models\Block;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
@@ -43,6 +45,7 @@ class BlockResource extends Resource
|
|||||||
->numeric()
|
->numeric()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('name')
|
Tables\Columns\TextColumn::make('name')
|
||||||
|
//->unique(ignoreRecord: true)
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
->sortable(),
|
->sortable(),
|
||||||
@@ -72,6 +75,10 @@ class BlockResource extends Resource
|
|||||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||||
Tables\Actions\RestoreBulkAction::make(),
|
Tables\Actions\RestoreBulkAction::make(),
|
||||||
]),
|
]),
|
||||||
|
])
|
||||||
|
->headerActions([
|
||||||
|
ImportAction::make()
|
||||||
|
->importer(BlockImporter::class),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,16 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources;
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Filament\Imports\CompanyImporter;
|
||||||
use App\Filament\Resources\CompanyResource\Pages;
|
use App\Filament\Resources\CompanyResource\Pages;
|
||||||
use App\Filament\Resources\CompanyResource\RelationManagers\PlantsRelationManager;
|
use App\Filament\Resources\CompanyResource\RelationManagers\PlantsRelationManager;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
|
use Filament\Actions\Imports\Importer;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
@@ -68,6 +71,10 @@ class CompanyResource extends Resource
|
|||||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||||
Tables\Actions\RestoreBulkAction::make(),
|
Tables\Actions\RestoreBulkAction::make(),
|
||||||
]),
|
]),
|
||||||
|
])
|
||||||
|
->headerActions([
|
||||||
|
ImportAction::make()
|
||||||
|
->importer(CompanyImporter::class)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,12 +40,33 @@ class ItemResource extends Resource
|
|||||||
Forms\Components\Textarea::make('description')
|
Forms\Components\Textarea::make('description')
|
||||||
->required()
|
->required()
|
||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
Forms\Components\Select::make('plant_id')
|
Forms\Components\Select::make('plant_id')
|
||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->required(),
|
->required()
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(fn ($set) => $set('block_id', null)), // Reset block_id when plant changes
|
||||||
|
|
||||||
Forms\Components\Select::make('block_id')
|
Forms\Components\Select::make('block_id')
|
||||||
->relationship('block', 'name')
|
->relationship('block', 'name')
|
||||||
->required(),
|
->required()
|
||||||
|
->options(fn (callable $get) =>
|
||||||
|
\App\Models\Block::where('plant_id', $get('plant_id'))
|
||||||
|
->pluck('name', 'id')
|
||||||
|
->toArray() // Convert collection to array
|
||||||
|
)
|
||||||
|
->reactive(), // Ensures the dropdown updates when plant_id changes
|
||||||
|
// Forms\Components\Select::make('plant_id')
|
||||||
|
// ->relationship('plant', 'name')
|
||||||
|
// ->required()
|
||||||
|
// ->reactive(),
|
||||||
|
// Forms\Components\Select::make('block_id')
|
||||||
|
// ->relationship('block', 'name')
|
||||||
|
// ->required()
|
||||||
|
// ->options(fn (callable $get) =>
|
||||||
|
// \App\Models\Block::where('plant_id', $get('plant_id'))->pluck('name', 'id')
|
||||||
|
// )
|
||||||
|
// ->reactive() // Updates dynamically when plant_id changes
|
||||||
|
// ->afterStateUpdated(fn ($set) => $set('block_id', null)), // Reset block_id when plant_id changes
|
||||||
Forms\Components\Select::make('line_id')
|
Forms\Components\Select::make('line_id')
|
||||||
->relationship('line', 'name')
|
->relationship('line', 'name')
|
||||||
->required(),
|
->required(),
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources;
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Filament\Imports\LineImporter;
|
||||||
use App\Filament\Resources\LineResource\Pages;
|
use App\Filament\Resources\LineResource\Pages;
|
||||||
use App\Filament\Resources\LineResource\RelationManagers;
|
use App\Filament\Resources\LineResource\RelationManagers;
|
||||||
use App\Models\Line;
|
use App\Models\Line;
|
||||||
@@ -9,6 +10,7 @@ use Filament\Forms;
|
|||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
@@ -87,6 +89,10 @@ class LineResource extends Resource
|
|||||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||||
Tables\Actions\RestoreBulkAction::make(),
|
Tables\Actions\RestoreBulkAction::make(),
|
||||||
]),
|
]),
|
||||||
|
])
|
||||||
|
->headerActions([
|
||||||
|
ImportAction::make()
|
||||||
|
->importer(LineImporter::class),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources;
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Filament\Imports\PlantImporter;
|
||||||
use App\Filament\Resources\PlantResource\Pages;
|
use App\Filament\Resources\PlantResource\Pages;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
@@ -9,6 +10,7 @@ use Filament\Forms\Components\Section;
|
|||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
@@ -91,6 +93,10 @@ class PlantResource extends Resource
|
|||||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||||
Tables\Actions\RestoreBulkAction::make(),
|
Tables\Actions\RestoreBulkAction::make(),
|
||||||
]),
|
]),
|
||||||
|
])
|
||||||
|
->headerActions([
|
||||||
|
ImportAction::make()
|
||||||
|
->importer(PlantImporter::class),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources;
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Filament\Imports\ProductionLineStopImporter;
|
||||||
use App\Filament\Resources\ProductionLineStopResource\Pages;
|
use App\Filament\Resources\ProductionLineStopResource\Pages;
|
||||||
use App\Filament\Resources\ProductionLineStopResource\RelationManagers;
|
use App\Filament\Resources\ProductionLineStopResource\RelationManagers;
|
||||||
use App\Models\ProductionLineStop;
|
use App\Models\ProductionLineStop;
|
||||||
@@ -9,6 +10,7 @@ use Filament\Forms;
|
|||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
@@ -114,6 +116,10 @@ class ProductionLineStopResource extends Resource
|
|||||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||||
Tables\Actions\RestoreBulkAction::make(),
|
Tables\Actions\RestoreBulkAction::make(),
|
||||||
]),
|
]),
|
||||||
|
])
|
||||||
|
->headerActions([
|
||||||
|
ImportAction::make()
|
||||||
|
->importer(ProductionLineStopImporter::class),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources;
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Filament\Imports\ProductionPlanImporter;
|
||||||
use App\Filament\Resources\ProductionPlanResource\Pages;
|
use App\Filament\Resources\ProductionPlanResource\Pages;
|
||||||
use App\Filament\Resources\ProductionPlanResource\RelationManagers;
|
use App\Filament\Resources\ProductionPlanResource\RelationManagers;
|
||||||
use App\Models\ProductionPlan;
|
use App\Models\ProductionPlan;
|
||||||
@@ -9,6 +10,7 @@ use Filament\Forms;
|
|||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
@@ -92,6 +94,10 @@ class ProductionPlanResource extends Resource
|
|||||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||||
Tables\Actions\RestoreBulkAction::make(),
|
Tables\Actions\RestoreBulkAction::make(),
|
||||||
]),
|
]),
|
||||||
|
])
|
||||||
|
->headerActions([
|
||||||
|
ImportAction::make()
|
||||||
|
->importer(ProductionPlanImporter::class),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,4 +27,9 @@ class Plant extends Model
|
|||||||
{
|
{
|
||||||
return $this->hasMany(Block::class);
|
return $this->hasMany(Block::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function lines(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Line::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ return new class extends Migration
|
|||||||
CREATE TABLE shifts (
|
CREATE TABLE shifts (
|
||||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||||
|
|
||||||
name TEXT NOT NULL,
|
|
||||||
block_id BIGINT NOT NULL,
|
block_id BIGINT NOT NULL,
|
||||||
plant_id BIGINT NOT NULL,
|
plant_id BIGINT NOT NULL,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
|
||||||
start_time TIME NOT NULL,
|
start_time TIME NOT NULL,
|
||||||
duration DECIMAL NOT NULL,
|
duration DECIMAL NOT NULL,
|
||||||
|
|||||||
Reference in New Issue
Block a user