Skip to content

Instantly share code, notes, and snippets.

@tmanOC
Forked from HristoZA/Car.php
Created October 16, 2020 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmanOC/2ce12e2cdf8c5d9d82e9167f8e66ee40 to your computer and use it in GitHub Desktop.
Save tmanOC/2ce12e2cdf8c5d9d82e9167f8e66ee40 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