error is occurred because it calls store function instead of update function, cant understand why it happens.
link to edit
<a href="{{url('/')}}/mechanic_brands/{{$br->mech_brand_id}}/edit"><i class="fas fa-edit"></i></a>
web.php
//add Mechanic Brands
Route::get('mechanic_brands/{mechanic_id}/Add','MechBrandController@Add');
//save Mechanic_Brands
Route::post('mechanic_brands/{mechanic_id}','MechBrandController@store');
//edit Mechanic Brands
Route::get('mechanic_brands/{mech_brand_id}/edit','MechBrandController@edit');
Route::post('mechanic_brands/{mech_brand_id}','MechBrandController@update');
//delete Mechanic Brands
Route::get('mechanic_brands/{mech_brand}','MechBrandController@destroy');
//get segment wise brand using ajax
Route::get('brand/Ajax/{segment}','MechBrandController@brandAjax');
edit view
<form method="post" action="{{url('/')}}/mechanic_brands/{{$mech_brand->mech_brand_id}}" enctype="multipart/form-data" novalidate>
{{csrf_field()}}
<div class="form-group">
<label for="inputPassword3" class="col-sm-3 control-label">Segment Name
<span class="required"> * </span></label>
<div class="col-sm-8">
<select class="form-control" name="segment_id" required data-validation-required-message="This field is required" onchange="getBrand(this.value)" >
@foreach($segment as $br)
@if($br->segment_id == $mech_brand->segment_id )
<option value="{{$br->segment_id}}" selected >{{$br->segment_name}}</option>
@else
<option value="{{$br->segment_id}}">{{$br->segment_name}}</option>
@endif
@endforeach
</select>
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-3 control-label">Brand Name
<span class="required"> * </span></label>
<div class="col-sm-8">
<select class="form-control" name="brand_id" required data-validation-required-message="This field is required">
@foreach($brand as $br)
@if($br->brand_id == $mech_brand->brand_id )
<option value="{{$br->brand_id}}" selected >{{$br->brand_name}}</option>
@else
<option value="{{$br->brand_id}}">{{$br->brand_name}}</option>
@endif
@endforeach
</select>
</div>
</div>
<div class="text-xs-right">
<button type="submit" class="btn btn-info">Submit</button>
<button type="reset" class="btn btn-inverse">Cancel</button>
</div>
</form>
controller
public function edit(MechBrand $mech_brand_id)
{
//dd('hi');
//dd($mech_brand_id);
$mech_brand=MechBrand::where('mech_brands.mech_brand_id',$mech_brand_id->mech_brand_id)
->join('segments','mech_brands.segment_id','=','segments.segment_id')
->join('brands','mech_brands.brand_id','=','brands.brand_id')
->select('segment_name','brand_name', 'mech_brands.*')->first();
$brand=Brands::get();
$segment=Segment::get();
//dd($statearea);
return view('backend.mechanic_brands.editMechBrands',compact('mech_brand','segment','brand'));
}
public function update(Request $req,MechBrand $mech_brand_id)
{
// dd($mech_brand_id);
//dd($req->all());
$mechanic_id=request('mechanic_id');
$segment_id=request('segment_id');
$brand_id=request('brand_id');
$mech_brand_id->update($req->all());
return redirect('mechanic/view');
}