Added combined unique and default value
This commit is contained in:
@@ -48,6 +48,9 @@ class ProductionLineStopResource extends Resource
|
|||||||
->required()
|
->required()
|
||||||
// ->nullable()
|
// ->nullable()
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->default(function () {
|
||||||
|
return optional(ProductionLineStop::latest()->first())->plant_id;
|
||||||
|
})
|
||||||
->disabled(fn (Get $get) => !empty($get('id')))
|
->disabled(fn (Get $get) => !empty($get('id')))
|
||||||
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
|
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
@@ -82,23 +85,18 @@ class ProductionLineStopResource extends Resource
|
|||||||
->toArray();
|
->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
// ->default(function (callable $get, callable $set) {
|
->default(function () {
|
||||||
// if ($get('id')) {
|
$latestShiftId = optional(ProductionLineStop::latest()->first())->shift_id;
|
||||||
// $getShift = ProductionLineStop::where('id', $get('id'))->first();
|
return optional(Shift::where('id', $latestShiftId)->first())->block_id;
|
||||||
// $getBlock = \App\Models\Shift::where('id', $getShift->shift_id)->first();
|
})
|
||||||
// // dd($getBlock->block_id);
|
|
||||||
// $set('block_name', $getBlock->block_id);
|
|
||||||
// }
|
|
||||||
// // return null; // Return null if no default value should be set
|
|
||||||
// })
|
|
||||||
// ->afterStateUpdated(fn ($set) => $set('shift_id', null))
|
// ->afterStateUpdated(fn ($set) => $set('shift_id', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if($get('id'))
|
if($get('id'))
|
||||||
{
|
{
|
||||||
$getShift = ProductionLineStop::where('id', $get('id'))->first();
|
$getShift = ProductionLineStop::where('id', $get('id'))->first();
|
||||||
// $getBlock = \App\Models\Shift::where('id', $getShift->shift_id)->first();
|
// $getBlock = \App\Models\Shift::where('id', $getShift->shift_id)->first();
|
||||||
$getBlock = Shift::where('id', $getShift->shift_id)->first();
|
$getBlock = Shift::where('id', $getShift->shift_id)->first();
|
||||||
if($getBlock->block_id)
|
if($getBlock->block_id)
|
||||||
{
|
{
|
||||||
$set('block_name', $getBlock->block_id);
|
$set('block_name', $getBlock->block_id);
|
||||||
$set('plsBlockError', null);
|
$set('plsBlockError', null);
|
||||||
@@ -137,6 +135,9 @@ class ProductionLineStopResource extends Resource
|
|||||||
->toArray();
|
->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->default(function () {
|
||||||
|
return optional(ProductionLineStop::latest()->first())->shift_id;
|
||||||
|
})
|
||||||
// ->afterStateUpdated(fn ($set) => $set('line_id', null))
|
// ->afterStateUpdated(fn ($set) => $set('line_id', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if($get('id'))
|
if($get('id'))
|
||||||
@@ -181,6 +182,9 @@ class ProductionLineStopResource extends Resource
|
|||||||
->toArray();
|
->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->default(function () {
|
||||||
|
return optional(ProductionLineStop::latest()->first())->line_id;
|
||||||
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if($get('id'))
|
if($get('id'))
|
||||||
{
|
{
|
||||||
@@ -481,7 +485,8 @@ class ProductionLineStopResource extends Resource
|
|||||||
])
|
])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
ImportAction::make()
|
ImportAction::make()
|
||||||
->importer(ProductionLineStopImporter::class),
|
->importer(ProductionLineStopImporter::class)
|
||||||
|
->maxRows(100000),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ 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;
|
||||||
|
use App\Models\Shift;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
@@ -40,6 +41,9 @@ class ProductionPlanResource extends Resource
|
|||||||
->required()
|
->required()
|
||||||
// ->nullable()
|
// ->nullable()
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->default(function () {
|
||||||
|
return optional(ProductionPlan::latest()->first())->plant_id;
|
||||||
|
})
|
||||||
->disabled(fn (Get $get) => !empty($get('id')))
|
->disabled(fn (Get $get) => !empty($get('id')))
|
||||||
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
|
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
@@ -73,12 +77,16 @@ class ProductionPlanResource extends Resource
|
|||||||
->toArray();
|
->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->default(function () {
|
||||||
|
$latestShiftId = optional(ProductionPlan::latest()->first())->shift_id;
|
||||||
|
return optional(Shift::where('id', $latestShiftId)->first())->block_id;
|
||||||
|
})
|
||||||
//->afterStateUpdated(fn ($set) => $set('shift_id', null))
|
//->afterStateUpdated(fn ($set) => $set('shift_id', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if($get('id'))
|
if($get('id'))
|
||||||
{
|
{
|
||||||
$getShift = ProductionPlan::where('id', $get('id'))->first();
|
$getShift = ProductionPlan::where('id', $get('id'))->first();
|
||||||
$getBlock = \App\Models\Shift::where('id', $getShift->shift_id)->first();
|
$getBlock = Shift::where('id', $getShift->shift_id)->first();
|
||||||
if($getBlock->block_id)
|
if($getBlock->block_id)
|
||||||
{
|
{
|
||||||
$set('block_name', $getBlock->block_id);
|
$set('block_name', $getBlock->block_id);
|
||||||
@@ -113,12 +121,15 @@ class ProductionPlanResource extends Resource
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return \App\Models\Shift::where('plant_id', $get('plant_id'))
|
return Shift::where('plant_id', $get('plant_id'))
|
||||||
->where('block_id', $get('block_name'))
|
->where('block_id', $get('block_name'))
|
||||||
->pluck('name', 'id')
|
->pluck('name', 'id')
|
||||||
->toArray();
|
->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->default(function () {
|
||||||
|
return optional(ProductionPlan::latest()->first())->shift_id;
|
||||||
|
})
|
||||||
// ->afterStateUpdated(fn ($set) => $set('line_id', null))
|
// ->afterStateUpdated(fn ($set) => $set('line_id', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if($get('id'))
|
if($get('id'))
|
||||||
@@ -167,6 +178,9 @@ class ProductionPlanResource extends Resource
|
|||||||
->toArray();
|
->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
|
// ->default(function () {
|
||||||
|
// return optional(ProductionPlan::latest()->first())->line_id;
|
||||||
|
// })
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if($get('id'))
|
if($get('id'))
|
||||||
{
|
{
|
||||||
@@ -223,7 +237,7 @@ class ProductionPlanResource extends Resource
|
|||||||
//$currentDate = date('Y-m-d');
|
//$currentDate = date('Y-m-d');
|
||||||
$yesterday = date('Y-m-d', strtotime('-1 days'));
|
$yesterday = date('Y-m-d', strtotime('-1 days'));
|
||||||
|
|
||||||
$shiftId = \App\Models\Shift::where('id', $get('shift_id'))
|
$shiftId = Shift::where('id', $get('shift_id'))
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
@@ -251,7 +265,7 @@ class ProductionPlanResource extends Resource
|
|||||||
{
|
{
|
||||||
$currentDate = date('Y-m-d');
|
$currentDate = date('Y-m-d');
|
||||||
|
|
||||||
$shiftId = \App\Models\Shift::where('id', $get('shift_id'))
|
$shiftId = Shift::where('id', $get('shift_id'))
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
@@ -285,7 +299,7 @@ class ProductionPlanResource extends Resource
|
|||||||
//$currentDate = date('Y-m-d');
|
//$currentDate = date('Y-m-d');
|
||||||
$yesterday = date('Y-m-d', strtotime('-1 days'));
|
$yesterday = date('Y-m-d', strtotime('-1 days'));
|
||||||
|
|
||||||
$shiftId = \App\Models\Shift::where('id', $get('shift_id'))
|
$shiftId = Shift::where('id', $get('shift_id'))
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
@@ -316,7 +330,7 @@ class ProductionPlanResource extends Resource
|
|||||||
{
|
{
|
||||||
$currentDate = date('Y-m-d');
|
$currentDate = date('Y-m-d');
|
||||||
|
|
||||||
$shiftId = \App\Models\Shift::where('id', $get('shift_id'))
|
$shiftId = Shift::where('id', $get('shift_id'))
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
@@ -532,7 +546,8 @@ class ProductionPlanResource extends Resource
|
|||||||
])
|
])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
ImportAction::make()
|
ImportAction::make()
|
||||||
->importer(ProductionPlanImporter::class),
|
->importer(ProductionPlanImporter::class)
|
||||||
|
->maxRows(100000),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Imports\ProductionQuantityImporter;
|
use App\Filament\Imports\ProductionQuantityImporter;
|
||||||
use App\Filament\Resources\ProductionQuantityResource\Pages;
|
use App\Filament\Resources\ProductionQuantityResource\Pages;
|
||||||
use App\Filament\Resources\ProductionQuantityResource\RelationManagers;
|
use App\Filament\Resources\ProductionQuantityResource\RelationManagers;
|
||||||
|
use App\Models\Item;
|
||||||
use App\Models\ProductionQuantity;
|
use App\Models\ProductionQuantity;
|
||||||
|
use App\Models\Shift;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
@@ -40,6 +42,9 @@ class ProductionQuantityResource extends Resource
|
|||||||
->required()
|
->required()
|
||||||
// ->nullable()
|
// ->nullable()
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->default(function () {
|
||||||
|
return optional(ProductionQuantity::latest()->first())->plant_id;
|
||||||
|
})
|
||||||
->disabled(fn (Get $get) => !empty($get('id')))
|
->disabled(fn (Get $get) => !empty($get('id')))
|
||||||
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
|
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
@@ -73,12 +78,16 @@ class ProductionQuantityResource extends Resource
|
|||||||
->toArray();
|
->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->default(function () {
|
||||||
|
$latestShiftId = optional(ProductionQuantity::latest()->first())->shift_id;
|
||||||
|
return optional(Shift::where('id', $latestShiftId)->first())->block_id;
|
||||||
|
})
|
||||||
// ->afterStateUpdated(fn ($set) => $set('shift_id', null))
|
// ->afterStateUpdated(fn ($set) => $set('shift_id', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if($get('id'))
|
if($get('id'))
|
||||||
{
|
{
|
||||||
$getShift = ProductionQuantity::where('id', $get('id'))->first();
|
$getShift = ProductionQuantity::where('id', $get('id'))->first();
|
||||||
$getBlock = \App\Models\Shift::where('id', $getShift->shift_id)->first();
|
$getBlock = Shift::where('id', $getShift->shift_id)->first();
|
||||||
if($getBlock->block_id)
|
if($getBlock->block_id)
|
||||||
{
|
{
|
||||||
$set('block_name', $getBlock->block_id);
|
$set('block_name', $getBlock->block_id);
|
||||||
@@ -113,13 +122,16 @@ class ProductionQuantityResource extends Resource
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return \App\Models\Shift::where('plant_id', $get('plant_id'))
|
return Shift::where('plant_id', $get('plant_id'))
|
||||||
->where('block_id', $get('block_name'))
|
->where('block_id', $get('block_name'))
|
||||||
->pluck('name', 'id')
|
->pluck('name', 'id')
|
||||||
->toArray();
|
->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(fn ($set) => $set('line_id', null))
|
->default(function () {
|
||||||
|
return optional(ProductionQuantity::latest()->first())->shift_id;
|
||||||
|
})
|
||||||
|
//->afterStateUpdated(fn ($set) => $set('line_id', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if($get('id'))
|
if($get('id'))
|
||||||
{
|
{
|
||||||
@@ -168,6 +180,9 @@ class ProductionQuantityResource extends Resource
|
|||||||
->toArray();
|
->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->default(function () {
|
||||||
|
return optional(ProductionQuantity::latest()->first())->line_id;
|
||||||
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if($get('id'))
|
if($get('id'))
|
||||||
{
|
{
|
||||||
@@ -200,15 +215,15 @@ class ProductionQuantityResource extends Resource
|
|||||||
->latest() // Orders by created_at DESC
|
->latest() // Orders by created_at DESC
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if($exists)
|
// if($exists)
|
||||||
{
|
// {
|
||||||
$existCode = \App\Models\Item::where('id', $exists->item_id)->first();
|
// $existCode = Item::where('id', $exists->item_id)->first();
|
||||||
$set('recent_qr', $existCode->code.'|'.$exists->serial_number);
|
// $set('recent_qr', $existCode->code.'|'.$exists->serial_number);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
$set('recent_qr', null);
|
// $set('recent_qr', null);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->extraAttributes(fn ($get) => [
|
->extraAttributes(fn ($get) => [
|
||||||
@@ -230,6 +245,8 @@ class ProductionQuantityResource extends Resource
|
|||||||
// ->required()
|
// ->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
->autofocus(true)
|
->autofocus(true)
|
||||||
|
->debounce(300)
|
||||||
|
// ->submitOnEnter()
|
||||||
->afterStateUpdated(function ($state, callable $get, callable $set) {
|
->afterStateUpdated(function ($state, callable $get, callable $set) {
|
||||||
// **Check if input is empty before processing**
|
// **Check if input is empty before processing**
|
||||||
if (empty($state)) {
|
if (empty($state)) {
|
||||||
@@ -307,7 +324,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
{
|
{
|
||||||
$currentDate = date('Y-m-d');
|
$currentDate = date('Y-m-d');
|
||||||
|
|
||||||
$shiftId = \App\Models\Shift::where('id', $get('shift_id'))
|
$shiftId = Shift::where('id', $get('shift_id'))
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
@@ -362,7 +379,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
//$currentDate = date('Y-m-d');
|
//$currentDate = date('Y-m-d');
|
||||||
$yesterday = date('Y-m-d', strtotime('-1 days'));
|
$yesterday = date('Y-m-d', strtotime('-1 days'));
|
||||||
|
|
||||||
$shiftId = \App\Models\Shift::where('id', $get('shift_id'))
|
$shiftId = Shift::where('id', $get('shift_id'))
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
@@ -388,7 +405,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
{
|
{
|
||||||
$currentDate = date('Y-m-d');
|
$currentDate = date('Y-m-d');
|
||||||
|
|
||||||
$shiftId = \App\Models\Shift::where('id', $get('shift_id'))
|
$shiftId = Shift::where('id', $get('shift_id'))
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
@@ -447,7 +464,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
//$currentDate = date('Y-m-d');
|
//$currentDate = date('Y-m-d');
|
||||||
$yesterday = date('Y-m-d', strtotime('-1 days'));
|
$yesterday = date('Y-m-d', strtotime('-1 days'));
|
||||||
|
|
||||||
$shiftId = \App\Models\Shift::where('id', $get('shift_id'))
|
$shiftId = Shift::where('id', $get('shift_id'))
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
@@ -484,7 +501,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
{
|
{
|
||||||
$currentDate = date('Y-m-d');
|
$currentDate = date('Y-m-d');
|
||||||
|
|
||||||
$shiftId = \App\Models\Shift::where('id', $get('shift_id'))
|
$shiftId = Shift::where('id', $get('shift_id'))
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
@@ -555,7 +572,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid QR')
|
->title('Invalid QR')
|
||||||
->body("Scan the valid QR code. (Ex: Item_Code|Serial_Number )")
|
->body("Scan the valid QR code.<br>(Ex: Item_Code|Serial_Number )")
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
return;
|
return;
|
||||||
@@ -623,7 +640,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid QR')
|
->title('Invalid QR')
|
||||||
->body("Scan the valid QR code. (Ex: Item_Code|Serial_Number )")
|
->body("Scan the valid QR code.<br>(Ex: Item_Code|Serial_Number )")
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
return;
|
return;
|
||||||
@@ -642,7 +659,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
$serialNumber = isset($parts[1]) ? trim($parts[1]) : null;
|
$serialNumber = isset($parts[1]) ? trim($parts[1]) : null;
|
||||||
|
|
||||||
// Fetch item using item code and plant_id
|
// Fetch item using item code and plant_id
|
||||||
$item = \App\Models\Item::where('code', $itemCode)
|
$item = Item::where('code', $itemCode)
|
||||||
->where('plant_id', $get('plant_id'))
|
->where('plant_id', $get('plant_id'))
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
@@ -698,11 +715,27 @@ class ProductionQuantityResource extends Resource
|
|||||||
->required()
|
->required()
|
||||||
->unique(ignoreRecord: true)
|
->unique(ignoreRecord: true)
|
||||||
->readOnly(true)
|
->readOnly(true)
|
||||||
->autocapitalize('serial_number'),
|
->autocapitalize('characters'),
|
||||||
//->columnSpanFull(),
|
//->columnSpanFull(),
|
||||||
Forms\Components\TextInput::make('recent_qr') //item_description
|
Forms\Components\TextInput::make('recent_qr') //item_description
|
||||||
->label('Last scanned QR')
|
->label('Last scanned QR')
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->default(function () {
|
||||||
|
// Get the latest 'item_id' foreign key from 'production_quantities' table
|
||||||
|
$latestProductionQuantity = ProductionQuantity::latest()->first();
|
||||||
|
if (!$latestProductionQuantity) {
|
||||||
|
return null; // Return null if no production quantities exist
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the corresponding 'code' from 'items' table where 'id' matches 'item_id'
|
||||||
|
$itemCode = optional(Item::find($latestProductionQuantity->item_id))->code;
|
||||||
|
|
||||||
|
// Get the latest 'serial_number' from 'production_quantities' table
|
||||||
|
$serialNumber = $latestProductionQuantity->serial_number;
|
||||||
|
|
||||||
|
// Combine 'code' and 'serial_number' into the desired format
|
||||||
|
return $itemCode && $serialNumber ? "{$itemCode} | {$serialNumber}" : null;
|
||||||
|
})
|
||||||
->readOnly(true),
|
->readOnly(true),
|
||||||
Forms\Components\TextInput::make('id')
|
Forms\Components\TextInput::make('id')
|
||||||
->hidden()
|
->hidden()
|
||||||
@@ -759,7 +792,8 @@ class ProductionQuantityResource extends Resource
|
|||||||
])
|
])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
ImportAction::make()
|
ImportAction::make()
|
||||||
->importer(ProductionQuantityImporter::class),
|
->importer(ProductionQuantityImporter::class)
|
||||||
|
->maxRows(100000),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user