Added hasMany relation on model files and Updated report filter functionality on resource file
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
This commit is contained in:
@@ -786,7 +786,15 @@ class ProcessOrderResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||||
|
} else {
|
||||||
|
return Plant::whereHas('processOrders', function ($query) {
|
||||||
|
$query->whereNotNull('id');
|
||||||
|
})->pluck('name', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('Item', null);
|
$set('Item', null);
|
||||||
@@ -800,6 +808,10 @@ class ProcessOrderResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
|
|
||||||
|
if (empty($plantId)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
return Line::whereHas('processOrders', function ($query) use ($plantId) {
|
return Line::whereHas('processOrders', function ($query) use ($plantId) {
|
||||||
if ($plantId) {
|
if ($plantId) {
|
||||||
$query->where('plant_id', $plantId);
|
$query->where('plant_id', $plantId);
|
||||||
@@ -817,6 +829,10 @@ class ProcessOrderResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
|
|
||||||
|
if (empty($plantId)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
return Item::whereHas('processOrders', function ($query) use ($plantId) {
|
return Item::whereHas('processOrders', function ($query) use ($plantId) {
|
||||||
if ($plantId) {
|
if ($plantId) {
|
||||||
$query->where('plant_id', $plantId);
|
$query->where('plant_id', $plantId);
|
||||||
@@ -924,7 +940,7 @@ class ProcessOrderResource extends Resource
|
|||||||
$indicators = [];
|
$indicators = [];
|
||||||
|
|
||||||
if (! empty($data['Plant'])) {
|
if (! empty($data['Plant'])) {
|
||||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||||
} else {
|
} else {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,11 @@ class Plant extends Model
|
|||||||
return $this->hasMany(WorkGroupMaster::class, 'plant_id', 'id');
|
return $this->hasMany(WorkGroupMaster::class, 'plant_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function processOrders()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProcessOrder::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function equipmentMasters()
|
public function equipmentMasters()
|
||||||
{
|
{
|
||||||
return $this->hasMany(EquipmentMaster::class, 'plant_id', 'id');
|
return $this->hasMany(EquipmentMaster::class, 'plant_id', 'id');
|
||||||
|
|||||||
Reference in New Issue
Block a user