7

モデルの 1 つから取得したオブジェクトから値を取得しようとしています。テーブルの内容に対応していないため、必要ではない属性のみが返されます。 元の配列にアクセスしたい。

やった:

$entries = Model::where('A', $A)->where('B', $B)->get();

@Foreach ($entries as $entry) 

$entry->id
$entry->name

@Endforeach

追加しようとしまし->originalたが、どちらも機能しません。

これは私の最初のエントリの一部ですvar_dump($entries)

(
    [items:protected] => Array
        (
            [0] => App\Models\TableA Object
                (
                    [table:protected] => Table A
                    [primaryKey] => id
                    [connection:protected] => 
                    [perPage:protected] => 15
                    [incrementing] => 1
                    [timestamps] => 1
                    [attributes:protected] => Array
                        (
                            [id] => 1
                            [name] => 2

                        )

                    [original:protected] => Array
                        (
                            [id] => 1
                            [name] => 1

                        )
4

2 に答える 2