Verified Commit 06e48eff authored by Korko's avatar Korko
Browse files

Eager load

parent 6a9956ad
Pipeline #291326 passed with stages
in 2 minutes and 34 seconds
......@@ -83,6 +83,6 @@ class Draw extends Model
abort_if($draw->expired, 404);
return $draw->load(['participants', 'participants.mail']);
return $draw->load('participants');
}
}
......@@ -9,7 +9,9 @@ use Illuminate\Notifications\Notifiable;
class Participant extends Model
{
use Notifiable;
use HashId;
use HashId {
resolveRouteBinding as resolveParticipant;
};
protected static $hashConnection = 'santa';
......@@ -71,4 +73,18 @@ class Participant extends Model
return static::findByHashOrFail($hash);
}
/**
* Retrieve the model for a bound value.
*
* @param mixed $value
* @param string|null $field
* @return \Illuminate\Database\Eloquent\Model|null
*/
public function resolveRouteBinding($value, $field = null)
{
$participant = $this->resolveParticipant($value);
return $participant->load(['dearsanta']);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment