order mods by hits

This commit is contained in:
cornernote 2015-08-10 22:31:41 +09:30
parent 0648375f5b
commit 114f3ee2f8
3 changed files with 6 additions and 2 deletions

View File

@ -38,8 +38,11 @@ class ModController extends Controller
*/
public function actionView($name)
{
$model = $this->findModel($name);
$model->hits++;
$model->save(false, ['hits']);
return $this->render('view', [
'model' => $this->findModel($name),
'model' => $model,
]);
}

View File

@ -47,7 +47,7 @@ class PackageController extends Controller
->one();
if ($package) {
$package->hits++;
$package->save();
$package->save(false, ['hits']);
return $package;
}
throw new HttpException(404, 'Package not found.');

View File

@ -50,6 +50,7 @@ class PackageSearch extends Package
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort' => ['defaultOrder' => ['hits' => SORT_DESC]],
]);
$this->load($params);