zaster
115
3
Laravel

Accessing a relation in a Collection

Posted 1 month ago by zaster
Collection {#617 ▼
  #items: array:1 [▼
    0 => SubJob {#619 ▼
..
..

      #relations: array:1 [▼
        "company" => Company {#651 ▶}
      ]

I want to do something like this

  $companies = $job->sub_jobs->company()->distinct('name')->pluck('name');   

I am getting this error

Method company does not exist.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.