Reputation: 2482
Here is my Routes.php
Route::group(['prefix' => 'api/v1', 'middleware' => 'auth:api'], function () {
Route::post('login', array('UsersController@user_login'));
});
And Here is my UsersController.php
public function user_login()
{
$email_id = Input::get('email_id');
$name = Input::get('name');
$api_token = str_random(50);
DB::table('users')-> insertGetId(array(
'email_id' => $email_id,
'name' => $name,
'api_token' => $api_token
));
$API = DB::table('users')->select('api_token')->
where('email_id' , '=' , $email_id)->get();
return response()->json(['api_token'=> $API]);
}
I am getting
'< Unexpected Error'
when I test my code in Postman. Where am I lacking in my code ?
Any help would be grateful. Thank You.
Upvotes: 0
Views: 1031
Reputation: 731
You're missing a comma:
DB::table('users')-> insertGetId(array(
'email_id' => $email_id,// This comma was missing
'name' => $name,
'api_token' => $api_token
));
Upvotes: 3