瀏覽代碼

更改字段类型

duqinya 5 年之前
父節點
當前提交
92f59b1906

+ 4 - 4
app/Http/Controllers/V2/StarNewsController.php

@@ -55,8 +55,8 @@ class StarNewsController extends BaseController
     public function create(Request $request)
     {
         $validator = Validator::make($request->all(), [
-            'title' => 'required|string',
-            'content' => 'required|string',
+            'title' => 'required|string|max:30',
+            'content' => 'required|string|max:300',
             'cover_img' => 'required',
         ]);
         if ($validator->fails()) {
@@ -72,8 +72,8 @@ class StarNewsController extends BaseController
     {
         $validator = Validator::make($request->all(), [
             'id' => 'required|exists:star_news',
-            'title' => 'required|string',
-            'content' => 'required|string',
+            'title' => 'required|string|max:30',
+            'content' => 'required|string|max:300',
             'cover_img' => 'required',
         ]);
 

+ 33 - 0
database/migrations/2019_07_18_115357_update_content_to_star_news_table.php

@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class UpdateContentToStarNewsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('star_news', function (Blueprint $table) {
+            $table->text('content')->comment('文字说明')->change();
+
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('star_news', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 0 - 0
storage/.gitkeep