I got stuck on access data on a multiple level of relationship on Laravel 5.4. I have a feeling that it is straight forward in Laravel but I just can't figure it out. Here is the setup:
I got 3 models: User/Post/Application - representing user come to the job site to apply on the job posts.
I have the login set up and want to allow user to view application they been sent to the related job posts:
public function index() {
$user = User::find(Auth::user()->id);
$applications = $user->appliedPosts;
return view('pages.user.appliedPost.index')->withApplications($applications);
}
I am able to connect the user with applications, but how do I get the title of the post based on the post_id on the "applications" table?
Thanks in advance.