如何解决抱歉,找不到您要查找的页面

时间:2018-05-26 07:00:43

标签: php laravel

我正在使用laravel 5.5,当我想要点击它显示以下错误的路线时(对不起,找不到您正在寻找的页面)但我完全不理解它谷歌它好几次但不工作任何机构都有助于提前解决这个问题。

这是我的路线

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

这是我的控制器

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;
    }

这是我的观点

@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

3 个答案:

答案 0 :(得分:1)

从您的路线中删除美元符号,它应该有效。

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

您还应该为路线命名,以便日后更容易维护和更改。

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

用法:

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

如果您稍后将路线更改为->get('url/{date}/{slug}'),则相同的route电话将有效。

答案 1 :(得分:0)

尝试使用route()之类的东西 变化

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

使用

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

并改变

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

使用

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

确保给定的控制器路径正确。

答案 2 :(得分:0)

关于您的错误消息,您正在调用错误的URL来调用路由。更新您的路线:

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

然后在您的刀片上尝试使用命名路由:

@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
  

你的html应该改变,在a。中使用div是不好的。