This commit is contained in:
kali 2024-03-29 17:47:46 +03:00
parent 74719c7250
commit 432b2547cf
21 changed files with 494 additions and 200 deletions

View File

@ -1,96 +0,0 @@
<?php
use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Extension\SandboxExtension;
use Twig\Markup;
use Twig\Sandbox\SecurityError;
use Twig\Sandbox\SecurityNotAllowedTagError;
use Twig\Sandbox\SecurityNotAllowedFilterError;
use Twig\Sandbox\SecurityNotAllowedFunctionError;
use Twig\Source;
use Twig\Template;
/* main/index.html.twig */
class __TwigTemplate_09ccf709a9c7f01a6f9c635608c9f350 extends Template
{
private $source;
private $macros = [];
public function __construct(Environment $env)
{
parent::__construct($env);
$this->source = $this->getSourceContext();
$this->blocks = [
'title' => [$this, 'block_title'],
'content' => [$this, 'block_content'],
];
}
protected function doGetParent(array $context)
{
// line 1
return "layouts/simple.html.twig";
}
protected function doDisplay(array $context, array $blocks = [])
{
$macros = $this->macros;
$this->parent = $this->loadTemplate("layouts/simple.html.twig", "main/index.html.twig", 1);
$this->parent->display($context, array_merge($this->blocks, $blocks));
}
// line 3
public function block_title($context, array $blocks = [])
{
$macros = $this->macros;
echo twig_escape_filter($this->env, ($context["title"] ?? null), "html", null, true);
}
// line 5
public function block_content($context, array $blocks = [])
{
$macros = $this->macros;
// line 6
echo " ";
echo twig_escape_filter($this->env, $this->env->getFunction('create_form')->getCallable()(), "html", null, true);
echo "
";
// line 7
echo twig_escape_filter($this->env, ($context["content"] ?? null), "html", null, true);
echo "
";
}
/**
* @codeCoverageIgnore
*/
public function getTemplateName()
{
return "main/index.html.twig";
}
/**
* @codeCoverageIgnore
*/
public function isTraitable()
{
return false;
}
/**
* @codeCoverageIgnore
*/
public function getDebugInfo()
{
return array ( 63 => 7, 58 => 6, 54 => 5, 47 => 3, 36 => 1,);
}
public function getSourceContext()
{
return new Source("", "main/index.html.twig", "/home/kali/php/untitled/views/main/index.html.twig");
}
}

View File

@ -1,101 +0,0 @@
<?php
use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Extension\SandboxExtension;
use Twig\Markup;
use Twig\Sandbox\SecurityError;
use Twig\Sandbox\SecurityNotAllowedTagError;
use Twig\Sandbox\SecurityNotAllowedFilterError;
use Twig\Sandbox\SecurityNotAllowedFunctionError;
use Twig\Source;
use Twig\Template;
/* layouts/simple.html.twig */
class __TwigTemplate_e48551b2ca758109aa7de7556ee07a2e extends Template
{
private $source;
private $macros = [];
public function __construct(Environment $env)
{
parent::__construct($env);
$this->source = $this->getSourceContext();
$this->parent = false;
$this->blocks = [
'title' => [$this, 'block_title'],
'content' => [$this, 'block_content'],
];
}
protected function doDisplay(array $context, array $blocks = [])
{
$macros = $this->macros;
// line 1
echo "<!DOCTYPE html>
<html lang=\"en\">
<head>
<meta charset=\"UTF-8\">
<title>";
// line 5
$this->displayBlock('title', $context, $blocks);
echo " </title>
<link rel=\"stylesheet\" href=\"vendor/twbs/bootstrap/dist/css/bootstrap.css\">
<link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css\" rel=\"stylesheet\"
integrity=\"sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN\" crossorigin=\"anonymous\" />
</head>
<body>
<div class=\"container\">
<div class=\"row\">
<div class=\"col-12\">
";
// line 15
$this->displayBlock('content', $context, $blocks);
// line 16
echo " </div>
</div>
</div>
</body>
</html>";
}
// line 5
public function block_title($context, array $blocks = [])
{
$macros = $this->macros;
}
// line 15
public function block_content($context, array $blocks = [])
{
$macros = $this->macros;
}
/**
* @codeCoverageIgnore
*/
public function getTemplateName()
{
return "layouts/simple.html.twig";
}
/**
* @codeCoverageIgnore
*/
public function getDebugInfo()
{
return array ( 76 => 15, 70 => 5, 60 => 16, 58 => 15, 45 => 5, 39 => 1,);
}
public function getSourceContext()
{
return new Source("", "layouts/simple.html.twig", "/home/kali/php/untitled/views/layouts/simple.html.twig");
}
}

View File

@ -17,6 +17,7 @@
"craft-group/phroute": "^2.1",
"twig/twig": "^3.0",
"illuminate/database": "^11.0",
"vlucas/phpdotenv": "^5.6"
"vlucas/phpdotenv": "^5.6",
"illuminate/filesystem": "^11.1"
}
}

133
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "857445edf4547c968bb438b2f705ab3b",
"content-hash": "8425ba8fa8c3256af1097d721de637ad",
"packages": [
{
"name": "brick/math",
@ -603,6 +603,73 @@
},
"time": "2024-03-19T20:07:36+00:00"
},
{
"name": "illuminate/filesystem",
"version": "v11.1.1",
"source": {
"type": "git",
"url": "https://github.com/illuminate/filesystem.git",
"reference": "5467e5c884a78847321926c748294c06f191027f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/filesystem/zipball/5467e5c884a78847321926c748294c06f191027f",
"reference": "5467e5c884a78847321926c748294c06f191027f",
"shasum": ""
},
"require": {
"illuminate/collections": "^11.0",
"illuminate/contracts": "^11.0",
"illuminate/macroable": "^11.0",
"illuminate/support": "^11.0",
"php": "^8.2",
"symfony/finder": "^7.0"
},
"suggest": {
"ext-fileinfo": "Required to use the Filesystem class.",
"ext-ftp": "Required to use the Flysystem FTP driver.",
"ext-hash": "Required to use the Filesystem class.",
"illuminate/http": "Required for handling uploaded files (^7.0).",
"league/flysystem": "Required to use the Flysystem local driver (^3.0.16).",
"league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^3.0).",
"league/flysystem-ftp": "Required to use the Flysystem FTP driver (^3.0).",
"league/flysystem-sftp-v3": "Required to use the Flysystem SFTP driver (^3.0).",
"psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).",
"symfony/filesystem": "Required to enable support for relative symbolic links (^7.0).",
"symfony/mime": "Required to enable support for guessing extensions (^7.0)."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "11.x-dev"
}
},
"autoload": {
"files": [
"functions.php"
],
"psr-4": {
"Illuminate\\Filesystem\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "The Illuminate Filesystem package.",
"homepage": "https://laravel.com",
"support": {
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2024-03-12T11:29:47+00:00"
},
{
"name": "illuminate/macroable",
"version": "v11.0.8",
@ -1157,6 +1224,70 @@
],
"time": "2024-03-02T12:46:12+00:00"
},
{
"name": "symfony/finder",
"version": "v7.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "6e5688d69f7cfc4ed4a511e96007e06c2d34ce56"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/6e5688d69f7cfc4ed4a511e96007e06c2d34ce56",
"reference": "6e5688d69f7cfc4ed4a511e96007e06c2d34ce56",
"shasum": ""
},
"require": {
"php": ">=8.2"
},
"require-dev": {
"symfony/filesystem": "^6.4|^7.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Finder\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/v7.0.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2023-10-31T17:59:56+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.29.0",

View File

@ -1,6 +1,7 @@
<?php
use itguild\forms\migrations\UserMigration;
use Illuminate\Filesystem\Filesystem;
const ROOT_PATH = __DIR__;
@ -8,4 +9,22 @@ require_once "vendor/autoload.php";
require_once "bootstrap/db.php";
UserMigration::up();
//$fileSystem = new Filesystem();
//
//$migration = new \Illuminate\Database\Migrations\MigrationCreator($fileSystem, "migrations/stubs");
//
////try {
//// $migration->create("some", "migrations", "my");
////} catch (Exception $e) {
//// var_dump($e->getMessage());
////}
//$rep = new \Illuminate\Database\Migrations\DatabaseMigrationRepository();
//$migrator = new \Illuminate\Database\Migrations\Migrator()
//UserMigration::up();
//\itguild\forms\migrations\FormsMigration::up();
//\itguild\forms\migrations\InputsTypeMigration::up();
//\itguild\forms\migrations\FormsInputMigration::up();
//\itguild\forms\migrations\FormsResMigration::up();
//\itguild\forms\migrations\InputsValueMigrations::up();
DB::forms('form_input')-> get();

View File

@ -18,6 +18,11 @@ $router->get('/', [\itguild\forms\app\controllers\MainController::class, 'indexA
$router->get('/example', [\itguild\forms\app\controllers\MainController::class, 'exampleAction']);
$router->get('/create-user', [\itguild\forms\app\controllers\UserController::class, 'createUserAction']);
$router->get('/get-user/{id}', [\itguild\forms\app\controllers\UserController::class, 'getUserAction']);
$router->get("/form/{id}", [\itguild\forms\app\controllers\FormController::class, "indexAction"]);
$router->get("/form-input/{id}", [\itguild\forms\app\controllers\FormInputController::class, "indexAction"]);
$router->get("/form-res/{id}", [\itguild\forms\app\controllers\FormResController::class, "indexAction"]);
$router->get("/input-type/{id}", [\itguild\forms\app\controllers\InputTypeController::class, "indexAction"]);
$router->get("/input-value/{id}", [\itguild\forms\app\controllers\InputValueController::class, "indexAction"]);
$dispatcher = new Phroute\Phroute\Dispatcher($router->getData());
$response = $dispatcher->dispatch($_SERVER['REQUEST_METHOD'], parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));

View 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' => "", ]);
}
}

View 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());
}
}

View 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());
}
}

View 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());
}
}

View 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());
}
}

View 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");
}
}

View 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");
}
}

View 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 = [
];
}

View 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 = [
];
}

View 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 = [
];
}

View 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");
}
}

View 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");
}
}

View 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");
}
}

View 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");
}
}

View 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");
}
}