Skip to content

Instantly share code, notes, and snippets.

@me7media
Last active March 11, 2020 15:45
Show Gist options
  • Save me7media/0fbb6a27acff85f2d3b14535336ceff1 to your computer and use it in GitHub Desktop.
Save me7media/0fbb6a27acff85f2d3b14535336ceff1 to your computer and use it in GitHub Desktop.
laravel must return a relationship instance
//this is example how to return a relationship instance in laravel if u have some logic to get it or troubles
public function user()
{
$id = ///some code to get $id
return $this->hasOne(User::class, 'id', 'id') // this just for new hasOne instance
->orWhere('id', $id); //get your niddle instanse
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment