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) public function actionView($name)
{ {
$model = $this->findModel($name);
$model->hits++;
$model->save(false, ['hits']);
return $this->render('view', [ return $this->render('view', [
'model' => $this->findModel($name), 'model' => $model,
]); ]);
} }

View File

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

View File

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