lundi 8 février 2021

LaravelCollective does not receive the data

I am starting with Laravel 5.5. I have an error when trying to send the data to the edit form:

`Illegal string offset 'name' (View: C: \ xampp \ htdocs \ laravel-ads \ resources \ views \ admin \ edit.blade.php)

 public function edit($id)
    {
        //
        $user = User::findOrFail($id);
        //var_dump($user['name']);
       return view('admin.edit', compact('user'));
    }
    <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:

Route::resource('admin', 'AdminController');

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 issue jumps in this place of Laravel:

 * @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'); 

This answer no works to me



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/39XxkCY
via IFTTT

Aucun commentaire:

Enregistrer un commentaire