簡體   English   中英

在 Laravel 中檢索數據格式

[英]Retrieved data formatting in laravel

我熟悉 CI 和 CakePHP,但在 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] => 
)

而在與其他模型的關系之后,它被絞死了。

它返回Eloquent 集合 這是一個有很多有用的助手可用的對象。 您可以訪問對象的任何部分或在控制器、模型或視圖中迭代對象:

在控制器中:

$obj->id;

在一個觀點:

{{ $obj->name }}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM