Updated validation functionality and failure messages in controller files
This commit is contained in:
@@ -33,27 +33,27 @@ class PlantController extends Controller
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
|
||||
if ("Bearer " . $expectedToken !== $header_auth)
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token'
|
||||
'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,
|
||||
];
|
||||
});
|
||||
$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
|
||||
]);
|
||||
return response()->json([
|
||||
'plants' => $plantsData
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user