Created
November 18, 2017 16:37
-
-
Save colindecarlo/29f12f1b3a4ed11aff92b270838c8856 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Event | |
{ | |
public function fights() | |
{ | |
return $this->hasMany(Fight::class)->orderBy('fightcard_order'); | |
} | |
public function topFight() | |
{ | |
return $this->hasOne(Fight::class)->orderBy('fightcard_order'); | |
} | |
} | |
// what's the difference | |
$topFight = $event->topFight()->with(['fighter1', 'fighter2'])->get(); | |
// between | |
$topFight = $event->topFight->load(['fighter1', 'fighter2']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment