2
I am registering suppliers, and I need to record it in a table and your address in another. I use a single view suppliers. to fill in all the data. How can I separate this data to save it 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');
}
The problem is getting the
id
address and write to the supplier?– rray
@rray, too. All data is populated in the vendor view. The action of this form goes to the vendor controller. I want to separate personal data and address, record each in their respective table and then make the relationship.
– buback