Skip to content

Instantly share code, notes, and snippets.

@EricMcWinNer
Created September 10, 2020 23:13
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 EricMcWinNer/995ee66dd5bc03d33da0bd2104d04e1c to your computer and use it in GitHub Desktop.
Save EricMcWinNer/995ee66dd5bc03d33da0bd2104d04e1c to your computer and use it in GitHub Desktop.
Using a one to one relationship
<?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