Created
January 16, 2017 20:11
-
-
Save hewerthomn/d05925ca827ca8e19fe597d027f2ae53 to your computer and use it in GitHub Desktop.
Laravel Eloquent selectList
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 | |
/*...*/ | |
public function selectList() | |
{ | |
$list = $this->select('name', 'id') | |
->orderBy('name') | |
->pluck('name', 'id'); | |
$arr = $list->toArray(); | |
$arr = ['' => 'Select'] + $arr; | |
return $arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment