dimanche 29 novembre 2015

Laravel Access to several tables

I'm having an issue in accessing to data that are related in more than one table, here my code:

<table class="table table-striped">
    <thead>
        <th>Ejercicio</th>
        <th>Unidad</th>
        <th>Descripcion</th>
        <th>Tipo actividad</th>
        <th>Operaciones</th>
    </thead>
    @foreach($exercises as $exercise)
    <tbody>
        <td>{{$exercise->name}}</td>
        <td>{{$exercise->unit}}</td>
        <td>{{$exercise->description}}</td>
        <td>{{$exercise->activity_id}}</td>
        <td>
            <?php echo link_to('exercise/edit/'.$exercise->id, $title = 'Editar', $attributes = array('class' => 'btn btn-primary'), $secure = null); ?>                
        </td>
    </tbody>
    @endforeach
</table

on line <td>{{$exercise->activity_id}}</td> this is just a foreign key for another table named activity_type which has an id and a name, so what I wanted to be shown is the name with this id.

How can I do that?



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

Aucun commentaire:

Enregistrer un commentaire