Skip to content

Instantly share code, notes, and snippets.

@j-dexx
Created July 31, 2019 09:44
Show Gist options
  • Select an option

  • Save j-dexx/ad381876c0711fb65245adc81818af5e to your computer and use it in GitHub Desktop.

Select an option

Save j-dexx/ad381876c0711fb65245adc81818af5e to your computer and use it in GitHub Desktop.
Journal
class Journal
{
// journals this journal references
public function references()
{
return $this->belongsToMany(Journal::class, 'references', 'journal_id', 'reference_id');
}
// inverse the keys to retrieve journals this is referenced by
public function referencedByJournals()
{
return $this->belongsToMany(Journal::class, 'references', 'reference_id', 'journal_id');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment