h"/> h">

Home >Backend Development >PHP Tutorial >orm gets the attribute value in the association table Wang Yin World Programming Language Ranking dos.ormitdos

orm gets the attribute value in the association table Wang Yin World Programming Language Ranking dos.ormitdos

WBOY
WBOYOriginal
2016-07-29 08:53:241674browse

ORM - Relational Object Model

The Eloquent ORM in laravel is used to interact with data tables. Each database table will interact with a corresponding "model". If you want to know more, please check the official documentation or Baidu. The code to obtain the attribute value in the association table is as follows:

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

The above introduces ORM to obtain attribute values ​​​​in the association table, including ORM content. I hope it will be helpful to friends who are interested in PHP tutorials.

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