From 13eb2737726e25fd65142d9597fd7e060c64bc6b Mon Sep 17 00:00:00 2001 From: Daniel-I-Am Date: Sat, 4 Sep 2021 12:09:14 +0200 Subject: [PATCH] Remove old views system for blog articles --- .../Controllers/BlogArticleController.php | 2 +- ...084238_remove_views_from_blog_articles.php | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2021_09_04_084238_remove_views_from_blog_articles.php diff --git a/app/Http/Controllers/BlogArticleController.php b/app/Http/Controllers/BlogArticleController.php index 8ede612..f425b85 100644 --- a/app/Http/Controllers/BlogArticleController.php +++ b/app/Http/Controllers/BlogArticleController.php @@ -61,7 +61,7 @@ class BlogArticleController extends Controller public function popular() { $data = BlogArticle::select() - ->orderBy('views', 'desc') + ->orderByUniqueViews('desc') ->orderBy('date', 'desc') ->where('published', true) ->limit(5) diff --git a/database/migrations/2021_09_04_084238_remove_views_from_blog_articles.php b/database/migrations/2021_09_04_084238_remove_views_from_blog_articles.php new file mode 100644 index 0000000..cda1674 --- /dev/null +++ b/database/migrations/2021_09_04_084238_remove_views_from_blog_articles.php @@ -0,0 +1,32 @@ +dropColumn('views'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('blog_articles', function (Blueprint $table) { + $table->integer('views')->default(0); + }); + } +}