douqiang4501 2017-06-19 04:32
浏览 73
已采纳

Laravel 5 Route错误无法正常工作

I`m new to the laravel 5.4.what i want to do is when i press the See Here green color button,All the details need to be shown in new view called seedetails.blade.php according to relevant Trainee_ID.for an example if i press MOB/TR 1741 See details button all the data in the database need to shown only according to that ID. see the interface .

enter image description here

relevant view for that view.

 <table class="table table-striped">
                  <thead>
                    <th>Trainee ID</th>
                    <th>Name with Initials</th>
                    <th>Working Division</th>
                    <th>Starting Date</th>
                    <th>Ending Date</th>
                    <th>See All the Details<</th>
                  </thead>
                  <tbody>
                    @foreach($items as $item)
                     <tr>
                  <td>{{ $item->trainee_id }}</td>
                  <td>{{ $item->name_with_initials }}</td>
                  <td>{{ $item->trainee_division }}</td>
                  <td>{{ $item->start_date }}</td>
                  <td>{{ $item->end_date }}</td>
                   <td>
                   <a  class="btn btn-success" href="Seedetails/{{ $item->traninee_id }}">See Here</a>
                 </td>
              </tr>
                    @endforeach
                  </tbody>
          </table>

Here is the necessary controller for retrive data according to trainee_id

public function user_details($traninee_id)
{
    $trainee_details= registerdetails::where('id','=',$traninee_id)->get()->first();
     return view('registeredusers.seedetails', compact('trainee_details'));
}

Here is the seedetails.blade.php which should retrieve the data and shown.which is linked to above view`s see button ,see the code.

`<div class="panel panel-default">
            <div class="panel-body">
             <div class="col-md-6 col-md-offset-3">
             <table class="table table-bordered">

              <tbody>
                  <tr>
                    <td>Full Name</td>
                    <td>{{ $item->full_name }}</td>
                  </tr>

                  <tr>
                    <td>Nic No</td>
                    <td>{{ $item->nic_no }}</td>
                  </tr>

                  <tr>
                    <td>Date Of Birth</td>
                    <td>{{ $item->date_of_birth }}</td>
                  </tr>
              </tbody>
             </table> 
             </div>
             </div>
             </div>
</div>

Here is the Route for that view

Route::get('Seedetails/{id}', 'UserRegisterController@user_details');

Then this is the error now um getting when i press the See details button.

enter image description here

  • 写回答

3条回答 默认 最新

  • dream_high1026 2017-06-19 04:51
    关注

    you are making a big mistake, try to pass the name of the column you have in the database to the route, so that you dont make a mistake, anyways try this in the html

    <td>
    <a class="btn btn-success" href="Seedetails/{{ $item->trainee_id }}">See Here</a>
    </td>
    

    and if possible rename your route to

    Route::get('Seedetails/{trainee_id?}', 'UserRegisterController@user_details')->where('trainee_id', '(.*)');;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私