Browse Source

Merge branch 'develop' of http://git.caihongxingqiu.net/rainbow/config-manage into develop

xielin 5 years ago
parent
commit
7b262fbcaa

+ 34 - 0
app/Http/Middleware/CorsMiddleware.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Closure;
+
+class CorsMiddleware
+{
+    /**
+     * Handle an incoming request.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \Closure  $next
+     * @return mixed
+     */
+    public function handle($request, Closure $next)
+    {
+        //Intercepts OPTIONS requests
+        if($request->isMethod('OPTIONS')) {
+            $response = response('', 200);
+        } else {
+            // Pass the request to the next middleware
+            $response = $next($request);
+        }
+
+        // Adds headers to the response
+        $response->header('Access-Control-Allow-Methods', 'HEAD, GET, POST, PUT, PATCH, DELETE');
+        $response->header('Access-Control-Allow-Headers', $request->header('Access-Control-Request-Headers'));
+        $response->header('Access-Control-Allow-Origin', '*');
+
+        // Sends it
+        return $response;
+    }
+}

+ 3 - 1
bootstrap/app.php

@@ -62,7 +62,9 @@ $app->singleton(
 | route or middleware that'll be assigned to some specific routes.
 | route or middleware that'll be assigned to some specific routes.
 |
 |
 */
 */
-
+ $app->middleware([
+    App\Http\Middleware\CorsMiddleware::class
+ ]);
  $app->routeMiddleware([
  $app->routeMiddleware([
      'auth' => App\Http\Middleware\Authenticate::class,
      'auth' => App\Http\Middleware\Authenticate::class,
      'jwt.chxq_auth' => App\Http\Middleware\JwtAuthMiddleware::class,
      'jwt.chxq_auth' => App\Http\Middleware\JwtAuthMiddleware::class,

+ 32 - 0
database/migrations/2019_08_14_011709_add_idx_status_to_star_news_table.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddIdxStatusToStarNewsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('star_news', function (Blueprint $table) {
+            $table->index('status','idx_status');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('star_news', function (Blueprint $table) {
+            //
+        });
+    }
+}