【发布时间】:2015-02-12 07:13:49
【问题描述】:
我有一个包含许多方法的模型。
class UserModel extends Eloquent{
private $active;
function __construct() {
$this->active = Config::get('app.ActiveFlag');
}
protected $table = 'User';
protected $fillable = array('usr_ID', 'username');
public function method1(){
//use $active here
}
public function method2(){
//use $active here
}
}
控制器:
$user = new UserModel($inputall);
$user->save();
没有构造函数,它工作正常。但是,使用构造函数它不会保存用户(生成的查询没有任何填充属性或值)。查询如下:
insert into User() values();
请问有什么意见吗?
【问题讨论】:
标签: php laravel constructor eloquent