visuddhinanda 3 лет назад
Родитель
Сommit
b46e93faad
1 измененных файлов с 58 добавлено и 0 удалено
  1. 58 0
      documents/laravel_quick_start.md

+ 58 - 0
documents/laravel_quick_start.md

@@ -0,0 +1,58 @@
+1. 建立表
+php artisan make:model Lesson -m
+
+2. 修改迁移文件,添加列
+
+
+3. 升级数据库
+php artisan migrate
+
+4. 降级
+
+php artisan migrate:rollback --step=1
+
+
+5. 升级数据库
+php artisan migrate
+
+6. 建立控制器
+
+php artisan make:controller --api --model=Lesson  LessonController
+
+7. 数据库查询
+
+        $table = new Tag();
+        $table = $table->where('name','aaa');
+        $count = $table->count();
+        // select count(*) where name = 'aaa';
+
+        $data = $table->select(['name','id'])->get();
+        // select name,id where name = 'aaa';
+        return $this->ok($data);
+
+        /*
+        ['rows'=>$data,'count'=>$count]
+        {
+            rows: data,
+            count: count,
+        }
+        */
+
+		/**
+ * GET tag/ -> index()
+ * GET tag/:id -> show()
+ * POST tag  -> store()
+ * PUT tag/:id -> update()
+ * DELETE tag/:id -> destroy()
+ */
+
+前端 api 配置
+
+.env
+
+ REACT_APP_API_HOST=http://127.0.0.1:8000/api/v2
+
+前端调用
+
+ApiFetch(`/progress?view=chapter-tag`)
+