I am having issues inserting data into my database tables. I have users table which is has a relation of one to many to school table and region table. That is, users table has foreign keys of school and region tables.
I have created the relations correctly but then when i try to insert values into the database, i get the error.
PS: I have one user(admins) in the user table (the school_id and region_id was inserted accurately) already which i saved through RegisterController. Now, when i sign in with the user(admin) already saved, i want to save other users through the UserController but then i get the error above.
What am i not doing right?. I am only a beginner with database relationship and laravel
General error: 1364 Field 'school_id' and `region_id`doesn't have a default value
meaning the field cannot be empty.
UserController
public function store(UserFormRequest $request)
{
$user = new User(array(
'name' => $request->get('name'),
'email' => $request->get('email'),
'password'=> $request->get('password'),
'phone' => $request->get('phone')
));
$user->save();
}