skip to Main Content

I am tring to access the route on blade template, so I getting the error below:

Route [{$name}] not defined.
Route::patch('/update_merchant/{merchant_id}', 'MerchantsController@update')->name('update');

Blade template

<form name="merchants_data" id="merchants_data" method="post" action="{{route('update_merchant.update', [$item->merchant_id])}}">      
    {{ csrf_field() }}    
    {!! method_field('patch') !!} 

Controller

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::findorfail($merchant_id);
    // Getting values from the blade template form
    $merchants->fees = $request->get('fees');
    $merchants->save();

    return redirect('/manage_merchants')->with('success', 'Transaction Fee updated.'); 
}

3

Answers


  1. It looks like you have changed the name of the route to update…

    you can do one thing is go to the root of the project in your command line.. and look up

    php artisan route:list
    

    This should give you a list of all the routes you currently have in your application …

    Login or Signup to reply.
  2. it seems your route name is "update" but you call "update_merchant.update"

    Login or Signup to reply.
  3. As Mehran said, you named your route ‘update’ and you called ‘update_merchant.update’ in your form. When you use

    ...->name('foo');
    

    That’s the name you have to use in the

    {{ route('foo') }}
    

    You don’t put URL in the ‘route’ asset, just the name.

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