Skip to content

Instantly share code, notes, and snippets.

@HristoZA
Last active October 16, 2020 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save HristoZA/e87e49e282e69475aec9a31820c75aa4 to your computer and use it in GitHub Desktop.
Save HristoZA/e87e49e282e69475aec9a31820c75aa4 to your computer and use it in GitHub Desktop.
Eloquent Blog Car
<?php
class Car extends Model
{
// ...
public function garage()
{
return $this->belongsTo('App\Garage');
}
public function owner()
{
return $this->hasOneThrough(
'App\Owner',
'App\Garage',
'id',
'id',
'garage_id',
'owner_id'
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment