diff --git a/app/Http/Admin/Services/Course.php b/app/Http/Admin/Services/Course.php index 0c5d3298..e76d595e 100644 --- a/app/Http/Admin/Services/Course.php +++ b/app/Http/Admin/Services/Course.php @@ -274,6 +274,7 @@ class Course extends Service $allCategories = $categoryRepo->findAll([ 'type' => CategoryModel::TYPE_COURSE, 'published' => 1, + 'deleted' => 0, ]); if ($allCategories->count() == 0) return []; diff --git a/app/Http/Admin/Services/FlashSale.php b/app/Http/Admin/Services/FlashSale.php index 3a90363b..8866de9a 100644 --- a/app/Http/Admin/Services/FlashSale.php +++ b/app/Http/Admin/Services/FlashSale.php @@ -50,7 +50,11 @@ class FlashSale extends Service { $courseRepo = new CourseRepo(); - $items = $courseRepo->findAll(['free' => 0, 'published' => 1]); + $items = $courseRepo->findAll([ + 'free' => 0, + 'published' => 1, + 'deleted' => 0, + ]); if ($items->count() == 0) return []; diff --git a/app/Http/Admin/Services/PointGift.php b/app/Http/Admin/Services/PointGift.php index 56487edf..5b929c02 100644 --- a/app/Http/Admin/Services/PointGift.php +++ b/app/Http/Admin/Services/PointGift.php @@ -215,7 +215,6 @@ class PointGift extends Service return $gift; } - protected function createVipPointGift($post) { $validator = new PointGiftValidator(); diff --git a/db/migrations/20220607014823.php b/db/migrations/20220607014823.php index a1f74762..02a12daf 100644 --- a/db/migrations/20220607014823.php +++ b/db/migrations/20220607014823.php @@ -1,10 +1,19 @@ handleSiteSettings(); @@ -12,7 +21,7 @@ final class V20220607014823 extends AbstractMigration protected function handleSiteSettings() { - $row = + $rows = [ [ 'section' => 'site', @@ -36,7 +45,7 @@ final class V20220607014823 extends AbstractMigration ], ]; - $this->table('kg_setting')->insert($row)->save(); + $this->insertSettings($rows); } } \ No newline at end of file diff --git a/db/migrations/SettingTrait.php b/db/migrations/SettingTrait.php new file mode 100644 index 00000000..cff86d00 --- /dev/null +++ b/db/migrations/SettingTrait.php @@ -0,0 +1,34 @@ + $row) { + $exists = $this->settingExits($row['section'], $row['item_key']); + if ($exists) unset($rows[$key]); + } + + if (count($rows) == 0) return; + + $this->table('kg_setting')->insert($rows)->save(); + } + + protected function settingExits($section, $itemKey) + { + $row = $this->getQueryBuilder() + ->select('*') + ->from('kg_setting') + ->where(['section' => $section, 'item_key' => $itemKey]) + ->execute()->fetch(); + + return $row ? true : false; + } + +} \ No newline at end of file