您好我正在使用laravel版本“Laravel Framework版本5.2.27 “而且我也成功创建了一个迁移表。我想在”用户“表中插入用户
use App\User;
public function insert(){
$insertRecord = User::insert(array($usersDetails));
}
但我正在解决这个问题
The localhost page isn’t working
localhost is currently unable to handle this request.
500
Details
我也在laravel中启用debug =“true”。
但我使用“使用DB;”类插入记录已成功添加。我的错是什么?
我在chrome响应中的firebug错误
Failed to load response data
我的路线文件是
Route::group(['middleware' => ['web']], function () {
});
// Home
Route::get('/', [
'uses' => 'HomeController@index'
]);
Route::get('register', 'RegisterController@getRegister');
Route::post('register', 'RegisterController@postRegister');
user.php的
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $table = 'users';
protected $fillable = ['id', 'gmail',
'name', 'password', 'created_at', 'updated_at',
'remember_token'];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
答案 0 :(得分:0)
您错过了一些代码。
在这段代码中,未设置变量$usersDetails
。它来自哪里?
public function insert(){
$insertRecord = User::insert(array($usersDetails));
}
你认为你的路线中有Route::post('register', 'RegisterController@postRegister');
来处理插入物吗?然而,您的控制器中的方法称为insert
,因此似乎甚至没有调用该方法。你应该在你的路线中调用正确的方法。