Feb 17, 2019
3
Level 1
How can I join 2 tables and sort them by date
Hi there, I don't really know how I can join two tables together in Laravel... Hopefully, someone can help here. So basically I have the regulars table and the commemoratives table. I would like all the items and show them by date. So now there are separate from each other, but how can I merge/join them together?
Controller:
public function getAll(){
$regulars = Regular::all();
$commemoratives = Commemorative::all();
return view('pages/all')->withRegulars($regulars)->withCommemoratives($commemoratives);
}
blade:
@foreach ($regulars as $regular)
@endforeach
@foreach ($commemoratives as $commemorative)
@endforeach
Thanks!!
Please or to participate in this conversation.