Vladimir Djukic
Vladimir Djukic

Reputation: 2072

How to select one column clumn from table and all records from relation table [Laravel 5]

I have Eloquent query like this:

Project::with('tasks')->get([]);

I need to take from projects table one coulmn 'name' and from tasks I wana get all...

Anyone know how to acomplish it?

Upvotes: 1

Views: 472

Answers (1)

Joseph Silber
Joseph Silber

Reputation: 219930

In order to be able to load the tasks, you need to load the project's id:

$projects = Project::with('tasks')->get(['id', 'name']);

Upvotes: 1

Related Questions