bd
This commit is contained in:
26
src/app/controllers/FormController.php
Normal file
26
src/app/controllers/FormController.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\app\controllers;
|
||||
|
||||
use itguild\forms\app\core\BaseController;
|
||||
|
||||
use itguild\forms\app\models\FormModel;
|
||||
use itguild\forms\debug\Debug;
|
||||
use itguild\forms\Form;
|
||||
|
||||
|
||||
class FormController extends BaseController
|
||||
{
|
||||
public function indexAction($id)
|
||||
{
|
||||
$form = FormModel::find($id);
|
||||
$fields = $form->fields;
|
||||
Debug::dd($fields);
|
||||
|
||||
}
|
||||
public function createFormAction()
|
||||
{
|
||||
$form = Form::Create([ 'title' => "dsds", 'status' => 1, 'params' => "", ]);
|
||||
}
|
||||
|
||||
}
|
16
src/app/controllers/FormInputController.php
Normal file
16
src/app/controllers/FormInputController.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\app\controllers;
|
||||
|
||||
use itguild\forms\app\core\BaseController;
|
||||
use itguild\forms\app\models\FormInputModel;
|
||||
use itguild\forms\debug\Debug;
|
||||
class FormInputController extends BaseController
|
||||
{
|
||||
public function indexAction($id)
|
||||
{
|
||||
Debug::prn(FormInputModel::find($id)->first());
|
||||
|
||||
}
|
||||
|
||||
}
|
16
src/app/controllers/FormResController.php
Normal file
16
src/app/controllers/FormResController.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\app\controllers;
|
||||
|
||||
use itguild\forms\app\core\BaseController;
|
||||
use itguild\forms\app\models\FormResModel;
|
||||
use itguild\forms\debug\Debug;
|
||||
class FormResController extends BaseController
|
||||
{
|
||||
public function indexAction($id)
|
||||
{
|
||||
Debug::prn(FormResModel::find($id)->first());
|
||||
|
||||
}
|
||||
|
||||
}
|
16
src/app/controllers/InputTypeController.php
Normal file
16
src/app/controllers/InputTypeController.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\app\controllers;
|
||||
|
||||
use itguild\forms\app\core\BaseController;
|
||||
use itguild\forms\app\models\InputTypeModel;
|
||||
use itguild\forms\debug\Debug;
|
||||
class InputTypeController extends BaseController
|
||||
{
|
||||
public function indexAction($id)
|
||||
{
|
||||
Debug::prn(InputTypeModel::find($id)->first());
|
||||
|
||||
}
|
||||
|
||||
}
|
16
src/app/controllers/InputValueController.php
Normal file
16
src/app/controllers/InputValueController.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\app\controllers;
|
||||
|
||||
use itguild\forms\app\core\BaseController;
|
||||
use itguild\forms\app\models\InputValueModel;
|
||||
use itguild\forms\debug\Debug;
|
||||
class InputValueController extends BaseController
|
||||
{
|
||||
public function indexAction($id)
|
||||
{
|
||||
Debug::prn(InputValueModel::find($id)->first());
|
||||
|
||||
}
|
||||
|
||||
}
|
23
src/app/models/FormInputModel.php
Normal file
23
src/app/models/FormInputModel.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\app\models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FormInputModel extends Model
|
||||
{
|
||||
protected $table = "form_input";
|
||||
|
||||
protected $fillable = [
|
||||
'form_id', 'input_type_id', 'params'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
|
||||
];
|
||||
|
||||
public function inputType()
|
||||
{
|
||||
return $this->hasOne(InputTypeModel::class, "id");
|
||||
}
|
||||
}
|
23
src/app/models/FormModel.php
Normal file
23
src/app/models/FormModel.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\app\models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FormModel extends Model
|
||||
{
|
||||
protected $table = "form";
|
||||
|
||||
protected $fillable = [
|
||||
'title', 'status', 'params'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
|
||||
];
|
||||
|
||||
public function fields()
|
||||
{
|
||||
return $this->hasMany(FormInputModel::class, "form_id");
|
||||
}
|
||||
}
|
18
src/app/models/FormResModel.php
Normal file
18
src/app/models/FormResModel.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\app\models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FormResModel extends Model
|
||||
{
|
||||
protected $table = "form_res";
|
||||
|
||||
protected $fillable = [
|
||||
'form_id', 'data'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
|
||||
];
|
||||
}
|
18
src/app/models/InputTypeModel.php
Normal file
18
src/app/models/InputTypeModel.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\app\models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class InputTypeModel extends Model
|
||||
{
|
||||
protected $table = "input_type";
|
||||
|
||||
protected $fillable = [
|
||||
'type', 'name', 'status'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
|
||||
];
|
||||
}
|
18
src/app/models/InputValueModel.php
Normal file
18
src/app/models/InputValueModel.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\app\models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class InputValueModel extends Model
|
||||
{
|
||||
protected $table = "input_value";
|
||||
|
||||
protected $fillable = [
|
||||
'form_input_id', 'value'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
|
||||
];
|
||||
}
|
33
src/migrations/FormsInputMigration.php
Normal file
33
src/migrations/FormsInputMigration.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\migrations;
|
||||
use Illuminate;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class FormsInputMigration extends Illuminate\Database\Migrations\Migration
|
||||
{
|
||||
|
||||
public static function up(): void
|
||||
{
|
||||
|
||||
Illuminate\Database\Capsule\Manager::schema()->create("form_input", function (Blueprint $table) {
|
||||
$table->id("id");
|
||||
$table->unsignedBigInteger('form_id');
|
||||
$table->unsignedBigInteger('input_type_id');
|
||||
$table->text('params');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('form_id');
|
||||
$table->index('input_type_id');
|
||||
$table->foreign('form_id', 'fk_form_input_form')->references('id')->on('form');
|
||||
$table->foreign('input_type_id', 'fk_form_input_input_type')->references('id')->on('input_type');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static function down(): void
|
||||
{
|
||||
Illuminate\Database\Capsule\Manager::schema()->drop("form_input");
|
||||
}
|
||||
|
||||
}
|
31
src/migrations/FormsMigration.php
Normal file
31
src/migrations/FormsMigration.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\migrations;
|
||||
use Illuminate;
|
||||
|
||||
class FormsMigration
|
||||
{
|
||||
|
||||
public static function up(): void
|
||||
{
|
||||
|
||||
Illuminate\Database\Capsule\Manager::schema()->create("form", function ($table) {
|
||||
$table->id('id');
|
||||
$table->string('title');
|
||||
$table->integer('status');
|
||||
$table->text('params')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
}
|
||||
public static function get()
|
||||
{
|
||||
return DB::forms('form_input')-> get();
|
||||
}
|
||||
|
||||
public static function down(): void
|
||||
{
|
||||
Illuminate\Database\Capsule\Manager::schema()->drop("form");
|
||||
}
|
||||
|
||||
}
|
28
src/migrations/FormsResMigration.php
Normal file
28
src/migrations/FormsResMigration.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\migrations;
|
||||
use Illuminate;
|
||||
|
||||
class FormsResMigration
|
||||
{
|
||||
|
||||
public static function up(): void
|
||||
{
|
||||
|
||||
Illuminate\Database\Capsule\Manager::schema()->create("form_res", function ($table) {
|
||||
$table->id('id');
|
||||
$table->unsignedBigInteger('form_id');
|
||||
$table->json('data');
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('form_id', 'fk_form_form')->references('id')->on('form');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static function down(): void
|
||||
{
|
||||
Illuminate\Database\Capsule\Manager::schema()->drop("form_res");
|
||||
}
|
||||
|
||||
}
|
25
src/migrations/InputsTypeMigration.php
Normal file
25
src/migrations/InputsTypeMigration.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\migrations;
|
||||
use Illuminate;
|
||||
|
||||
class InputsTypeMigration
|
||||
{
|
||||
public static function up(): void
|
||||
{
|
||||
|
||||
Illuminate\Database\Capsule\Manager::schema()->create("input_type", function ($table) {
|
||||
$table->id('id');
|
||||
$table->string('type');
|
||||
$table->string('name');
|
||||
$table->integer('status');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static function down(): void
|
||||
{
|
||||
Illuminate\Database\Capsule\Manager::schema()->drop("input_type");
|
||||
}
|
||||
|
||||
}
|
28
src/migrations/InputsValueMigrations.php
Normal file
28
src/migrations/InputsValueMigrations.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\migrations;
|
||||
use Illuminate;
|
||||
|
||||
class InputsValueMigrations
|
||||
{
|
||||
|
||||
public static function up(): void
|
||||
{
|
||||
|
||||
Illuminate\Database\Capsule\Manager::schema()->create("input_value", function ($table) {
|
||||
$table->id('id');
|
||||
$table->unsignedBigInteger('form_input_id');
|
||||
$table->string('value');
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('form_input_id', 'fk_form_input')->references('id')->on('form_input');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static function down(): void
|
||||
{
|
||||
Illuminate\Database\Capsule\Manager::schema()->drop("input_value");
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user