mercredi 1 février 2017

Iterate through object

I can't for the life of me, iterate through my models to show a table of my database.

here is where I do the request.

public function index()
    {
        $vehicles = vehicle::all();
        return view('vehicles', compact('vehicles'));
    }

And here is my view :

<table class ="vehicles-table">
  <tr>
    <td> id</td>
    <td> First Name</td>
    <td> Last Name</td>
    <td> Contact Number</td>
    <td> email</td>
    <td> manufacturer</td>
    <td> type</td>
    <td> year</td>
    <td> colour</td>
    <td> mileage</td>
  </tr>
@foreach($vehicles as $vehicle)
    @if($vehicle->soft_del == 1)
        @continue
    @endif
    <tr>
        @foreach($vehicle as $info)
            @if($loop->iteration >= 11)
                @break
            @endif
            <td>  </td>
        @endforeach
    </tr>
@endforeach

Here is what I get

Even though I get this in tinker

How can I iterate through my vehicles effectively ?



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

Aucun commentaire:

Enregistrer un commentaire