6 Commits

Author SHA1 Message Date
dhanabalan
f5345fc2b8 Added policy files 2025-07-02 18:07:09 +05:30
dhanabalan
cd09b912ee Added hasMany relations for guard patrol entry 2025-07-02 18:03:26 +05:30
dhanabalan
008e9ff791 Added view invoice serial quantity dashboard permission 2025-07-02 17:58:58 +05:30
dhanabalan
a0c0588e49 Removed unwanted enter line space 2025-07-02 17:44:27 +05:30
dhanabalan
137341fc6c Added sticker master controller file 2025-07-02 17:43:30 +05:30
dhanabalan
33d22dec5b Added plant controller file 2025-07-02 17:26:33 +05:30
13 changed files with 1083 additions and 3 deletions

View File

@@ -21,7 +21,6 @@ class ObdController extends Controller
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
$expectedUser = env('API_AUTH_USER');

View File

@@ -0,0 +1,74 @@
<?php
namespace App\Http\Controllers;
use App\Models\Plant;
use Illuminate\Http\Request;
class PlantController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*/
public function get_all_data(Request $request)
{
$expectedUser = env('API_AUTH_USER');
$expectedPw = env('API_AUTH_PW');
$header_auth = $request->header('Authorization');
$expectedToken = $expectedUser . ':' . $expectedPw;
if ("Bearer " . $expectedToken !== $header_auth)
{
return response()->json([
'status_code' => 'ERROR',
'status_description' => 'Invalid authorization token'
], 403);
}
$plants = Plant::with('company')->orderBy('code')->get();
$plantsData = $plants->map(function($plant) {
return [
'company' => $plant->company ? $plant->company->name : "", // Get company name
'plant_code' => (String)$plant->code,
'plant_name' => $plant->name,
'plant_address' => $plant->address,
];
});
return response()->json([
'plants' => $plantsData
]);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, string $id)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(string $id)
{
//
}
}

View File

@@ -0,0 +1,140 @@
<?php
namespace App\Http\Controllers;
use App\Models\Item;
use App\Models\MotorTestingMaster;
use App\Models\Plant;
use App\Models\StickerMaster;
use Illuminate\Http\Request;
class StickerMasterController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*/
public function get_master(Request $request)
{
$expectedUser = env('API_AUTH_USER');
$expectedPw = env('API_AUTH_PW');
$header_auth = $request->header('Authorization');
$expectedToken = $expectedUser . ':' . $expectedPw;
// if ("Bearer " . $expectedToken !== $header_auth)
// {
// return response("Unauthorized", 403)
// ->header('Content-Type', 'text/plain');
// }
//$data = $request->all();
if ("Bearer " . $expectedToken !== $header_auth)
{
return response()->json([
'status_code' => 'ERROR',
'status_description' => 'Invalid authorization token'
], 403);
}
$plantCode = $request->header('plant-code');
$itemCode = $request->header('item-code');
if ($plantCode == null || $plantCode == '')
{
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Plant name cannot be empty"
], 400);
}
else if ($itemCode == null || $itemCode == '')
{
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Item code cannot be empty"
], 400);
}
$plant = Plant::where('code', $plantCode)->first();
if (!$plant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Plant not found"
], 400);
}
$plantId = $plant->id;
$item = Item::where('plant_id', $plantId)->where('code', $itemCode)->first();
$description = $item ? $item->description : '';
$uom = $item ? $item->uom : '';
$category = $item ? $item->category : '';
$item = Item::where('code', $itemCode)->first();
if (!$item)
{
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Item Code not found in item table for the plant : $plant->name"
], 404);
}
$stickerMaster = StickerMaster::where('plant_id', $plant->id)->where('item_id', $item->id)->first();
if (!$stickerMaster)
{
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Item Code not found in master table for the plant : $plant->name"
], 404);
}
$output = [
"item_description" => $description ?? "",
"uom" => $uom ?? "",
"Part_Validation_1" => $stickerMaster->laser_part_validation1 ?? "",
"Part_Validation_2" => $stickerMaster->laser_part_validation2 ?? "",
"Part_Validation_3" => "",
"Part_Validation_4" => "",
"Part_Validation_5" => ""
];
return response()->json($output, 200);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, string $id)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(string $id)
{
//
}
}

View File

@@ -62,4 +62,24 @@ class Plant extends Model
{
return $this->hasMany(TestingPanelReading::class);
}
public function guardNames()
{
return $this->hasMany(GuardName::class, 'plant_id', 'id');
}
public function checkPointNames()
{
return $this->hasMany(CheckPointName::class, 'plant_id', 'id');
}
public function checkPointTimes()
{
return $this->hasMany(CheckPointTime::class, 'plant_id', 'id');
}
public function guardPatrolEntries()
{
return $this->hasMany(GuardPatrolEntry::class, 'plant_id', 'id');
}
}

View File

@@ -0,0 +1,106 @@
<?php
namespace App\Policies;
use Illuminate\Auth\Access\Response;
use App\Models\Configuration;
use App\Models\User;
class ConfigurationPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->checkPermissionTo('view-any Configuration');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Configuration $configuration): bool
{
return $user->checkPermissionTo('view Configuration');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->checkPermissionTo('create Configuration');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Configuration $configuration): bool
{
return $user->checkPermissionTo('update Configuration');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Configuration $configuration): bool
{
return $user->checkPermissionTo('delete Configuration');
}
/**
* Determine whether the user can delete any models.
*/
public function deleteAny(User $user): bool
{
return $user->checkPermissionTo('delete-any Configuration');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Configuration $configuration): bool
{
return $user->checkPermissionTo('restore Configuration');
}
/**
* Determine whether the user can restore any models.
*/
public function restoreAny(User $user): bool
{
return $user->checkPermissionTo('restore-any Configuration');
}
/**
* Determine whether the user can replicate the model.
*/
public function replicate(User $user, Configuration $configuration): bool
{
return $user->checkPermissionTo('replicate Configuration');
}
/**
* Determine whether the user can reorder the models.
*/
public function reorder(User $user): bool
{
return $user->checkPermissionTo('reorder Configuration');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Configuration $configuration): bool
{
return $user->checkPermissionTo('force-delete Configuration');
}
/**
* Determine whether the user can permanently delete any models.
*/
public function forceDeleteAny(User $user): bool
{
return $user->checkPermissionTo('force-delete-any Configuration');
}
}

View File

@@ -0,0 +1,106 @@
<?php
namespace App\Policies;
use Illuminate\Auth\Access\Response;
use App\Models\LocatorInvoiceValidation;
use App\Models\User;
class LocatorInvoiceValidationPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->checkPermissionTo('view-any LocatorInvoiceValidation');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, LocatorInvoiceValidation $locatorinvoicevalidation): bool
{
return $user->checkPermissionTo('view LocatorInvoiceValidation');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->checkPermissionTo('create LocatorInvoiceValidation');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, LocatorInvoiceValidation $locatorinvoicevalidation): bool
{
return $user->checkPermissionTo('update LocatorInvoiceValidation');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, LocatorInvoiceValidation $locatorinvoicevalidation): bool
{
return $user->checkPermissionTo('delete LocatorInvoiceValidation');
}
/**
* Determine whether the user can delete any models.
*/
public function deleteAny(User $user): bool
{
return $user->checkPermissionTo('delete-any LocatorInvoiceValidation');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, LocatorInvoiceValidation $locatorinvoicevalidation): bool
{
return $user->checkPermissionTo('restore LocatorInvoiceValidation');
}
/**
* Determine whether the user can restore any models.
*/
public function restoreAny(User $user): bool
{
return $user->checkPermissionTo('restore-any LocatorInvoiceValidation');
}
/**
* Determine whether the user can replicate the model.
*/
public function replicate(User $user, LocatorInvoiceValidation $locatorinvoicevalidation): bool
{
return $user->checkPermissionTo('replicate LocatorInvoiceValidation');
}
/**
* Determine whether the user can reorder the models.
*/
public function reorder(User $user): bool
{
return $user->checkPermissionTo('reorder LocatorInvoiceValidation');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, LocatorInvoiceValidation $locatorinvoicevalidation): bool
{
return $user->checkPermissionTo('force-delete LocatorInvoiceValidation');
}
/**
* Determine whether the user can permanently delete any models.
*/
public function forceDeleteAny(User $user): bool
{
return $user->checkPermissionTo('force-delete-any LocatorInvoiceValidation');
}
}

View File

@@ -0,0 +1,106 @@
<?php
namespace App\Policies;
use Illuminate\Auth\Access\Response;
use App\Models\Locator;
use App\Models\User;
class LocatorPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->checkPermissionTo('view-any Locator');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Locator $locator): bool
{
return $user->checkPermissionTo('view Locator');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->checkPermissionTo('create Locator');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Locator $locator): bool
{
return $user->checkPermissionTo('update Locator');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Locator $locator): bool
{
return $user->checkPermissionTo('delete Locator');
}
/**
* Determine whether the user can delete any models.
*/
public function deleteAny(User $user): bool
{
return $user->checkPermissionTo('delete-any Locator');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Locator $locator): bool
{
return $user->checkPermissionTo('restore Locator');
}
/**
* Determine whether the user can restore any models.
*/
public function restoreAny(User $user): bool
{
return $user->checkPermissionTo('restore-any Locator');
}
/**
* Determine whether the user can replicate the model.
*/
public function replicate(User $user, Locator $locator): bool
{
return $user->checkPermissionTo('replicate Locator');
}
/**
* Determine whether the user can reorder the models.
*/
public function reorder(User $user): bool
{
return $user->checkPermissionTo('reorder Locator');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Locator $locator): bool
{
return $user->checkPermissionTo('force-delete Locator');
}
/**
* Determine whether the user can permanently delete any models.
*/
public function forceDeleteAny(User $user): bool
{
return $user->checkPermissionTo('force-delete-any Locator');
}
}

View File

@@ -0,0 +1,106 @@
<?php
namespace App\Policies;
use Illuminate\Auth\Access\Response;
use App\Models\Machine;
use App\Models\User;
class MachinePolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->checkPermissionTo('view-any Machine');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Machine $machine): bool
{
return $user->checkPermissionTo('view Machine');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->checkPermissionTo('create Machine');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Machine $machine): bool
{
return $user->checkPermissionTo('update Machine');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Machine $machine): bool
{
return $user->checkPermissionTo('delete Machine');
}
/**
* Determine whether the user can delete any models.
*/
public function deleteAny(User $user): bool
{
return $user->checkPermissionTo('delete-any Machine');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Machine $machine): bool
{
return $user->checkPermissionTo('restore Machine');
}
/**
* Determine whether the user can restore any models.
*/
public function restoreAny(User $user): bool
{
return $user->checkPermissionTo('restore-any Machine');
}
/**
* Determine whether the user can replicate the model.
*/
public function replicate(User $user, Machine $machine): bool
{
return $user->checkPermissionTo('replicate Machine');
}
/**
* Determine whether the user can reorder the models.
*/
public function reorder(User $user): bool
{
return $user->checkPermissionTo('reorder Machine');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Machine $machine): bool
{
return $user->checkPermissionTo('force-delete Machine');
}
/**
* Determine whether the user can permanently delete any models.
*/
public function forceDeleteAny(User $user): bool
{
return $user->checkPermissionTo('force-delete-any Machine');
}
}

View File

@@ -0,0 +1,106 @@
<?php
namespace App\Policies;
use Illuminate\Auth\Access\Response;
use App\Models\MotorTestingMaster;
use App\Models\User;
class MotorTestingMasterPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->checkPermissionTo('view-any MotorTestingMaster');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, MotorTestingMaster $motortestingmaster): bool
{
return $user->checkPermissionTo('view MotorTestingMaster');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->checkPermissionTo('create MotorTestingMaster');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, MotorTestingMaster $motortestingmaster): bool
{
return $user->checkPermissionTo('update MotorTestingMaster');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, MotorTestingMaster $motortestingmaster): bool
{
return $user->checkPermissionTo('delete MotorTestingMaster');
}
/**
* Determine whether the user can delete any models.
*/
public function deleteAny(User $user): bool
{
return $user->checkPermissionTo('delete-any MotorTestingMaster');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, MotorTestingMaster $motortestingmaster): bool
{
return $user->checkPermissionTo('restore MotorTestingMaster');
}
/**
* Determine whether the user can restore any models.
*/
public function restoreAny(User $user): bool
{
return $user->checkPermissionTo('restore-any MotorTestingMaster');
}
/**
* Determine whether the user can replicate the model.
*/
public function replicate(User $user, MotorTestingMaster $motortestingmaster): bool
{
return $user->checkPermissionTo('replicate MotorTestingMaster');
}
/**
* Determine whether the user can reorder the models.
*/
public function reorder(User $user): bool
{
return $user->checkPermissionTo('reorder MotorTestingMaster');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, MotorTestingMaster $motortestingmaster): bool
{
return $user->checkPermissionTo('force-delete MotorTestingMaster');
}
/**
* Determine whether the user can permanently delete any models.
*/
public function forceDeleteAny(User $user): bool
{
return $user->checkPermissionTo('force-delete-any MotorTestingMaster');
}
}

View File

@@ -0,0 +1,106 @@
<?php
namespace App\Policies;
use Illuminate\Auth\Access\Response;
use App\Models\PalletValidation;
use App\Models\User;
class PalletValidationPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->checkPermissionTo('view-any PalletValidation');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, PalletValidation $palletvalidation): bool
{
return $user->checkPermissionTo('view PalletValidation');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->checkPermissionTo('create PalletValidation');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, PalletValidation $palletvalidation): bool
{
return $user->checkPermissionTo('update PalletValidation');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, PalletValidation $palletvalidation): bool
{
return $user->checkPermissionTo('delete PalletValidation');
}
/**
* Determine whether the user can delete any models.
*/
public function deleteAny(User $user): bool
{
return $user->checkPermissionTo('delete-any PalletValidation');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, PalletValidation $palletvalidation): bool
{
return $user->checkPermissionTo('restore PalletValidation');
}
/**
* Determine whether the user can restore any models.
*/
public function restoreAny(User $user): bool
{
return $user->checkPermissionTo('restore-any PalletValidation');
}
/**
* Determine whether the user can replicate the model.
*/
public function replicate(User $user, PalletValidation $palletvalidation): bool
{
return $user->checkPermissionTo('replicate PalletValidation');
}
/**
* Determine whether the user can reorder the models.
*/
public function reorder(User $user): bool
{
return $user->checkPermissionTo('reorder PalletValidation');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, PalletValidation $palletvalidation): bool
{
return $user->checkPermissionTo('force-delete PalletValidation');
}
/**
* Determine whether the user can permanently delete any models.
*/
public function forceDeleteAny(User $user): bool
{
return $user->checkPermissionTo('force-delete-any PalletValidation');
}
}

View File

@@ -0,0 +1,106 @@
<?php
namespace App\Policies;
use Illuminate\Auth\Access\Response;
use App\Models\ReworkLocatorInvoiceValidation;
use App\Models\User;
class ReworkLocatorInvoiceValidationPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->checkPermissionTo('view-any ReworkLocatorInvoiceValidation');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, ReworkLocatorInvoiceValidation $reworklocatorinvoicevalidation): bool
{
return $user->checkPermissionTo('view ReworkLocatorInvoiceValidation');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->checkPermissionTo('create ReworkLocatorInvoiceValidation');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, ReworkLocatorInvoiceValidation $reworklocatorinvoicevalidation): bool
{
return $user->checkPermissionTo('update ReworkLocatorInvoiceValidation');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, ReworkLocatorInvoiceValidation $reworklocatorinvoicevalidation): bool
{
return $user->checkPermissionTo('delete ReworkLocatorInvoiceValidation');
}
/**
* Determine whether the user can delete any models.
*/
public function deleteAny(User $user): bool
{
return $user->checkPermissionTo('delete-any ReworkLocatorInvoiceValidation');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, ReworkLocatorInvoiceValidation $reworklocatorinvoicevalidation): bool
{
return $user->checkPermissionTo('restore ReworkLocatorInvoiceValidation');
}
/**
* Determine whether the user can restore any models.
*/
public function restoreAny(User $user): bool
{
return $user->checkPermissionTo('restore-any ReworkLocatorInvoiceValidation');
}
/**
* Determine whether the user can replicate the model.
*/
public function replicate(User $user, ReworkLocatorInvoiceValidation $reworklocatorinvoicevalidation): bool
{
return $user->checkPermissionTo('replicate ReworkLocatorInvoiceValidation');
}
/**
* Determine whether the user can reorder the models.
*/
public function reorder(User $user): bool
{
return $user->checkPermissionTo('reorder ReworkLocatorInvoiceValidation');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, ReworkLocatorInvoiceValidation $reworklocatorinvoicevalidation): bool
{
return $user->checkPermissionTo('force-delete ReworkLocatorInvoiceValidation');
}
/**
* Determine whether the user can permanently delete any models.
*/
public function forceDeleteAny(User $user): bool
{
return $user->checkPermissionTo('force-delete-any ReworkLocatorInvoiceValidation');
}
}

View File

@@ -0,0 +1,106 @@
<?php
namespace App\Policies;
use Illuminate\Auth\Access\Response;
use App\Models\TestingPanelReading;
use App\Models\User;
class TestingPanelReadingPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->checkPermissionTo('view-any TestingPanelReading');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, TestingPanelReading $testingpanelreading): bool
{
return $user->checkPermissionTo('view TestingPanelReading');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->checkPermissionTo('create TestingPanelReading');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, TestingPanelReading $testingpanelreading): bool
{
return $user->checkPermissionTo('update TestingPanelReading');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, TestingPanelReading $testingpanelreading): bool
{
return $user->checkPermissionTo('delete TestingPanelReading');
}
/**
* Determine whether the user can delete any models.
*/
public function deleteAny(User $user): bool
{
return $user->checkPermissionTo('delete-any TestingPanelReading');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, TestingPanelReading $testingpanelreading): bool
{
return $user->checkPermissionTo('restore TestingPanelReading');
}
/**
* Determine whether the user can restore any models.
*/
public function restoreAny(User $user): bool
{
return $user->checkPermissionTo('restore-any TestingPanelReading');
}
/**
* Determine whether the user can replicate the model.
*/
public function replicate(User $user, TestingPanelReading $testingpanelreading): bool
{
return $user->checkPermissionTo('replicate TestingPanelReading');
}
/**
* Determine whether the user can reorder the models.
*/
public function reorder(User $user): bool
{
return $user->checkPermissionTo('reorder TestingPanelReading');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, TestingPanelReading $testingpanelreading): bool
{
return $user->checkPermissionTo('force-delete TestingPanelReading');
}
/**
* Determine whether the user can permanently delete any models.
*/
public function forceDeleteAny(User $user): bool
{
return $user->checkPermissionTo('force-delete-any TestingPanelReading');
}
}

View File

@@ -132,7 +132,6 @@ class PermissionSeeder extends Seeder
Permission::updateOrCreate(['name' => 'view guard patrol entry status dashboard']);
Permission::updateOrCreate(['name' => 'view guard patrol day count dashboard']);
Permission::updateOrCreate(['name' => 'view guard patrol hourly count dashboard']);
Permission::updateOrCreate(['name' => 'view invoice serial quantity dashboard']);
}
}