0
Well the problem that happens is this, have in my application the phone field that is present in a relationship for personFisica then a person has a hasMany relationship for phones and that in turn has a belongsto for good person so far all right the problem is happening when I will do the since they are two inputs, the view code looks like this:
@foreach($pessoaFisica->telefones as $tel)
<div class="col-sm-6">
<label for="telefone" class="col-sm-6 control-label">Telefone:</label>
<input type="tel" class="form-control" name="numero[]" id="numero"
placeholder="Telefone - obrigatório"
value="{{isset($tel->numero) ? $tel->numero : null}}">
</div>
@endforeach
this gives a list of phones as follows:
and now I’m trying to take the two fields to edit on the table, and I’m trying to do it this way:
$dados = $request->input('numero');
$this->telefone->where('id_pessoa', $idPessoa)->update($dados);
but a mistake is happening. I know this is happening because it is a list but I don’t know how to insert it in bulk at once or otherwise.
But in case the only would not just take the first record?
– André Martins
@Andrémartins read the documentation. Only is the request method, where you set that it will return an associative array only with the inputs you set. Read documentation, search for: Mass assign, Input Request and Eloquent Update
– juniorb2ss