Created
September 11, 2020 15:00
-
-
Save EricMcWinNer/87ed414e0b108cd8351aa1cfe40ad96d 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 | |
foreach($candidates as $candidate) { | |
// Do what you want with $candidate | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment