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

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

WBOY
Release: 2016-06-13 08:41:43
Original
1142 people have browsed it

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

ORM——关系对象模型

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

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

  

Related labels:
orm
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template