Browse Source

Merge branch 'develop'

wzq 5 years ago
parent
commit
784b45ea5b

+ 2 - 1
.rocketeer/hooks.php

@@ -28,7 +28,8 @@ return [
             'composer dumpautoload',
             'composer dumpautoload',
             'chmod -R 777 bootstrap',
             'chmod -R 777 bootstrap',
             'chmod -R 777 storage',
             'chmod -R 777 storage',
-            'chmod -R 777 public'
+            'chmod -R 777 public',
+            'service php-fpm reload'
         ],
         ],
         'cleanup' => [],
         'cleanup' => [],
     ],
     ],

+ 1 - 1
app/Http/Controllers/UploadController.php

@@ -23,7 +23,7 @@ class UploadController extends Controller
 //            //获取文件的绝对路径,但是获取到的在本地不能打开
 //            //获取文件的绝对路径,但是获取到的在本地不能打开
             $filePath = $request->file('image')->getRealPath();
             $filePath = $request->file('image')->getRealPath();
             //要保存的文件名 时间+扩展名
             //要保存的文件名 时间+扩展名
-            if (in_array($kuoname, ['jpg', 'jpeg', 'png'])) {
+            if (in_array($kuoname, ['jpg', 'jpeg','png'])) {
                 $width = Image::make($filePath)->width();
                 $width = Image::make($filePath)->width();
                 $height = Image::make($filePath)->height();
                 $height = Image::make($filePath)->height();
                 //要保存的文件名 时间+扩展名
                 //要保存的文件名 时间+扩展名

+ 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) {
+            //
+        });
+    }
+}