order mods by hits
This commit is contained in:
parent
0648375f5b
commit
114f3ee2f8
@ -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,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.');
|
||||||
|
@ -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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user