在一些基于laravel的包中,存在对未声明的属性的引用,但是该模型的表列的名称。laravel:在未声明的情况下访问属性
门票表:
id
name
content
和票务型号:
class Ticket extends Model {
//there is no "protected $content;" defined inside model
$this->content = foo;
......
}
没有模特属性创建动态基于模型的表列?
是,laravel雄辩的列名映射到模型上的属性。这是ORM(对象关系映射器)的典型行为。请参阅:http://www.webgeekly.com/tutorials/php/the-benefits-of-using-object-relational-mapping-in-php/ – Mysteryos