Missing required parameters for route issue in laravel

10,326

As you are using dot (.) operator in your resource route it will generating nested routes.

You need to change your route name with single name like cms-home or cms_home

Then you can simple use it as:

Route::resource('cms_home','CmsHomeController');

In your blade you can call it:

<a href="{{ route('cms-home.create') }}" class="nav-link">

Please have look at this referance

Share:
10,326
Volka Dimitrev
Author by

Volka Dimitrev

World around me changing rapidly and I'm always in a learning curve . And I love to be there.

Updated on June 05, 2022

Comments

  • Volka Dimitrev
    Volka Dimitrev almost 2 years

    In my laravel based application I have following link in my admin.blade.php

    <ul class="nav nav-treeview">
      <li class="nav-item">
        <a href="{{ route('cms.home.create') }}" class="nav-link">
          <i class="far fa-circle nav-icon"></i>
          <p>{{ __('Home Page') }}</p>
        </a>
      </li>
    </ul>
    

    In my project I have another blade called, create.blade.php which is in the following path

    views/cms/home/create.blade.php
    

    I have a controller called, CmsHomeController.php for that blade

    In CmsHomeController I have a method called create

    public function create()
    {            
        return view('cms.home.create'); 
    }
    

    Once the user clicks on the above mentioned link in the admin.blade.php, user should go to the create.blade.php blade.

    And in my web.php I have registered my route as follows,

    Route::resource('cms.home','CmsHomeController');
    

    But now the issue is,

    When I click on that link in admin blade, I'm getting an error saying

    Facade\Ignition\Exceptions\ViewException
    Missing required parameters for [Route: cms.home.create] [URI: cms/{cm}/home/create]. (View: C:\xampp\htdocs\mylaravelproject\resources\views\layouts\admin.blade.php) 
    

    In create.blade.php , I'm having just a simple form

    Where am I doing wrong and what would be the correct fix?

    UPDATE:

    I tried running

    php artisan route:list
    

    This is what I got

    enter image description here

    I don't have such a param called, 'cm'..

    • Dipak Mewada
      Dipak Mewada about 4 years
      You can check your route name with this command php artisan route:list and check name against the route.
    • Dipak Mewada
      Dipak Mewada about 4 years
      have a look at my answer i have just posted below!!
  • Volka Dimitrev
    Volka Dimitrev about 4 years
    But i'm not passing any params to my method and what is this 'cm'?
  • Arnaud
    Arnaud about 4 years
    I don't know your entire application, i just read the error message Missing required parameters for [Route: cms.home.create] [URI: cms/{cm}/home/create]
  • Volka Dimitrev
    Volka Dimitrev about 4 years
    Well, I don't really have a param or a variable called 'cm'
  • Volka Dimitrev
    Volka Dimitrev about 4 years
    yes that seem to be the issue, changed my route to this, Route::get('/cms/home/create', 'CmsHomeController@index')->name('cms-home.create'); and it's working now. thanks for the guidance
  • Dipak Mewada
    Dipak Mewada about 4 years
    @VolkaDimitrev Great!! Glad to help you on your concern.