在Laravel i 5.2中通过id检索数据时出错

时间:2017-02-04 06:12:24

标签: mysql routes laravel-5.2

我正在尝试从我的数据库中检索数据,显示特定Id的数据。 这是我的数据库结构。enter image description here

这是路线:

Route::get('/terms/(:any)', 'PagesController@terms');

和pagesController

use App\User;
use App\Role;
use App\Permission;
use App\Item;
use App\tbl_question_category;
use App\subject_title;
use Illuminate\Http\Request;
use App\Http\Requests;

class PagesController extends Controller
{


    public function terms($question_category_id)
    {
        return view::make('QuizeBangla.terms')
            ->with('title','Terms & Condition')
            ->with('terms',tbl_question_category::find($question_category_id));
    }
}

型号名称为t tbl_question_category,此处为代码

命名空间App;

使用Illuminate \ Database \ Eloquent \ Model;

class tbl_question_category extends Model
{

    protected $table='tbl_question_category';
    public function UserTest(){
        return $this->belongsTo('App\UserTest');
    }
}

这是我想要显示数据的代码terms.blade.php

@extends('QuizeBangla.layouts.app')


@section('content')


@include('TopMenu')

    <section id="page-breadcrumb">
        <div class="vertical-center sun">
             <div class="container">
                <div class="row">
                    <div class="action">
                        <div class="col-sm-12">
                            <h1 class="title">Terms & Condition</h1>
                            <p></p>
                        </div>                        
                    </div>
                </div>
            </div>
        </div>
   </section>
    <!--/#action-->

    <section id="map-section">
        <div class="container">
            <table class="table">
                <tr class="success">
                    <td><b>Exams</b></td>
                    <td>Total Question</td>
                    <td>Test Duration</td>
                    <td>Toal Marks</td>
                    <td></td>
                    <td>Click Start</td>
                </tr>

                    <tr>
                        <td>{{ $terms->category_title }}  </td>
                        <td>{{ $terms->number_of_questions }}</td>
                        <td>{{ $terms->test_duration }}</td>
                        <td>{{ $terms->toral_marks }}</td>
                        <td></td>
                        <td>Start</td>
                    </tr>

            </table >
            <div id="gmap"></div>
        </div>
    </section> <!--/#map-section-->

@include('footer')

@endsection

输入我的网址以获取ID为6的数据时,http://localhost:8000/terms/6表示找不到网页。找不到我愚蠢的错误在哪里。

0 个答案:

没有答案