Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
public function getOneToMany($id)
{
	 //      $tasks = App\Project::findOrFail($id)->tasks()->orderBy('name')->get();
    dd($tasks);		
}

...

Scroll Office Title
title일대다 검색 결과

 

만약 Task 의 부모 모델을 찾으려면 다음과 같이 Task 모델의 project() 메소드를 호출하면 됩니다.

Code Block
>>> App\Task::find(1)->project
=> <App\Project #0000000002558acd00000000675df7f7> {
       id: 1,
       user_id: 1,
       name: "개인",
       is_public: 0,
       created_at: "2015-07-25 00:26:57",
       updated_at: "2015-07-25 00:26:57"
   }

...