Skip to content

Instantly share code, notes, and snippets.

@hewerthomn
Created January 16, 2017 20:11
Show Gist options
  • Save hewerthomn/d05925ca827ca8e19fe597d027f2ae53 to your computer and use it in GitHub Desktop.
Save hewerthomn/d05925ca827ca8e19fe597d027f2ae53 to your computer and use it in GitHub Desktop.
Laravel Eloquent selectList
<?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