Home >Backend Development >PHP Tutorial >orm gets the attribute value in the association table, the attribute value in the orm table_PHP tutorial

orm gets the attribute value in the association table, the attribute value in the orm table_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:54:17811browse

orm gets the attribute value in the association table, the attribute value in the orm table

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;
    }

 

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1121221.htmlTechArticleorm gets the attribute value in the association table, the attribute value in the orm table ORM relational object model Eloquent ORM in laravel is used For interacting with data tables, each database table will be associated with a corresponding "model...
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