php - 如何使用父 $table 属性从父类的子类运行 Eloquent create()?
问题描述
我有以下课程
class Business extends Eloquent {
protected $table = 'business';
protected $fillable = [{stuff}];
}
class Employee extends Business {
protected $table = 'employee';
protected $fillable = [{stuff}];
public function business_create(array $attributes = []) {
parent::create($attributes);
}
}
当我尝试运行 business_create() 时,Eloquent 尝试在“员工”表上创建一条记录。如何在父类上从子类运行创建并使用父属性?
解决方案
推荐阅读
- python - 如何在 python 中的 csv 文件生成的 2D 热图上叠加梯度场?
- python - 并发支付控制
- django - 如何在另一个模板语言中使用 Django 模板语言?
- rust - 如何将 &mut Peekable 更改为 &[u8]?
- c# - 拆分具有文本限定符的多行字符串
- ruby-on-rails - 使用两列的组合上传excel数据?
- tcp - 在使用 FIN 数据包发起终止之后从 TCP 连接接收数据包有多常见?
- reactjs - 如何在 reactjs 的一个组件表中打开模态编辑和 addClient
- php - 如果传递参数,Curl PHP 不会获取数据
- java - 找到4个元素的第i个数字的最小值