-1
您好我希望儘量減少這樣的代碼:如何在laravel中優化查詢?
if (empty(Input::get('channelName'))) {
$channels = Channel::orderBy('updated_at', 'desc')->paginate($perPage)->setPath('?limit=' . $perPage);
} else {
$channels = Channel::where('name', 'like', '%' . Input::get('channelName') . '%')->orderBy('updated_at', 'desc')->paginate($perPage)->setPath('?limit=' . $perPage);
}