Last active
March 11, 2020 15:45
-
-
Save me7media/0fbb6a27acff85f2d3b14535336ceff1 to your computer and use it in GitHub Desktop.
laravel must return a relationship instance
This file contains 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
//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