Laravel does not take into consideration the ISNULL method however, you can pass it in as a raw query and still make use of it as it’s more efficient than IF statements and the results will stay the same if you ever go beyond 1000000 employees (accepted answer), like so:
public function employees()
{
return $this->hasMany('Employee')
->orderBy(DB::raw('ISNULL(sortOrder), sortOrder'), 'ASC');
}
Update:
You can also use the orderByRaw() method:
public function employees()
{
return $this->hasMany('Employee')
->orderByRaw('ISNULL(sortOrder), sortOrder ASC');
}