I have the following query in laravel 5.1.
$dataName = App\Category::with('categoryLang', 'categoryLang.seo')->find($id);
echo "<pre>"; print_r($dataName); echo "</pre>"; return;
that returns the following object App\Category
App\Category Object
(
[table:protected] => category
[connection:protected] =>
[primaryKey:protected] => id
[perPage:protected] => 15
[incrementing] => 1
[timestamps] => 1
[attributes:protected] => Array
(
[id] => 60
[ordine] => 100
[hot] => 0
[active] => 0
[file] =>
[parent_id] => 0
[sizechart] => 0
[created_at] => 2017-06-06 19:18:49
[updated_at] => 2017-06-06 19:18:49
)
[original:protected] => Array
(
[id] => 60
[ordine] => 100
[hot] => 0
[active] => 0
[file] =>
[parent_id] => 0
[sizechart] => 0
[created_at] => 2017-06-06 19:18:49
[updated_at] => 2017-06-06 19:18:49
)
[relations:protected] => Array
(
[categoryLang] => Illuminate\Database\Eloquent\Collection Object
(
[items:protected] => Array
(
[0] => App\CategoryLng Object
(
[table:protected] => category_lng
[connection:protected] =>
[primaryKey:protected] => id
[perPage:protected] => 15
[incrementing] => 1
[timestamps] => 1
[attributes:protected] => Array
(
[id] => 121
[category] => ciao
[slug] =>
[lang] => it
[category_id] => 60
[created_at] => 2017-06-06 19:18:49
[updated_at] => 2017-06-06 19:18:49
)
[original:protected] => Array
(
[id] => 121
[category] => ciao
[slug] =>
[lang] => it
[category_id] => 60
[created_at] => 2017-06-06 19:18:49
[updated_at] => 2017-06-06 19:18:49
)
[relations:protected] => Array
(
[seo] => App\Seo Object
(
[table:protected] => seo
[connection:protected] =>
[primaryKey:protected] => id
[perPage:protected] => 15
[incrementing] => 1
[timestamps] => 1
[attributes:protected] => Array
(
[id] => 1125
[title] => asdasdasdas
[description] => asdasdasdasd
[keywords] => asdasdasdasd
[seoble_type] => App\CategoryLng
[seoble_id] => 121
[created_at] => 2017-06-06 19:18:57
[updated_at] => 2017-06-06 19:18:57
)
[original:protected] => Array
(
[id] => 1125
[title] => asdasdasdas
[description] => asdasdasdasd
[keywords] => asdasdasdasd
[seoble_type] => App\CategoryLng
[seoble_id] => 121
[created_at] => 2017-06-06 19:18:57
[updated_at] => 2017-06-06 19:18:57
)
[relations:protected] => Array
(
)
[hidden:protected] => Array
(
)
[visible:protected] => Array
(
)
[appends:protected] => Array
(
)
[fillable: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] =>
)
)
[hidden:protected] => Array
(
)
[visible:protected] => Array
(
)
[appends:protected] => Array
(
)
[fillable: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] =>
)
)
)
)
[hidden:protected] => Array
(
)
[visible:protected] => Array
(
)
[appends:protected] => Array
(
)
[fillable: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] =>
)
How can I read the values of the sub-object App\Seo without having to run across the entire object? I'm sure there is another way but I'm a very beginner with laravel.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire