久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<small id='YbqnQ'></small><noframes id='YbqnQ'>

      <i id='YbqnQ'><tr id='YbqnQ'><dt id='YbqnQ'><q id='YbqnQ'><span id='YbqnQ'><b id='YbqnQ'><form id='YbqnQ'><ins id='YbqnQ'></ins><ul id='YbqnQ'></ul><sub id='YbqnQ'></sub></form><legend id='YbqnQ'></legend><bdo id='YbqnQ'><pre id='YbqnQ'><center id='YbqnQ'></center></pre></bdo></b><th id='YbqnQ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='YbqnQ'><tfoot id='YbqnQ'></tfoot><dl id='YbqnQ'><fieldset id='YbqnQ'></fieldset></dl></div>
          <bdo id='YbqnQ'></bdo><ul id='YbqnQ'></ul>

      1. <tfoot id='YbqnQ'></tfoot>
        <legend id='YbqnQ'><style id='YbqnQ'><dir id='YbqnQ'><q id='YbqnQ'></q></dir></style></legend>

      2. 此集合實例上不存在屬性 [名稱]

        Property [name] does not exist on this collection instance(此集合實例上不存在屬性 [名稱])

              • <bdo id='1Yii7'></bdo><ul id='1Yii7'></ul>

                <legend id='1Yii7'><style id='1Yii7'><dir id='1Yii7'><q id='1Yii7'></q></dir></style></legend>
                <i id='1Yii7'><tr id='1Yii7'><dt id='1Yii7'><q id='1Yii7'><span id='1Yii7'><b id='1Yii7'><form id='1Yii7'><ins id='1Yii7'></ins><ul id='1Yii7'></ul><sub id='1Yii7'></sub></form><legend id='1Yii7'></legend><bdo id='1Yii7'><pre id='1Yii7'><center id='1Yii7'></center></pre></bdo></b><th id='1Yii7'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='1Yii7'><tfoot id='1Yii7'></tfoot><dl id='1Yii7'><fieldset id='1Yii7'></fieldset></dl></div>

                • <small id='1Yii7'></small><noframes id='1Yii7'>

                    <tbody id='1Yii7'></tbody>
                  <tfoot id='1Yii7'></tfoot>
                • 本文介紹了此集合實例上不存在屬性 [名稱]的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我在數據庫中有 3 個表(用戶、區域、區域用戶),

                  用戶表:ID名稱用戶名密碼

                  區域表:ID姓名

                  area_user 表:ID用戶身份area_id

                  我正在嘗試創建一個(列出用戶頁面),它將顯示所有用戶表列以及用戶分配的區域.

                  User.php 模型文件

                   belongsToMany('AppArea','area_user');}

                  Area.php 模型文件:

                  belongsToMany('AppUser','area_user','area_id','user_id');}}

                  UserController@index 文件:

                  middleware('auth');}/*** 顯示資源列表.** @return IlluminateHttpResponse*/公共函數索引(){$users = User::get();return view('users._list',['用戶'=>$用戶]);}

                  最后是表格視圖文件:-

                  @foreach($users as $u)<tr role="row" class="odd"><td class="sorting_1">{{$u->name}}</td><td></td><td>{{$u->areas]}}</td><td>{{route('show_user', ['id' => $u->id])}}</td></tr></tbody>@endforeach

                  如果我只使用區域屬性 ($u->areas) 在用戶表視圖(指定區域)中輸入,它將顯示所有區域列:-

                  <預><代碼>[{身份證":3,"name": "C",location_id":1,created_at":空,updated_at":空,樞軸":{"user_id": 4,area_id":3}},{身份證":4,"name": "D",location_id":2,created_at":空,updated_at":空,樞軸":{"user_id": 4,area_id":4}}]

                  <小時>

                   @foreach($users as $u)<tr role="row" class="odd"><td class="sorting_1">{{$u->name}}</td><td></td><td>{{$u->areas->name]}}</td><td>{{route('show_user', ['id' => $u->id])}}</td></tr></tbody>@endforeach

                  請注意,如果我在上面的視圖 ($u->areas->name) 中指定區域關系中的列名,則顯示錯誤:-

                  此集合實例上不存在屬性 [名稱].(查看:C:xampphtdocs

                  如何在視圖文件中只顯示(areas.name)列

                  解決方案

                  因為 areas 是一個集合,所以你應該像這樣循環:

                  @foreach($users as $u)<tr role="row" class="odd"><td class="sorting_1">{{$u->name}}</td><td></td><td>@foreach($u->areas as $area){{$area->name}},@endforeach</td><td>{{route('show_user', ['id' => $u->id])}}</td></tr></tbody>@endforeach

                  如果你想用逗號分隔它們,你可以這樣做而無需循環:

                   @foreach($users as $u)<tr role="row" class="odd"><td class="sorting_1">{{$u->name}}</td><td></td><td>{{ $u->areas->pluck('name')->implode(', ') }}</td><td>{{route('show_user', ['id' => $u->id])}}</td></tr></tbody>@endforeach

                  I have 3 tables in DB (users , areas , area_user),

                  Users table: id name username password

                  areas table: id name

                  area_user table: id user_id area_id

                  I am trying to create a (List users page) which will show all user table column with user assigned areas.

                  User.php Model file

                    <?php
                  
                  namespace App;
                  
                  use IlluminateNotificationsNotifiable;
                  use IlluminateFoundationAuthUser as Authenticatable;
                  
                  class User extends Authenticatable{
                      use Notifiable;
                  
                      /**
                       * The attributes that are mass assignable.
                       *
                       * @var array
                       */
                      protected $fillable = ['name', 'email', 'password','role_id',];
                  
                      /**
                       * The attributes that should be hidden for arrays.
                       *
                       * @var array
                       */
                      protected $hidden = ['password', 'remember_token',];
                  
                      public function areas(){
                          return $this->belongsToMany('AppArea','area_user');
                      }
                  

                  Area.php Model file:

                  <?php
                  
                  namespace App;
                  
                  use IlluminateDatabaseEloquentModel;
                  
                  class Area extends Model{
                      protected $fillable = ['name'];
                  
                      public function users(){
                          return $this->belongsToMany('AppUser','area_user','area_id','user_id');
                      }
                  }
                  

                  UserController@index file :

                  <?php
                  
                  namespace AppHttpControllers;
                  
                  use AppAreas;
                  use AppRoles;
                  use AppUser;
                  use IlluminateHttpRequest;
                  
                  class UserController extends Controller{
                  
                      public function __construct(){
                          // $this->middleware('auth');
                      }
                  
                      /**
                       * Display a listing of the resource.
                       *
                       * @return IlluminateHttpResponse
                       */
                      public function index(){
                          $users = User::get();
                          return view('users._list',
                          ['users'=> $users]
                      );
                      }
                  

                  Finally the table view file:-

                  @foreach($users as $u)
                              <tr role="row" class="odd">
                                  <td class="sorting_1">{{$u->name}}</td>
                                  <td></td>
                                  <td>{{$u->areas]}}</td>
                                  <td>{{route('show_user', ['id' => $u->id])}}</td>
                              </tr></tbody>
                  @endforeach
                  

                  If i typed in user table view (assigned areas) with only using the areas property ($u->areas), it will show all the areas column:-

                  [
                    {
                      "id": 3,
                      "name": "C",
                      "location_id": 1,
                      "created_at": null,
                      "updated_at": null,
                      "pivot": {
                        "user_id": 4,
                        "area_id": 3
                      }
                    },
                    {
                      "id": 4,
                      "name": "D",
                      "location_id": 2,
                      "created_at": null,
                      "updated_at": null,
                      "pivot": {
                        "user_id": 4,
                        "area_id": 4
                      }
                    }
                  ]
                  


                   @foreach($users as $u)
                                  <tr role="row" class="odd">
                                      <td class="sorting_1">{{$u->name}}</td>
                                      <td></td>
                                      <td>{{$u->areas->name]}}</td>
                                      <td>{{route('show_user', ['id' => $u->id])}}</td>
                                  </tr></tbody>
                      @endforeach
                  

                  Notice that if i specify the column name in Areas relationship in the above view ($u->areas->name) , error showing:-

                  Property [name] does not exist on this collection instance. (View: C:xampphtdocs

                  How can i show only the (areas.name) column in view file

                  解決方案

                  Because the areas is a collection so you should loop over it like this :

                  @foreach($users as $u)
                      <tr role="row" class="odd">
                          <td class="sorting_1">{{$u->name}}</td>
                          <td></td>
                          <td>
                          @foreach($u->areas as $area)
                              {{$area->name}}, 
                          @endforeach
                          </td>
                          <td>{{route('show_user', ['id' => $u->id])}}</td>
                      </tr></tbody>
                  @endforeach
                  

                  And if you want to separate them whith comma for example you can do it like that without looping :

                      @foreach($users as $u)
                      <tr role="row" class="odd">
                          <td class="sorting_1">{{$u->name}}</td>
                          <td></td>
                          <td>
                              {{ $u->areas->pluck('name')->implode(', ') }}
                          </td>
                          <td>{{route('show_user', ['id' => $u->id])}}</td>
                      </tr></tbody>
                  @endforeach
                  

                  這篇關于此集合實例上不存在屬性 [名稱]的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環)
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數)
                  Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結果填充變量)
                  MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“localhost的訪問被拒絕)

                    <legend id='4pv63'><style id='4pv63'><dir id='4pv63'><q id='4pv63'></q></dir></style></legend>
                        • <bdo id='4pv63'></bdo><ul id='4pv63'></ul>
                        • <i id='4pv63'><tr id='4pv63'><dt id='4pv63'><q id='4pv63'><span id='4pv63'><b id='4pv63'><form id='4pv63'><ins id='4pv63'></ins><ul id='4pv63'></ul><sub id='4pv63'></sub></form><legend id='4pv63'></legend><bdo id='4pv63'><pre id='4pv63'><center id='4pv63'></center></pre></bdo></b><th id='4pv63'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='4pv63'><tfoot id='4pv63'></tfoot><dl id='4pv63'><fieldset id='4pv63'></fieldset></dl></div>
                            <tbody id='4pv63'></tbody>

                            <small id='4pv63'></small><noframes id='4pv63'>

                            <tfoot id='4pv63'></tfoot>

                            主站蜘蛛池模板: 日韩欧美中文在线 | 久久久久亚洲精品 | 国产高清精品一区二区三区 | 91福利网址 | 日本高清中文字幕 | av一级久久 | 亚洲国产精品成人综合久久久 | 日日日日日日bbbbb视频 | 国产视频综合 | 99精品热视频 | 91在线观看视频 | 亚洲男人的天堂网站 | 二区在线观看 | 国产免费让你躁在线视频 | 在线视频 亚洲 | 波多野吉衣久久 | 亚洲精品专区 | 久久国产区 | 亚洲综合在线播放 | 亚洲精品久久久久久久久久久 | 成人av网站在线观看 | 波多野结衣一区二区 | 国产精品成人一区二区三区夜夜夜 | 国产在线看片 | 亚洲三区在线观看 | 日韩欧美在线观看视频 | 黄色一级大片在线免费看产 | 国产视频中文字幕 | av国产精品 | 亚洲高清一区二区三区 | 成人综合久久 | 成人一区av | av片在线观看 | 亚洲精品久久久久avwww潮水 | 欧美a级成人淫片免费看 | 久久骚| 久久99精品久久久久子伦 | 日韩视频一级 | 成人在线视频观看 | 日韩成人在线网址 | 精品国产一区二区三区性色av |