Home  >  Article  >  php教程  >  orm获取关联表里的属性值,orm表里属性值

orm获取关联表里的属性值,orm表里属性值

WBOY
WBOYOriginal
2016-06-13 08:41:431059browse

orm获取关联表里的属性值,orm表里属性值

ORM——关系对象模型

laravel中的Eloquent ORM用于和数据表互动,其中每个数据库表会和一个对应的「模型」互动,想要了解请查看官方文档或自行百度。获取关联表里的属性值代码如下:

    /**
     * [getContactAttribute 获取卖家联系人]
     */
    public function getContactAttribute()
    {
        return $this->hasOne('App\Http\Models\Supplier', 'SupplierId', 'SupplierId')->first()->contact;
    }

  

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn