2016-03-12 29 views
0

我是laravel中的新成員。我熟悉CI和CakePHP,但在laravel中是新的。在網上閱讀了laravel之後,我安裝了laravel並從數據庫中檢索數據,但是我不明白檢索到的對象,這是什麼。請幫我理解它。檢索到的數據在laravel中格式化

App\Models\Question Object 
(
    [primaryKey:protected] => id 
    [fillable:protected] => Array 
     (
      [0] => name 
      [1] => email 
      [2] => password 
     ) 

    [hidden:protected] => Array 
     (
      [0] => password 
      [1] => remember_token 
     ) 

    [connection:protected] => 
    [table:protected] => 
    [perPage:protected] => 15 
    [incrementing] => 1 
    [timestamps] => 1 
    [attributes:protected] => Array 
     (
      [id] => 1 
      [t_num] => aP5z78e 
      [university] => 5 
      [course] => 1 
      [branch] => 0 
      [subject] => 6 
      [type] => 1 
      [year] => 2007,2011 
      [session] => 
      [question] => State and explain Thevenin's therom with example. 
      [paper_code] => 
      [marks] => 
      [slug] => state-and-explain-thevenins-therom-with-example 
      [additional_info] => 
      [option_1] => 
      [option_2] => 
      [option_3] => 
      [option_4] => 
      [answer] => 
      [status] => 1 
      [user_id] => 1 
      [created] => 1439622767 
      [modified] => 1439622767 
     ) 

    [original:protected] => Array 
     (
      [id] => 1 
      [t_num] => aP5z78e 
      [university] => 5 
      [course] => 1 
      [branch] => 0 
      [subject] => 6 
      [type] => 1 
      [year] => 2007,2011 
      [session] => 
      [question] => State and explain 
      [paper_code] => 
      [marks] => 
      [slug] => state-and-explain 
      [additional_info] => 
      [option_1] => 
      [option_2] => 
      [option_3] => 
      [option_4] => 
      [answer] => 
      [status] => 1 
      [user_id] => 1 
      [created] => 1439622767 
      [modified] => 1439622767 
     ) 

    [relations:protected] => Array 
     (
     ) 

    [visible:protected] => Array 
     (
     ) 

    [appends:protected] => Array 
     (
     ) 

    [guarded:protected] => Array 
     (
      [0] => * 
     ) 

    [dates:protected] => Array 
     (
     ) 

    [dateFormat:protected] => 
    [casts:protected] => Array 
     (
     ) 

    [touches:protected] => Array 
     (
     ) 

    [observables:protected] => Array 
     (
     ) 

    [with:protected] => Array 
     (
     ) 

    [morphClass:protected] => 
    [exists] => 1 
    [wasRecentlyCreated] => 
) 

,並與其他機型的關係後,其絞刑。

回答

0

它返回Eloquent collection。這是一個有很多有用的助手可用的對象。可以訪問該對象的任何部分或迭代在控制器模型中的對象或一個觀點:

在控制器:

$obj->id; 

在視圖中:

{{ $obj->name }}