107 lines
2.4 KiB
PHP
107 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Line;
|
|
use App\Models\ModuleList;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ModuleFGLineController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index()
|
|
{
|
|
//
|
|
}
|
|
|
|
public function get_moduleFGFilter(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);
|
|
}
|
|
|
|
$lineName = $request->header('line-name');
|
|
|
|
if (empty($lineName))
|
|
{
|
|
return response()->json([
|
|
'status_code' => 'ERROR',
|
|
'status_description' => "Line name can't be empty!"
|
|
], 404);
|
|
}
|
|
|
|
|
|
$line = Line::where('name', $lineName)->first();
|
|
|
|
if (!$line) {
|
|
return response()->json([
|
|
'status_code' => 'ERROR',
|
|
'status_description' => "Line '{$lineName}' not found!"
|
|
], 404);
|
|
}
|
|
|
|
if ($line->type !== 'FG Line') {
|
|
return response()->json([
|
|
'status_code' => 'ERROR',
|
|
'status_description' => "Line '{$lineName}' is not of type FG Line."
|
|
], 400);
|
|
}
|
|
// Default logic to return filter names
|
|
$filterNames = ModuleList::orderBy('created_at', 'asc')
|
|
->get()
|
|
->unique('filter_name')
|
|
->pluck('filter_name')
|
|
->filter()
|
|
->values();
|
|
|
|
return response()->json([
|
|
'status_code' => 'SUCCESS',
|
|
'status_description' => $filterNames
|
|
], 200);
|
|
}
|
|
|
|
/**
|
|
* 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)
|
|
{
|
|
//
|
|
}
|
|
}
|