瀏覽代碼

Add UIKit model, migration and controller

Daniel Supernault 5 年之前
父節點
當前提交
fcab5010d6
共有 3 個文件被更改,包括 70 次插入0 次删除
  1. 10 0
      app/Http/Controllers/UIKitController.php
  2. 21 0
      app/UIKit.php
  3. 39 0
      database/migrations/2020_04_13_045435_create_uikit_table.php

+ 10 - 0
app/Http/Controllers/UIKitController.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+
+class UIKitController extends Controller
+{
+    //
+}

+ 21 - 0
app/UIKit.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class UIKit extends Model
+{
+    protected $table = 'uikit';
+    protected $fillable = [
+    	'k',
+    	'v',
+    	'defv',
+    	'dhis'
+    ];
+
+    public static function section($k)
+    {
+    	return (new self)->where('k', $k)->first()->v;
+    }
+}

+ 39 - 0
database/migrations/2020_04_13_045435_create_uikit_table.php

@@ -0,0 +1,39 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateUikitTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('uikit', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->string('k')->unique()->index();
+            $table->text('v')->nullable();
+            $table->json('meta')->nullable();
+            // default value for rollbacks
+            $table->text('defv')->nullable();
+            // delta history
+            $table->text('dhis')->nullable();
+            $table->unsignedInteger('edit_count')->default(0)->nullable();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('uikit');
+    }
+}