Created
September 10, 2020 23:13
-
-
Save EricMcWinNer/995ee66dd5bc03d33da0bd2104d04e1c to your computer and use it in GitHub Desktop.
Using a one to one relationship
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
<?php | |
namespace App\Http\Controllers; | |
use App\Models\User; | |
class RandomController extends Controller { | |
public function getUserVote(){ | |
$user = User::find(1); // Get a User Instance | |
$vote = $user->vote; // Get the Vote that this User has | |
// Do whatever with it | |
return response(['vote' => $vote], 200); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment