Commit 817b744e authored by shajiaiming's avatar shajiaiming

fix

parent 407587bd
......@@ -22,15 +22,25 @@ class ExploreController extends BaseController
goto doEnd;
}
$app_category_model = ExploreAppCategory::find()->where(['platform_id' => $platform_id, 'status' => ExploreAppCategory::STATUS_ON])->all();
foreach ($app_category_model as &$val) {
$app_category_model = ExploreAppCategory::find()->where(['platform_id' => $platform_id, 'status' => ExploreAppCategory::STATUS_ON])->orderBy('sort')->all();
if (false == $app_category_model) {
$msg = 'success';
$code = 0;
$data = null;
goto doEnd;
}
foreach ($app_category_model as $key => $val) {
unset($val->apps);
$val->name = $val->name[$this->lang];
$apps_model = ExploreApp::find()->select('id, name, icon, type, app_url, slogan')
->where(['app_category_id' => (int)$val->id])
->where(['app_category_id' => (int)$val->id, 'status' => ExploreApp::STATUS_ON])
->orderBy('sort')
->limit($val->limit)
->all();
if (empty($apps_model)) {
unset($app_category_model[$key]);
continue;
}
foreach ($apps_model as &$app) {
$app->name = $app->name[$this->lang];
}
......@@ -39,7 +49,9 @@ class ExploreController extends BaseController
unset($val->limit);
unset($val->platform_id);
}
$data = $app_category_model;
foreach ($app_category_model as $val) {
$data[] = $val;
}
$msg = 'success';
$code = 0;
doEnd :
......@@ -95,7 +107,8 @@ class ExploreController extends BaseController
$id_arr = explode(',', $ids);
$order = "FIELD(`id`,$ids)";
$apps_model = ExploreApp::find()->select('id, name, icon, type, app_url, slogan')
->where(['in', 'id', $id_arr])
->where(['status' => ExploreApp::STATUS_ON])
->andWhere(['in', 'id', $id_arr])
->orderBy([$order => true])
->limit(4)
->all();
......
......@@ -59,7 +59,7 @@ class ExploreAppCategory extends BaseActiveRecord
public function getApplications()
{
return $this->hasMany(ExploreApp::className(), ['app_category_id' => 'id'])->select(['id', 'name', 'icon', 'app_url', 'slogan', 'type']);
return $this->hasMany(ExploreApp::className(), ['app_category_id' => 'id'])->select(['id', 'name', 'icon', 'app_url', 'slogan', 'type'])->orderBy('sort');
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment