I have three table accidents, vehicle and people. I am performing curd operation but I am not able to update as there are multiple rows and columns. Can you please check the routes and actually idk the correct way of updating
public function edit($id)
{
$resultset = DB::select('select * from accidents where id = ?',[$id]);
$vehicle = DB::table('vehicle')
->select(['vehicle.type', 'vehicle.details', 'vehicle.vehicleno', 'people.age', 'people.gender', 'people.status'])
->join('people','people.vehicle_id','=','vehicle.id')
->where('people.accidents_id','=',$id)
->get();
return view('updaterecord', array('accident'=>$resultset,'vehicle'=>$vehicle));
}
public function update($id)
{
$branch = $request->input('branch');
$roadname = $request->input('roadname');
$caseregister = $request->input('casereg');
$description = $request->input('description');
$ipc_mvact =$request->input('ipc_mvact');
$type = $request->input('vehicletype');
$vehicleno = $request->input('vehicleno');
$vehicledetails = $request->input('vdetails');
$age=$request->input('age');
$gender=$request->input('gender');
$status=$request->input('status');
DB::update('update acidents set branch = ?, roadname=? ,casereg=?, description=?, IPC_MVAct_Sections=? where id = ?',[$branch,$roadname,$caseregister,$description, $ipc_mvact,$id]);
DB::update('update vehicle set type = ?, vehicleno=? ,vehicledetails=? where accidents_id = ?',[$type,$vehicleno,$vehicledetails,$id]);
DB::update('update people set age = ?, gender=? ,status=? where accidents_id = ?',[$age,$gender,$status,$id]);
return redirect('/admin/tables');
}
// Routes
Route::namespace('Auth')->group(function () {
Route::get('/login', '\App\Http\Controllers\AdminController@index');
Route::post('/admin', '\App\Http\Controllers\AdminController@checklogin');
Route::get('/admin/dashboard', '\App\Http\Controllers\AdminController@successlogin');
Route::get('/admin/tables', '\App\Http\Controllers\AdminController@showtable');
Route::get('/admin/tables/viewrecord/{id}', '\App\Http\Controllers\AdminController@viewaccident');
Route::get('/admin/tables/editrecord/{id}', '\App\Http\Controllers\AdminController@edit');
Route::post('/admin/tables/edit/{id}', '\App\Http\Controllers\AdminController@update');});
//form
<form action="/edit/<?php echo $accident[0]->id; ?>" method="POST">