I'm doing a supplier registration, and I need to record it in one table and its address in another. I use a single view vendors.blade to fill in all the data. How can I separate this data to write them to their respective tables?
Suppliers table:
id | int
nome | varchar
endereco_id | int
Address Table:
id | int
logradouro | varchar
bairro | varchar
cep | int
Controller:
public function store(Request $request)
{
$input = $request->all();
Fornecedor::create($input);
return redirect('fornecedores');
}
Model:
public function endereco() {
return $this->hasMany('App\Endereco', 'id', 'endereco_id');
}