mardi 19 février 2019

Join 3 tables in Modal - Laravel

I would like to Join the following 3 tables: * Member * Roll * Rollmapping

Member Table

|id|first_name|last_name|......

Roll Table

|id|roll_id|member_id|status|.....

Rollmapping

|id|roll_date|........

the idea is that when I click on the show member blade I can see all roll dates which have a set status - In this case "P"

I have this on my Member.php file

  public function outstanding()
{
    return $this->roll()->where('status', '=', 'P');
}

On the show.blade under member i have the following table:

<table class="table">
                        <thead class = 'text-primary'>
                            <th class="text-center">Date</th>
                            <th></th>
                        </thead>
                        <tbody>
                        @foreach ($member->outstanding as $o)
                        <tr>
                            <td class="text-center"></td> 
                            <td class="text-center"><a href="" title="Paid" class="btn btn-success"><i class="material-icons">done</i></a></td>
                        </tr>
                        @endforeach
                        </tbody> 
                    </table>

This is returning the correct response, but with the Roll_ID, I would like a Join to Show the Roll_date from the rollmapping table

I need this to be on the Member Modal so I am only display data for that member.

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire