I have a confusion and I need a help to solve.
I am trying to add a record to a table that depends on the initial record, it is an event log table related to the initial registration of a call record.
As I try to do this it is with an input hidden, but it does not receive the id and it generates the following error (Undefined property:Illuminate\Support\Collection::$id).
This is part of the view with the record button of the incidences.
@foreach ($data as $call)
<tr class="active">
<td align="center"></td>
<td style="text-align: center"></td>
<td></td>
<td></td>
<td align="center">
@if($call->type == 1)
<span class="label label-info">Saliente</span>
@else
<span class="label label-success">Entrante</span>
@endif
</td>
<td></td>
<td></td>
<td align="center">
<a class="btn btn-info btn-xs" href="" data-toggle="tooltip" rel="tooltip" data-placement="top" title="Detalle de llamada"> <i class="material-icons">info_outline</i> </a>
@permission('role-edit')
<a class="btn btn-primary btn-xs" href="" data-toggle="tooltip" data-placement="top" title="Editar registro de llamada"> <i class="material-icons">create</i> </a>
@endpermission
<a class="btn btn-warning btn-xs" href="" data-toggle="tooltip" rel="tooltip" data-placement="top" title="Registrar incidencia"> <i class="material-icons">event</i> </a>
{!! Form::open(['method' => 'DELETE','route' => ['calls.destroy', $call->id],'style'=>'display:inline']) !!}
@permission('role-delete')
<button type="submit" class="btn btn-danger btn-xs" data-toggle="tooltip" data-placement="top" title="Eliminar llamada"><i class="material-icons delete-white">delete</i></button>
@endpermission
{!! Form::close() !!}
</td>
</tr>
@endforeach
This is part of the view where the issue is logged, but I need to pass the id in the hidden field.
{!! Form::open(array('route' => 'comments.store','method' => 'POST')) !!}
<div class="col-md-12 col-xs-12">
<div class="input-group">
<div class="col-md-4 col-xs-4">
{!! Form::select('call_id', $calls, null, ['class' => 'form-control', 'placeholder' => 'Seleccionar cliente']) !!}
</div>
<div class="col-md-8 col-xs-8">
{!! Form::text('name', null, array('placeholder' => 'Registrar incidencia','class' => 'form-control')) !!}
</div>
<span class="input-group-btn">
<button type="submit" class="btn btn-success btn-xs" data-toggle="tooltip" rel="tooltip" data-placement="top" title="Guardar">
<i class="material-icons">save</i>
</button>
</span>
</div>
</div>
{!! Form::close() !!}
The error generated by the view is:
Undefined property: Illuminate\Support\Collection::$id
These are my methods for the controller (CommentController).
public function create()
{
$calls = Call::orderBy('id', 'asc')->lists('name', 'id');
return view('comments.create', compact('calls'));
}
public function store(Request $request)
{
//return $request->all();
$this->validate($request, [
'name' => 'required|unique:categories|max:255',
]);
$comments = Comment::create([
'name' => $request->get('name'),
'call_id' => $request->get('call_id'),
]);
return redirect()->route('comments.index')
->with('success','Comentario agregado correctamente!!!');
}
This is my route method.
Route::resource('comments','CommentController');
Someone who can guide me, since I have used several methods and I have not been able to solve it.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire