Hey guys, I'm setting up a football club management system just to practice and in that a doubt arose, I have the following eloquent:
$matches = DB::table('ut_tickets AS TIC')
->select('TIC.id', 'STA.name AS stadium', 'CLM.name AS club_main', 'CLV.name AS club_visitor', 'CLM.arms AS arms_main', 'CLV.arms AS arms_visitor', 'MAT.date_match', 'MAT.schedule_match', 'CHAMP.name AS championship')
->join('ut_lots AS LOT', 'LOT.id', 'TIC.id_lot')
->join('ut_matches AS MAT', 'MAT.id', 'LOT.id_match')
->join('ut_stadiums AS STA', 'STA.id', 'MAT.id_stadium')
->join('ut_clubs AS CLM', 'CLM.id', 'MAT.id_club_main')
->join('ut_clubs AS CLV', 'CLV.id', 'MAT.id_club_visitor')
->join('ut_championships AS CHAMP', 'CHAMP.id', 'MAT.id_championship')
->join('ut_transactions AS TRAN', 'TRAN.id', 'TIC.id_transaction')
->join('users AS USR', 'USR.id', 'TRAN.id_user')
->where('TRAN.id_user', Auth::user()->id)
->groupBy('MAT.id')->orderBy('MAT.date_match', 'DESC')->get();
dd($matches);
The dd is returning me to collection:
Collection {#397 ▼
#items: array:1 [▼
0 => {#384 ▼
+"id": 1
+"stadium": "Beira Rio"
+"club_main": "Internacional"
+"club_visitor": "Grêmio"
+"arms_main": "/images/clubs/1/1537880299212.png"
+"arms_visitor": "/images/clubs/2/1537880338132.png"
+"date_match": "2018-12-21"
+"schedule_match": "16:00:00"
+"championship": "Gauchão 2018"
}
]
}
In my front end, I intend to customize as the user has attended the game, if it is, display the data one way, if not another.
But the way I mounted it returns only if you have a ticket purchased from that customer. Is it possible for me to bring all the data even though the user has not bought the ticket? If so, how would I have to set up this Eloquent to bring those frequented and not frequented (The way I thought it was according to the ticket ticket if there is a id_user
register in the ut_tickets
table is because he bought, I know how to handle the result for when it does not buy: x