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
Release: 2016-07-12 08:54:17
Original
822 people have browsed it

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;
    }
Copy after login

 

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...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template