1

i am using laravel 5.5 when i want to hit the route it shows the following error like (Sorry, the page you are looking for could not be found) but i completely fail to understand it it google it several time but not work any body help to solve this thanks in advance.

this is my route

Route::get('order/{$id}', 'front\FrontController@order');
Route::get('booking/{$id}', 'front\FrontController@booking');

this is my controller

public function index(){
        $categorys = DB::table('categories')->where('cate_status', '=', 'enable')->get();
        $rooms = DB::table('rooms')->where('status', '=', 'Enable')->get();
        return view('welcome', compact('categorys','rooms'));
    }


public function order($id){
            echo $id;
        }

    public function booking($id){
        echo $id;
    }

this is my views

@foreach($categorys as $category)
                    <div class="col-md-4 col-sm-6 col-xs-12">
                        <div class="hover-content">
                            <a href="{{url('order/'.$category->id)}}">
                            <img src="{{asset('assets/site')}}/images/menu/thumb/{{$category->cate_img}}" alt="chinese" class="img-responsive animation">
                            <div class="overlay animation">
                                <h4 class="text-uppercase">{{$category->cate_name}}</h4>
                            </div>
                            </a>
                        </div>
                    </div>
                    @endforeach
Shahid Hussain
  • 157
  • 1
  • 1
  • 8

3 Answers3

1

Remove the dollar sign from your routes and it should work.

Route::get('order/{id}', 'front\FrontController@order');
Route::get('booking/{id}', 'front\FrontController@booking');

You should also name your routes for easier maintenance and changes in the future.

Route::name('foobar')->get('url/{slug}/{date}', 'foo@BarController@foobar');

Usage:

route('foobar', ['slug' => 'stackoverflow', 'date' => '2018'])

If you later change the route to ->get('url/{date}/{slug}'), the same route call will work.

Marwelln
  • 28,492
  • 21
  • 93
  • 117
0

try to use route() something like this Change.

<a href="{{url('order/'.$category->id)}}">

With

<a href="{{ route('order.get',$category->id) }}">

And change

Route::get('order/{$id}', 'front\FrontController@order');

With

Route::get('order/{$id}', 'front\FrontController@order')->name('order.get');

Make sure given controller path should be correct.

Rahul
  • 1,617
  • 1
  • 9
  • 18
0

Regard to your error message you are calling wrong url for calling route. Update your routes:

Route::name('order.show')->get('order/{$id}', 'front\FrontController@order');
Route::name('booking.show')->get('booking/{$id}', 'front\FrontController@booking');

Then on your blade try to use named route:

@foreach($categorys as $category)
    <div class="col-md-4 col-sm-6 col-xs-12">
        <div class="hover-content">
            <a href="{{route('order.show', $category)}}">
                <img src="{{asset('assets/site')}}/images/menu/thumb/{{$category->cate_img}}" alt="chinese" class="img-responsive animation">
                <div class="overlay animation">
                    <h4 class="text-uppercase">{{$category->cate_name}}</h4>
                </div>
            </a>
         </div>
     </div>
     @endforeach

Your html should be change, it's not good to use div in a.

train_fox
  • 1,517
  • 1
  • 12
  • 31