瀏覽代碼

生成彩虹豆

wzq 5 年之前
父節點
當前提交
92ab451a5e

+ 1 - 1
app/Http/Controllers/Post/PostController.php

@@ -58,7 +58,7 @@ class PostController extends Controller
                 'share_count',
                 'comment_count',
                 'collect_count',
-                'will_collect_bean',
+                'create_bean',
                 'is_suggest'
             ]
         ];

+ 1 - 1
app/Repositories/Post/PostRepository.php

@@ -145,7 +145,7 @@ class PostRepository
         }
 
         $sort = 'post.id';
-        if(isset($request['sort']) && in_array($request['sort'], ['praise_count', 'share_count', 'pv', 'comment_count'])){
+        if(isset($request['sort']) && in_array($request['sort'], ['praise_count', 'share_count', 'pv', 'comment_count', 'create_bean'])){
             $sort = $request['sort'];
         }
 

+ 1 - 5
app/Transformers/Post/PostTransformer.php

@@ -16,10 +16,6 @@ class PostTransformer extends TransformerAbstract
 {
     public function transform(Post $post)
     {
-        $imgs = [];
-        foreach($post->imgs as $img){
-            $imgs[] = $img;
-        }
         return [
             'id' => $post['id'],
             'created_at' => Carbon::parse($post['created_at'])->toDateTimeString(),
@@ -34,7 +30,7 @@ class PostTransformer extends TransformerAbstract
             'share_count' => $post->data->share_real_count.'/'.$post->data->share_count,
             'comment_count' => $post->data->comment_count,
             'collect_count' => $post->data->collect_real_count.'/'.$post->data->collect_count,
-            'will_collect_bean' => $post->data->will_collect_bean,
+            'create_bean' => $post->data->create_bean,
             'is_suggest' => $post['is_suggest'],
         ];
     }

+ 35 - 0
database/migrations/2019_06_06_161402_add_create_bean_to_table_post_data.php

@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddCreateBeanToTablePostData extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('post_data', function (Blueprint $table) {
+            $table->integer('create_bean')
+                ->default(0)
+                ->after('will_collect_bean')
+                ->comment('生成彩虹豆');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('post_data', function (Blueprint $table) {
+            //
+        });
+    }
+}