Add UIKit model, migration and controller

This commit is contained in:
Daniel Supernault 2020-04-26 23:28:24 -06:00
parent 591a192928
commit fcab5010d6
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
3 changed files with 70 additions and 0 deletions

View file

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

21
app/UIKit.php Normal file
View file

@ -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;
}
}

View file

@ -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');
}
}