1
0
forked from poc/pds

Added FGnames list out api

This commit is contained in:
dhanabalan
2025-07-14 12:15:27 +05:30
parent 52a25fec8e
commit b1674bba53
2 changed files with 110 additions and 0 deletions

View File

@@ -0,0 +1,107 @@
<?php
namespace App\Http\Controllers;
use App\Models\Line;
use App\Models\Plant;
use Illuminate\Http\Request;
class ModuleProductionFGLineController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}
public function get_moduleFGFilterList(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);
}
$plantName = $request->header('plant-name');
$FGName = $request->header('fg-lines');
if (empty($plantName)) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Plant name can't be empty!"
], 404);
}
if (empty($FGName)) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "FG line name can't be empty!"
], 404);
}
$plant = Plant::where('name', $plantName)->first();
if (!$plant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Plant '{$plantName}' not found!"
], 404);
}
$fgLines = Line::where('plant_id', $plant->id)
->where('type', $FGName)
->pluck('name'); // Only get line names
if ($fgLines->isEmpty()) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "No FG lines found for the selected plant and line!"
], 404);
}
return response()->json([
'status_code' => 'SUCCESS',
'status_description' => $fgLines,
]);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*/
public function show(string $id)
{
//
}
/**
* 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

@@ -14,6 +14,7 @@ use App\Http\Controllers\ModuleInvoiceQuantityController;
use App\Http\Controllers\ModuleInvoiceTypeController;
use App\Http\Controllers\ModulePlantController;
use App\Http\Controllers\ModulePlantLineController;
use App\Http\Controllers\ModuleProductionFGLineController;
use App\Http\Controllers\ModuleProductionLineStopController;
use App\Http\Controllers\ModuleProductionOrderDataController;
use App\Http\Controllers\ObdController;
@@ -89,6 +90,8 @@ Route::get('get/module-plantline-name/data', [ModulePlantLineController::class,
Route::get('get/module-line-filter-name/data', [ModuleFilterController::class, 'get_moduleFilter']);
Route::get('get/module-fgline-filter-list/data', [ModuleProductionFGLineController::class, 'get_moduleFGFilterList']);
Route::get('get/module-fgline-filter-name/data', [ModuleFGLineController::class, 'get_moduleFGFilter']);
Route::get('get/module-filter-value/data', [ModuleFilterDataController::class, 'get_moduleFilterData']);