I am trying to insert the data of a form of a Condominium class with the user already logged in and authenticated, the user_id is foreign key to the Condominium table, in my understanding the store method should already bring the user_id in the array to insert the data but this is not happening, and because of this it generates an SQL error saying that the field user_id can not be null (since it is a foreign key as it said). It takes the create and store methods of CondomínioController:
public function create()
{
$condominio = auth()->user()->condominio;
//$condominio = Condominios::create()->get();
$title='Cadastrar Condominio';
return view('admin.condominio.create',compact('title'));
}
public function store(Request $request)
{
$condominio = auth()->user()->condominio;
//dd($request->all());
Condominios::create($request->all());
return redirect()->route('admin.condominio.index')->with('message', 'condominio criado com sucesso!');