Created
May 31, 2013 15:18
-
-
Save timothylhuillier/5685691 to your computer and use it in GitHub Desktop.
Model::lists() -> renvoie tableau au lieu d'un objet
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
// la l.2 fait la même chose que la l.5/6 | |
$jobs = Job::lists('name', 'id'); | |
// Ancien | |
$jobs = Job::all(); | |
foreach($jobs as $job) { $jobArray[$job->id] = $job->name; } | |
// Les 2 renvoies le même array : | |
array (size=14) | |
2 => string 'Gérant de projet' (length=17) | |
3 => string 'Surintendant de chantier' (length=24) | |
5 => string 'Commis de bureau' (length=16) | |
8 => string 'Charpentier-menuisier' (length=21) | |
22 => string 'Manoeuvre' (length=9) | |
42 => string 'Assistant surintendant' (length=22) | |
43 => string 'Estimateur junior' (length=17) | |
44 => string 'Estimateur senior' (length=17) | |
45 => string 'Agent de prévention santé et sécurité du travail' (length=52) | |
46 => string 'Commis de chantier' (length=18) | |
47 => string 'Stagiaire' (length=9) | |
48 => string 'Assistant gérant de projets' (length=28) | |
49 => string 'Secrétaire' (length=11) | |
50 => string 'Développement des affaires' (length=27) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment