Amalmax
289
8
Laravel

Why did not update vehicle columns values in Laravel 5.6?

Posted 8 months ago by Amalmax

working with laravel 5.6 and mysql db. I have table name with vehicles. and I have vehicle table update form as edit.blade.php in vehicles view file. edit blade file form action is,

<form  method="post"  action="{{ route('vehicles.edit', $vehicles->id)  }}" enctype="multipart/form-data">

and vehiclecontroller update function is,

public function update(Request $request, $id)
    {
         $this->validate($request, [
            'provincename'     => 'required|min:3',
            'districtname'    => 'required',
            'townname'    => 'required',
            'brandname'    => 'required',
            'modelname'    => 'required',
            'year'    => 'required',
            'condition'    => 'required',
            'milage'    => 'required',
            'data'    => 'required',
            'price'    => 'required',
            'telephone'    => 'required',
            'categoryname'    => 'required',
            'tramsmission'    => 'required',
            'fueltype'    => 'required',
            'enginecapacity'   => 'required'
        ]);
        $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 my update route is,

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

my vehicle edit route is,

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

but when I click update button it is not update table values.No any error occurred.

Please sign in or create an account to participate in this conversation.