Route resource not defined laravel 5.3

Question

I'm trying to insert data in laravel 5.3, I'm new to Laravel and I'm trying to use the resource routing system. When I load my page I get -

InvalidArgumentException in UrlGenerator.php line 314:
Route [/admin/register-account.store] not defined.

Routes

Route::group(['middleware' => 'auth'], function() {
   //Applicaion home
   Route::get('/home', 'HomeController@index');

   //Admin routes
   Route::get('/admin/home', 'AdminController@index');

   //Register Account Routes
   Route::resource('/admin/register-account', 'RegAccController');

});

Form

<form action="{{ route('/admin/register-account.store') }}" type="post">
        <input type="text" placeholder="Account name" name="acc_name" />
        <input type="text" placeholder="Account location" name="acc_location" />
        <input type="text" placeholder="Account website" name="acc_website" />

        <input type="hidden" name="_token" value="{{ csrf_token() }}" />
        <button type="submit" class="primary-btn">Register Account</button>
</form>

Controller

public function store(Request $request)
{
  $this->validate($request, [
     'acc_name' => 'required',
     'acc_location' => 'required',
     'acc_website' => 'required',
  ]);

  $regAcc = new Account;
  $regAcc->name = $request->name;
  $regAcc->website = $request->acc_location;
  $regAcc->location = $request->acc_website;
  $regAcc->save();

  return view('admin.reg-acc');
}

I believe my issue is where I define the form action name however I've tried a number of combinations and I can't seem to get another error.


Show source
| laravel   | php   | laravel-5.3   2017-01-07 20:01 1 Answers

Answers to Route resource not defined laravel 5.3 ( 1 )

  1. 2017-01-07 20:01

    When you're using route() helper, you should use name of the resource route, not path.

    The route() function generates a URL for the given named route

    For example:

    {{ route('register-account.store') }}
    

    You can see actual routes names with executing this command (see Name column):

    php artisan route:list
    

Leave a reply to - Route resource not defined laravel 5.3

◀ Go back