I have searched online and no similar situation seems to address my cares. I have written this code to create a form and save to the DB using Laravel 5.1.*. whenever i try loading the page it kept on throwing this error which I'll need a solution to. This is the code for view:
@section('body')
{!! Form::open('action'=>'UsersController@store') !!}
<p>{!! Form::text('name', 'Abraham Adeoya', ['class'=>'css-input', 'placeholder'=>'enter firstname & lastname']) !!}</p>
<p>{!! Form::email('email', 'ken4ward@yahoo.com', ['class'=>'css-input', 'placeholder'=>'example@domain.com']) !!}</p>
<p>{!! Form::text('username', 'ken4ward', ['class'=>'css-input', 'placeholder'=>'enter username']) !!}</p>
<p>{!! Form::password('password', '111111', ['class'=>'css-input', 'placeholder'=>'password']) !!}</p>
<p>{!! Form::password('repeatpassword', 111111, ['class'=>'css-input', 'placeholder'=>'repeat password']) !!}</p>
<p>{!! Form::submit('Create', ['class'=>'css-button']) !!}</p>
{!! Form::close() !!}
@stop
The problems with this code snippet above is that the password fields and the button do accept CSS effects applied, and it throws the the error page.
This is the controller:
class UsersController extends Controller
{
public function index()
{
$users = User::all();
return view('users.index')->with('users', $users);
}
public function create()
{
return view('users.create');
}
public function store(Request $request)
{
$users = new User();
$users->name = $request->name;
$users->email = $request->email;
$users->username = $request->username;
$users->password = $request->password;
$users->updated_at = $request->updated_at;
$users->created_at = $request->created_at;
$users->save();
}
This is the route:
Route::get('users', 'UsersController@index');
Route::get('users/create', 'UsersController@create');
Route::get('users/create', 'UsersController@store');
This is the error message:
QueryException in Connection.php line 651:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null (SQL: insert into `users` (`name`, `email`, `username`, `password`, `updated_at`, `created_at`) values (, , , , , ))
in Connection.php line 651
at Connection->runQueryCallback('insert into `users` (`name`, `email`, `username`, `password`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?)', array(null, null, null, null, null, null), object(Closure)) in Connection.php line 611
at Connection->run('insert into `users` (`name`, `email`, `username`, `password`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?)', array(null, null, null, null, null, null), object(Closure)) in Connection.php line 391
at Connection->statement('insert into `users` (`name`, `email`, `username`, `password`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?)', array(null, null, null, null, null, null)) in Connection.php line 347
at Connection->insert('insert into `users` (`name`, `email`, `username`, `password`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?)', array(null, null, null, null, null, null)) in Processor.php line 32
at Processor->processInsertGetId(object(Builder), 'insert into `users` (`name`, `email`, `username`, `password`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?)', array(null, null, null, null, null, null), 'id') in Builder.php line 1799
at Builder->insertGetId(array('name' => null, 'email' => null, 'username' => null, 'password' => null, 'updated_at' => null, 'created_at' => null), 'id')
at call_user_func_array(array(object(Builder), 'insertGetId'), array(array('name' => null, 'email' => null, 'username' => null, 'password' => null, 'updated_at' => null, 'created_at' => null), 'id')) in Builder.php line 943
at Builder->__call('insertGetId', array(array('name' => null, 'email' => null, 'username' => null, 'password' => null, 'updated_at' => null, 'created_at' => null), 'id')) in Model.php line 1638
at Builder->insertGetId(array('name' => null, 'email' => null, 'username' => null, 'password' => null, 'updated_at' => null, 'created_at' => null), 'id') in Model.php line 1638
at Model->insertAndSetId(object(Builder), array('name' => null, 'email' => null, 'username' => null, 'password' => null, 'updated_at' => null, 'created_at' => null)) in Model.php line 1607
at Model->performInsert(object(Builder), array()) in Model.php line 1513
at Model->save() in UsersController.php line 50
at UsersController->store(object(Request))
at call_user_func_array(array(object(UsersController), 'store'), array(object(Request))) in Controller.php line 256
at Controller->callAction('store', array(object(Request))) in ControllerDispatcher.php line 164
at ControllerDispatcher->call(object(UsersController), object(Route), 'store') in ControllerDispatcher.php line 112
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 114
at ControllerDispatcher->callWithinStack(object(UsersController), object(Route), object(Request), 'store') in ControllerDispatcher.php line 69
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\UsersController', 'store') in Route.php line 203
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134
at Route->run(object(Request)) in Router.php line 712
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 714
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 679
at Router->dispatchToRoute(object(Request)) in Router.php line 639
at Router->dispatch(object(Request)) in Kernel.php line 236
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 122
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 54
at require_once('C:\Users\ken4ward\Documents\xampp\htdocs\schoolapp\public\index.php') in server.php line 21
1/2
PDOException in Connection.php line 390:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null
in Connection.php line 390
at PDOStatement->execute(array(null, null, null, null, null, null)) in Connection.php line 390
at Connection->Illuminate\Database\{closure}(object(MySqlConnection), 'insert into `users` (`name`, `email`, `username`, `password`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?)', array(null, null, null, null, null, null)) in Connection.php line 644
at Connection->runQueryCallback('insert into `users` (`name`, `email`, `username`, `password`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?)', array(null, null, null, null, null, null), object(Closure)) in Connection.php line 611
at Connection->run('insert into `users` (`name`, `email`, `username`, `password`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?)', array(null, null, null, null, null, null), object(Closure)) in Connection.php line 391
at Connection->statement('insert into `users` (`name`, `email`, `username`, `password`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?)', array(null, null, null, null, null, null)) in Connection.php line 347
at Connection->insert('insert into `users` (`name`, `email`, `username`, `password`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?)', array(null, null, null, null, null, null)) in Processor.php line 32
at Processor->processInsertGetId(object(Builder), 'insert into `users` (`name`, `email`, `username`, `password`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?)', array(null, null, null, null, null, null), 'id') in Builder.php line 1799
at Builder->insertGetId(array('name' => null, 'email' => null, 'username' => null, 'password' => null, 'updated_at' => null, 'created_at' => null), 'id')
at call_user_func_array(array(object(Builder), 'insertGetId'), array(array('name' => null, 'email' => null, 'username' => null, 'password' => null, 'updated_at' => null, 'created_at' => null), 'id')) in Builder.php line 943
at Builder->__call('insertGetId', array(array('name' => null, 'email' => null, 'username' => null, 'password' => null, 'updated_at' => null, 'created_at' => null), 'id')) in Model.php line 1638
at Builder->insertGetId(array('name' => null, 'email' => null, 'username' => null, 'password' => null, 'updated_at' => null, 'created_at' => null), 'id') in Model.php line 1638
at Model->insertAndSetId(object(Builder), array('name' => null, 'email' => null, 'username' => null, 'password' => null, 'updated_at' => null, 'created_at' => null)) in Model.php line 1607
at Model->performInsert(object(Builder), array()) in Model.php line 1513
at Model->save() in UsersController.php line 50
at UsersController->store(object(Request))
at call_user_func_array(array(object(UsersController), 'store'), array(object(Request))) in Controller.php line 256
at Controller->callAction('store', array(object(Request))) in ControllerDispatcher.php line 164
at ControllerDispatcher->call(object(UsersController), object(Route), 'store') in ControllerDispatcher.php line 112
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 114
at ControllerDispatcher->callWithinStack(object(UsersController), object(Route), object(Request), 'store') in ControllerDispatcher.php line 69
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\UsersController', 'store') in Route.php line 203
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134
at Route->run(object(Request)) in Router.php line 712
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 714
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 679
at Router->dispatchToRoute(object(Request)) in Router.php line 639
at Router->dispatch(object(Request)) in Kernel.php line 236
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 122
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 54
at require_once('C:\Users\ken4ward\Documents\xampp\htdocs\schoolapp\public\index.php') in server.php line 21
Please help me out of this issue.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire