📜  null 检查嵌套对象 laravel - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:09.002000             🧑  作者: Mango

代码示例1
object_get($model, 'nested.relation.field')

Example:
$model = Book::with('author.country')->findOrFail($id);
$country_name = array_get($model->toArray(), 'author.country.name');
// or
$country_name = object_get($model, 'author.country.name');