I am starting with Laravel 5.5. I have the following bug when sending the data to edit. Illegal string offset 'name' (View: C: \ xampp \ htdocs \ laravel-ads \ resources \ views \ admin \ edit.blade.php)
The data loads very well in the index view from where it is sent to the edit view through a link.
The commented var_dump () in the controller function confirms that it receives the name variable correctly. It is a String with the user's name.
public function edit($id)
{
//
$user = User::findOrFail($id);
//var_dump($user['name']);
return view('admin.edit', compact('user'));
}
The view form is not the problem because the error is triggered by the commenting form. Here it is:
<div class="container">
<h1 class="text center">Editor de Usuario</h1>
{!! Form::model($user, ['method' => 'PATCH', 'action' => ['AdminController@update', $user->id], 'files' => true]) !!}
<div class="form-group">
{!! Form::label('id', 'Id') !!}
{!! Form::number('id', '', ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('id_rol', 'Rol') !!}
{!! Form::number('id_rol', '', ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('imagen', 'Imagen') !!}
{!! Form::file('imagen', '', ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('name', 'Nombre') !!}
{!! Form::text('name', '', ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('email', 'Email') !!}
{!! Form::email('email', '', ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('password', 'Password') !!}
{!! Form::password('password', '', ['class' => 'form-control']) !!}
</div>
{!! Form::submit('Editar', ['class' => 'btn btn-success']) !!}
{!! Form::close() !!}
</div>
The route:
public function edit($id)
{
//
$user = User::findOrFail($id);
//var_dump($user['name']);
return view('admin.edit', compact('user'));
}
my index.blade.php:
<div class="container-fluid"></div>
<h1 class="text-center"> Usuarios</h1>
<div class="table-responsive">
<table class="table table-dark">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Rol</th>
<th scope="col">Foto</th>
<th scope="col">Nombre</th>
<th scope="col">Email</th>
<th scope="col">Ultima actualizacion</th>
<th scope="col">Creado</th>
</tr>
</thead>
<tbody>
@foreach($users as $user)
<tr>
<th scope="row"></th>
<td></td>
<td><img src="images/" alt="imagen de usuario" width="150"></td>
<td><a href=""> </a></td>
<td></td>
<td></td>
<td></td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
The error jumps to me in the following Laravel php file:
* @param string $value
* @param array $options
*
* @return \Illuminate\Support\HtmlString
*/
public function input($type, $name, $value = null, $options = [])
{
$this->type = $type;
if (! isset($options['name'])) {
$options['name'] = $name;
}
// We will get the appropriate value for the given field. We will look for the
// value in the session for the value in the old input data then we'll look
// in the model instance if one is set. Otherwise we will just use empty.
$id = $this->getIdAttribute($name, $options);
if (! in_array($type, $this->skipValueTypes)) {
$value = $this->getValueAttribute($name, $value);
}
// Once we have the type, value, and ID we can merge them into the rest of the
// attributes array so we can convert them into their HTML attribute format
// when creating the HTML element. Then, we will return the entire input.
$merge = compact('type', 'value', 'id');
I have tried the solution transmitted here without success Thanks.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3tDsT84
via IFTTT
Aucun commentaire:
Enregistrer un commentaire