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 深度学习残差模块模型
  • ¥20 两个不同Subnet的点对点连接
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计
  • ¥23 (标签-bug|关键词-密码错误加密)