I have two questions/help to fix here:
$this->all()->lists('name', 'id')->all()
orderBy
method.helper.php
if (! function_exists('withEmpty')) {
function withEmpty($selectList, $emptyLabel = '')
{
return array('' => $emptyLabel) + $selectList;
}
}
Agent.php (model)
public function getNameAttribute($value){
return $this->lname.', '.$this->fname.' '.$this->mname;
}
public function listAgents($emptyLabel = '--Select Agent--'){
return withEmpty($this->all()->lists('name', 'id')->all(), $emptyLabel);
}
1. Change this:
$this->all()->lists('name', 'id')->all()
To:
$this->all()->lists('name', id)
2. You can't do that. Use sortBy()
and sortByDesc()
collection methods with a closure instead:
->sortBy(function($i) {
return $i->name;
});