php - Property [species_code] does not exist on this collection instance -


i have problem eloquent, trying combine 3 table display data in 1 table on view pages. turns error . please me.

did error on coding or table relation?

models:

treecategory models

namespace app;  use illuminate\database\eloquent\model; use app\treescientific;  class treecategory extends model {  protected $fillable = [      'id',     'code',     'category',  ];  public function scientific() {     return $this->hasmany('app\treescientific','tree_category_id'); } } 

treescientific

namespace app;

use illuminate\database\eloquent\model; use app\treecommon;  class treescientific extends model {   protected $fillable = [      'tree_category_id',     'species_code',     'scientific_name',  ];  public function common() {     return $this->hasone('app\treecommon','scientific_id'); }   } 

treecommons

namespace app;  use illuminate\database\eloquent\model;  class treecommon extends model {   protected $fillable = [      'scientific_id',     'common_name',  ];   } 

blade.php

 <tbody>       @foreach ($category $kategori)       <tr>         <td>{{$loop -> iteration}}</td>         <td>{{$kategori -> code}}</td>         <td>{{$kategori -> scientific -> species_code}}</td>         <td>{{$kategori -> scientific -> scientific_name}}</td>         <td>{{$kategori -> scientific -> common -> common_name}}</td>        @endforeach 

controller

use app\treecategory; use app\treescientific; use app\treecommon;

class pokokcontroller extends controller {     public function pokokindex()     {       $category = treecategory::all();       $scientific = treescientific::all();       $common = treecommon::all();        return view('')->with('category',$category)-         >with('scientific',$scientific)->with('common',$common);     }  } 


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -