Kaynağa Gözat

添加登陆注册

chenxiqiang 6 yıl önce
ebeveyn
işleme
838de6db11

+ 34
- 0
manage-server/app/Http/Controllers/ClassifyController.php Dosyayı Görüntüle

@@ -0,0 +1,34 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Models\Classify;
7
+
8
+class ClassifyController extends Controller
9
+{
10
+    public function list(Request $request)
11
+    {
12
+        $classify_array = [];
13
+        $classifys = Classify::all();
14
+
15
+        $root = new Classify();
16
+        $root->id = 0;
17
+        $root->pid = 0;
18
+        $root->name = '/';
19
+        $classify_array[0] = $root;
20
+
21
+        foreach ($classifys as $classify) {
22
+            $classify_array[$classify->id] = $classify;
23
+        }
24
+
25
+        foreach ($classify_array as $key=>$value) {
26
+            $classify_array[$value->getPid()]->children[$key] = $value;
27
+        }
28
+
29
+        return response()->json([
30
+            "status" => 0,
31
+            "data" => $root
32
+        ]);
33
+    }
34
+}

+ 1
- 1
manage-server/app/Http/Controllers/CommonController.php Dosyayı Görüntüle

@@ -10,7 +10,6 @@ use App\Models\MaternityMatronOrder;
10 10
 use App\Models\Product;
11 11
 use App\Models\ProductOrder;
12 12
 use Illuminate\Http\Request;
13
-use Illuminate\Support\Facades\Log;
14 13
 
15 14
 class CommonController extends Controller
16 15
 {
@@ -27,6 +26,7 @@ class CommonController extends Controller
27 26
         $miniProgram = app("wechat.mini_program");
28 27
 
29 28
         $auth = $miniProgram->auth->session($code);
29
+        if($auth->open)
30 30
         return response()->json($auth);
31 31
     }
32 32
 

+ 15
- 0
manage-server/app/Models/Classify.php Dosyayı Görüntüle

@@ -0,0 +1,15 @@
1
+<?php
2
+
3
+namespace App\Models;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class Classify extends Model
8
+{
9
+    protected $fillable = [
10
+        'pid', // 父id
11
+        'name', // 名称
12
+    ];
13
+
14
+    protected $children = [];
15
+}

+ 33
- 0
manage-server/database/migrations/2018_08_20_014238_create_classifys_table.php Dosyayı Görüntüle

@@ -0,0 +1,33 @@
1
+<?php
2
+
3
+use Illuminate\Support\Facades\Schema;
4
+use Illuminate\Database\Schema\Blueprint;
5
+use Illuminate\Database\Migrations\Migration;
6
+
7
+class CreateClassifysTable extends Migration
8
+{
9
+    /**
10
+     * Run the migrations.
11
+     *
12
+     * @return void
13
+     */
14
+    public function up()
15
+    {
16
+        Schema::create('classifys', function (Blueprint $table) {
17
+            $table->increments('id');
18
+            $table->timestamps();
19
+            $table->unsignedInteger('pid'); // 父id
20
+            $table->string('name'); // 名称
21
+        });
22
+    }
23
+
24
+    /**
25
+     * Reverse the migrations.
26
+     *
27
+     * @return void
28
+     */
29
+    public function down()
30
+    {
31
+        Schema::dropIfExists('classifys');
32
+    }
33
+}

+ 2
- 0
manage-server/routes/api.php Dosyayı Görüntüle

@@ -27,6 +27,8 @@ Route::post('/{order_type}/status', 'CommonController@status');
27 27
 Route::get('/{order_type}/{id}', 'CommonController@get')->where('id', '[0-9]+');;
28 28
 Route::delete('/{order_type}/{id}', 'CommonController@delete');
29 29
 
30
+Route::get('/classify', 'ClassifyController@list');
31
+
30 32
 Route::get('/campaigns', 'CampaignController@list');
31 33
 
32 34
 Route::get('/products', 'ProductController@list');

Loading…
İptal
Kaydet