0

I still can't understand why I can't point my blade to the custom function I made in my controller. I create a route like this,

Route::get('/orders/storeInitialItems', 'OrdersController@storeInitialItems')->name('orders.storeInitialItems');

and in my controller I have this,

public function storeInitialItems()
{
    return view('orders.storeInitialItems');
}

but when I run the page, storeInitialItems.blade.php, the error seems calling the show() function of my controller.

enter image description here

Why is that happening?

update

Complete routes for ORDERS

Route::get('/orders','OrdersController@index')->name('orders.index');
Route::get('/orders/create', 'OrdersController@create')->name('orders.create');
Route::post('/orders', 'OrdersController@store')->name('orders.store');
Route::get('/orders/{order}/edit', 'OrdersController@edit')->name('orders.edit');
Route::post('/orders/{order}', 'OrdersController@update')->name('orders.update');
Route::delete('/orders/{order}', 'OrdersController@destroy')->name('orders.delete');

Route::resource('orders', 'OrdersController');

Route::put('orders/{order}/pub', 'OrdersController@publish')->name('orders.publish');
Route::put('orders/{order}/cancel', 'OrdersController@cancel')->name('orders.cancel');
Route::put('orders/{order}/delivered', 'OrdersController@delivered')->name('orders.delivered');

Route::get('/orders/storeInitialItems', 'OrdersController@storeInitialItems')->name('orders.storeInitialItems');
Route::get('/orders/{order}/delivery', 'OrdersController@viewdeliveryItems')->name('orders.delivery');
Route::get('/orders/acceptDelivery', 'OrdersController@acceptDelivery')->name('orders.acceptDelivery');
sanyassh
  • 8,100
  • 13
  • 36
  • 70
SleepWalker
  • 613
  • 1
  • 12
  • 39
  • Maybe there is a confusion in yours routes probably due to your path `'/orders/...'`. https://stackoverflow.com/questions/42552728/laravel-routes-going-to-wrong-route Look at this, or show us all of yours routes maybe we can see the problem ! Have a nice day :) – baddeveloper Apr 02 '19 at 06:07
  • 1
    [Try to put yours customs route before your ressource](https://stackoverflow.com/questions/16661292/add-new-methods-to-a-resource-controller-in-laravel) – baddeveloper Apr 02 '19 at 06:15
  • ahhh i see... putting the storeInitialItems before Route::resource('orders', 'OrdersController'); works – SleepWalker Apr 02 '19 at 06:18
  • thanks @dbkable! but I have t give the "check" to @Md.Sukel Ali's answer – SleepWalker Apr 02 '19 at 06:19

1 Answers1

1

Add your orders.storeInitialItems route

Route::get('/orders/storeInitialItems', 'OrdersController@storeInitialItems')->name('orders.storeInitialItems');

before,

Route::resource('orders', 'OrdersController');

or add some extra path with your storeInitialItems

Route::get('/orders/storeInitialItems/add-some-extra-path', 'OrdersController@storeInitialItems')->name('orders.storeInitialItems');
Md.Sukel Ali
  • 2,987
  • 5
  • 22
  • 34