Pass a view data by href to another view with method post

1

I am learning laravel for a job in college with my classmates, they have more experience in the language but none of them could explain how to do this

I have a data in a view that I want to send to another to fill a space in a form

The code of the first view is this:

<tbody>
  @foreach($areas as $area)
  <tr>
    <td>{{ $area -> COD_AREA}} </td>
    <td>{{ $area -> NOMBRE_AREA}} </td>
    <td>{{ $area -> DESC_AREA}} </td>
    <td>
        <div class="text-center">
          <h4>
            <a href='{{ route('subarea.create',$area->NOMBRE_AREA) }}' data-toggle="tooltip" data-placement="right" title="Registar Subarea">
              <i class="fas fa-plus-square" aria-hidden="true"></i>
            </a>
          </h4>
        </div> 
    </td>
  </tr>
  @endforeach
</tbody>

And the code of the second view is this:

<div>
{!! Form::open(['route'=>'subarea.store','method'=>'POST']) !!}
.....
<div class="form-group row">
    {!! Form::label('NOMBRE_AREA','Nombre del area al que pertenece',['class'=>'col-sm-2 col-form-label']) !!}
    <div class="col-sm-10">
        {!! Form::text('NOMBRE_AREA', $area, ['class'=>'form-control']) !!}
    </div>    
</div>
</div>
    
asked by UnUsuario 29.04.2018 в 17:49
source

1 answer

0

You define the parameter in the route to receive the data:

Route::get('miruta/{area}', 'miControlador@showForm'); 

In the controller you receive the data and simply pass it on sight:

public function showForm($area) {

   // ...

    return view('mivista', compact('area'));
}

And in the view should serve you the code you have:

{!! Form::text('NOMBRE_AREA', $area, ['class'=>'form-control']) !!}
    
answered by 29.04.2018 / 17:53
source