Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

graffislife's avatar

Route [inventory.orderShirt] not defined.

I am making a page where there are 3 tables. Inventory, Rate, and Order. Inventory and Rate alone is working. but adding the order gives me that error.

shows.blade

//rating
 {!! Form::open(array('route' => array('inventory.showRate', $inventories->id), 'method'=>'POST')) !!}
                        
{{Form::label('rating','Rating')}}
{{Form::select('rating', ['1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5'], '3', ['placeholder' => 'Select rating'])}}
{{Form::submit('Submit', ['class'=>'btn btn-primary'])}} //inventory

ID {$inventories->id}} Name {{$inventories->name}}

//order {!! Form::open(array('route' => array('inventory.orderShirt', $inventories->id), 'method'=>'POST')) !!}

{{Form::submit('Submit', ['class'=>'btn btn-primary'])}}

{!! Form::close()!!}

controller.php

    public function shows($id)
    {
        $inventories =  Inventory::find($id);                
        return view('inventory.show')->with('inventories', $inventories);

        
    }
    public function showRate(Request $request, $id)
    {   
        $inventories =  Inventory::find($id); 
        //create rating
        $ratings = new Rating;
        $ratings->rating = $request->input('rating');
        $ratings->inv_id = $inventories->id;
        $ratings->user_id = auth()->user()->id;
        $ratings->save();

        return redirect('/store')->with('success','Rating updated');
    }
    public function orderShirt(Request $request, $id)
    {
        $inventories =  Inventory::find($id);  
        //create order
        $orders = new Order;
        $orders->order_id = Str::random(20);
        $orders->inv_order_id = $inventories->id;
        $orders->user_order_id = auth()->user()->id;
        $orders->save();

        return redirect('/store')->with('success','Order complete!');

        // ->with('success','order added');

    }

web.php

Route::post('/store/{id}','InventoryController@orderShirt')->name('inventory.orderShirt'); 
Route::post('/store/{id}','InventoryController@showRate')->name('inventory.showRate'); 
Route::get('store/{id}', 'InventoryController@shows')->name('inventory.shows');

I hope you could help me! Thank you in advance :) P.S. I am using laravel collective

0 likes
16 replies
rin4ik's avatar

please make a search this inventory.order in your text editor you have defined it somewhere. and try to hard refresh the browser (ctrl+f5)

graffislife's avatar

I already did both. I has in the web.php and shows.blade

rin4ik's avatar

@graffislife run php artisan route:list and make sure you have that route inventory.orderShirt

graffislife's avatar

Ohh. it's not showing up. But I did it correctly, did I?

36864's avatar

Did you cache your routes at any point? Try clearing the route cache with php artisan route:clear.

rin4ik's avatar

@graffislife can you please for a moment remove this route

Route::post('/store/{id}','InventoryController@showRate')->name('inventory.showRate'); 

and try to run php artisan route:list again. if it's the case change this route path /store/{id} it's the same for two different routes (and route action Post in both routes) that's way laravel gets 2 one

36864's avatar

I completely missed that.

You can't have two routes on the same url. How would you expect laravel to know which route to use when you hit either of those urls?

rin4ik's avatar
rin4ik
Best Answer
Level 50

@graffislife change this route path /store/{id} it's the same for two different routes (and route action Post in both routes) that's way laravel gets 2 one

rin4ik's avatar

@graffislife this route is for updating ratings I think it should be put or patch instead of post

Route::put('/store/{id}','InventoryController@showRate')->name('inventory.showRate'); 
graffislife's avatar

Is there a way that I can do rate and order in one page? Because that's what I am planning to do

Please or to participate in this conversation.