Added store logic for controller
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\DriverMaster;
|
||||||
|
use App\Models\VehicleMaster;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Str;
|
use Str;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
@@ -19,10 +21,21 @@ class SapFileController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
*/
|
*/
|
||||||
// public function store(Request $request)
|
public function store(Request $request)
|
||||||
// {
|
{
|
||||||
// //
|
$request->validate([
|
||||||
// }
|
'name' => 'required|string',
|
||||||
|
'identification1' => 'nullable|string',
|
||||||
|
'identification2' => 'nullable|string',
|
||||||
|
'identification3' => 'nullable|string',
|
||||||
|
'contact_number' => 'nullable|string',
|
||||||
|
'alternate_number' => 'nullable|string',
|
||||||
|
]);
|
||||||
|
|
||||||
|
DriverMaster::create($request->all());
|
||||||
|
|
||||||
|
return response()->json(['success' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
public function getSapData(Request $request)
|
public function getSapData(Request $request)
|
||||||
{
|
{
|
||||||
@@ -145,40 +158,6 @@ class SapFileController extends Controller
|
|||||||
], 500);
|
], 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
// $table = 'class_characteristics';
|
|
||||||
// $columns = Schema::getColumnListing($table); // returns lowercase column names
|
|
||||||
|
|
||||||
// $rows = [];
|
|
||||||
// foreach ($lines as $line) {
|
|
||||||
// $values = str_getcsv($line); // split by comma
|
|
||||||
|
|
||||||
// $row = [];
|
|
||||||
// foreach ($columns as $index => $column) {
|
|
||||||
// $value = $values[$index] ?? null; // if missing, set null
|
|
||||||
// if ($value === '') $value = null; // empty string -> null
|
|
||||||
// $row[$column] = $value;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $rows[] = $row;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return response()->json([
|
|
||||||
// 'status' => 'DEBUG_ROWS',
|
|
||||||
// 'rows_sample' => array_slice($rows, 0, 5),
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
|
|
||||||
// Insert into database
|
|
||||||
// foreach ($rows as $row) {
|
|
||||||
// \App\Models\ClassCharacteristic::create($row);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return response()->json([
|
|
||||||
// 'status' => 'SUCCESS',
|
|
||||||
// 'rows_imported' => count($rows),
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
|
|
||||||
// Prepare arrays
|
// Prepare arrays
|
||||||
// $serialNumbers = [];
|
// $serialNumbers = [];
|
||||||
// $remainingRows = [];
|
// $remainingRows = [];
|
||||||
@@ -251,7 +230,7 @@ class SapFileController extends Controller
|
|||||||
if (!empty($invalidSerials)) {
|
if (!empty($invalidSerials)) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status' => 'ERROR',
|
'status' => 'ERROR',
|
||||||
'status_description' => 'Some serial numbers are invalid (less than 13 characters)',
|
'status_description' => 'serial numbers are invalid (less than 13 characters)',
|
||||||
'invalid_serials' => $invalidSerials
|
'invalid_serials' => $invalidSerials
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user