user267019
user267019

Reputation: 109

Laravel 5.1 resource route does not work properly

// routes.php
Route::resource('/image', 'ImageController');
Route::get('/create', 'ImageController@create');
Route::post('/store', 'ImageController@store');

// create.blade.php
{!! Form::open(array('url' => '/store', 'method'=>'POST')) !!}
    .......
{!! Form::close() !!}

Here if i don't write these two lines (Route::get('/create', 'ImageController@create'); Route::post('/store', 'ImageController@store');) The resource routing of create and store does not work and show some errors. Why this happens? Thanks in advance.

Upvotes: 0

Views: 881

Answers (1)

pinkal vansia
pinkal vansia

Reputation: 10330

When creating resource route you don't have to create individual routes. Because all RESTfull default routes will be created for you automatically.

You just need following route

Route::resource('image', 'ImageController');

then change form as below

{!! Form::open(array('route' => array('image.store'))) !!}
    .......
{!! Form::close() !!}

Read More

Upvotes: 3

Related Questions