2015-06-21 86 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