samedi 25 novembre 2017

Error Foreach on the views laravel

I am trying to show the result of a query in my modal window where I implement a table where I want to show me the results but it gives me an error Undefined variable:vehiculos I have already tried everything and without results I hope you can help me attach my code.

esta es mi vista.

   <!-- Modal -->
  <div class="modal fade" id="m-buscar" role="dialog">
    <div class="modal-dialog modal-lg">

      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Lista de Carros</h4>
        </div>
        <div class="modal-body">
        <div class="panel-body">
        <table class="table">
    <thead>
        <tr>
            <th>placa</th>
            <th>modelo</th>
            <th>Email</th>
            <th>Carros Propios</th>
            <th>Carros Manejados</th>
            <th>Opciones</th>
        </tr>
    </thead>
        <tbody>
        @foreach($vehiculos as $key => $c)
            <tr class="id">
                <td></td>
                <td></td>
                <td></td>
            </tr>
        @endforeach
    </tbody>
    </table>
      </div>
        </div>
       </div>
      </div>

This my Controller

public function verCarro(Request $r)
    {
      $vehiculos = vehiculo::join('users','vehiculos.user_id','=','users.id')
                    ->select('vehiculos.id','vehiculos.marca','vehiculos.modelo','vehiculos.placa')  
                    ->where('vehiculos.user_id','=', $r->id)
                    ->orderBy('vehiculos.id','DESC')
                    ->get();

        return view('admin.usuario.buscar', compact('vehiculos'));
    }

here Call my modal

$(document).on('click','.btn-user',function(e){
                var id = $(this).val();
                $.ajax({
                    type: 'get',
                    url: "",
                    data:{id:id},
                    success:function(data)
                    {
                        $('#m-buscar').modal('show');   
                })
            })



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2BmlrD9
via IFTTT

Aucun commentaire:

Enregistrer un commentaire