[TASK] migration working
This commit is contained in:
parent
42c50342ab
commit
699709110e
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@
|
||||
|
||||
data/
|
||||
!data/*.example
|
||||
/var
|
||||
|
||||
@ -16,7 +16,10 @@
|
||||
"slim/twig-view": "^3.0",
|
||||
"php-di/php-di": "^6.0",
|
||||
"symfony/webpack-encore-bundle": "^1.7",
|
||||
"illuminate/database": "^6.10"
|
||||
"illuminate/database": "^6.10",
|
||||
"phpoffice/phpspreadsheet": "^1.10",
|
||||
"monolog/monolog": "^2.0",
|
||||
"illuminate/filesystem": "^6.12"
|
||||
},
|
||||
"require-dev": {
|
||||
"squizlabs/php_codesniffer": "^3.5",
|
||||
|
||||
441
composer.lock
generated
441
composer.lock
generated
@ -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": "a3595f1a4e17edea63911463f15936e0",
|
||||
"content-hash": "6d0bc9534e2727a4625cf476c41b4682",
|
||||
"packages": [
|
||||
{
|
||||
"name": "catfan/medoo",
|
||||
@ -331,6 +331,58 @@
|
||||
],
|
||||
"time": "2020-01-07T14:13:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/filesystem",
|
||||
"version": "v6.12.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/filesystem.git",
|
||||
"reference": "f94e71adfd9d4c9a8faaf5b3fe8e4c5f4be4c536"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/filesystem/zipball/f94e71adfd9d4c9a8faaf5b3fe8e4c5f4be4c536",
|
||||
"reference": "f94e71adfd9d4c9a8faaf5b3fe8e4c5f4be4c536",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/contracts": "^6.0",
|
||||
"illuminate/support": "^6.0",
|
||||
"php": "^7.2",
|
||||
"symfony/finder": "^4.3.4"
|
||||
},
|
||||
"suggest": {
|
||||
"league/flysystem": "Required to use the Flysystem local and FTP drivers (^1.0).",
|
||||
"league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^1.0).",
|
||||
"league/flysystem-cached-adapter": "Required to use the Flysystem cache (^1.0).",
|
||||
"league/flysystem-sftp": "Required to use the Flysystem SFTP driver (^1.0).",
|
||||
"psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0)"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "6.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"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",
|
||||
"time": "2020-01-21T13:56:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/support",
|
||||
"version": "v6.10.0",
|
||||
@ -450,6 +502,251 @@
|
||||
],
|
||||
"time": "2018-03-21T22:21:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "markbaker/complex",
|
||||
"version": "1.4.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/MarkBaker/PHPComplex.git",
|
||||
"reference": "1ea674a8308baf547cbcbd30c5fcd6d301b7c000"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/1ea674a8308baf547cbcbd30c5fcd6d301b7c000",
|
||||
"reference": "1ea674a8308baf547cbcbd30c5fcd6d301b7c000",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.6.0|^7.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3",
|
||||
"phpcompatibility/php-compatibility": "^8.0",
|
||||
"phpdocumentor/phpdocumentor": "2.*",
|
||||
"phploc/phploc": "2.*",
|
||||
"phpmd/phpmd": "2.*",
|
||||
"phpunit/phpunit": "^4.8.35|^5.4.0",
|
||||
"sebastian/phpcpd": "2.*",
|
||||
"squizlabs/php_codesniffer": "^3.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Complex\\": "classes/src/"
|
||||
},
|
||||
"files": [
|
||||
"classes/src/functions/abs.php",
|
||||
"classes/src/functions/acos.php",
|
||||
"classes/src/functions/acosh.php",
|
||||
"classes/src/functions/acot.php",
|
||||
"classes/src/functions/acoth.php",
|
||||
"classes/src/functions/acsc.php",
|
||||
"classes/src/functions/acsch.php",
|
||||
"classes/src/functions/argument.php",
|
||||
"classes/src/functions/asec.php",
|
||||
"classes/src/functions/asech.php",
|
||||
"classes/src/functions/asin.php",
|
||||
"classes/src/functions/asinh.php",
|
||||
"classes/src/functions/atan.php",
|
||||
"classes/src/functions/atanh.php",
|
||||
"classes/src/functions/conjugate.php",
|
||||
"classes/src/functions/cos.php",
|
||||
"classes/src/functions/cosh.php",
|
||||
"classes/src/functions/cot.php",
|
||||
"classes/src/functions/coth.php",
|
||||
"classes/src/functions/csc.php",
|
||||
"classes/src/functions/csch.php",
|
||||
"classes/src/functions/exp.php",
|
||||
"classes/src/functions/inverse.php",
|
||||
"classes/src/functions/ln.php",
|
||||
"classes/src/functions/log2.php",
|
||||
"classes/src/functions/log10.php",
|
||||
"classes/src/functions/negative.php",
|
||||
"classes/src/functions/pow.php",
|
||||
"classes/src/functions/rho.php",
|
||||
"classes/src/functions/sec.php",
|
||||
"classes/src/functions/sech.php",
|
||||
"classes/src/functions/sin.php",
|
||||
"classes/src/functions/sinh.php",
|
||||
"classes/src/functions/sqrt.php",
|
||||
"classes/src/functions/tan.php",
|
||||
"classes/src/functions/tanh.php",
|
||||
"classes/src/functions/theta.php",
|
||||
"classes/src/operations/add.php",
|
||||
"classes/src/operations/subtract.php",
|
||||
"classes/src/operations/multiply.php",
|
||||
"classes/src/operations/divideby.php",
|
||||
"classes/src/operations/divideinto.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Mark Baker",
|
||||
"email": "mark@lange.demon.co.uk"
|
||||
}
|
||||
],
|
||||
"description": "PHP Class for working with complex numbers",
|
||||
"homepage": "https://github.com/MarkBaker/PHPComplex",
|
||||
"keywords": [
|
||||
"complex",
|
||||
"mathematics"
|
||||
],
|
||||
"time": "2018-10-13T23:28:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "markbaker/matrix",
|
||||
"version": "1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/MarkBaker/PHPMatrix.git",
|
||||
"reference": "5348c5a67e3b75cd209d70103f916a93b1f1ed21"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/5348c5a67e3b75cd209d70103f916a93b1f1ed21",
|
||||
"reference": "5348c5a67e3b75cd209d70103f916a93b1f1ed21",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.6.0|^7.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
|
||||
"phpcompatibility/php-compatibility": "dev-master",
|
||||
"phploc/phploc": "^4",
|
||||
"phpmd/phpmd": "dev-master",
|
||||
"phpunit/phpunit": "^5.7",
|
||||
"sebastian/phpcpd": "^3.0",
|
||||
"squizlabs/php_codesniffer": "^3.0@dev"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Matrix\\": "classes/src/"
|
||||
},
|
||||
"files": [
|
||||
"classes/src/functions/adjoint.php",
|
||||
"classes/src/functions/antidiagonal.php",
|
||||
"classes/src/functions/cofactors.php",
|
||||
"classes/src/functions/determinant.php",
|
||||
"classes/src/functions/diagonal.php",
|
||||
"classes/src/functions/identity.php",
|
||||
"classes/src/functions/inverse.php",
|
||||
"classes/src/functions/minors.php",
|
||||
"classes/src/functions/trace.php",
|
||||
"classes/src/functions/transpose.php",
|
||||
"classes/src/operations/add.php",
|
||||
"classes/src/operations/directsum.php",
|
||||
"classes/src/operations/subtract.php",
|
||||
"classes/src/operations/multiply.php",
|
||||
"classes/src/operations/divideby.php",
|
||||
"classes/src/operations/divideinto.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Mark Baker",
|
||||
"email": "mark@lange.demon.co.uk"
|
||||
}
|
||||
],
|
||||
"description": "PHP Class for working with matrices",
|
||||
"homepage": "https://github.com/MarkBaker/PHPMatrix",
|
||||
"keywords": [
|
||||
"mathematics",
|
||||
"matrix",
|
||||
"vector"
|
||||
],
|
||||
"time": "2019-10-06T11:29:25+00:00"
|
||||
},
|
||||
{
|
||||
"name": "monolog/monolog",
|
||||
"version": "2.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Seldaek/monolog.git",
|
||||
"reference": "c861fcba2ca29404dc9e617eedd9eff4616986b8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/c861fcba2ca29404dc9e617eedd9eff4616986b8",
|
||||
"reference": "c861fcba2ca29404dc9e617eedd9eff4616986b8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2",
|
||||
"psr/log": "^1.0.1"
|
||||
},
|
||||
"provide": {
|
||||
"psr/log-implementation": "1.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
|
||||
"doctrine/couchdb": "~1.0@dev",
|
||||
"elasticsearch/elasticsearch": "^6.0",
|
||||
"graylog2/gelf-php": "^1.4.2",
|
||||
"jakub-onderka/php-parallel-lint": "^0.9",
|
||||
"php-amqplib/php-amqplib": "~2.4",
|
||||
"php-console/php-console": "^3.1.3",
|
||||
"phpspec/prophecy": "^1.6.1",
|
||||
"phpunit/phpunit": "^8.3",
|
||||
"predis/predis": "^1.1",
|
||||
"rollbar/rollbar": "^1.3",
|
||||
"ruflin/elastica": ">=0.90 <3.0",
|
||||
"swiftmailer/swiftmailer": "^5.3|^6.0"
|
||||
},
|
||||
"suggest": {
|
||||
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
|
||||
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
|
||||
"elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client",
|
||||
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
|
||||
"ext-mbstring": "Allow to work properly with unicode symbols",
|
||||
"ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)",
|
||||
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
|
||||
"mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)",
|
||||
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
|
||||
"php-console/php-console": "Allow sending log messages to Google Chrome",
|
||||
"rollbar/rollbar": "Allow sending log messages to Rollbar",
|
||||
"ruflin/elastica": "Allow sending log messages to an Elastic Search server"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Monolog\\": "src/Monolog"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jordi Boggiano",
|
||||
"email": "j.boggiano@seld.be",
|
||||
"homepage": "http://seld.be"
|
||||
}
|
||||
],
|
||||
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
|
||||
"homepage": "http://github.com/Seldaek/monolog",
|
||||
"keywords": [
|
||||
"log",
|
||||
"logging",
|
||||
"psr-3"
|
||||
],
|
||||
"time": "2019-12-20T14:22:59+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nesbot/carbon",
|
||||
"version": "2.28.0",
|
||||
@ -761,6 +1058,99 @@
|
||||
],
|
||||
"time": "2019-09-26T11:24:58+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpoffice/phpspreadsheet",
|
||||
"version": "1.10.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
|
||||
"reference": "1648dc9ebef6ebe0c5a172e16cf66732918416e0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/1648dc9ebef6ebe0c5a172e16cf66732918416e0",
|
||||
"reference": "1648dc9ebef6ebe0c5a172e16cf66732918416e0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-ctype": "*",
|
||||
"ext-dom": "*",
|
||||
"ext-fileinfo": "*",
|
||||
"ext-gd": "*",
|
||||
"ext-iconv": "*",
|
||||
"ext-libxml": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-simplexml": "*",
|
||||
"ext-xml": "*",
|
||||
"ext-xmlreader": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"ext-zip": "*",
|
||||
"ext-zlib": "*",
|
||||
"markbaker/complex": "^1.4",
|
||||
"markbaker/matrix": "^1.2",
|
||||
"php": "^7.1",
|
||||
"psr/simple-cache": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"dompdf/dompdf": "^0.8.3",
|
||||
"friendsofphp/php-cs-fixer": "^2.16",
|
||||
"jpgraph/jpgraph": "^4.0",
|
||||
"mpdf/mpdf": "^8.0",
|
||||
"phpcompatibility/php-compatibility": "^9.3",
|
||||
"phpunit/phpunit": "^7.5",
|
||||
"squizlabs/php_codesniffer": "^3.5",
|
||||
"tecnickcom/tcpdf": "^6.3"
|
||||
},
|
||||
"suggest": {
|
||||
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
|
||||
"jpgraph/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
|
||||
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
|
||||
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Maarten Balliauw",
|
||||
"homepage": "https://blog.maartenballiauw.be"
|
||||
},
|
||||
{
|
||||
"name": "Mark Baker",
|
||||
"homepage": "https://markbakeruk.net"
|
||||
},
|
||||
{
|
||||
"name": "Franck Lefevre",
|
||||
"homepage": "https://rootslabs.net"
|
||||
},
|
||||
{
|
||||
"name": "Erik Tilt"
|
||||
},
|
||||
{
|
||||
"name": "Adrien Crivelli"
|
||||
}
|
||||
],
|
||||
"description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
|
||||
"homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
|
||||
"keywords": [
|
||||
"OpenXML",
|
||||
"excel",
|
||||
"gnumeric",
|
||||
"ods",
|
||||
"php",
|
||||
"spreadsheet",
|
||||
"xls",
|
||||
"xlsx"
|
||||
],
|
||||
"time": "2019-12-01T23:13:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpoption/phpoption",
|
||||
"version": "1.7.2",
|
||||
@ -1953,6 +2343,55 @@
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2019-11-26T23:25:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/finder",
|
||||
"version": "v4.4.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/finder.git",
|
||||
"reference": "3a50be43515590faf812fbd7708200aabc327ec3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/finder/zipball/3a50be43515590faf812fbd7708200aabc327ec3",
|
||||
"reference": "3a50be43515590faf812fbd7708200aabc327ec3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.4-dev"
|
||||
}
|
||||
},
|
||||
"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": "Symfony Finder Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2020-01-04T13:00:46+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/http-foundation",
|
||||
"version": "v5.0.2",
|
||||
|
||||
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
|
||||
class InitializeDatabase extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$builder = Capsule::schema();
|
||||
|
||||
$builder->create(
|
||||
'dimensions',
|
||||
function ($table) {
|
||||
$table->increments('id');
|
||||
$table->string('name')->unique();
|
||||
$table->string('short')->unique();
|
||||
}
|
||||
);
|
||||
|
||||
$builder->create(
|
||||
'groups',
|
||||
function ($table) {
|
||||
$table->increments('id');
|
||||
$table->string('name')->unique();
|
||||
}
|
||||
);
|
||||
|
||||
$builder->create(
|
||||
'articles',
|
||||
function ($table) {
|
||||
$table->increments('id');
|
||||
$table->string('name')->unique();
|
||||
$table->string('short')->unique();
|
||||
$table->unsignedInteger('group_id');
|
||||
$table->foreign('group_id')->references('id')->on('groups');
|
||||
$table->float('content_size');
|
||||
$table->float('portion_size');
|
||||
$table->float('portion_price');
|
||||
$table->unsignedInteger('content_dimension');
|
||||
$table->foreign('content_dimension')->references('id')->on('dimensions');
|
||||
$table->unsignedInteger('portion_dimension');
|
||||
$table->foreign('portion_dimension')->references('id')->on('dimensions');
|
||||
|
||||
$table->timestamps();
|
||||
}
|
||||
);
|
||||
|
||||
$builder->create(
|
||||
'sets',
|
||||
function ($table) {
|
||||
$table->increments('id');
|
||||
$table->string('name')->unique();
|
||||
|
||||
$table->timestamps();
|
||||
}
|
||||
);
|
||||
|
||||
$builder->create(
|
||||
'set_article',
|
||||
function ($table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('order');
|
||||
$table->unsignedInteger('set_id');
|
||||
$table->foreign('set_id')->references('id')->on('sets');
|
||||
$table->unsignedInteger('article_id');
|
||||
$table->foreign('article_id')->references('id')->on('articles');
|
||||
|
||||
$table->timestamps();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
}
|
||||
42
src/Controller/DatabaseController.php
Normal file
42
src/Controller/DatabaseController.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Chrosey\Inventur\Controller;
|
||||
|
||||
use Illuminate\Database\Migrations\DatabaseMigrationRepository;
|
||||
use Illuminate\Database\Migrations\Migrator;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Slim\Psr7\Stream;
|
||||
|
||||
class DatabaseController
|
||||
{
|
||||
protected $container;
|
||||
|
||||
function __construct(ContainerInterface $container)
|
||||
{
|
||||
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
function migrate($request, $response, $args)
|
||||
{
|
||||
$capsule = $this->container->get('db')->getDatabaseManager();
|
||||
$repository = new DatabaseMigrationRepository($capsule, 'migrations');
|
||||
if (!$repository->repositoryExists()) {
|
||||
$repository->createRepository();
|
||||
}
|
||||
|
||||
$migrationFilesPath = __DIR__ . '/../../database/migrations/';
|
||||
$fs = new Filesystem();
|
||||
|
||||
$migrator = new Migrator($repository, $capsule, $fs);
|
||||
|
||||
$files = $fs->files($migrationFilesPath);
|
||||
|
||||
$migrator->run($files);
|
||||
}
|
||||
|
||||
function getMigrations()
|
||||
{
|
||||
}
|
||||
}
|
||||
73
src/Controller/SpreadsheetController.php
Normal file
73
src/Controller/SpreadsheetController.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace Chrosey\Inventur\Controller;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
use Slim\Psr7\Stream;
|
||||
|
||||
class SpreadsheetController
|
||||
{
|
||||
protected $spreadsheet;
|
||||
protected $container;
|
||||
|
||||
function __construct(ContainerInterface $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
|
||||
$this->spreadsheet = new Spreadsheet();
|
||||
$this->spreadsheet->getProperties()
|
||||
->setCreator("Christian Seyfferth")
|
||||
->setLastModifiedBy("hristian Seyfferth")
|
||||
->setTitle("Inventur Tabelle")
|
||||
->setSubject("Inventur Tabelle")
|
||||
->setDescription("Inventur Tabelle, generated using PHP classes.")
|
||||
->setKeywords("office 2016 openxml php")
|
||||
->setCategory("Test result file");
|
||||
}
|
||||
|
||||
function create($request, $response, $args)
|
||||
{
|
||||
$this->getTemplate();
|
||||
|
||||
$path = $this->container->get('data_directory');
|
||||
|
||||
$writer = new Xlsx($this->spreadsheet);
|
||||
$writer->save($path . 'template.xlsx');
|
||||
|
||||
return $response->withHeader('Location', "excel/download")
|
||||
->withStatus(200);
|
||||
}
|
||||
|
||||
function getTemplate()
|
||||
{
|
||||
$sheet = $this->spreadsheet->getActiveSheet();
|
||||
$sheet->setCellValue('A1', 'Template !');
|
||||
}
|
||||
|
||||
function getInventurTabelle()
|
||||
{
|
||||
}
|
||||
|
||||
function download($request, $response, $args)
|
||||
{
|
||||
$file = $this->container->get('data_directory') . 'template.xlsx';
|
||||
$fh = fopen($file, 'rb');
|
||||
|
||||
$stream = new Stream($fh);
|
||||
|
||||
$response = $response
|
||||
->withHeader('Content-Description', 'File Transfer')
|
||||
->withHeader('Content-Type', 'application/force-download')
|
||||
->withHeader('Content-Type', 'application/octet-stream')
|
||||
->withHeader('Content-Type', 'application/download')
|
||||
->withHeader('Content-Disposition', 'attachment;filename="' . basename($file) . '"')
|
||||
->withHeader('Expires', '0')
|
||||
->withHeader('Cache-Control', 'must-revalidate')
|
||||
->withHeader('Pragma', 'public')
|
||||
->withBody($stream);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
use DI\Container;
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Logger;
|
||||
use Slim\Factory\AppFactory;
|
||||
use Slim\Views\Twig;
|
||||
use Slim\Views\TwigMiddleware;
|
||||
@ -37,7 +39,15 @@ $container->set('db', static function () {
|
||||
return $capsule;
|
||||
});
|
||||
|
||||
$container->set('log', static function() {
|
||||
$log = new Logger('inventur');
|
||||
$log->pushHandler(new StreamHandler(__DIR__.'/../var/logs/app.log', Logger::WARNING));
|
||||
|
||||
return $log;
|
||||
});
|
||||
|
||||
$container->set('upload_directory', __DIR__ . '/../data/uploads');
|
||||
$container->set('data_directory', __DIR__ . '/../data/');
|
||||
|
||||
$app = AppFactory::create();
|
||||
|
||||
|
||||
127
src/routes.php
127
src/routes.php
@ -2,11 +2,13 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Chrosey\Inventur\Controller\DatabaseController;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Slim\Psr7\Stream;
|
||||
use Slim\Psr7\UploadedFile;
|
||||
use Slim\Routing\RouteCollectorProxy;
|
||||
use Chrosey\Inventur\Controller\SpreadsheetController;
|
||||
|
||||
$app->get('/', function (Request $request, Response $response, $args) {
|
||||
return $this->get('view')->render($response, 'frontend.html', []);
|
||||
@ -48,8 +50,133 @@ $app->group('/api', function (RouteCollectorProxy $group): void {
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
||||
$group->get('/excel', SpreadsheetController::class . ':create');
|
||||
$group->get('/excel/download', SpreadsheetController::class . ':download');
|
||||
});
|
||||
|
||||
$app->get('/migrate', DatabaseController::class . ':migrate')->setName('migrations');
|
||||
|
||||
$app->get('/seed', function (Request $request, Response $response, $args) {
|
||||
$db = $this->get('db');
|
||||
|
||||
if ($db::schema()->hasTable('dimensions')) {
|
||||
$entries = [
|
||||
[
|
||||
'name' => 'Liter',
|
||||
'short' => 'l'
|
||||
], [
|
||||
'name' => 'Stück',
|
||||
'short' => 'Stk'
|
||||
], [
|
||||
'name' => 'Flasche',
|
||||
'short' => 'Fl'
|
||||
], [
|
||||
'name' => 'Glas',
|
||||
'short' => 'Gl'
|
||||
], [
|
||||
'name' => 'Tasse',
|
||||
'short' => 'T'
|
||||
]
|
||||
];
|
||||
foreach ($entries as $item) {
|
||||
try {
|
||||
$db->table('dimensions')->insert($item);
|
||||
} catch (\Throwable $th) {
|
||||
$this->get('log')->error($th);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($db::schema()->hasTable('group')) {
|
||||
$entries = [
|
||||
[
|
||||
'name' => 'Bier'
|
||||
], [
|
||||
'name' => 'afG Gastro'
|
||||
], [
|
||||
'name' => 'afG offen'
|
||||
], [
|
||||
'name' => 'Wein und Sekt'
|
||||
], [
|
||||
'name' => 'Fingerfood'
|
||||
], [
|
||||
'name' => 'Heißgetränke'
|
||||
]
|
||||
];
|
||||
|
||||
foreach ($entries as $item) {
|
||||
try {
|
||||
$db->table('group')->insert($item);
|
||||
} catch (\Throwable $th) {
|
||||
$this->get('log')->error($th);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($db::schema()->hasTable('sets')) {
|
||||
$entries = [
|
||||
[
|
||||
'name' => 'UG'
|
||||
], [
|
||||
'name' => 'mobile'
|
||||
], [
|
||||
'name' => 'Studio'
|
||||
], [
|
||||
'name' => 'Domstufen'
|
||||
]
|
||||
];
|
||||
|
||||
foreach ($entries as $item) {
|
||||
try {
|
||||
$db->table('sets')->insert($item);
|
||||
} catch (\Throwable $th) {
|
||||
$this->get('log')->error($th);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($db::schema()->hasTable('articles')) {
|
||||
$file = file_get_contents(__DIR__ . '/../data/articles.theater.json');
|
||||
$entries = json_decode($file, true);
|
||||
|
||||
foreach ($entries as $entry) {
|
||||
try {
|
||||
$cDim = $db
|
||||
->table('dimensions')
|
||||
->where(
|
||||
'short',
|
||||
'=',
|
||||
str_replace('.', '', $entry['dimension'])
|
||||
)->first();
|
||||
$pDim = $db
|
||||
->table('dimensions')
|
||||
->where(
|
||||
'short',
|
||||
'=',
|
||||
str_replace('.', '', $entry['portion']['type'])
|
||||
)->first();
|
||||
$item = [
|
||||
'name' => $entry['name'],
|
||||
'short' => $entry['short'],
|
||||
'content_size' => $entry['content']['size'],
|
||||
'portion_size' => $entry['portion']['size'],
|
||||
'content_dimension' => $cDim->id,
|
||||
'portion_dimension' => $pDim->id,
|
||||
'portion_price' => $entry['portion']['price'],
|
||||
'group_id' => 1
|
||||
];
|
||||
print_r($item);
|
||||
$db->table('articles')->insert($item);
|
||||
} catch (\Throwable $th) {
|
||||
$this->get('log')->error($th);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->get('view')->render($response, 'frontend.html', []);
|
||||
})->setName('migrations');
|
||||
|
||||
/**
|
||||
* Move Uploaded File to Target Destination
|
||||
*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user