skip to Main Content

I am trying to update a field in the database but I get this error

"{"error":"Resource item not found."}"

below is my update code

 public function update(Request $request, $merchant_id)
    {
        // Validation for required fields (and using some regex to validate our numeric value)
        $request->validate([
            'fees'=>'required',
    
        ]); 
        $merchants = Merchants_data::find($merchant_id);
        $merchants->fees =  $request->get('fees');
        $merchants->save();
 
        return redirect('/manage_merchants')->with('success', 'Transaction Fee updated.'); // -> resources/views/stocks/index.blade.php
    }

below is my route

Route::patch('update_merchant/{merchant_id}', 'MerchantsController@update')->name('update');

2

Answers


  1. The error "Resource item not found" indicates that the database query in the update() method was not able to find the resource with the specified $merchant_id.
    Check if you have a $merchant_id with that value in your database

    Login or Signup to reply.
  2. Can you first trying this :

     public function update(Request $request, $merchant_id)
    {
        dd($request, $merchant_id);
    
    }
    

    And tell me what you got.
    My first idea is that you got 2 parameters here, but only one in your route.
    I’m not sure that you can retrieve $request and $merchant_id in your function.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search