Last active
September 11, 2020 14:57
-
-
Save EricMcWinNer/18b543d3848c6abb98accdd36b7a76ad to your computer and use it in GitHub Desktop.
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\PoliticalParty; | |
class RandomController extends Controller { | |
/** | |
* Gets candidates | |
*/ | |
public function getCandidates() { | |
$party = PoliticalParty::find(1); | |
$candidates = $party->candidates; // Returns a Laravel Collection | |
return response(['candidates' => $candidates], 200); // Returns JSON object containing an array of candidates | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment