mercredi 24 octobre 2018

Why did not update table columns values in Laravel 5.6?

in laravel 5.6 app I have table name as vehicles, then I need update some of table values in VehicleController update function as this,

public function update(Request $request, $id)
    {

        $vehicle = Vehicle::find($id);

        $vehicle->provincename = $request->input('provincename');
        $vehicle->districtname = $request->input('districtname');
        $vehicle->townname = $request->input('townname');
        $vehicle->brandname = $request->input('brandname');
        $vehicle->modelname = $request->input('modelname');
        $vehicle->modelyear = $request->input('year');
        $vehicle->condition = $request->input('condition');
        $vehicle->milage = $request->input('milage');
        $vehicle->detail = $request->input('data');
        $vehicle->price = $request->input('price');
        $vehicle->telephone = $request->input('telephone');
        $vehicle->categoryname =  $request->input('categoryname');
        $vehicle->transmission = $request->input('transmission');
        $vehicle->fueltype = $request->input('fueltype');
        $vehicle->enginecapacity = $request->input('enginecapacity');
        $vehicle->user_id = Auth::user()->id;

        $vehicle->save();

and edit form action is,

<form  method="post"  action="" enctype="multipart/form-data">

and update route is,

Route::post('myads/{id}', [
    'uses' => '\App\Http\Controllers\VehicleController@update',
])->name('vehicles.edit');

and controller edit function,

 public function edit($id)
    {
       $vehicles = Vehicle::findOrFail($id);
}

and edit route is,

Route::get('myads/{id}/edit', [
    'uses' => '\App\Http\Controllers\VehicleController@edit',
    'as'=> 'vehicles.edit'
]);

but when I click update button it did not update values. no any error occurred here only redirect back to edit form. how can fix this problem?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire