2015-06-21 65 views
0

我已经将我的代码剥离到最低限度,并且仍然想要输入的字段由Eloquent设置为空白。我已经设置了可填写的所有必要字段,并可以更新最初设置为空白的字段。Eloquent创建只插入空白字段

我正在使用Slim框架与雄辩。

帖子:

$app->post('/register', function() use($app){ 
    $request = $app->request; 

$username = $request->post('username'); 
//this if was for validation which I removed for testing 
if(true){ 
    $app->user->where('username', 'B1401812')->update(['username'=> 'FRANK']); 
    $app->user->create(array(
     'username' => 'bob', 
     'password' => 'ptest' 
    )); 
}else{ 
    $app->render('auth/register.php', [ 
     'errors'=> $v->errors(), 
     'request' => $request 
    ]); 

} 

用户模型:

class User extends Eloquent 
{ 
protected $table = 'user_information'; 


protected $fillable = [ 
    'username', 
    'password', 
    'active', 
    'banner_location', 
    'profile_picture_location' 
]; 
public function __construct() 
{ 

} 
...some other functions 

我试着提出解决方案,如禁用,没有运气的质量分配的保护。

+0

你可以编辑你的问题,添加你的整个路线功能? –

+0

当然,我已经加入了其余的。 – Josh

回答

0

我不知道苗条如何利用雄辩,但你可以尝试下面的代码?我不确定$app->user上的实例是指什么。

+0

对不起,只是澄清$ app->用户只是一个函数,它返回一个新的用户,我不认为这是问题,因为它插入行,只是该行的用户名和密码字段设置为空 – Josh