first commit

This commit is contained in:
Kevin Adametz 2021-01-08 17:48:20 +01:00
commit 0baac018a2
1011 changed files with 145854 additions and 0 deletions

64
.env Normal file
View file

@ -0,0 +1,64 @@
APP_NAME=partner.gruene-seele.bio
APP_ENV=local
APP_KEY=base64:w0K6RjfleoAOpuICea14JnaZ28PNc6EMzIFMQZ3MVtU=
APP_DEBUG=true
APP_URL=https://partner.gruene-seele.test
APP_CHECKOUT_MAIL=kevin.adametz@me.com
APP_CHECKOUT_TEST_MAIL=kevin.adametz@me.com
APP_INFO_MAIL=kevin.adametz@me.com
APP_INFO_TEST_MAIL=kevin.adametz@me.com
APP_MAIN_TAX = 1.19
LOG_CHANNEL=stack
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=192.168.1.8
DB_PORT=3306
DB_DATABASE=grueneseele
DB_USERNAME=kadmin
DB_PASSWORD=KT32vQ7ix
#DB_CONNECTION=mysql
#DB_HOST=localhost
#DB_PORT=3306
#DB_DATABASE=web28_db4
#DB_USERNAME=web28_4
#DB_PASSWORD=MbDQuPZYOjxGpfNSr=9/5
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=s182.goserver.host
MAIL_PORT=587
MAIL_USERNAME=web28p3
MAIL_PASSWORD=WeE2bmI9GjB7pDgi
#MAIL_ENCRYPTION=SSL
MAIL_FROM_ADDRESS=partner@gruene-seele.bio
MAIL_FROM_NAME="Partner Grüne Seele bio"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

35
.gitignore vendored Normal file
View file

@ -0,0 +1,35 @@
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
/vendor
/node_modules
/storage/language
/storage/framework
/storage/logs
/public/vendor
/storage/app

8
.idea/.gitignore generated vendored Normal file
View file

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

4
.idea/deployment.xml generated Normal file
View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" serverName="https://partner.gruene-seele.test" />
</project>

6
.idea/encodings.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

6
.idea/laravel-plugin.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="LaravelPluginSettings">
<option name="pluginEnabled" value="true" />
</component>
</project>

10
.idea/misc.xml generated Normal file
View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ComposerJsonPluginSettings">
<unboundedVersionInspectionSettings>
<excludedPackages />
</unboundedVersionInspectionSettings>
<customRepositories />
<composerUpdateOptions />
</component>
</project>

8
.idea/modules.xml generated Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/partner.gruene-seele.bio.iml" filepath="$PROJECT_DIR$/.idea/partner.gruene-seele.bio.iml" />
</modules>
</component>
</project>

164
.idea/partner.gruene-seele.bio.iml generated Normal file
View file

@ -0,0 +1,164 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/app" isTestSource="false" packagePrefix="App\" />
<sourceFolder url="file://$MODULE_DIR$/database/factories" isTestSource="false" packagePrefix="Database\Factories\" />
<sourceFolder url="file://$MODULE_DIR$/database/seeders" isTestSource="false" packagePrefix="Database\Seeders\" />
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" packagePrefix="Tests\" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/container" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/log" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/event-dispatcher" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-message" />
<excludeFolder url="file://$MODULE_DIR$/vendor/opis/closure" />
<excludeFolder url="file://$MODULE_DIR$/vendor/filp/whoops" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psy/psysh" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-client" />
<excludeFolder url="file://$MODULE_DIR$/vendor/nikic/php-parser" />
<excludeFolder url="file://$MODULE_DIR$/vendor/brick/math" />
<excludeFolder url="file://$MODULE_DIR$/vendor/asm89/stack-cors" />
<excludeFolder url="file://$MODULE_DIR$/vendor/voku/portable-ascii" />
<excludeFolder url="file://$MODULE_DIR$/vendor/league/commonmark" />
<excludeFolder url="file://$MODULE_DIR$/vendor/facade/ignition" />
<excludeFolder url="file://$MODULE_DIR$/vendor/facade/flare-client-php" />
<excludeFolder url="file://$MODULE_DIR$/vendor/facade/ignition-contracts" />
<excludeFolder url="file://$MODULE_DIR$/vendor/ramsey/collection" />
<excludeFolder url="file://$MODULE_DIR$/vendor/nesbot/carbon" />
<excludeFolder url="file://$MODULE_DIR$/vendor/league/flysystem" />
<excludeFolder url="file://$MODULE_DIR$/vendor/league/mime-type-detection" />
<excludeFolder url="file://$MODULE_DIR$/vendor/egulias/email-validator" />
<excludeFolder url="file://$MODULE_DIR$/vendor/dnoegel/php-xdg-base-dir" />
<excludeFolder url="file://$MODULE_DIR$/vendor/vlucas/phpdotenv" />
<excludeFolder url="file://$MODULE_DIR$/vendor/ramsey/uuid" />
<excludeFolder url="file://$MODULE_DIR$/vendor/mockery/mockery" />
<excludeFolder url="file://$MODULE_DIR$/vendor/laravel/framework" />
<excludeFolder url="file://$MODULE_DIR$/vendor/laravel/tinker" />
<excludeFolder url="file://$MODULE_DIR$/vendor/laravel/sail" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phar-io/manifest" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phar-io/version" />
<excludeFolder url="file://$MODULE_DIR$/vendor/myclabs/deep-copy" />
<excludeFolder url="file://$MODULE_DIR$/vendor/monolog/monolog" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phpunit/php-invoker" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phpunit/php-file-iterator" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phpunit/php-timer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phpspec/prophecy" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phpunit/php-code-coverage" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phpunit/phpunit" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phpunit/php-text-template" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/http-client-contracts" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/routing" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/finder" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/deprecation-contracts" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php80" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-normalizer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/css-selector" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-grapheme" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php72" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/error-handler" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-ctype" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/mime" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/console" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-idn" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php73" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/event-dispatcher-contracts" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/http-foundation" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/var-dumper" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/event-dispatcher" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-iconv" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/string" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/service-contracts" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/translation-contracts" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/http-kernel" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/lexer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/theseer/tokenizer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/process" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/translation" />
<excludeFolder url="file://$MODULE_DIR$/vendor/hamcrest/hamcrest-php" />
<excludeFolder url="file://$MODULE_DIR$/vendor/fakerphp/faker" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/inflector" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/instantiator" />
<excludeFolder url="file://$MODULE_DIR$/vendor/ralouphie/getallheaders" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phpoption/phpoption" />
<excludeFolder url="file://$MODULE_DIR$/vendor/fruitcake/laravel-cors" />
<excludeFolder url="file://$MODULE_DIR$/vendor/fideloper/proxy" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/object-enumerator" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/lines-of-code" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/diff" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/type" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/cli-parser" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/exporter" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/code-unit" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/comparator" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/resource-operations" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/recursion-context" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/complexity" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/version" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/object-reflector" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/code-unit-reverse-lookup" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/global-state" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/environment" />
<excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/guzzle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/psr7" />
<excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/promises" />
<excludeFolder url="file://$MODULE_DIR$/vendor/webmozart/assert" />
<excludeFolder url="file://$MODULE_DIR$/vendor/dragonmantank/cron-expression" />
<excludeFolder url="file://$MODULE_DIR$/vendor/tijsverkoyen/css-to-inline-styles" />
<excludeFolder url="file://$MODULE_DIR$/vendor/swiftmailer/swiftmailer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/nunomaduro/collision" />
<excludeFolder url="file://$MODULE_DIR$/vendor/graham-campbell/result-type" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phpdocumentor/reflection-common" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phpdocumentor/type-resolver" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phpdocumentor/reflection-docblock" />
<excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/simple-cache" />
<excludeFolder url="file://$MODULE_DIR$/vendor/php-http/message-factory" />
<excludeFolder url="file://$MODULE_DIR$/vendor/dompdf/dompdf" />
<excludeFolder url="file://$MODULE_DIR$/vendor/seld/jsonlint" />
<excludeFolder url="file://$MODULE_DIR$/vendor/seld/phar-utils" />
<excludeFolder url="file://$MODULE_DIR$/vendor/league/event" />
<excludeFolder url="file://$MODULE_DIR$/vendor/league/oauth2-server" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phpseclib/phpseclib" />
<excludeFolder url="file://$MODULE_DIR$/vendor/lcobucci/jwt" />
<excludeFolder url="file://$MODULE_DIR$/vendor/react/promise" />
<excludeFolder url="file://$MODULE_DIR$/vendor/laravel/helpers" />
<excludeFolder url="file://$MODULE_DIR$/vendor/laravel/passport" />
<excludeFolder url="file://$MODULE_DIR$/vendor/laravelcollective/html" />
<excludeFolder url="file://$MODULE_DIR$/vendor/barryvdh/laravel-dompdf" />
<excludeFolder url="file://$MODULE_DIR$/vendor/barryvdh/laravel-debugbar" />
<excludeFolder url="file://$MODULE_DIR$/vendor/barryvdh/laravel-ide-helper" />
<excludeFolder url="file://$MODULE_DIR$/vendor/barryvdh/reflection-docblock" />
<excludeFolder url="file://$MODULE_DIR$/vendor/paragonie/random_compat" />
<excludeFolder url="file://$MODULE_DIR$/vendor/jenssegers/date" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phenx/php-svg-lib" />
<excludeFolder url="file://$MODULE_DIR$/vendor/cocur/slugify" />
<excludeFolder url="file://$MODULE_DIR$/vendor/justinrainbow/json-schema" />
<excludeFolder url="file://$MODULE_DIR$/vendor/nyholm/psr7" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phenx/php-font-lib" />
<excludeFolder url="file://$MODULE_DIR$/vendor/defuse/php-encryption" />
<excludeFolder url="file://$MODULE_DIR$/vendor/setasign/fpdf" />
<excludeFolder url="file://$MODULE_DIR$/vendor/setasign/fpdi" />
<excludeFolder url="file://$MODULE_DIR$/vendor/askedio/laravel5-profanity-filter" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/dbal" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/event-manager" />
<excludeFolder url="file://$MODULE_DIR$/vendor/firebase/php-jwt" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/cache" />
<excludeFolder url="file://$MODULE_DIR$/vendor/cviebrock/eloquent-sluggable" />
<excludeFolder url="file://$MODULE_DIR$/vendor/yajra/laravel-datatables-oracle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/reliese/laravel" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-factory" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/filesystem" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/debug" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/psr-http-message-bridge" />
<excludeFolder url="file://$MODULE_DIR$/vendor/intervention/image" />
<excludeFolder url="file://$MODULE_DIR$/vendor/laracasts/flash" />
<excludeFolder url="file://$MODULE_DIR$/vendor/maximebf/debugbar" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sabberworm/php-css-parser" />
<excludeFolder url="file://$MODULE_DIR$/vendor/laravel/ui" />
<excludeFolder url="file://$MODULE_DIR$/vendor/digital-bird/shoppingcart" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

163
.idea/php.xml generated Normal file
View file

@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PhpIncludePathManager">
<include_path>
<path value="$PROJECT_DIR$/vendor/psr/container" />
<path value="$PROJECT_DIR$/vendor/psr/log" />
<path value="$PROJECT_DIR$/vendor/psr/event-dispatcher" />
<path value="$PROJECT_DIR$/vendor/psr/http-message" />
<path value="$PROJECT_DIR$/vendor/opis/closure" />
<path value="$PROJECT_DIR$/vendor/filp/whoops" />
<path value="$PROJECT_DIR$/vendor/psy/psysh" />
<path value="$PROJECT_DIR$/vendor/psr/http-client" />
<path value="$PROJECT_DIR$/vendor/nikic/php-parser" />
<path value="$PROJECT_DIR$/vendor/brick/math" />
<path value="$PROJECT_DIR$/vendor/asm89/stack-cors" />
<path value="$PROJECT_DIR$/vendor/voku/portable-ascii" />
<path value="$PROJECT_DIR$/vendor/league/commonmark" />
<path value="$PROJECT_DIR$/vendor/facade/ignition" />
<path value="$PROJECT_DIR$/vendor/facade/flare-client-php" />
<path value="$PROJECT_DIR$/vendor/facade/ignition-contracts" />
<path value="$PROJECT_DIR$/vendor/ramsey/collection" />
<path value="$PROJECT_DIR$/vendor/nesbot/carbon" />
<path value="$PROJECT_DIR$/vendor/league/flysystem" />
<path value="$PROJECT_DIR$/vendor/league/mime-type-detection" />
<path value="$PROJECT_DIR$/vendor/egulias/email-validator" />
<path value="$PROJECT_DIR$/vendor/dnoegel/php-xdg-base-dir" />
<path value="$PROJECT_DIR$/vendor/vlucas/phpdotenv" />
<path value="$PROJECT_DIR$/vendor/ramsey/uuid" />
<path value="$PROJECT_DIR$/vendor/mockery/mockery" />
<path value="$PROJECT_DIR$/vendor/laravel/framework" />
<path value="$PROJECT_DIR$/vendor/laravel/tinker" />
<path value="$PROJECT_DIR$/vendor/laravel/sail" />
<path value="$PROJECT_DIR$/vendor/phar-io/manifest" />
<path value="$PROJECT_DIR$/vendor/phar-io/version" />
<path value="$PROJECT_DIR$/vendor/myclabs/deep-copy" />
<path value="$PROJECT_DIR$/vendor/monolog/monolog" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-invoker" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-file-iterator" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-timer" />
<path value="$PROJECT_DIR$/vendor/phpspec/prophecy" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-mbstring" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-code-coverage" />
<path value="$PROJECT_DIR$/vendor/phpunit/phpunit" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-text-template" />
<path value="$PROJECT_DIR$/vendor/symfony/http-client-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/routing" />
<path value="$PROJECT_DIR$/vendor/symfony/finder" />
<path value="$PROJECT_DIR$/vendor/symfony/deprecation-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php80" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-normalizer" />
<path value="$PROJECT_DIR$/vendor/symfony/css-selector" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-grapheme" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php72" />
<path value="$PROJECT_DIR$/vendor/symfony/error-handler" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-ctype" />
<path value="$PROJECT_DIR$/vendor/symfony/mime" />
<path value="$PROJECT_DIR$/vendor/symfony/console" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-idn" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php73" />
<path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/http-foundation" />
<path value="$PROJECT_DIR$/vendor/symfony/var-dumper" />
<path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-iconv" />
<path value="$PROJECT_DIR$/vendor/symfony/string" />
<path value="$PROJECT_DIR$/vendor/symfony/service-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/translation-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/http-kernel" />
<path value="$PROJECT_DIR$/vendor/doctrine/lexer" />
<path value="$PROJECT_DIR$/vendor/theseer/tokenizer" />
<path value="$PROJECT_DIR$/vendor/symfony/process" />
<path value="$PROJECT_DIR$/vendor/symfony/translation" />
<path value="$PROJECT_DIR$/vendor/hamcrest/hamcrest-php" />
<path value="$PROJECT_DIR$/vendor/fakerphp/faker" />
<path value="$PROJECT_DIR$/vendor/doctrine/inflector" />
<path value="$PROJECT_DIR$/vendor/doctrine/instantiator" />
<path value="$PROJECT_DIR$/vendor/ralouphie/getallheaders" />
<path value="$PROJECT_DIR$/vendor/phpoption/phpoption" />
<path value="$PROJECT_DIR$/vendor/fruitcake/laravel-cors" />
<path value="$PROJECT_DIR$/vendor/fideloper/proxy" />
<path value="$PROJECT_DIR$/vendor/sebastian/object-enumerator" />
<path value="$PROJECT_DIR$/vendor/sebastian/lines-of-code" />
<path value="$PROJECT_DIR$/vendor/sebastian/diff" />
<path value="$PROJECT_DIR$/vendor/sebastian/type" />
<path value="$PROJECT_DIR$/vendor/sebastian/cli-parser" />
<path value="$PROJECT_DIR$/vendor/sebastian/exporter" />
<path value="$PROJECT_DIR$/vendor/sebastian/code-unit" />
<path value="$PROJECT_DIR$/vendor/sebastian/comparator" />
<path value="$PROJECT_DIR$/vendor/sebastian/resource-operations" />
<path value="$PROJECT_DIR$/vendor/sebastian/recursion-context" />
<path value="$PROJECT_DIR$/vendor/sebastian/complexity" />
<path value="$PROJECT_DIR$/vendor/sebastian/version" />
<path value="$PROJECT_DIR$/vendor/sebastian/object-reflector" />
<path value="$PROJECT_DIR$/vendor/sebastian/code-unit-reverse-lookup" />
<path value="$PROJECT_DIR$/vendor/sebastian/global-state" />
<path value="$PROJECT_DIR$/vendor/sebastian/environment" />
<path value="$PROJECT_DIR$/vendor/guzzlehttp/guzzle" />
<path value="$PROJECT_DIR$/vendor/guzzlehttp/psr7" />
<path value="$PROJECT_DIR$/vendor/guzzlehttp/promises" />
<path value="$PROJECT_DIR$/vendor/webmozart/assert" />
<path value="$PROJECT_DIR$/vendor/dragonmantank/cron-expression" />
<path value="$PROJECT_DIR$/vendor/tijsverkoyen/css-to-inline-styles" />
<path value="$PROJECT_DIR$/vendor/swiftmailer/swiftmailer" />
<path value="$PROJECT_DIR$/vendor/nunomaduro/collision" />
<path value="$PROJECT_DIR$/vendor/graham-campbell/result-type" />
<path value="$PROJECT_DIR$/vendor/phpdocumentor/reflection-common" />
<path value="$PROJECT_DIR$/vendor/phpdocumentor/type-resolver" />
<path value="$PROJECT_DIR$/vendor/phpdocumentor/reflection-docblock" />
<path value="$PROJECT_DIR$/vendor/composer" />
<path value="$PROJECT_DIR$/vendor/psr/simple-cache" />
<path value="$PROJECT_DIR$/vendor/php-http/message-factory" />
<path value="$PROJECT_DIR$/vendor/dompdf/dompdf" />
<path value="$PROJECT_DIR$/vendor/seld/jsonlint" />
<path value="$PROJECT_DIR$/vendor/seld/phar-utils" />
<path value="$PROJECT_DIR$/vendor/league/event" />
<path value="$PROJECT_DIR$/vendor/league/oauth2-server" />
<path value="$PROJECT_DIR$/vendor/phpseclib/phpseclib" />
<path value="$PROJECT_DIR$/vendor/lcobucci/jwt" />
<path value="$PROJECT_DIR$/vendor/react/promise" />
<path value="$PROJECT_DIR$/vendor/laravel/helpers" />
<path value="$PROJECT_DIR$/vendor/laravel/passport" />
<path value="$PROJECT_DIR$/vendor/laravelcollective/html" />
<path value="$PROJECT_DIR$/vendor/barryvdh/laravel-dompdf" />
<path value="$PROJECT_DIR$/vendor/barryvdh/laravel-debugbar" />
<path value="$PROJECT_DIR$/vendor/barryvdh/laravel-ide-helper" />
<path value="$PROJECT_DIR$/vendor/barryvdh/reflection-docblock" />
<path value="$PROJECT_DIR$/vendor/paragonie/random_compat" />
<path value="$PROJECT_DIR$/vendor/jenssegers/date" />
<path value="$PROJECT_DIR$/vendor/phenx/php-svg-lib" />
<path value="$PROJECT_DIR$/vendor/cocur/slugify" />
<path value="$PROJECT_DIR$/vendor/justinrainbow/json-schema" />
<path value="$PROJECT_DIR$/vendor/nyholm/psr7" />
<path value="$PROJECT_DIR$/vendor/phenx/php-font-lib" />
<path value="$PROJECT_DIR$/vendor/defuse/php-encryption" />
<path value="$PROJECT_DIR$/vendor/setasign/fpdf" />
<path value="$PROJECT_DIR$/vendor/setasign/fpdi" />
<path value="$PROJECT_DIR$/vendor/askedio/laravel5-profanity-filter" />
<path value="$PROJECT_DIR$/vendor/doctrine/dbal" />
<path value="$PROJECT_DIR$/vendor/doctrine/event-manager" />
<path value="$PROJECT_DIR$/vendor/firebase/php-jwt" />
<path value="$PROJECT_DIR$/vendor/doctrine/cache" />
<path value="$PROJECT_DIR$/vendor/cviebrock/eloquent-sluggable" />
<path value="$PROJECT_DIR$/vendor/yajra/laravel-datatables-oracle" />
<path value="$PROJECT_DIR$/vendor/reliese/laravel" />
<path value="$PROJECT_DIR$/vendor/psr/http-factory" />
<path value="$PROJECT_DIR$/vendor/symfony/filesystem" />
<path value="$PROJECT_DIR$/vendor/symfony/debug" />
<path value="$PROJECT_DIR$/vendor/symfony/psr-http-message-bridge" />
<path value="$PROJECT_DIR$/vendor/intervention/image" />
<path value="$PROJECT_DIR$/vendor/laracasts/flash" />
<path value="$PROJECT_DIR$/vendor/maximebf/debugbar" />
<path value="$PROJECT_DIR$/vendor/sabberworm/php-css-parser" />
<path value="$PROJECT_DIR$/vendor/laravel/ui" />
<path value="$PROJECT_DIR$/vendor/digital-bird/shoppingcart" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="7.3" />
<component name="PhpUnit">
<phpunit_settings>
<PhpUnitSettings configuration_file_path="$PROJECT_DIR$/phpunit.xml" custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" use_configuration_file="true" />
</phpunit_settings>
</component>
</project>

10
.idea/phpunit.xml generated Normal file
View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PHPUnit">
<option name="directories">
<list>
<option value="$PROJECT_DIR$/tests" />
</list>
</option>
</component>
</project>

8
.idea/symfony2.xml generated Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Symfony2PluginSettings">
<option name="directoryToWeb" value="public" />
<option name="pluginEnabled" value="true" />
<option name="twigBundleNamespaceSupport" value="false" />
</component>
</project>

7
.idea/vagrant.xml generated Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VagrantProjectSettings">
<option name="instanceFolder" value="" />
<option name="provider" value="" />
</component>
</project>

2135
.phpstorm.meta.php Normal file

File diff suppressed because it is too large Load diff

22134
_ide_helper.php Normal file

File diff suppressed because it is too large Load diff

42
app/Console/Kernel.php Normal file
View file

@ -0,0 +1,42 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}

View file

@ -0,0 +1,55 @@
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];
/**
* Report or log an exception.
*
* @param \Throwable $exception
* @return void
*
* @throws \Exception
*/
public function report(Throwable $exception)
{
parent::report($exception);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Throwable $exception
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Throwable
*/
public function render($request, Throwable $exception)
{
return parent::render($request, $exception);
}
}

View file

@ -0,0 +1,187 @@
<?php
namespace App\Http\Controllers;
use App\Models\PaymentMethod;
use App\Models\UserAccount;
use App\Repositories\UserRepository;
use App\Services\HTMLHelper;
use App\Services\SysLog;
use App\User;
use Auth;
use Illuminate\Support\Facades\Mail;
use Request;
use Validator;
class AdminUserController extends Controller
{
protected $userRepo;
public function __construct(UserRepository $userRepo)
{
$this->middleware('superadmin');
$this->userRepo = $userRepo;
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index()
{
$data = [
//'values' => User::where('admin', 0)->get(),
'values' => User::where('confirmation_code_remider', '!=', 2)->get(),
];
return view('admin.user.index', $data);
}
public function edit($user_id)
{
$user = User::findOrFail($user_id);
if(!$user->account){
$user->account = new UserAccount();
}
$data = [
'user' => $user,
];
return view('admin.user.edit', $data);
}
/**
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*/
public function store(Request $request)
{
$data = Request::all();
$user = User::findOrFail($data['id']);
if(isset($data['save-admin'])){
$user->admin = $data['admin'];
SysLog::action('save-admin', 'admin_user', 3)
->setUserId(Auth::user()->id)
->setModel($user->id, User::class)
->setMessage('Set user admin value: '.HTMLHelper::getRoleLabel($user->admin))
->save();
}
if(isset($data['save-confirmed'])){
$data['confirmed'] = isset($data['confirmed']) ? true : false;
$user->confirmed = $data['confirmed'];
if($data['confirmed']){
if(!isset($data['confirmation_date']) || $data['confirmation_date'] == ""){
$user->confirmation_date = now();
}else{
$user->confirmation_date = \Carbon::parse(str_replace("- ", "", $data['confirmation_date']));
}
}else{
$user->confirmation_date = null;
}
SysLog::action('save-confirmed', 'admin_user', 3)
->setUserId(Auth::user()->id)
->setModel($user->id, User::class)
->setMessage('Set user confirmed value: '.$user->confirmed." to date: ".$data['confirmation_date'])
->save();
}
if(isset($data['save-active'])){
$data['active'] = isset($data['active']) ? true : false;
$user->active = $data['active'];
if($data['active']){
if(!isset($data['active_date']) || $data['active_date'] == ""){
$user->active_date = now();
}else{
$user->active_date = \Carbon::parse(str_replace("- ", "", $data['active_date']));
}
}else{
$user->active_date = null;
}
SysLog::action('save-active', 'admin_user', 3)
->setUserId(Auth::user()->id)
->setModel($user->id, User::class)
->setMessage('Set user active value: '.$user->active." to date: ".$data['active_date'])
->save();
}
if(isset($data['save-account'])){
$old = $user->getPaymentAccountDateFormat(true);
if(!isset($data['payment_account']) || $data['payment_account'] == ""){
$user->payment_account = null;
}else{
$user->wizard = 100;
$user->payment_account = \Carbon::parse(str_replace("- ", "", $data['payment_account']));
}
SysLog::action('save-account', 'admin_user', 3)
->setUserId(Auth::user()->id)
->setModel($user->id, User::class)
->setMessage('Set user payment_account from date: '.$old." to date: ".$data['payment_account'])
->save();
}
if(isset($data['save-shop'])){
$old = $user->getPaymentShopDateFormat(true);
if(!isset($data['payment_shop']) || $data['payment_shop'] == ""){
$user->payment_shop = null;
}else{
$user->wizard = 100;
$user->payment_shop = \Carbon::parse(str_replace("- ", "", $data['payment_shop']));
}
SysLog::action('save-shop', 'admin_user', 3)
->setUserId(Auth::user()->id)
->setModel($user->id, User::class)
->setMessage('Set user payment_shop from date: '.$old." to date: ".$data['payment_shop'])
->save();
}
if(isset($data['save-test_mode'])){
$user->test_mode = isset($data['test_mode']) ? true : false;
SysLog::action('save-test_mode', 'admin_user', 3)
->setUserId(Auth::user()->id)
->setModel($user->id, User::class)
->setMessage('Set user test_mode value: '.$user->test_mode)
->save();
}
if(isset($data['save-payment_methods'])){
$user->payment_methods = isset($data['payment_methods']) ? array_map('intval', $data['payment_methods']) : null;
SysLog::action('save-payment_methods', 'admin_user', 3)
->setUserId(Auth::user()->id)
->setModel($user->id, User::class)
->setMessage('Set user payment_methods value: '.$user->getPaymentMethodsShort())
->save();
}
$user->save();
\Session()->flash('alert-save', true);
return redirect('/admin/users');
}
public function deleteUser($user_id)
{
$user = User::findOrFail($user_id);
$this->userRepo->deleteUser($user);
\Session()->flash('alert-success', "Kontakt gelöscht");
return redirect('/admin/users');
}
public function userLoginAs($userId){
if(Auth::user()->isSuperAdmin()){
$user = User::find($userId);
Auth::login($user);
return redirect('/home');
}
}
}

View file

@ -0,0 +1,103 @@
<?php
namespace App\Http\Controllers\Api;
use Illuminate\Support\Facades\Hash;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Carbon\Carbon;
class AuthController extends Controller
{
//protected static API_MAIL = 'api.thomas.krummel@gmail.com';
//protected static API_PASS = 'UF(Q<9knap!ev3vH?5~!b8DP';
//protected static API_URL = 'https://mein.sterntours.test/api/';
public $successStatus = 200;
public function login(Request $request)
{
$request->validate([
'email' => 'required|string|email',
'password' => 'required|string',
'remember_me' => 'boolean'
]);
$credentials = request(['email', 'password']);
if (!Auth::attempt($credentials))
return response()->json([
'message' => 'Unauthorized'
], 401);
$user = $request->user();
$tokenResult = $user->createToken('Personal Access Token');
$token = $tokenResult->token;
if ($request->remember_me){
$token->expires_at = Carbon::now()->addWeeks(1);
}else{
$token->expires_at = Carbon::now()->addDays(1);
}
$token->save();
return response()->json([
'access_token' => $tokenResult->accessToken,
'token_type' => 'Bearer',
'expires_at' => Carbon::parse(
$tokenResult->token->expires_at
)->toDateTimeString()
]);
}
public function checked(Request $request)
{
return response()->json([
'message' => 'login'
]);
}
public function logout(Request $request)
{
$request->user()->token()->revoke();
return response()->json([
'message' => 'Successfully logged out'
]);
}
/**
* Get the authenticated User
*
* @return [json] user object
*/
/* public function user(Request $request)
{
return response()->json($request->user());
}
*/
/*public function signup(Request $request)
{
$request->validate([
'name' => 'required|string',
'email' => 'required|string|email|unique:users',
'password' => 'required|string|confirmed'
]);
$user = new User([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
$user->save();
return response()->json([
'message' => 'Successfully created user!'
], 201);
}*/
}

View file

@ -0,0 +1,700 @@
<?php
namespace App\Http\Controllers\Api;
use App\Mail\MailCheckout;
use App\Models\Country;
use App\Models\Product;
use App\Models\ShippingCountry;
use App\Models\ShoppingOrder;
use App\Models\ShoppingOrderItem;
use App\Models\ShoppingUser;
use App\Services\CustomerPriority;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Carbon\Carbon;
use Illuminate\Support\Facades\Mail;
use PHPUnit\Framework\Constraint\Count;
use Yard;
class ShoppingUserController extends Controller
{
//protected static API_MAIL = 'api.thomas.krummel@gmail.com';
//protected static API_PASS = 'UF(Q<9knap!ev3vH?5~!b8DP';
protected $successStatus = 200;
protected $member_id = 3; //thomas.krummel@gmail.com
/**
* @param Request $request
* wp_order_numbers[1234, 1234]
* @return \Illuminate\Http\JsonResponse
*/
public function status(Request $request)
{
$request->validate([
'wp_order_numbers' => 'required',
]);
if(!is_array($request->wp_order_numbers)){
$wp_order_numbers = json_decode($request->wp_order_numbers);
}else{
$wp_order_numbers = $request->wp_order_numbers;
}
if(!$wp_order_numbers || !is_array($wp_order_numbers)){
return response()->json([
'success' => false,
'message' => 'wp_order_numbers need as json [1234, 1234] ',
'time' => Carbon::now()->toDateTimeString()
], 400);
}
$status = [];
foreach ($wp_order_numbers as $wp_order_number){
$shopping_user = ShoppingUser::where('wp_order_number', '=', $wp_order_number)->first();
$status[] = [
'wp_order_number' => $wp_order_number,
'user' => $shopping_user ? true : false,
'order' => ($shopping_user && $shopping_user->shopping_order) ? true : false,
'status' => $shopping_user ? $shopping_user->getAPIShippedType() : false,
];
}
return response()->json([
'success' => true,
'data' => $status,
'time' => Carbon::now()->toDateTimeString()
], 200);
}
/**
* @param Request $request
* wp_order_number [1234]
* @return \Illuminate\Http\JsonResponse
*/
public function cancel(Request $request)
{
$request->validate([
'wp_order_number' => 'required|int',
]);
$shopping_user = ShoppingUser::where('wp_order_number', '=', $request->wp_order_number)->first();
if (!$shopping_user) {
return response()->json([
'success' => false,
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' not found',
'order' => false,
'status' => false,
'time' => Carbon::now()->toDateTimeString()
], 400);
}
if(!$shopping_user->shopping_order){
return response()->json([
'success' => false,
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' has no order',
'order' => false,
'status' => $shopping_user->getAPIShippedType(),
'time' => Carbon::now()->toDateTimeString()
], 400);
}
if($shopping_user->shopping_order->shipped > 0){
return response()->json([
'success' => false,
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' can not cancel',
'order' => true,
'status' => $shopping_user->getAPIShippedType(),
'time' => Carbon::now()->toDateTimeString()
], 400);
}
$shopping_user->shopping_order->shipped = 10;
$shopping_user->shopping_order->save();
return response()->json([
'success' => true,
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' is cancel',
'order' => true,
'status' => $shopping_user->getAPIShippedType(),
'time' => Carbon::now()->toDateTimeString()
], 200);
}
/**
* @param Request $request
* wp_order_number [1234]
* @return \Illuminate\Http\JsonResponse
*/
public function open(Request $request)
{
$request->validate([
'wp_order_number' => 'required|int',
]);
$shopping_user = ShoppingUser::where('wp_order_number', '=', $request->wp_order_number)->first();
if (!$shopping_user) {
return response()->json([
'success' => false,
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' not found',
'order' => false,
'status' => false,
'time' => Carbon::now()->toDateTimeString()
], 400);
}
if(!$shopping_user->shopping_order){
return response()->json([
'success' => false,
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' has no order',
'order' => false,
'status' => $shopping_user->getAPIShippedType(),
'time' => Carbon::now()->toDateTimeString()
], 400);
}
if($shopping_user->shopping_order->shipped !== 10){
return response()->json([
'success' => false,
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' can not open',
'order' => true,
'status' => $shopping_user->getAPIShippedType(),
'time' => Carbon::now()->toDateTimeString()
], 400);
}
$shopping_user->shopping_order->shipped = 0;
$shopping_user->shopping_order->save();
return response()->json([
'success' => true,
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' is open',
'order' => true,
'status' => $shopping_user->getAPIShippedType(),
'time' => Carbon::now()->toDateTimeString()
], 200);
}
/**
* @param Request $request
* wp_order_numbers [1234, 1234]
* @return \Illuminate\Http\JsonResponse
*/
public function show(Request $request)
{
//$this->member_id = auth()->user()->m_sponsor;
$request->validate([
'wp_order_numbers' => 'required',
]);
if(!is_array($request->wp_order_numbers)){
$wp_order_numbers = json_decode($request->wp_order_numbers);
}else{
$wp_order_numbers = $request->wp_order_numbers;
}
if(!$wp_order_numbers || !is_array($wp_order_numbers)){
return response()->json([
'success' => false,
'message' => 'wp_order_numbers need as json [1234, 1234] ',
'time' => Carbon::now()->toDateTimeString()
], 400);
}
$data = [];
foreach ($wp_order_numbers as $wp_order_number){
$shopping_user = ShoppingUser::where('wp_order_number', '=', $wp_order_number)->first();
$user = false;
$order = false;
if ($shopping_user) {
$user = $this->prepareForShow($shopping_user);
$order = $this->prepareForShowOrder($shopping_user->shopping_order);
}
$data[] = [
'wp_order_number' => $wp_order_number,
'user' => $user,
'order' => $order,
'customer_number' => $shopping_user ? $shopping_user->number : false,
'member_email' => ($shopping_user && $shopping_user->member) ? $shopping_user->member->email : false,
'status' => $shopping_user ? $shopping_user->getAPIShippedType() : false, ];
}
return response()->json([
'success' => true,
'data' => $data,
'time' => Carbon::now()->toDateTimeString()
], 200);
}
/**
* @param Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function store(Request $request)
{
$request->validate([
'billing_email' => 'required|string|email',
'billing_firstname' => 'required|string',
'billing_lastname' => 'required|string',
'billing_address' => 'required|string',
'billing_zipcode' => 'required|string',
'billing_city' => 'required|string',
'billing_country_code' => 'required|string',
'wp_order_number' => 'required|int|unique:shopping_users,wp_order_number',
'wp_order_date' => 'required|date',
]);
$this->member_id = auth()->user()->m_sponsor;
$data = $this->prepareForStore($request->all());
$data['member_id'] = $this->member_id ;
$data['number'] = ShoppingUser::max('number') + 1;
$data['mode'] = $request->mode ? $request->mode : 'live';
$data['is_from'] = 'extern';
$data['is_for'] = 'ot';
$shopping_user = ShoppingUser::create($data);
//Kundenhoheit prüfen
$priority = CustomerPriority::checkOne($shopping_user, true, false);
\App\Services\Shop::newUserOrder($shopping_user->number);
//exists //like //update
$user = $this->prepareForShow($shopping_user);
return response()->json([
'success' => true,
'data' => [
'wp_order_number' => $shopping_user->wp_order_number,
'user' => $user,
'customer_priority' => $priority,
'customer_number' => $shopping_user->number,
'member_email' => $shopping_user->member->email
],
'time' => Carbon::now()->toDateTimeString()
], 200);
}
/**
* @param Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function update(Request $request)
{
$request->validate([
'wp_order_number' => 'required|int',
]);
$shopping_user = ShoppingUser::where('wp_order_number', '=', $request->wp_order_number)->first();
if (!$shopping_user) {
return response()->json([
'success' => false,
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' not found',
'time' => Carbon::now()->toDateTimeString()
], 400);
}
$data = $this->prepareForUpdate($request->all());
//Kundenhoheit prüfen
$priority = CustomerPriority::checkChangeOne($shopping_user, $data, true);
$updated = $shopping_user->fill($data)->save();
\App\Services\Shop::newUserOrder($shopping_user->number);
if ($updated){
$user = $this->prepareForShow($shopping_user);
$order = $this->prepareForShowOrder($shopping_user->shopping_order);
return response()->json([
'success' => true,
'data' => [
'wp_order_number' => $shopping_user->wp_order_number,
'user' => $user,
'order' => $order,
'customer_priority' => $priority,
'customer_number' => $shopping_user ? $shopping_user->number : false,
'member_email' => ($shopping_user && $shopping_user->member) ? $shopping_user->member->email : false,
'status' => $shopping_user ? $shopping_user->getAPIShippedType() : false,
],
'time' => Carbon::now()->toDateTimeString()
], 200);
}
return response()->json([
'success' => false,
'message' => 'Entry could not be updated'
], 500);
}
public function order(Request $request)
{
$request->validate([
'wp_order_number' => 'required|int',
'wp_order' => 'required',
]);
$shopping_user = ShoppingUser::where('wp_order_number', '=', $request->wp_order_number)->first();
if (!$shopping_user) {
return response()->json([
'success' => false,
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' not found',
'time' => Carbon::now()->toDateTimeString()
], 400);
}
if($shopping_user->shopping_order){
return response()->json([
'success' => false,
'message' => 'Order with wp_order_number ' . $request->wp_order_number . ' exists',
'time' => Carbon::now()->toDateTimeString()
], 400);
}
if(!is_array($request->wp_order)){
$wp_order = json_decode($request->wp_order);
}else{
$wp_order = $request->wp_order;
}
$wp_invoice_path = isset($request->wp_invoice_path) ? $request->wp_invoice_path : null;
$wp_advertising = isset($request->wp_advertising) ? $request->wp_advertising : '';
$wp_incentives = isset($request->wp_incentives) ? $request->wp_incentives : '';
$wp_notice = [
'wp_advertising' => $wp_advertising,
'wp_incentives' => $wp_incentives,
];
$wp_order = $this->prepareOrder($wp_order, $shopping_user, $wp_invoice_path, $wp_notice);
if ($wp_order){
$user = $this->prepareForShow($shopping_user);
$order = $this->prepareForShowOrder($shopping_user->shopping_order);
return response()->json([
'success' => true,
'data' => [
'wp_order_number' => $shopping_user->wp_order_number,
'wp_invoice_path' => $wp_invoice_path,
'wp_advertising' => $wp_advertising,
'wp_incentives' => $wp_incentives,
'wp_order' => $wp_order,
'user' => $user,
'order' => $order,
'customer_number' => $shopping_user->number,
'member_email' => $shopping_user->member->email,
'status' => $shopping_user->getAPIShippedType(),
],
'time' => Carbon::now()->toDateTimeString()
], 200);
}
return response()->json([
'success' => false,
'message' => 'Order could not be stored'
], 500);
}
public function delete(Request $request)
{
$request->validate([
'wp_order_number' => 'required|int',
]);
$shopping_user = ShoppingUser::where('wp_order_number', '=', $request->wp_order_number)->where('mode', '=', 'dev')->first();
if (!$shopping_user) {
return response()->json([
'success' => false,
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' not found or mode != dev',
'time' => Carbon::now()->toDateTimeString()
], 400);
}
$shopping_order = $shopping_user->shopping_order;
if($shopping_order){
foreach ($shopping_order->shopping_order_items as $shopping_order_item){
$shopping_order_item->delete();
}
$shopping_order->delete();
}
$shopping_user->wp_order_number = time();
$shopping_user->save();
if ($shopping_user->delete()) {
return response()->json([
'success' => true
]);
}
return response()->json([
'success' => false,
'message' => 'Entry could not be deleted'
], 500);
}
private function prepareForShow($shopping_user){
if(!$shopping_user){
return false;
}
$shopping_user_data = $shopping_user->toArray();
$needs = ['wp_order_number', 'wp_order_date', 'billing_company', 'billing_firstname', 'billing_lastname', 'billing_address', 'billing_address_2', 'billing_zipcode', 'billing_city', 'billing_phone', 'billing_email',
'same_as_billing', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_phone',
'created_at', 'updated_at', 'user_deleted_at']; //'has_buyed', 'subscribed',
//$salutation = array('mr' => 1, 'ms' => 2);
$ret = [];
foreach ($shopping_user_data as $key=>$value){
if($key === 'billing_country_id'){
$ret['billing_country_code'] = $shopping_user->billing_country_id ? $shopping_user->billing_country->code : null;
}
if($key === 'shipping_country_id'){
$ret['shipping_country_code'] = $shopping_user->shipping_country_id ? $shopping_user->shipping_country->code : null;
}
if($key === 'billing_salutation'){
$ret['billing_salutation'] = $shopping_user->billing_salutation === 'ms' ? 2 : 1;
}
if($key === 'shipping_salutation'){
$ret['shipping_salutation'] = $shopping_user->shipping_salutation === 'ms' ? 2 : 1;
}
if(in_array($key, $needs)){
$ret[$key] = $value;
}
}
return $ret;
}
private function prepareForShowOrder($shopping_order){
if(!$shopping_order){
return false;
}
$ret = [
'country' => isset($shopping_order->shipping_country->country->code) ? $shopping_order->shipping_country->country->code : '',
'wp_invoice_path' => $shopping_order->wp_invoice_path,
'total' => ($shopping_order->total*100),
'shipping' => ($shopping_order->shipping*100),
'total_net' => ($shopping_order->subtotal*100),
'tax_rate' => ($shopping_order->tax_rate*100),
'tax' => ($shopping_order->tax*100),
'total_with_shipping' => ($shopping_order->total_shipping*100),
'weight' => $shopping_order->weight,
];
$ret['items'] = [];
foreach ($shopping_order->shopping_order_items as $item){
$ret['items'][] = [
'article' => $item->product->wp_number,
'name' => $item->product->name,
'qty' => $item->qty,
'price' => ($item->price * 100),
];
}
return $ret;
}
private function prepareForUpdate($data){
//$salutation = array(1 => 'mr', 2 => 'ms', 3=>null);
if(isset($data['billing_salutation'])){
$data['billing_salutation'] = (int) $data['billing_salutation'];
$data['billing_salutation'] = $data['billing_salutation'] == 2 ? 'ms' : 'mr';
}
if(isset($data['shipping_salutation'])){
$data['shipping_salutation'] = (int) $data['shipping_salutation'];
$data['shipping_salutation'] = $data['shipping_salutation'] == 2 ? 'ms' : 'mr';
}
$ret = [];
$needs = [ 'billing_salutation', 'billing_company', 'billing_firstname', 'billing_lastname', 'billing_address', 'billing_address_2', 'billing_zipcode', 'billing_city', 'billing_phone', 'billing_email', 'same_as_billing',
'shipping_salutation', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_phone'];
foreach ($data as $key=>$value){
if($key === 'billing_country_code' && isset($data['billing_country_code'])) {
$ret['billing_country_id'] = Country::getCountryIdByCodeOrOne($data['billing_country_code']);
}
if($key === 'shipping_country_code' && isset($data['shipping_country_code']) ) {
$ret['shipping_country_id'] = Country::getCountryIdByCodeOrOne($data['shipping_country_code']);
}
if($key === 'billing_phone') {
$ret['billing_phone'] = strlen($data['billing_phone']) <= 3 ? '' : $data['billing_phone'];
}
if($key === 'shipping_phone') {
$ret['shipping_phone'] = strlen($data['shipping_phone']) <= 3 ? '' : $data['shipping_phone'];
}
if(in_array($key, $needs)){
$ret[$key] = $value;
}
}
return $ret;
}
private function prepareForStore($data){
//$salutation = array(1 => 'mr', 2 => 'ms', 3=>null);
if(isset($data['billing_salutation'])){
$data['billing_salutation'] = (int) $data['billing_salutation'];
$data['billing_salutation'] = $data['billing_salutation'] == 2 ? 'ms' : 'mr';
}
if(isset($data['shipping_salutation'])){
$data['shipping_salutation'] = (int) $data['shipping_salutation'];
$data['shipping_salutation'] = $data['shipping_salutation'] == 2 ? 'ms' : 'mr';
}
$ret = [];
$needs = [ 'billing_salutation', 'billing_company', 'billing_firstname', 'billing_lastname', 'billing_address', 'billing_address_2', 'billing_zipcode', 'billing_city', 'billing_country_id', 'billing_phone', 'billing_email',
'shipping_salutation', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_country_id', 'shipping_phone',
'same_as_billing', //'has_buyed', 'subscribed',
'wp_order_number', 'wp_order_date'];
foreach ($needs as $need){
$ret[$need] = isset($data[$need]) ? $data[$need] : null;
if ($need === 'billing_country_id') {
$ret['billing_country_id'] = isset($data['billing_country_code']) ? Country::getCountryIdByCodeOrOne($data['billing_country_code']) : 1;
}
if ($need === 'shipping_country_id') {
$ret['shipping_country_id'] = isset($data['shipping_country_code']) ? Country::getCountryIdByCodeOrOne($data['shipping_country_code']) : $ret['billing_country_id'];
}
if ($need === 'billing_phone' && $ret[$need] !== null) {
$ret['billing_phone'] = strlen($data['billing_phone']) <= 3 ? '' : $data['billing_phone'];
}
if ($need === 'shipping_phone' && $ret[$need] !== null) {
$ret['shipping_phone'] = strlen($data['shipping_phone']) <= 3 ? '' : $data['shipping_phone'];
}
if ($need === 'wp_order_date') {
$ret['wp_order_date'] = Carbon::parse($ret['wp_order_date'])->toDateTimeString();
}
if ($need === 'same_as_billing') {
$ret['same_as_billing'] = isset($data['same_as_billing']) ? $data['same_as_billing'] : true;
}
}
$ret['has_buyed'] = true;
$ret['subscribed'] = false;
return $ret;
}
private function prepareOrder($wp_shopping_order, $shopping_user, $wp_invoice_path, $wp_notice){
Yard::instance('shopping')->destroy();
$ret = [];
if(is_array($wp_shopping_order)){
foreach ($wp_shopping_order as $order) {
//$object = json_decode(json_encode($order), FALSE);
$order = (object) $order;
$error = [];
if (!isset($order->article) || !isset($order->qty) || !isset($order->price)) {
$error[] = "article parameter is missing";
} else {
$product = Product::whereWpNumber($order->article)->first();
if (!$product) {
$error[] = "article not found";
} else {
if ($order->price != ($product->price * 100)) {
$error[] = "different price: " . ($product->price * 100);
}
Yard::instance('shopping')->add($product->id, $product->name, (int) $order->qty, $product->price, ['image' => [], 'slug' => $product->slug, 'weight' => $product->weight]);
}
}
$order->message = $error;
$ret[] = $order;
}
$ShippingCountry = ShippingCountry::whereCountryId($shopping_user->shipping_country_id)->first();
if($ShippingCountry){
Yard::instance('shopping')->setShippingCountryWithPrice($ShippingCountry->id);
}
$shopping_order = $this->makeShoppingOrder($shopping_user, $wp_invoice_path, $wp_notice);
$this->orderStatusSendMail($shopping_order);
$shopping_user->shopping_order = $shopping_order;
Yard::instance('shopping')->destroy();
}
return $ret;
}
private function makeShoppingOrder($shopping_user, $wp_invoice_path, $wp_notice){
$data = [
'shopping_user_id' => $shopping_user->id,
'auth_user_id' => $shopping_user->auth_user_id,
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
'user_shop_id' => auth()->user()->user_sponsor->shop->id,
'member_id' => $shopping_user->member_id,
'total' => Yard::instance('shopping')->total(2, '.', ''),
'subtotal' => Yard::instance('shopping')->subtotal(2, '.', ''),
'shipping' => Yard::instance('shopping')->shipping(2, '.', ','),
'shipping_net' => Yard::instance('shopping')->shippingNet(2, '.', ''),
'subtotal_ws' => Yard::instance('shopping')->subtotalWithShipping(2, '.', ''),
'tax' => Yard::instance('shopping')->taxWithShipping(2, '.', ''),
'total_shipping' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
'points' => Yard::instance('shopping')->points(),
'weight' => Yard::instance('shopping')->weight(),
'paid' => true,
'txaction' => 'extern',
'wp_invoice_path' => $wp_invoice_path,
'wp_notice' => $wp_notice,
'mode' => $shopping_user->mode,
];
$shopping_order = $shopping_user->shopping_order;
if($shopping_order){
$shopping_order->fill($data);
$shopping_order->save();
}else{
$shopping_order= ShoppingOrder::create($data);
}
$items = Yard::instance('shopping')->content();
$shopping_order->shopping_order_items()->each(function($model) use ($items, $shopping_order) {
foreach ($items as $item) {
if ($model->row_id === $item->rowId) {
$model->fill([
'shopping_order_id' => $shopping_order->id,
'row_id' => $item->rowId,
'product_id' => $item->id,
'qty' => $item->qty,
'price' => $item->price,
'price_net' => Yard::instance('shopping')->rowPriceNet($item, 3, '.', ''),
'tax_rate' => $item->taxRate,
'slug' => $item->options->slug,
])->save();
return false;
}
}
return $model->delete();
});
foreach ($items as $item) {
if (!ShoppingOrderItem::where('shopping_order_id', $shopping_order->id)->where('row_id', $item->rowId)->count())
ShoppingOrderItem::create([
'shopping_order_id' => $shopping_order->id,
'row_id' => $item->rowId,
'product_id' => $item->id,
'qty' => $item->qty,
'price' => $item->price,
'price_net' => Yard::instance('shopping')->rowPriceNet($item, 3, '.', ''),
'tax_rate' => $item->taxRate,
'slug' => $item->options->slug
]);
}
return $shopping_order;
}
public function orderStatusSendMail(ShoppingOrder $shopping_order){
$bcc = [];
$user_mail = $shopping_order->shopping_user->member->email;
if($shopping_order->mode === 'dev'){
$bcc[] = config('app.checkout_test_mail');
}else{
$bcc[] = config('app.checkout_mail');
}
Mail::to($user_mail)->bcc($bcc)->send(new MailCheckout($shopping_order->txaction, $shopping_order, null, false, $shopping_order->mode));
}
}

View file

@ -0,0 +1,86 @@
<?php
namespace App\Http\Controllers;
use App\Models\Attribute;
use App\Models\ProductAttribute;
use Request;
class AttributeController extends Controller
{
public function __construct()
{
$this->middleware('admin');
}
public function index()
{
$data = [
'values' => Attribute::all(),
'trans' => array_keys(config('localization.supportedLocales')),
];
return view('admin.attribute.index', $data);
}
public function store()
{
$data = Request::all();
if($data['id'] == "new"){
$model = Attribute::create([
'parent_id' => null,
'name' => $data['name'],
'pos' => $data['pos'],
'active' => isset($data['active']) ? true : false,
]);
}else{
$model = Attribute::find($data['id']);
$model->parent_id = null;
$model->name = $data['name'];
$model->pos = $data['pos'];
$model->active = isset($data['active']) ? true : false;
$model->save();
}
if(!empty($data['trans'])){
$trans = [];
foreach ($data['trans'] as $lang => $value){
if($value && $value != null){
$trans[$lang] = $value;
}
}
if(count($trans)){
$model->trans_name = $trans;
$model->save();
}
}
\Session()->flash('alert-save', '1');
return redirect(route('admin_product_attributes'));
}
public function delete($id){
if(ProductAttribute::where('attribute_id', $id)->count()){
\Session()->flash('alert-error', 'Eintrag wird als Produktattribute verwendet');
return redirect(route('admin_product_attributes'));
}
/* if(Attribute::where('parent_id', $id)->count()){
\Session()->flash('alert-error', 'Eintrag wird als Main Attribute verwendet');
return redirect(route('admin_industry_sectors'));
}
*/
$model = Attribute::findOrFail($id);
$model->delete();
\Session()->flash('alert-success', 'Eintrag gelöscht');
return redirect(route('admin_product_attributes'));
}
}

View file

@ -0,0 +1,40 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ConfirmsPasswords;
class ConfirmPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Confirm Password Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password confirmations and
| uses a simple trait to include the behavior. You're free to explore
| this trait and override any functions that require customization.
|
*/
use ConfirmsPasswords;
/**
* Where to redirect users when the intended url fails.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
}

View file

@ -0,0 +1,22 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/
use SendsPasswordResetEmails;
}

View file

@ -0,0 +1,48 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
protected function authenticated(Request $request, $user)
{
$user->last_login = date('Y-m-d H:i:s');
$user->save();
}
}

View file

@ -0,0 +1,73 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use App\Models\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\Models\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ResetsPasswords;
class ResetPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
/**
* Where to redirect users after resetting their password.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
}

View file

@ -0,0 +1,42 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\VerifiesEmails;
class VerificationController extends Controller
{
/*
|--------------------------------------------------------------------------
| Email Verification Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling email verification for any
| user that recently registered with the application. Emails may also
| be re-sent if the user didn't receive the original email message.
|
*/
use VerifiesEmails;
/**
* Where to redirect users after verification.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
}

View file

@ -0,0 +1,200 @@
<?php
namespace App\Http\Controllers;
use App\Models\Category;
use App\Models\IqImage;
use App\Models\ProductCategory;
use\Request;
class CategoryController extends Controller
{
public function __construct()
{
$this->middleware('admin');
}
public function index()
{
$data = [
'values' => Category::all(),
];
return view('admin.category.index', $data);
}
public function edit($id)
{
if($id == "new"){
$model = new Category();
$model->active = true;
}else{
$model = Category::findOrFail($id);
}
$data = [
'category' => $model,
'trans' => array_keys(config('localization.supportedLocales')),
];
return view('admin.category.edit', $data);
}
public function store()
{
$data = Request::all();
$data['active'] = isset($data['active']) ? true : false;
$data['parent_id'] = isset($data['parent_id']) ? $data['parent_id'] : null;
if($data['id'] == "new"){
$model = Category::create($data);
}else{
$model = Category::find($data['id']);
$model->fill($data)->save();
}
$trans = [];
if(!empty($data['trans_name'])){
foreach ($data['trans_name'] as $lang => $value){
if($value && $value != null){
$trans[$lang] = $value;
}
}
}
$model->trans_name = $trans;
$model->save();
$trans = [];
if(!empty($data['trans_headline'])){
foreach ($data['trans_headline'] as $lang => $value){
if($value && $value != null){
$trans[$lang] = $value;
}
}
}
$model->trans_headline = $trans;
$model->save();
\Session()->flash('alert-save', '1');
return redirect(route('admin_product_categories'));
}
public function delete($id){
if(ProductCategory::where('category_id', $id)->count()){
\Session()->flash('alert-error', 'Eintrag wird als Produkt-Kategorie verwendet');
return redirect(route('admin_product_categories'));
}
if(Category::where('parent_id', $id)->count()){
\Session()->flash('alert-error', 'Eintrag wird als Haup-Kategorie verwendet');
return redirect(route('admin_product_categories'));
}
$model = Category::findOrFail($id);
$model->delete();
\Session()->flash('alert-success', 'Eintrag gelöscht');
return redirect(route('admin_product_categories'));
}
// Upload FILE -----------------------------------------------------------------------------------------------------------------------
public function imageUpload(){
$category_id = Request::get('category_id');
$category = Category::findOrFail($category_id);
try {
$image = \App\Services\Slim::getImages('images')[0];
if ( isset($image['output']['data']) )
{
// Base64 of the image
$data = $image['output']['data'];
$file_ex = array( 'image/jpeg' => 'jpg', 'image/png' => 'png');
if (!isset($file_ex[$image['output']['type']])) {
\Session()->flash('alert-danger', 'File is not jpg or png!');
return redirect(route('admin_product_edit', [$category->id]));
}
$ext = $file_ex[$image['output']['type']];
// Original file name
$name = $image['output']['name'];
$name = \App\Services\Slim::sanitizeFileName($name);
$path = 'images/iq_images/';
$image_name = "";
do {
$image_name = uniqid('', false) . '_' . $name;
} while (\Storage::disk('public')->exists($path.$image_name));
$data = \Storage::disk('public')->put(
$path.$image_name,
$data
);
$iq_image = IqImage::create([
'filename' => $image_name,
'original_name' => $image['output']['name'],
'ext' => $ext,
'mine' => $image['output']['type'],
'size' => $image['input']['size']
]);
$category->headline_image_id = $iq_image->id;
$category->save();
\Session()->flash('alert-success', "Datei hochgeladen");
return redirect(route('admin_product_category_edit', [$category->id]));
}
\Session()->flash('alert-danger', "Datei leer");
return redirect(route('admin_product_category_edit', [$category->id]));
}
catch (Exception $e) {
\Session()->flash('alert-danger', "Fehler".$e);
return redirect(route('admin_product_category_edit', [$category->id]));
}
}
public function imageDelete($image_id, $category_id){
$category = Category::findOrFail($category_id);
$iq_image = IqImage::findOrFail($image_id);
if($iq_image->id == $category->iq_image->id){
$file = 'images/iq_images/'.$iq_image->filename;
\Storage::disk('public')->delete($file);
$category->headline_image_id = NULL;
$category->save();
$iq_image->delete();
\Session()->flash('alert-success', "Datei gelöscht");
return redirect(route('admin_product_category_edit', [$category->id]));
}
\Session()->flash('alert-danger', "Datei nicht gefunden");
return redirect(route('admin_product_category_edit', [$category->id]));
}
public function imageAttribute($image_id, $attr, $val = false){
$iq_image = IqImage::findOrFail($image_id);
$iq_image->{$attr} = $val;
$iq_image->save();
\Session()->flash('alert-success', "Wert gespeichert");
return redirect()->back();
}
}

View file

@ -0,0 +1,13 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}

View file

@ -0,0 +1,83 @@
<?php
namespace App\Http\Controllers;
use App\Models\Country;
use Request;
class CountryController extends Controller
{
public function __construct()
{
$this->middleware('admin');
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index()
{
$data = [
'values' => Country::all(),
];
return view('admin.country.index', $data);
}
public function edit($id)
{
if($id === "new"){
$model = new Country();
$model->active = true;
}else{
$model = Country::findOrFail($id);
}
$data = [
'country' => $model,
'trans' => array_keys(config('localization.supportedLocales')),
];
return view('admin.country.edit', $data);
}
public function store()
{
$data = Request::all();
$data['active'] = isset($data['active']) ? true : false;
$data['switch'] = isset($data['switch']) ? true : false;
$data['own_eur'] = isset($data['own_eur']) ? true : false;
$data['currency'] = isset($data['currency']) ? true : false;
$data['currency_faktor'] = $data['currency_faktor'] == "" ? null : reFormatNumber($data['currency_faktor']);
if(!isset($data['attr'])){
$data['attr'] = [];
}
if($data['id'] === "new"){
$model = Country::create([
/* 'parent_id' => null,
'name' => $data['name'],
'pos' => $data['pos'],
'active' => isset($data['active']) ? true : false,
*/
]);
}else{
$model = Country::find($data['id']);
$model->fill($data);
$model->save();
}
\Session()->flash('alert-save', '1');
return redirect(route('admin_country_edit', $model->id));
}
}

View file

@ -0,0 +1,240 @@
<?php
namespace App\Http\Controllers;
use App\Mail\MailCustomMessage;
use App\Mail\MailVerifyAccount;
use App\Models\UserHistory;
use App\Models\UserMessage;
use App\Repositories\UserRepository;
use App\User;
use Carbon;
use Illuminate\Support\Facades\Mail;
class CronController extends Controller
{
protected $userRepo;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct(UserRepository $userRepo)
{
$this->userRepo = $userRepo;
// $this->middleware('auth');
}
public function index()
{
//$this->checkConfirmation();
//TODO
//SEPA Booking
//Mail reminder
}
public function action($action = false, $key = false){
if($key !== 'key'){
abort(404);
}
if($action === 'check_payments_account'){
$this->checkPaymentsAccounts();
}
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function checkConfirmation()
{
$now = date('Y-m-d H:i:s');
$next = date('Y-m-d H:i:s', strtotime('+3 week'));
$users = User::where('confirmed', '=', 0)->where('confirmation_code_to', '<', $now)->get();
foreach ($users as $user) {
//delete user
if ($user->confirmation_code_remider == 1) {
$this->userRepo->deleteUser($user);
}
//send new remider
if ($user->confirmation_code_remider == 0) {
Mail::to($user->email)->send(new MailVerifyAccount($user->confirmation_code, $user));
$user->confirmation_code_to = $next;
$user->confirmation_code_remider = 1;
$user->save();
}
}
return "TOSK";
}
public function checkPaymentsAccounts(){
/*RULES
reminders
> 21 remind_first_days = 31 reminder_first
> 21 remind_first_days + sepa = 32 reminder_first_sepa
> 14 remind_sec_days = 33 reminder_sec
> 2 remind_last_days = 34 reminder_last
> 0 deaktiv = 35 reminder_deaktiv
> 0 deaktiv + sepa = 36 reminder_deaktiv_sepa
== 7 abo_booking_days + sepa + cron = 37 reminder_collect_sepa
*/
//max Date for reminder
$renewalDate = Carbon::now()->modify('+'.(config('mivita.remind_first_days')+1).' days');
//dump($renewalDate);
$users = User::where('payment_account', '!=', NULL)
->where('active', '=', 1)
->where('blocked', '!=', 1)
->where('payment_account', '<', $renewalDate)
->get();
/* $user = User::find(2);
$this->checkReminderPayments($user);
dump($user->daysActiveAccount());
dump($user->email." | ".$user->getPaymentAccountDateFormat());
die();*/
foreach ($users as $user){
$this->checkReminderPayments($user);
/*dump($user->daysActiveAccount());
dump($user->email." | ".$user->getPaymentAccountDateFormat());
dump('-------------------');*/
}
return "TOSK";
}
private function checkReminderPayments(User $user){
/* $isSend = $this->checkIsReminderSend($user, 31);
$isSend = $this->checkIsReminderSend($user, 32);
$isSend = $this->checkIsReminderSend($user, 33);
$isSend = $this->checkIsReminderSend($user, 34);
$isSend = $this->checkIsReminderSend($user, 35);
$isSend = $this->checkIsReminderSend($user, 36);
return ;*/
//35 reminder_deaktiv, 36 reminder_deaktiv_sepa
if(!$user->isActiveAccount()){
if($user->isAboOption()){
$isSend = $this->checkIsReminderSend($user, 35);
return $isSend;
}
$isSend = $this->checkIsReminderSend($user, 36);
return $isSend;
}
//34 reminder_last
if($user->daysActiveAccount() <= config('mivita.remind_last_days')){
$isSend = $this->checkIsReminderSend($user, 34);
return $isSend;
}
//33 reminder_sec
if($user->daysActiveAccount() <= config('mivita.remind_sec_days')){
if(!$user->isAboOption()){
$isSend = $this->checkIsReminderSend($user, 33);
return $isSend;
}
}
//31 reminder_first, 32 reminder_first_sepa
if($user->daysActiveAccount() > config('mivita.remind_sec_days')){
if($user->isAboOption()){
$isSend = $this->checkIsReminderSend($user, 32);
return $isSend;
}
$isSend = $this->checkIsReminderSend($user, 31);
return $isSend;
}
}
private function checkIsReminderSend(User $user, $status){
$isSend = UserHistory::whereUserId($user->id)
->whereAction('reminder_payments')
->whereIdentifier($user->payment_account)
->whereStatus($status)
->get()->last();
if($isSend){
return true;
}
$referenz = $this->sendReminderMail($user, $status);
//is not sent create
UserHistory::create(['user_id' => $user->id, 'action'=>'reminder_payments', 'referenz'=>$referenz, 'identifier'=>$user->payment_account, 'status'=>$status]);
return false;
}
private function sendReminderMail(User $user, $status){
$days = $user->daysActiveAccount();
if($days < 0){
$days = $days*-1;
}
//dump($days);
//dump($status);
$pay_date = Carbon::parse($user->payment_account)->modify('- '.config('mivita.abo_booking_days').' days')->format('d.m.Y');
$datetime = $user->getPaymentAccountDateFormat();
$price = "";
if($user->payment_order_id && isset($user->payment_order_product->price)){
$price = 'von '.$user->payment_order_product->getFormattedPrice().' EUR';
}
$message = __('reminder.copy_first_'.$status, ['days'=>$days, 'datetime'=>$datetime, 'price' =>$price, 'pay_date'=>$pay_date]);
$message_last = __('reminder.copy_last_'.$status, ['days'=>$days, 'datetime'=>$datetime, 'price' =>$price, 'pay_date'=>$pay_date]);
$button = __('reminder.button_'.$status);
$message = preg_replace("/[\n\r]/","",$message);
$message_last = preg_replace("/[\n\r]/","",$message_last);
$data = [
'subject' => __('reminder.subject')." | ID: ".$status,
'message' => $message,
'message_last' => $message_last,
'url' => route('user_membership'),
'button' => $button,
];
//dump($data);
$sender = User::find(1);
$customer_mail = UserMessage::create([
'user_id' => $user->id,
'send_user_id' => $sender->id,
'email' => $user->email,
'subject' => $data['subject'],
'message' => $data['message']." ".$data['message_last'],
]);
try{
if($status >= 34){
Mail::to($user->email)->bcc(config('app.default_mail'))->send(new MailCustomMessage($user, $data, $sender, false));
}else{
Mail::to($user->email)->send(new MailCustomMessage($user, $data, $sender, false));
}
}
catch(\Exception $e){
\Log::channel('cron')->error('Mail Error: '.$e->getMessage());
// Never reached
$customer_mail->fail = true;
$customer_mail->error = $e->getMessage();
$customer_mail->save();
return 0;
}
$customer_mail->send = true;
$customer_mail->sent_at = now();
$customer_mail->save();
return 1;
}
}

View file

@ -0,0 +1,205 @@
<?php
namespace App\Http\Controllers;
use App\Models\ShoppingUser;
use App\Repositories\CustomerRepository;
use App\Services\CustomerPriority;
use App\Services\HTMLHelper;
use Request;
use Validator;
class CustomerController extends Controller
{
protected $customerRepository;
public function __construct(CustomerRepository $customerRepository)
{
$this->middleware('admin');
$this->customerRepository = $customerRepository;
}
public function index()
{
if(Request::get('reset') === 'filter'){
set_user_attr('filter_member_id', null);
set_user_attr('filter_customer_member', null);
return redirect(route('admin_customers'));
}
$filter_members = ShoppingUser::join('users', 'member_id', '=', 'users.id')->groupBy('member_id')->join('user_accounts', 'account_id', '=', 'user_accounts.id')->select('users.id', 'users.email', 'user_accounts.first_name', 'user_accounts.last_name')->get(); //->pluck('email', 'id')->unique()->toArray();
$data = [
'filter_members' => $filter_members,
];
return view('admin.customer.index', $data);
}
public function detail($id)
{
$shopping_user = ShoppingUser::findOrFail($id);
$data = [
'shopping_user' => $shopping_user,
'isAdmin' => true,
'isView' => 'customer',
];
return view('admin.customer.detail', $data);
}
public function edit($id)
{
if($id === "new"){
$shopping_user = new ShoppingUser();
$shopping_user->id = "new";
}else{
$shopping_user = ShoppingUser::findOrFail($id);
}
$data = [
'shopping_user' => $shopping_user,
'isAdmin' => true,
'isView' => 'customer',
];
return view('admin.customer.edit', $data);
}
public function store($id)
{
$data = Request::all();
if ($data['action'] === 'shopping-user-change-member') {
if (!isset($data['change_member_key']) || $data['change_member_key'] !== config('main.edit_data_pass')) {
$data = [
'change_member_error' => "Das Passwort ist falsch.",
'shopping_user' => ShoppingUser::find($id),
'isAdmin' => true,
'isView' => 'customer',
];
return view('admin.customer.detail', $data);
}
//change
$shopping_user = ShoppingUser::findOrFail($data['id']);
CustomerPriority::newMemberForCustomer($shopping_user, $data['change_member_id'], $data['customer_set_member_for']);
\Session()->flash('alert-save', true);
return redirect(route('admin_customer_detail', [$shopping_user->id]));
}
if ($data['action'] === 'shopping-user-store') {
$rules = array(
'billing_salutation' => 'required',
'billing_firstname'=>'required',
'billing_lastname'=>'required',
'billing_email'=>'required|email',
'billing_address'=>'required',
'billing_zipcode'=>'required',
'billing_city' => 'required',
'billing_country_id' => 'required'
);
if(!Request::get('same_as_billing')){
$rules = array_merge($rules, [
'shipping_firstname'=>'required',
'shipping_lastname'=>'required',
'shipping_address'=>'required',
'shipping_zipcode'=>'required',
'shipping_city' => 'required',
'shipping_salutation' => 'required',
'shipping_country_id' => 'required'
]);
}
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
return back()->withErrors($validator)->withInput(Request::all());
}
$shopping_user = ShoppingUser::findOrFail($id);
$data['has_buyed'] = true;
$data['subscribed'] = true;
if($shopping_user->auth_user_id > 0){
$data['has_buyed'] = true;
$data['subscribed'] = false;
}
$data['same_as_billing'] = isset($data['same_as_billing']) ? true : false;
$data['shipping_country_id'] = isset($data['shipping_country_id']) ? $data['shipping_country_id'] : $data['billing_country_id'];
CustomerPriority::checkChangeOne($shopping_user, $data, true);
$shopping_user->fill($data);
$shopping_user->save();
\App\Services\Shop::newUserOrder($shopping_user->number);
\Session()->flash('alert-save', true);
}
return redirect(route('admin_customer_detail', [$shopping_user->id]));
}
public function getCustomers()
{
$query = ShoppingUser::select('shopping_users.*')->where('auth_user_id', '=', NULL);
set_user_attr('filter_member_id', Request::get('filter_member_id'));
if(Request::get('filter_member_id') != ""){
$query->where('member_id', '=', Request::get('filter_member_id'));
}
/* set_user_attr('filter_customer_member', Request::get('filter_customer_member'));
if(Request::get('filter_customer_member') != ""){
if(Request::get('filter_customer_member') === 'customers'){
$query->where('auth_user_id', '=', NULL);
}
if(Request::get('filter_customer_member') === 'members'){
$query->where('auth_user_id', '!=', NULL);
}
}*/
return \DataTables::eloquent($query)
->addColumn('id', function (ShoppingUser $ShoppingUser) {
return '<a href="' . route('admin_customer_detail', [$ShoppingUser->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
})
->addColumn('billing_email', function (ShoppingUser $ShoppingUser) {
return $ShoppingUser->faker_mail ? "-" : $ShoppingUser->billing_email;
})
->addColumn('billing_salutation', function (ShoppingUser $ShoppingUser) {
return HTMLHelper::getSalutationLang($ShoppingUser->billing_salutation);
})
->addColumn('billing_country_id', function (ShoppingUser $ShoppingUser) {
return $ShoppingUser->billing_country ? $ShoppingUser->billing_country->getLocated() : '';
})
->addColumn('isMember', function (ShoppingUser $ShoppingUser) {
return get_active_badge($ShoppingUser->auth_user_id).($ShoppingUser->mode==='dev' ? ' <span class="badge badge-warning">dev</span>' : '');
})
->addColumn('member_id', function (ShoppingUser $ShoppingUser) {
if($ShoppingUser->is_like){
return '<button type="button" class="btn btn-xs btn-outline-info" data-toggle="modal" data-target="#modals-load-content"
data-id="'.$ShoppingUser->id.'"
data-action="shopping-user-is-like-member"
data-back="'.route('admin_customers').'"
data-modal="modal-xl"
data-route="'.route('modal_load').'"><span class="fa fa-edit"></span> Berater zuordnen</button>';
}
if($ShoppingUser->member_id){
return '<a href="'.route('admin_lead_edit', [$ShoppingUser->member_id]).'">'.$ShoppingUser->member->getFullName().'</a>';
}
return '';
})
->addColumn('created_at', function (ShoppingUser $ShoppingUser) {
return $ShoppingUser->created_at->format('d.m.Y');
})
->addColumn('subscribed', function (ShoppingUser $ShoppingUser) {
return get_active_badge($ShoppingUser->subscribed);
})
->filterColumn('billing_email', function($query, $keyword) {
if($keyword != ""){
$query->where('billing_email', 'LIKE', '%'.$keyword.'%');
}
})
->orderColumn('id', 'id $1')
->orderColumn('billing_country_id', 'billing_country_id $1')
->orderColumn('billing_salutation', 'billing_salutation $1')
->orderColumn('billing_email', 'billing_email $1')
->orderColumn('created_at', 'created_at $1')
->orderColumn('isMember', 'auth_user_id $1')
->orderColumn('member_id', 'member_id $1')
->orderColumn('subscribed', 'subscribed $1')
->rawColumns(['id', 'subscribed', 'isMember', 'member_id'])
->make(true);
}
}

View file

@ -0,0 +1,100 @@
<?php
namespace App\Http\Controllers;
use App\Services\HTMLHelper;
use DataTables;
use App\User;
class DataTableController extends Controller
{
public function datatable()
{
return view('datatable');
}
public function getUsers()
{
$query = User::with('account')->select('users.*')->where('users.deleted_at', '=', null)->where('users.admin', "<", 4);
return \DataTables::eloquent($query)
->addColumn('first_name', function (User $user) {
return $user->account ? $user->account->first_name : '';
})
->addColumn('last_name', function (User $user) {
return $user->account ? $user->account->last_name : '';
})
->addColumn('id', function (User $user) {
return '<a href="' . route('admin_lead_edit', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
})
->addColumn('admin', function (User $user) {
return '<a href="#" data-toggle="modal" data-target="#modals-admin" data-id="'.$user->id.'" data-email="'.$user->email.'" data-admin="'.$user->admin.'">'.HTMLHelper::getRoleLabel($user->admin).'</a>';
})
->addColumn('confirmed', function (User $user) {
$date = $user->getConfirmationDateFormat();
$link = '<a href="#" data-toggle="modal" data-target="#modals-confirmed" data-id="'.$user->id.'" data-email="'.$user->email.'" data-confirmed="'.$user->confirmed.'" data-confirmation_date="'.$date.'">';
return $user->confirmed ? $link.'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$date.'</span></a>' : $link.'<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
})
->addColumn('active', function (User $user) {
$date = $user->getActiveDateFormat();
$link = '<a href="#" data-toggle="modal" data-target="#modals-active" data-id="'.$user->id.'" data-email="'.$user->email.'" data-active="'.$user->active.'" data-active_date="'.$date.'">';
return $user->active ? $link.'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$date.'</span></a>' : $link.'<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
})
->addColumn('account', function (User $user) {
$date = $user->getPaymentAccountDateFormat();
$link = '<a href="#" data-toggle="modal" data-target="#modals-account" data-id="'.$user->id.'" data-email="'.$user->email.'" data-payment_account="'.$date.'">';
if($user->payment_account){
if($user->isActiveAccount()){
return $link.'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$date.'</span></a>';
}
return $link.'<span class="badge badge-pill badge-warning"><i class="fa fa-ban"></i> '.$date.'</span></a>';
}
return $link.'<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
})
/* ->addColumn('shop', function (User $user) {
$date = $user->getPaymentShopDateFormat();
$link = '<a href="#" data-toggle="modal" data-target="#modals-shop" data-id="'.$user->id.'" data-email="'.$user->email.'" data-payment_shop="'.$date.'">';
if($user->payment_shop){
if($user->isActiveShop()){
return $link.'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$date.'</span></a>';
}
return $link.'<span class="badge badge-pill badge-warning"><i class="fa fa-ban"></i> '.$date.'</span></a>';
}
return $link.'<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
})
->addColumn('since', function (User $user) {
if($user->shop){
if($user->shop->active){
return $user->shop->getActiveDateFormatSmall();
}
return $user->shop->getActiveDateFormatSmall();
}
return "-";
})*/
->addColumn('my_payment_methods', function (User $user) {
$payment_methods = json_encode($user->payment_methods);
$link = '<a href="#" data-toggle="modal" data-target="#modals-payment_methods" data-id="'.$user->id.'" data-email="'.$user->email.'" data-payment_methods="'.htmlspecialchars($payment_methods).'">';
if(!$user->payment_methods){
return $link.'<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
}
return $link.'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$user->getPaymentMethodsShort().'</span></a>';
})
->addColumn('action_delete', function (User $user) {
return '<span class="no-line-break"><a href="' . route('admin_user_delete', [$user->id]) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="fa fa-trash"></span></a>
<a href="' . route('admin_user_login_as', [$user->id]) . '" class="btn icon-btn btn-sm btn-warning" onclick="return confirm(\''.__('Login as User?').'\');"><span class="fa fa-sign-in-alt"></span></a></span>';
})
->addColumn('test_mode', function (User $user) {
$link = '<a href="#" data-toggle="modal" data-target="#modals-test_mode" data-id="'.$user->id.'" data-email="'.$user->email.'" data-test_mode="'.$user->test_mode.'">';
return $user->test_mode ? $link.'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span></a>' : $link.'<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
})
->orderColumn('id', 'id $1')
->orderColumn('confirmed', 'confirmed $1')
->orderColumn('active', 'active $1')
->orderColumn('shop', 'shop $1')
->orderColumn('admin', 'active $1')
->rawColumns(['id', 'admin', 'confirmed', 'active', 'account', 'shop', 'my_payment_methods', 'test_mode', 'action_delete'])
->make(true);
}
}

View file

@ -0,0 +1,158 @@
<?php
namespace App\Http\Controllers;
use App\Models\ShoppingPayment;
use App\User;
use Auth;
use Carbon\Carbon;
use Config;
use Request;
use Util;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index()
{
if(!Auth::check()){
return redirect('login');
}
return redirect('home');
}
//login / Dashboard
public function show()
{
if(!Auth::check()){
return redirect('login');
}
$data = [
'user' => Auth::user(),
'now' => Carbon::now(),
];
return view('home', $data);
}
public function loadingModal(){
$data = Request::get('data');
$target = Request::get('target');
$response = "";
if($data === "data_protection"){
$data = [
'modal' => true,
'user_shop' => Util::getUserShop(),
];
$response = view('legal.data_protect_de', $data)->render();
}
if($data === "imprint"){
$data = [
'modal' => true,
'user_shop' => Util::getUserShop(),
];
$response = view('legal.imprint_de', $data)->render();
}
if($data === "shop_term_of_use"){
$data = [
'modal' => true,
'user_shop' => Util::getUserShop(),
];
$response = view('legal.shop_term_of_use_de', $data)->render();
}
if($data === "agb"){
$data = [
'modal' => true,
'user_shop' => Util::getUserShop(),
];
$response = view('legal.agb_de', $data)->render();
}
if(Request::ajax()) {
return response()->json(['response' => $response, 'target'=>$target]);
}
abort(404);
}
public function verify($confirmation_code){
if( ! $confirmation_code)
{
return redirect('/status/error');
}
$user = User::whereConfirmationCode($confirmation_code)->first();
if ( ! $user)
{
return redirect('/status/not/found');
}
if($user->confirmed === 0){
$user->confirmed = 1;
//kill after wizzard!
// $user->confirmation_code = null;
// $user->confirmation_code_to = null;
// $user->confirmation_code_remider = 0;
$user->confirmation_date = now();
}
$user->save();
//Login!
Auth::login($user);
return redirect('/home');
}
public function statusRegister(){
return view('status.status_register');
}
public function statusVerify(){
return view('status.status_verify');
}
public function statusError(){
return view('status.status_error');
}
public function notFound(){
return view('status.not_found');
}
public function blocked()
{
return view('status.user_blocked');
}
/**
* @return string
*/
public function checkMail(){
$data = Request::all();
if($data['user_id'] === "new"){
if(User::where('email', $data['email'])->count()){
return json_encode(false);
}
}else{
if(User::where('email', $data['email'])->where('id', '!=', $data['user_id'])->count()){
return json_encode(false);
}
}
return json_encode(true);
}
}

View file

@ -0,0 +1,106 @@
<?php
namespace App\Http\Controllers;
use App\Models\Product;
use App\Models\ProductImage;
use App\Repositories\ProductRepository;
use Request;
use Validator;
class ImportProductController extends Controller
{
protected $productRepo;
public function __construct(ProductRepository $productRepo)
{
$this->middleware('admin');
$this->productRepo = $productRepo;
}
public function import(){
$path = app_path().'/../_static/products/';
include($path.'_all_products.php');
$slugs = array();
foreach ($get_products as $c_id => $values){
foreach ($values as $val){
if(in_array($val['slug'], $slugs)){
continue;
}
$slugs[] = $val['slug'];
include($path.$val['slug'].'.php');
$data = [
'id' => 'new',
'name' => $val['name'],
'title' => '',
'copy' => $copy,
'price' => $price,
'price_ek' => 0,
'tax' => 19,
'price_old' => null,
'contents' => $content,
'number' => $item_no,
'icons' => $icons,
'description' => $description,
'usage' => $usage,
'ingredients' => $ingredients,
'pos' => null,
'amount' => 0,
'active' => 1,
'categories' => array($c_id),
];
$product = $this->productRepo->update($data);
//images
foreach($images as $image){
$i_path = storage_path().'/'.'app'.'/products/' .$val['slug'].'/'.$image['image'];
$mine = \File::mimeType($i_path);
$ext = \File::extension($i_path);
$size = \File::size($i_path);
$original_name = $image['image'];
$name = \App\Services\Slim::sanitizeFileName($image['image']);
$name = uniqid() . '_' . $name;
$img = \Image::make($i_path);
$img->resize(600, 800, function ($c) {
// $c->aspectRatio();
$c->upsize();
});
//
\Storage::put('/public/images/product/'.$product->id.'/'.$name, (string) $img->encode());
ProductImage::create([
'product_id' => $product->id,
'filename' => $name,
'original_name' => $original_name,
'ext' => $ext,
'mine' => $mine,
'size' => $size
]);
}
}
}
die("okay");
//array('slug' => 'aloe-vera-gel99', 'name' => 'Aloe Vera Gel 99%', 'first' => 'aloe-vera-gel99-1.jpg', 'hover' => 'aloe-vera-gel99-2.jpg'),
}
}

View file

@ -0,0 +1,78 @@
<?php
namespace App\Http\Controllers;
use App\Models\Category;
use App\Models\Ingredient;
use App\Models\IqImage;
use App\Models\ProductCategory;
use App\Models\ProductIngredient;
use\Request;
class IngredientController extends Controller
{
public function __construct()
{
$this->middleware('admin');
}
public function index()
{
$data = [
'values' => Ingredient::all(),
];
return view('admin.ingredient.index', $data);
}
public function edit($id)
{
if($id === "new"){
$model = new Ingredient();
$model->active = true;
}else{
$model = Ingredient::findOrFail($id);
}
$data = [
'model' => $model,
//'trans' => array_keys(config('localization.supportedLocales')),
];
return view('admin.ingredient.edit', $data);
}
public function store()
{
$data = Request::all();
$data['active'] = isset($data['active']) ? true : false;
if($data['id'] === "new"){
$model = Ingredient::create($data);
}else{
$model = Ingredient::find($data['id']);
$model->fill($data)->save();
}
\Session()->flash('alert-save', '1');
return redirect(route('admin_product_ingredients'));
}
public function delete($id){
if(ProductIngredient::where('ingredient_id', $id)->count()) {
\Session()->flash('alert-error', 'Eintrag wird als Produkt-Inhaltsstoff verwendet');
return redirect(route('admin_product_ingredients'));
}
$model = Ingredient::findOrFail($id);
$model->delete();
\Session()->flash('alert-success', 'Eintrag gelöscht');
return redirect(route('admin_product_ingredients'));
}
}

View file

@ -0,0 +1,396 @@
<?php
namespace App\Http\Controllers;
use App\Mail\MailCustomMessage;
use App\Mail\MailVerifyAccount;
use App\Mail\MailVerifyContact;
use App\Mail\MailAccountActive;
use App\Models\UserAccount;
use App\Models\UserHistory;
use App\Repositories\ContractPDFRepository;
use App\Repositories\UserRepository;
use App\Services\UserService;
use App\User;
use Illuminate\Support\Facades\Mail;
use Request;
use Validator;
class LeadController extends Controller
{
protected $userRepo;
public function __construct(UserRepository $userRepo)
{
$this->middleware('admin');
$this->userRepo = $userRepo;
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index()
{
$data = [
'values' => User::where('admin', '=', 0)->where('confirmation_code_remider', '!=', 2)->get(),
];
return view('admin.lead.index', $data);
}
/**
* @param $id
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function edit($id)
{
if($id === "new"){
$user = new User();
$user->account = new UserAccount();
$user->account->same_as_billing = 1;
$user->account->country_id = 1;
$user->account->shipping_country_id = 1;
$user->id = "new";
}else{
$user = User::findOrFail($id);
if(!$user->account){
$user->account = new UserAccount();
}
}
$data = [
'show' => Request::get('show'),
'user' => $user,
'can_change_mail' => true,
'm_data_load' => false,
'm_data_error' => false,
];
return view('admin.lead.edit', $data);
}
/**
* @param $id
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function editPost($id)
{
$m_data_load = false;
$m_data_error = false;
$data = Request::all();
if(!isset($data['edit_m_data_key']) || $data['edit_m_data_key'] !== config('main.edit_data_pass')){
$m_data_error = "Das Passwort ist falsch.";
}else{
$m_data_load = true;
}
if($id === "new"){
$user = new User();
$user->account = new UserAccount();
$user->account->same_as_billing = 1;
$user->account->country_id = 1;
$user->account->shipping_country_id = 1;
$user->id = "new";
}else{
$user = User::findOrFail($id);
if(!$user->account){
$user->account = new UserAccount();
}
}
$next_account_id = UserAccount::max('m_account') +1;
if($user->account->m_account === null){
$user->account->m_account = $next_account_id;
}
$data = [
'show' => 'check_lead',
'user' => $user,
'm_data_load' => $m_data_load,
'm_data_error' => $m_data_error,
'can_change_mail' => true,
'next_account_id' => $next_account_id
];
return view('admin.lead.edit', $data);
}
/**
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*/
public function store(Request $request)
{
$data = Request::all();
$show = Request::get('show');
if ($data['user_id'] === "new" || $data['user_id'] == 0) {
$rules = array(
'salutation' => 'required',
'first_name'=>'required',
'last_name'=>'required',
'email' => 'required|string|email|max:255|unique:users',
'email-confirm' => 'required|same:email',
);
}else{
$rules = array(
'salutation' => 'required',
'first_name'=>'required',
'last_name'=>'required',
'address'=>'required',
'zipcode'=>'required',
'city' => 'required',
'email' => 'required|string|email|max:255|exists:users,email',
'email-confirm' => 'required|same:email',
);
if(!Request::get('same_as_billing')){
$rules = array_merge($rules, [
'shipping_firstname'=>'required',
'shipping_lastname'=>'required',
'shipping_address'=>'required',
'shipping_zipcode'=>'required',
'shipping_city' => 'required',
'shipping_salutation' => 'required'
]);
}
}
if(isset($data['m_account']) && $data['m_account']){
$user = User::findOrFail($data['user_id']);
$rules['m_account'] = 'unique:user_accounts,m_account,'.$user->account->id.',id';
}
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
if ($data['user_id'] === "new" || $data['user_id'] == 0) {
$user_id = "new";
}else{
$user = User::findOrFail($data['user_id']);
$user_id = $user->id;
}
return redirect(route('admin_lead_edit', [$user_id])."?show=".$show)->withErrors($validator)->withRequest(Request::all());
}
if ($data['user_id'] === "new" || $data['user_id'] == 0) {
$user = new User();
$user->id = "new";
$user->account = new UserAccount();
}else {
$user = User::findOrFail($data['user_id']);
if(!$user->account){
$user->account = new UserAccount();
}
}
$this->userRepo->update($data);
if(isset($data['m_data_edit']) && $data['m_data_edit'] === "TSOK"){
$user = $this->userRepo->getModel();
$user->m_level = isset($data['m_level']) ? $data['m_level'] : NULL;
$user->m_sponsor = isset($data['m_sponsor']) ? $data['m_sponsor'] : NULL;
$user->save();
}
if(isset($data['contact_verify'])){
$user = $this->userRepo->getModel();
$confirmation_code = UserService::createConfirmationCode();
$user->lang = $user->getLandByCountry();
$user->confirmation_code = $confirmation_code;
//10 == start wizard form create Lead
$user->wizard = 10;
$user->save();
Mail::to($user->email)->send(new MailVerifyContact($confirmation_code, $user));
\Session()->flash('alert-save', true);
return redirect(route('admin_leads'));
}
\Session()->flash('alert-save', true);
return redirect(route('admin_lead_edit', [$user->id])."?show=".$show);
}
//user released when register is complete
public function released($action, $id){
$user = User::findOrFail($id);
if($action === 'completed'){
$validator = Validator::make(Request::all(), []);
if(!$user->m_sponsor){
$validator->errors()->add('m_sponsor', __('Berater hat keinen Sponsor.'));
}
if(!$user->account->m_first_name){
$validator->errors()->add('m_first_name', __('Berater hat keinen Vornamen.'));
}
if(!$user->account->m_first_name){
$validator->errors()->add('m_last_name', __('Berater hat keinen Nachnamen.'));
}
if(!$user->account->m_account){
$validator->errors()->add('m_account', __('Berater hat keine Account ID'));
}
if ($validator->errors()->count()) {
return back()->withErrors($validator)->withRequest(Request::all());
}
//create PDF
$pdf = new ContractPDFRepository($user);
$pdf->_set('disk', 'user');
$pdf->_set('dir', '/'.$user->id.'/documents/');
$pdf->_set('user_id', $user->id);
$pdf->_set('identifier', 'contract');
$pdf->createContractPDF();
//set wizard tp payments
$user->wizard = 20;
$user->active = 1;
$user->active_date = now();
$user->confirmation_code = null;
$user->confirmation_code_to = null;
$user->confirmation_code_remider = 0;
$user->save();
//mail with code to user?
Mail::to($user->email)->send(new MailAccountActive($user));
UserHistory::create(['user_id' => $user->id, 'action'=>'released_completed', 'status'=>0]);
\Session()->flash('alert-success', "Berater freigeschaltet!");
}
if($action === 'incomplete'){
//reset release
$confirmation_code = UserService::createConfirmationCode();
$user->confirmation_code = $confirmation_code;
$user->confirmation_code_to = date('Y-m-d H:i:s', strtotime('+1 week'));
$user->confirmation_code_remider = 0;
$user->wizard = 1;
$user->release_account = null;
$user->save();
$input = Request::all();
$data = [
'subject' => $input['account_incomplete_subject'],
'message' => $input['account_incomplete_message'],
'confirmation_code' => $confirmation_code,
];
try {
Mail::to($user->email)->send(new MailCustomMessage($user, $data, \Auth::user(), true));
}
catch(\Exception $e){
dump($e->getMessage());
dd("error");
}
UserHistory::create(['user_id' => $user->id, 'action'=>'released_incomplete', 'status'=>0]);
\Session()->flash('alert-success', "E-Mail an Berater gesendet.");
}
return redirect(route('admin_lead_edit', [$user->id]));
}
//send new verfified mail to user
public function newMailVerified($id){
$user = User::findOrFail($id);
$confirmation_code = UserService::createConfirmationCode();
$user->confirmation_code = $confirmation_code;
$user->confirmation_code_to = date('Y-m-d H:i:s', strtotime('+1 week'));
$user->confirmation_code_remider = 0;
$user->save();
try {
Mail::to($user->email)->send(new MailVerifyAccount($confirmation_code, $user));
}
catch(\Exception $e){
dump($e->getMessage());
dd("error");
}
UserHistory::create(['user_id' => $user->id, 'action'=>'new_mail_verified', 'status'=>0]);
\Session()->flash('alert-success', "E-Mail erneut gesendet");
return redirect(route('admin_lead_edit', [$user->id]));
}
public function deleteFile($user_id, $file_id, $relation){
if($relation === 'upload'){
$user = User::findOrFail($user_id);
$file = $user->files()->findOrFail($file_id);
//remove file
\Storage::disk('user')->delete($file->dir.$file->filename);
$file->delete();
\Session()->flash('alert-success', "Datei gelöscht");
}
return back();
}
public function getLeads()
{
$query = User::with('account')->select('users.*')->where('users.deleted_at', '=', null)->where('users.admin', "<", 4);
return \DataTables::eloquent($query)
->addColumn('first_name', function (User $user) {
return $user->account ? $user->account->first_name : '';
})
->addColumn('last_name', function (User $user) {
return $user->account ? $user->account->last_name : '';
})
->addColumn('user_level', function (User $user) {
return $user->user_level ? $user->user_level->name : '';
})
->addColumn('id', function (User $user) {
return '<a href="' . route('admin_lead_edit', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
})
->addColumn('confirmed', function (User $user) {
return $user->confirmed ? '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
})
->addColumn('active', function (User $user) {
return $user->active ? ' <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
})
->addColumn('agreement', function (User $user) {
return $user->agreement ? ' <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
})
->addColumn('payment_account', function (User $user) {
return $user->payment_account ? ' <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
})
->addColumn('payment_account_date', function (User $user) {
return $user->payment_account ? $user->getPaymentAccountDateFormat(false) : "-";
})
->addColumn('payment_shop', function (User $user) {
return $user->payment_shop ? ' <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
})
->addColumn('payment_shop_date', function (User $user) {
return $user->payment_shop ? $user->getPaymentShopDateFormat(false) : "-";
})
->addColumn('turnover', function (User $user) {
return "-";
})
->addColumn('sales_total', function (User $user) {
return "-";
})
->orderColumn('id', 'id $1')
->orderColumn('confirmed', 'confirmed $1')
->orderColumn('active', 'active $1')
->orderColumn('agreement', 'agreement $1')
->orderColumn('payment_account', 'payment_account $1')
->orderColumn('payment_shop', 'payment_shop $1')
->rawColumns(['id', 'confirmed', 'active', 'agreement', 'payment_account', 'payment_shop'])
->make(true);
}
}

View file

@ -0,0 +1,170 @@
<?php
namespace App\Http\Controllers;
use App\Mail\MailInfo;
use App\Models\Product;
use App\Models\ShoppingInstance;
use App\Models\UserHistory;
use App\User;
use Auth;
use Carbon;
use Config;
use Illuminate\Validation\Rules\In;
use Request;
use Util;
use Yard;
use Illuminate\Support\Facades\Mail;
class MembershipController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
public function index()
{
$user = User::find(Auth::user()->id);
$diff_months = 0;
if($user->payment_account){
$diff_months = Carbon::now()->diffInMonths(Carbon::parse($user->payment_account)) +1;
}
$userHistoryPaymentOrder = UserHistory::whereUserId($user->id)->whereAction('payment_order')->get()->last();
$userHistoryUpgradeOrder = UserHistory::whereUserId($user->id)->whereAction('upgrade_order')->get()->last();
$userHistoryDeleteMembership = UserHistory::whereUserId($user->id)->whereAction('delete_membership')->whereStatus(50)->get()->last();
$data = [
'user' => $user,
'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
'upgrade' => Product::where('active', true)->where('show_at', '=', 4)->where('identifier', 'upgrade')->get(),
'diff_months' => $diff_months,
'userHistoryPaymentOrder' => $userHistoryPaymentOrder,
'userHistoryUpgradeOrder' => $userHistoryUpgradeOrder,
'userHistoryDeleteMembership' => $userHistoryDeleteMembership,
];
return view('user.membership.index', $data);
}
public function storePayment($action){
$data = Request::all();
//#### remove_abo
if($action === "remove_abo"){
if(Request::get('abo_options_remove')){
$user = User::find(Auth::user()->id);
$user->abo_options = false;
$user->save();
$user->account->payment_data = null;
$user->account->save();
UserHistory::create(['user_id' => $user->id, 'action'=>'abo_options_remove', 'status'=>10]);
\Session()->flash('alert-success', "Abo-Option deaktiviert");
return back();
}
\Session()->flash('alert-error', "Fehler, Checkbox nicht bestätigt.");
return back();
}
//#### payment order
//#### shop upgrade
if($action === "upgrade_order" || $action === "payment_order"){
if(Request::get('switchers-package-wizard')){
$user = User::find(Auth::user()->id);
Yard::instance('shopping')->destroy();
$product = Product::find(Request::get('switchers-package-wizard'));
$showAboOptions = false;
if(Request::get('abo_options')){
$showAboOptions = true;
$user->abo_options = true;
$user->save();
}
if($product && $product->active && $product->show_at >= 3){
$image = "";
if($product->images->count()){
$image = $product->images->first()->slug;
}
$qty = Request::get('qty') ? Request::get('qty') : 1;
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
do {
$identifier = Util::getToken();
} while( ShoppingInstance::where('identifier', $identifier)->count() );
$data = [];
$data['is_from'] = 'membership';
$data['is_for'] = 'me';
ShoppingInstance::create([
'identifier' => $identifier,
'user_shop_id' => 1, //is first faker shop for nuy intern
'auth_user_id' => Auth::user()->id,
'payment' => 3, //Berater Membership
'subdomain' => url('/'),
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
'shopping_data' => $data,
'back' => url()->previous(),
]);
Yard::instance('shopping')->store($identifier);
//add to DB
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
UserHistory::create(['user_id' => $user->id, 'action'=>$action, 'status'=>1, 'product_id'=>$product->id, 'identifier'=>$identifier, 'abo_options'=>$showAboOptions]);
//$path = str_replace('http', 'https', $path);
return redirect()->secure($path);
}
}
}
if($action === "change_order"){
if(Request::get('switchers-package-wizard')){
$user = User::find(Auth::user()->id);
$product = Product::find(Request::get('switchers-package-wizard'));
if($user->payment_order_id == $product->id){
\Session()->flash('alert-success', "keine Änderung vorgenommen.");
return back();
}
if($product && $product->active && $product->show_at >= 3){
$user->payment_order_id = $product->id;
$user->save();
UserHistory::create(['user_id' => $user->id, 'action'=>$action, 'status'=>10, 'product_id'=>$product->id]);
\Session()->flash('alert-success', "gebuchtes Paket wurde geändert.");
return back();
}
}
}
if($action === "delete_membership"){
if(Request::get('delete_membership_mivita')){
//TODO
$user = User::find(Auth::user()->id);
if($user->isTestMode()){
$mail = config('app.info_test_mail');
}else{
$mail = config('app.info_mail');
}
Mail::to($mail)->send(new MailInfo($user, 'delete_membership'));
UserHistory::create(['user_id' => $user->id, 'action'=>$action, 'status'=>50]);
\Session()->flash('alert-success', "Mitgliedschaft beenden ist beantragt");
return back();
}
\Session()->flash('alert-error', "Fehler, Checkbox nicht bestätigt.");
return back();
}
}
}

View file

@ -0,0 +1,93 @@
<?php
namespace App\Http\Controllers;
use App\Models\Homeparty;
use App\Models\HomepartyUser;
use App\Models\Product;
use App\Models\ShoppingOrder;
use App\Models\ShoppingUser;
use App\User;
use Request;
class ModalController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function load(){
$data = Request::all();
$ret = "";
$status = false;
if(Request::ajax()){
if($data['action'] === 'shopping-order-change-member'){
$value = ShoppingOrder::find($data['id']);
$route = route('admin_sales_customers_detail', [$value->id]);
$ret = view("admin.modal.member", compact('value', 'data', 'route'))->render();
}
if($data['action'] === 'shopping-user-change-member'){
$value = ShoppingUser::find($data['id']);
$route = route('admin_customer_edit', [$value->id]);
$ret = view("admin.modal.member", compact('value', 'data', 'route'))->render();
}
if($data['action'] === 'shopping-user-is-like-member'){
$current = ShoppingUser::find($data['id']); //current user form order
$possibles = [];
if($current->is_like){
$likes = $current->getNotice('like');
foreach ($likes as $like_id=>$number){
$possibles[] = ShoppingUser::find($like_id);
}
}
$ret = view("admin.modal.is_like_member", compact('current', 'possibles', 'data'))->render();
}
if($data['action'] === 'user-order-show-product'){
$product = Product::find($data['id']); //current user form order
$ret = view("admin.modal.show_product", compact('product', 'data'))->render();
}
if($data['action'] === 'user-order-my-delivery-show'){
$user = \Auth::user();
$ret = view("admin.modal.show_user_customers", compact('user', 'data'))->render();
}
if($data['action'] === 'user-order-my-delivery-add'){
$user = \Auth::user();
/* $product = Product::find($data['id']); //current user form order
$ret = view("admin.modal.show_product", compact('product', 'data'))->render(); */
}
if($data['action'] === 'homeparty-add-product') {
$homeparty = Homeparty::find($data['id']);
$homeparty_user = HomepartyUser::find($data['user_id']);
$data['homeparty'] = $homeparty;
$ret = view("user.homeparty.modal_show_products", compact( 'data', 'homeparty', 'homeparty_user'))->render();
}
}
return response()->json(['response' => $data, 'html'=>$ret, 'status'=>$status]);
}
}
/* <button type="button" class="btn btn-sm btn-primary" data-toggle="modal"
data-target="#modals-load-content"
data-id="{{ $value->id }}"
data-model="emailTemplate"
data-action="modal-email-template"
data-url=""
data-redirect="back"
data-route="{{ route('modal_load') }}"><span class="fa fa-edit"></span></button>*/

View file

@ -0,0 +1,168 @@
<?php
/*
* clearingtype
elv Debit payment
cc Credit card
rec Invoice
cod Cash on delivery
vor Prepayment
sb Online Bank Transfer
wlt e-wallet
fnc Financing
*/
/*private $payment_methods= [
'wlt#PPE' => 'PayPal',
'cc' => 'CreditCard',
'sb#GPY' => 'giropay',
'sb#PNT' => 'Sofort',
'wlt#PDT' => 'paydirekt',
'fnc' => 'Rechnungskauf',
'pref' => 'Vorauskasse',
];*/
namespace App\Http\Controllers\Pay;
use App\Http\Controllers\Controller;
use App\Models\PaymentTransaction;
use App\Models\ShoppingPayment;
use App\Services\Payone;
use Illuminate\Http\Request;
use Util;
use Yard;
class PayController extends Controller
{
private $default = [];
private $personalData = [];
private $method = [];
private $prepayment = [];
/* private $onlineTransfer = [];
private $creditCard = []; */
private $deliveryData = [];
// private $payment_method;
private $urls = [];
private $shopping_user;
private $shopping_order;
private $shopping_payment;
private $reference;
public function __construct() {
}
public function init($shopping_user, $shopping_order){
$this->shopping_user = $shopping_user;
$this->shopping_order = $shopping_order;
$this->default['mode'] = $this->shopping_order->mode;
}
public function getShoppingPayment(){
return $this->shopping_payment;
}
//make Payone payment
public function setPrePayment($payment_method, $amount, $currency, $ret = []){
$this->reference = substr(uniqid('m', false), 0, 16);
$this->setMethod($payment_method, $ret);
$this->prepayment = [
"reference" => $this->reference, // a unique reference, e.g. order number
"amount" => $amount, // amount in smallest currency unit, i.e. cents
"currency" => $currency,
"param" => $this->shopping_order->id,
];
$this->shopping_payment = ShoppingPayment::create([
'shopping_order_id' => $this->shopping_order->id,
'clearingtype' => $this->method["clearingtype"],
'wallettype' => $this->method["wallettype"],
'onlinebanktransfertype' => $this->method["onlinebanktransfertype"],
'reference' => $this->reference,
'amount' => $amount,
'currency' => $currency,
'mode' => $this->shopping_order->mode,
]);
$this->default['mode'] = $this->shopping_order->mode;
return $this->reference;
}
public function setPersonalData(){
$this->personalData = [
"firstname" => $this->shopping_user->billing_firstname,
"lastname" => $this->shopping_user->billing_lastname, // mandatory
"street" => $this->shopping_user->billing_address,
"zip" => $this->shopping_user->billing_zipcode,
"city" => $this->shopping_user->billing_city,
"country" => ($this->shopping_user->billing_country) ? $this->shopping_user->billing_country->code : "DE", // mandatory
"email" => $this->shopping_user->billing_email,
// "language" => ($this->shopping_user->billing_country) ? strtoupper($this->shopping_user->billing_country->code) : "DE", // mandatory
"language" => "DE",
];
}
private function setMethod($payment_method, $ret = []){
//vorkasse
if($payment_method === 'vor'){
$this->method = [
"clearingtype" => "vor",
"wallettype" => "",
'onlinebanktransfertype' => "",
"request" => "authorization",
];
}
//Rechnungskauf
if($payment_method[0] === 'fnc'){
$this->method = [
"clearingtype" => "fnc",
"wallettype" => "",
'onlinebanktransfertype' => "",
"request" => "authorization",
];
}
}
public function ResponseData($identifier){
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->prepayment, $this->urls);
//RECHNUNG MIV
$payt = PaymentTransaction::create([
'shopping_payment_id' => $this->shopping_payment->id,
'request' => $this->method['request'],
'txid' => 0,
'userid' => 0,
'status' => $this->shopping_payment->clearingtype,
'transmitted_data' => $request,
'txaction' => 'open',
'mode' => $this->shopping_payment->mode,
]);
Util::setUserHistoryValue(['status'=>5]);
return redirect(route('user_checkout_final', [$payt->id, $this->reference, $identifier]));
}
}

View file

@ -0,0 +1,87 @@
<?php
namespace App\Http\Controllers;
use App\Models\PaymentMethod;
use App\Models\UserLevel;
use Request;
class PaymentMethodController extends Controller
{
public function __construct()
{
$this->middleware('admin');
}
public function index()
{
$data = [
'values' => PaymentMethod::all(),
'trans' => array_keys(config('localization.supportedLocales')),
];
return view('admin.payment_method.index', $data);
}
public function store()
{
$data = Request::all();
if($data['id'] === "new"){
$model = PaymentMethod::create([
'name' => $data['name'],
'short' => $data['short'],
'pos' => $data['pos'],
'show_at' => $data['show_at'],
'default' => isset($data['default']) ? true : false,
'active' => isset($data['active']) ? true : false,
]);
}else{
$model = PaymentMethod::find($data['id']);
$model->name = $data['name'];
$model->short = $data['short'];
$model->pos = $data['pos'];
$model->show_at = $data['show_at'];
$model->default = isset($data['default']) ? true : false;
$model->active = isset($data['active']) ? true : false;
$model->save();
}
/* if(!empty($data['trans'])){
$trans = [];
foreach ($data['trans'] as $lang => $value){
if($value && $value != null){
$trans[$lang] = $value;
}
}
if(count($trans)){
$model->trans_name = $trans;
$model->save();
}
}*/
\Session()->flash('alert-save', '1');
return redirect(route('admin_payment_methods'));
}
/*public function delete($id){
if(ProductAttribute::where('attribute_id', $id)->count()){
\Session()->flash('alert-error', 'Eintrag wird als Produktattribute verwendet');
return redirect(route('admin_product_attributes'));
}
$model = Attribute::findOrFail($id);
$model->delete();
\Session()->flash('alert-success', 'Eintrag gelöscht');
return redirect(route('admin_product_attributes'));
}
*/
}

View file

@ -0,0 +1,233 @@
<?php
namespace App\Http\Controllers;
use App\Models\Country;
use App\Models\Product;
use App\Models\ProductImage;
use App\Models\ProductIngredient;
use App\Repositories\ProductRepository;
use Request;
use Validator;
class ProductController extends Controller
{
protected $productRepo;
public function __construct(ProductRepository $productRepo)
{
$this->middleware('admin');
$this->productRepo = $productRepo;
}
public function index()
{
if(Request::get('show_active_products')){
set_user_attr('show_active_products', Request::get('show_active_products'));
}
if(get_user_attr('show_active_products') === "true"){
$values = Product::where('active', true)->orderBy('pos', 'DESC')->orderBy('id', 'DESC')->get();
}else{
$values = Product::orderBy('pos', 'DESC')->orderBy('id', 'DESC')->get();
}
$data = [
'values' => $values
];
return view('admin.product.index', $data);
}
public function edit($id)
{
if($id === "new"){
$model = new Product();
$model->active = true;
}else{
$model = Product::findOrFail($id);
}
$country_for_prices = Country::where('own_eur', '=', true)->orWhere('currency', '=', true)->get();
$data = [
'product' => $model,
'country_for_prices' => $country_for_prices,
];
return view('admin.product.edit', $data);
}
public function store()
{
$data = Request::all();
$rules = array(
'name' => 'required',
);
if($data['wp_number']){
if($data['id'] !== "new"){
$model = Product::findOrFail($data['id']);
$rules['wp_number'] = 'unique:products,wp_number,'.$model->id;
}else{
$rules['wp_number'] = 'unique:products,wp_number';
}
}
$validator = Validator::make(Request::all(), $rules);
if($data['id'] === "new"){
$model = new Product();
}else{
$model = Product::findOrFail($data['id']);
}
$country_for_prices = Country::where('own_eur', '=', true)->orWhere('currency', '=', true)->get();
$data = [
'product' => $model,
'country_for_prices' => $country_for_prices,
];
if ($validator->fails()) {
return view('admin.product.edit', $data)->withErrors($validator);
} else {
$product = $this->productRepo->update(Request::all());
\Session()->flash('alert-save', true);
return redirect(route('admin_product_edit', [$product->id]));
}
\Session()->flash('alert-save', '1');
return redirect(route('admin_product_show'));
}
public function copy($id){
$model = Product::findOrFail($id);
$product = $this->productRepo->copy($model);
\Session()->flash('alert-success', 'Eintrag kopiert');
return redirect(route('admin_product_show'));
}
public function delete($id, $do = 'product', $did = null){
if($do === 'product'){
$model = Product::findOrFail($id);
$model->delete();
\Session()->flash('alert-success', 'Eintrag gelöscht');
return redirect(route('admin_product_show'));
}
if($do === 'ingredient'){
$model = Product::findOrFail($id);
$ProductIngredient = ProductIngredient::where('ingredient_id', $did)->where('product_id', $model->id)->first();
if($ProductIngredient){
$ProductIngredient->delete();
\Session()->flash('alert-success', 'Eintrag gelöscht');
return redirect(route('admin_product_edit', [$model->id]));
}
}
}
// Upload FILE -----------------------------------------------------------------------------------------------------------------------
public function imageUpload(){
$product_id = Request::get('product_id');
$product = Product::findOrFail($product_id);
try {
$image = \App\Services\Slim::getImages('images')[0];
if ( isset($image['output']['data']) )
{
// Base64 of the image
$data = $image['output']['data'];
$file_ex = array( 'image/jpeg' => 'jpg', 'image/png' => 'png');
if (!isset($file_ex[$image['output']['type']])) {
\Session()->flash('alert-danger', 'File is not jpg or png!');
return redirect(route('admin_product_edit', [$product->id]));
}
$ext = $file_ex[$image['output']['type']];
// Original file name
$name = $image['output']['name'];
$name = \App\Services\Slim::sanitizeFileName($name);
$name = uniqid() . '_' . $name;
$data = \Storage::disk('public')->put(
'images/product/'.$product->id.'/'.$name,
$data
);
ProductImage::create([
'product_id' => $product->id,
'filename' => $name,
'original_name' => $image['output']['name'],
'ext' => $ext,
'mine' => $image['output']['type'],
'size' => $image['input']['size']
]);
\Session()->flash('alert-success', "Datei hochgeladen");
return redirect(route('admin_product_edit', [$product->id]));
}
\Session()->flash('alert-danger', "Datei leer");
return redirect(route('admin_product_edit', [$product->id]));
}
catch (Exception $e) {
\Session()->flash('alert-danger', "Fehler".$e);
return redirect(route('admin_product_edit', [$product->id]));
}
}
public function imageDelete($image_id, $product_id){
$product = Product::findOrFail($product_id);
$product_image = ProductImage::findOrFail($image_id);
if($product_image->product_id == $product->id){
$file = 'images/product/'.$product->id.'/'.$product_image->filename;
\Storage::disk('public')->delete($file);
$product_image->delete();
\Session()->flash('alert-success', "Datei gelöscht");
return redirect(route('admin_product_edit', [$product->id]));
}
\Session()->flash('alert-danger', "Datei nicht gefunden");
return redirect(route('admin_product_edit', [$product->id]));
}
public function imageAttribute($product_id, $attr, $val = false){
if(is_numeric($val) && $val < 0){
$val = 0;
}
$product_image = ProductImage::findOrFail($product_id);
$product_image->{$attr} = $val;
$product_image->save();
\Session()->flash('alert-success', "Wert gespeichert");
return redirect()->back();
}
}

View file

@ -0,0 +1,301 @@
<?php
namespace App\Http\Controllers;
use App\Models\PaymentTransaction;
use App\Models\ShoppingOrder;
use App\Models\ShoppingPayment;
use App\Models\ShoppingUser;
use App\Models\UserShop;
use App\Services\CustomerPriority;
use App\Services\Payment;
use Request;
class SalesController extends Controller
{
public function __construct(){
$this->middleware('admin');
}
public function users(){
if(Request::get('reset') === 'filter'){
return redirect(route('admin_sales_users'));
}
$data = [
];
return view('admin.sales.users', $data);
}
public function usersDetail($id)
{
$ShoppingOrder = ShoppingOrder::find($id);
if($ShoppingOrder->shipped === 0){
$ShoppingOrder->shipped = 1;
$ShoppingOrder->save();
}
$data = [
'shopping_order' => $ShoppingOrder,
'isAdmin' => true,
'isView' => 'sales_user',
];
return view('admin.sales.user_detail', $data);
}
public function usersStore($id)
{
die("keine funktion");
$data = [
'shopping_order' => ShoppingOrder::find($id),
'isAdmin' => true,
];
return view('admin.sales.user_detail', $data);
}
public function usersDatatable(){
$query = ShoppingOrder::with('shopping_user', 'shopping_payments')->select('shopping_orders.*')->where('shopping_orders.auth_user_id', '!=', NULL);
return \DataTables::eloquent($query)
->addColumn('id', function (ShoppingOrder $ShoppingOrder) {
return '<a href="' . route('admin_sales_users_detail', [$ShoppingOrder->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
})
->addColumn('created_at', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->created_at->format("d.m.Y");
})
->addColumn('txaction', function (ShoppingOrder $ShoppingOrder) {
return Payment::getShoppingOrderBadge($ShoppingOrder);
})
->addColumn('total_shipping', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->getFormattedTotalShipping()."";
})
->addColumn('payment', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->getLastShoppingPayment('getPaymentType');
})
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>';
})
->addColumn('is_for', function (ShoppingOrder $ShoppingOrder) {
if($ShoppingOrder->shopping_user->is_for === 'me'){
return '<span class="badge badge-pill badge-secondary">Beraterbestellung</span>';
}
if($ShoppingOrder->shopping_user->is_for === 'ot'){
return '<span class="badge badge-pill badge-info">Kundenbestellung</span>';
}
if($ShoppingOrder->shopping_user->is_for === 'hp'){
return '<span class="badge badge-pill badge-dark">Homepartybestellung</span>';
}
return '-';
})
->addColumn('reference', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->getLastShoppingPayment('reference');
})
->addColumn('orders', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->shopping_user ? $ShoppingOrder->shopping_user->orders : '';
})
->orderColumn('id', 'id $1')
->orderColumn('txaction', 'txaction $1')
->orderColumn('shipped', 'shipped $1')
->orderColumn('total_shipping', 'total_shipping $1')
->rawColumns(['id', 'txaction', 'is_for', 'shipped'])
->make(true);
}
public function customers()
{
if(Request::get('reset') === 'filter'){
set_user_attr('filter_txaction', null);
set_user_attr('filter_member_id', null);
return redirect(route('admin_sales_customers'));
}
$filter_members = ShoppingOrder::join('users', 'member_id', '=', 'users.id')->groupBy('member_id')->join('user_accounts', 'account_id', '=', 'user_accounts.id')->select('users.id', 'users.email', 'user_accounts.first_name', 'user_accounts.last_name')->get(); //->pluck('email', 'id')->unique()->toArray();
$data = [
'filter_members' => $filter_members,
];
return view('admin.sales.customers', $data);
}
public function customersDetail($id)
{
$ShoppingOrder = ShoppingOrder::find($id);
if($ShoppingOrder->shipped === 0){
$ShoppingOrder->shipped = 1;
$ShoppingOrder->save();
}
$data = [
'shopping_order' => $ShoppingOrder,
'isAdmin' => true,
'isView' => 'sales_customer',
];
return view('admin.sales.customer_detail', $data);
}
public function customersStore($id)
{
$data = Request::all();
$change_member_error = false;
if($data['action']==='shopping-order-change-member'){
if(!isset($data['change_member_key']) || $data['change_member_key'] !== config('main.edit_data_pass')){
$change_member_error = "Das Passwort ist falsch.";
}else{
//change
$shopping_order = ShoppingOrder::findOrFail($data['id']);
CustomerPriority::newMemberForOrder($shopping_order, $data['change_member_id'], $data['customer_set_member_for']);
\Session()->flash('alert-save', true);
return redirect(route('admin_sales_customers_detail', [$shopping_order->id]));
}
}
if($data['action']==='shopping-user-is-like-member'){
if(!isset($data['change_member_key']) || $data['change_member_key'] !== config('main.edit_data_pass')){
\Session()->flash('alert-error', 'Das Passwort ist falsch.');
return redirect($data['back']);
}else{
if(!isset($data['is_like_shopping_user_id'])){
\Session()->flash('alert-error', 'Keine Änderung ausgewählt');
return redirect($data['back']);
}
$shopping_user = ShoppingUser::findOrFail($data['id']);
$set_like_shopping_user = ShoppingUser::findOrFail($data['is_like_shopping_user_id']);
$send_member_mail = isset($data['send_member_mail']) ? true : false;
$change_shopping_user = isset($data['change_shopping_user']) ? true : false;
//Mail send in setIsLike
CustomerPriority::setIsLike($shopping_user, $set_like_shopping_user, $send_member_mail, $change_shopping_user);
\Session()->flash('alert-save', true);
return redirect($data['back']);
}
}
$data = [
'change_member_error' => $change_member_error,
'shopping_order' => ShoppingOrder::find($id),
'isAdmin' => true,
'isView' => 'sales_customer',
];
return view('admin.sales.customer_detail', $data);
}
public function customersDatatable(){
$query = ShoppingOrder::with('shopping_user')->select('shopping_orders.*')->where('shopping_orders.auth_user_id', NULL);
set_user_attr('filter_txaction', Request::get('filter_txaction'));
if(Request::get('filter_txaction') != ""){
if(Request::get('filter_txaction') === 'NULL'){
$query->where('txaction', '=', NULL);
}else{
$query->where('txaction', '=', Request::get('filter_txaction'));
}
}
set_user_attr('filter_member_id', Request::get('filter_member_id'));
if(Request::get('filter_member_id') != ""){
$query->where('member_id', '=', Request::get('filter_member_id'));
}
return \DataTables::eloquent($query)
->addColumn('id', function (ShoppingOrder $ShoppingOrder) {
return '<a href="' . route('admin_sales_customers_detail', [$ShoppingOrder->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
})
->addColumn('created_at', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->created_at->format("d.m.Y");
})
->addColumn('txaction', function (ShoppingOrder $ShoppingOrder) {
return Payment::getShoppingOrderBadge($ShoppingOrder);
})
->addColumn('total_shipping', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->getFormattedTotalShipping()."";
})
->addColumn('payment', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->getLastShoppingPayment('getPaymentType');
})
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>';
})
->addColumn('is_for', function (ShoppingOrder $ShoppingOrder) {
if($ShoppingOrder->shopping_user->is_for === 'me'){
return '<span class="badge badge-pill badge-secondary">Beraterbestellung</span>';
}
if($ShoppingOrder->shopping_user->is_for === 'ot'){
return '<span class="badge badge-pill badge-info">Kundenbestellung</span>';
}
if($ShoppingOrder->shopping_user->is_for === 'hp'){
return '<span class="badge badge-pill badge-dark">Homepartybestellung</span>';
}
return '-';
})
->addColumn('reference', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->getLastShoppingPayment('reference');
})
->addColumn('member_id', function (ShoppingOrder $ShoppingOrder) {
if($ShoppingOrder->member_id) {
return $ShoppingOrder->member_id ? '<a href="' . route('admin_lead_edit', [$ShoppingOrder->member_id]) . '">' . $ShoppingOrder->member->getFullName() . '</a>' : '';
}
if($ShoppingOrder->shopping_user && $ShoppingOrder->shopping_user->is_like){
return '<button type="button" class="btn btn-xs btn-outline-info" data-toggle="modal" data-target="#modals-load-content"
data-id="'.$ShoppingOrder->shopping_user->id.'"
data-action="shopping-user-is-like-member"
data-back="'.route('admin_sales_customers').'"
data-modal="modal-xl"
data-route="'.route('modal_load').'"><span class="fa fa-edit"></span> Berater zuordnen</button>';
}
return '';
})
->orderColumn('id', 'id $1')
->orderColumn('txaction', 'txaction $1')
->orderColumn('member_id', 'member_id $1')
->orderColumn('shipped', 'shipped $1')
->orderColumn('total_shipping', 'total_shipping $1')
->rawColumns(['id', 'member_id', 'txaction', 'user_shop_id', 'is_for', 'shipped'])
->make(true);
}
public function store(){
$data = Request::all();
if(!isset($data['id'])){
abort(404);
}
if(isset($data['action'])){
if($data['action'] === 'store_shipped' && isset($data['shipped'])){
$shopping_order = ShoppingOrder::findOrFail($data['id']);
$shopping_order->shipped = $data['shipped'];
$shopping_order->save();
}
if($data['action'] === 'store_txaction' && isset($data['txaction']) && isset($data['payment_id'])){
$shopping_order = ShoppingOrder::findOrFail($data['id']);
$shopping_payment = ShoppingPayment::findOrFail($data['payment_id']);
PaymentTransaction::create([
'shopping_payment_id' => $shopping_payment->id,
'request' => 'transaction',
'txid' => 0,
'userid' => 0,
'status' => 'FNCMIV',
'transmitted_data' => NULL,
'txaction' => $data['txaction'],
'mode' => $shopping_payment->mode,
]);
$shopping_order->txaction = $data['txaction'];
$shopping_order->paid = true;
$shopping_order->save();
$shopping_payment->txaction = $data['txaction'];
$shopping_payment->save();
//TODO can send MAIL
//Payment::paymentStatusSendMail($shopping_order, $shopping_payment, $data);
}
}
if(isset($data['back'])){
return redirect($data['back']);
}
}
}

View file

@ -0,0 +1,152 @@
<?php
namespace App\Http\Controllers;
use App\Models\Shipping;
use App\Models\ShippingCountry;
use App\Models\ShippingPrice;
use Request;
use Validator;
class ShippingController extends Controller
{
public function __construct()
{
$this->middleware('superadmin');
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index()
{
$data = [
'values' => Shipping::all(),
];
return view('admin.shipping.index', $data);
}
public function edit($shipping_id)
{
if($shipping_id === "new"){
$shipping = new Shipping();
$shipping->active = 1;
}else{
$shipping = Shipping::findOrFail($shipping_id);
}
$data = [
'value' => $shipping,
];
return view('admin.shipping.edit', $data);
}
/**
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*/
public function store(Request $request)
{
$shipping = false;
$data = Request::all();
if($data['action'] === 'shipping'){
if ($data['id'] === "new") {
$shipping = new Shipping();
$rules = array('name' => 'required');
} else {
$shipping = Shipping::findOrFail($data['id']);
$rules = array('name' => 'required');
}
$ret = ['value' => $shipping];
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
return view('admin.shipping.edit', $ret)->withErrors($validator);
}
$data = Request::all();
$shipping->name = $data['name'];
$shipping->free = $data['free'];
$shipping->active = isset($data['active']) ? true : false;
$shipping->save();
}
if($data['action'] === 'price'){
$shipping = Shipping::findOrFail($data['shipping_id']);
$rules = array('price' => 'required');
$ret = ['value' => $shipping];
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
return view('admin.shipping.edit', $ret)->withErrors($validator);
}
if ($data['id'] === "new") {
$price = ShippingPrice::create($data);
} else {
$price = ShippingPrice::findOrFail($data['id']);
if($price->shipping_id != $shipping->id){
abort(404);
}
$price->fill($data);
$price->save();
}
}
if($data['action'] === 'country'){
$shipping = Shipping::findOrFail($data['shipping_id']);
foreach($data['country_ids'] as $country_id){
if(ShippingCountry::where('country_id', $country_id)->count() == 0){
ShippingCountry::create([
'shipping_id' => $shipping->id,
'country_id' => $country_id
]);
}
}
}
if($shipping){
\Session()->flash('alert-save', true);
return redirect(route('admin_shipping_edit', [$shipping->id]));
}
return redirect(route('admin_shippings'));
}
public function deleteShipping($id)
{
$model = Shipping::findOrFail($id);
$model->delete();
\Session()->flash('alert-success', "Versandkosten gelöscht");
return redirect('/admin/shippings');
}
public function deletePrice($id)
{
$model = ShippingPrice::findOrFail($id);
$shipping = $model->shipping;
$model->delete();
\Session()->flash('alert-success', "Preis gelöscht");
return redirect(route('admin_shipping_edit', [$shipping->id]));
}
public function deleteCountry($id)
{
$model = ShippingCountry::findOrFail($id);
if($model->shopping_orders->count()){
abort(403, 'Einträge vorhanden');
}
$shipping = $model->shipping;
$model->delete();
\Session()->flash('alert-success', "Preis gelöscht");
return redirect(route('admin_shipping_edit', [$shipping->id]));
}
}

View file

@ -0,0 +1,148 @@
<?php
namespace App\Http\Controllers;
use App\Models\IqImage;
use App\Models\IqSite;
use Request;
class SitesController extends Controller
{
public function __construct()
{
$this->middleware('admin');
}
public function index()
{
//
}
public function show($site)
{
$data = [
'value' => IqSite::find(1),
'site' => $site,
];
return view('admin.site.edit', $data);
}
public function store($site)
{
$data = Request::all();
$data['products'] = isset($data['products']) ? $data['products'] : null;
$data['set_products'] = isset($data['set_products']) ? $data['set_products'] : null;
if($site == "new"){
// $model = IqSite::create($data);
}else{
$model = IqSite::find(1);
$model->fill($data);
$model->save();
}
\Session()->flash('alert-save', '1');
return redirect(route('admin_sites', ['start']));
}
// Upload FILE -----------------------------------------------------------------------------------------------------------------------
public function imageUpload($site){
$model = IqSite::find(1);
try {
$image = \App\Services\Slim::getImages('images')[0];
if ( isset($image['output']['data']) )
{
// Base64 of the image
$data = $image['output']['data'];
$file_ex = array( 'image/jpeg' => 'jpg', 'image/png' => 'png');
if (!isset($file_ex[$image['output']['type']])) {
\Session()->flash('alert-danger', 'File is not jpg or png!');
return redirect(route('admin_sites', [$model->slug]));
}
$ext = $file_ex[$image['output']['type']];
// Original file name
$name = $image['output']['name'];
$name = \App\Services\Slim::sanitizeFileName($name);
$path = 'images/iq_images/';
$image_name = "";
do {
$image_name = uniqid('', false) . '_' . $name;
} while (\Storage::disk('public')->exists($path.$image_name));
$data = \Storage::disk('public')->put(
$path.$image_name,
$data
);
$iq_image = IqImage::create([
'filename' => $image_name,
'original_name' => $image['output']['name'],
'ext' => $ext,
'mine' => $image['output']['type'],
'size' => $image['input']['size']
]);
$model->iq_image_id = $iq_image->id;
$model->save();
\Session()->flash('alert-success', "Datei hochgeladen");
return redirect(route('admin_sites', [$model->slug]));
}
\Session()->flash('alert-danger', "Datei leer");
return redirect(route('admin_sites', [$model->slug]));
}
catch (Exception $e) {
\Session()->flash('alert-danger', "Fehler".$e);
return redirect(route('admin_sites', [$model->slug]));
}
}
public function imageDelete($site, $image_id){
$iq_image = IqImage::findOrFail($image_id);
$model = IqSite::find(1);
if($iq_image->id == $model->iq_image->id){
$file = 'images/iq_images/'.$iq_image->filename;
\Storage::disk('public')->delete($file);
$model->iq_image_id = NULL;
$model->save();
$iq_image->delete();
\Session()->flash('alert-success', "Datei gelöscht");
return redirect(route('admin_sites', [$model->slug]));
}
\Session()->flash('alert-danger', "Datei nicht gefunden");
return redirect(route('admin_sites', [$model->slug]));
}
public function imageAttribute($site, $image_id, $attr, $val = false){
$iq_image = IqImage::findOrFail($image_id);
$iq_image->{$attr} = $val;
$iq_image->save();
\Session()->flash('alert-success', "Wert gespeichert");
return redirect()->back();
}
}

View file

@ -0,0 +1,205 @@
<?php
namespace App\Http\Controllers\SyS;
use App\Http\Controllers\Api\KasController;
use App\Http\Controllers\Api\KasSLLController;
use App\Http\Controllers\Controller;
use App\Mail\MailInfo;
use App\Models\PaymentMethod;
use App\Models\ShoppingUser;
use App\Models\UserShop;
use App\Repositories\ContractPDFRepository;
use App\Services\CustomerPriority;
use App\Services\Shop;
use App\User;
use Auth;
use Illuminate\Support\Facades\Mail;
use Request;
class AdminToolsController extends Controller
{
protected $userRepo;
public function __construct()
{
$this->middleware('sysadmin');
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index()
{
dd('index');
}
public function customers()
{
$shopping_users = ShoppingUser::where('member_id', '=', NULL)->where('auth_user_id', '=', NULL)->get();
$data = [
'values' => $shopping_users,
'text' => '',
];
return view('sys.admin.customers', $data);
}
public function customerStore()
{
$data = Request::all();
$ret = "";
if($data['action'] === 'makePaymentMethodsDefault'){
$users = User::where('payment_methods', '=', NULL)->get();
//$users = User::all();
foreach ($users as $user){
$user->payment_methods = PaymentMethod::getDefaultAsArray();
$user->save();
}
}
if($data['action'] === 'checkForAll'){
$shopping_users = CustomerPriority::checkForAll();
}
if($data['action'] === 'checkContractPDF'){
//create PDF
$user = User::findOrFail(80);
$pdf = new ContractPDFRepository($user);
$pdf->_set('disk', 'user');
$pdf->_set('dir', '/'.$user->id.'/documents/');
$pdf->_set('user_id', $user->id);
$pdf->_set('identifier', 'contract');
$pdf->createContractPDF();
}
if(strpos($data['action'], 'checkOne_') !== false){
$id = (int) str_replace('checkOne_', '', $data['action']);
$shopping_user = ShoppingUser::findOrFail($id);
$ret = CustomerPriority::checkOne($shopping_user);
}
\Session()->flash('alert-success', $ret);
return back();
}
public function cronjobs()
{
//$user_shops = UserShop::all();
$text = "";
$values = [
'check_payments_account' => route('cron_jobs_action', ['check_payments_account', 'key'])
];
$data = [
'values' => $values,
'text' => $text,
];
return view('sys.admin.cronjobs', $data);
}
public function cronjobsStore()
{
$data = Request::all();
\Session()->flash('alert-save', true);
return back();
}
public function domainSSL()
{
$user_shops = UserShop::all();
$text = "";
$kas = new KasController();
$domain = 'mivita.care';
$ssl = KasSLLController::getApiSSLParameter();
$subdomains = $kas->action('get_subdomains');
foreach ($subdomains as $subdomain){
$text .= $subdomain['subdomain_name']." - ".$subdomain['ssl_certificate_sni']."\n";
if($subdomain['ssl_certificate_sni'] !== "Y"){
$pra = array(
'hostname' => $subdomain['subdomain_name'],
);
$pra = array_merge($pra, $ssl);
$value = $kas->action('update_ssl', $pra);
$text .= $value."\n";
}
}
$data = [
'values' => $user_shops,
'text' => $text,
];
return view('sys.admin.domain-ssl', $data);
}
public function domainSSLStore()
{
$data = Request::all();
\Session()->flash('alert-save', true);
return back();
}
public function shoppingOrders()
{
$shopping_users = ShoppingUser::all();
$data = [
'values' => $shopping_users,
'text' => '',
];
return view('sys.admin.shopping-orders', $data);
}
public function shoppingOrdersStore()
{
//first run
$data = Request::all();
if($data['action'] === 'first_run'){
$shopping_users = ShoppingUser::whereHas('shopping_order', function($q) {
$q->where('txaction', 'paid')->OrWhere('txaction', 'appointed');
})->get();
$order_email = [];
$order_number = [];
foreach ($shopping_users as $shopping_user){
$order_email[$shopping_user->billing_email] = isset($order_email[$shopping_user->billing_email]) ? $order_email[$shopping_user->billing_email] + 1 : 1;
if($shopping_user->number) {
$order_number[$shopping_user->number] = isset($order_number[$shopping_user->number]) ? $order_number[$shopping_user->number] + 1 : 1;
$shopping_user->orders = $order_number[$shopping_user->number];
}else {
$shopping_user->orders = $order_email[$shopping_user->billing_email];
}
$shopping_user->save();
}
\Session()->flash('alert-save', true);
}
if($data['action'] === 'next_run'){
Shop::userOrders();
\Session()->flash('alert-save', true);
}
return back();
}
}

View file

@ -0,0 +1,54 @@
<?php
namespace App\Http\Controllers\SyS;
use App\Http\Controllers\Controller;
use App\Repositories\ImportRepository;
use Request;
class ImportController extends Controller
{
protected $userRepo;
protected $import;
public function __construct(ImportRepository $import)
{
$this->middleware('sysadmin');
$this->import = $import;
}
public function import()
{
$data = [
];
return view('sys.admin.import', $data);
}
public function importStore()
{
$input = Request::all();
return $this->import->upload($input);
}
public function importShow($type, $file, $skip = 0, $limit = 4000)
{
$import = $this->import->read($type, $file, $skip, $limit);
$data = [
'limit' => $limit,
'type' => $type,
'file' => $file,
'import' => $import,
'skip' => $skip,
];
return view('sys.admin.import-show', $data);
}
}

View file

@ -0,0 +1,50 @@
<?php
namespace App\Http\Controllers\SyS;
use App\Http\Controllers\Controller;
use App\Models\SySetting;
use Request;
class SettingController extends Controller
{
protected $userRepo;
public function __construct()
{
$this->middleware('sysadmin');
}
public function index()
{
$data = [
'values' => SySetting::all(),
];
return view('sys.settings.index', $data);
}
public function store()
{
$data = Request::all();
$data['active'] = isset($data['active']) ? true : false;
if($data['id'] === "new"){
$model = SySetting::create($data);
}else{
$model = SySetting::find($data['id']);
$model->fill($data);
$model->save();
}
\Session()->flash('alert-save', '1');
return redirect(route('sysadmin_settings'));
}
}

View file

@ -0,0 +1,27 @@
<?php
namespace App\Http\Controllers;
use App\User;
use App\Http\Controllers\Controller;
use Auth;
class TemplateController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function index()
{
if(Auth::check()) {
}
return view('templates.index', ['title' => 'Page 2']);
}
}

View file

@ -0,0 +1,181 @@
<?php
namespace App\Http\Controllers;
use App;
use File;
use Request;
class TranslationController extends Controller
{
protected $languagesPath;
protected $directory_separator;
protected $from;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->directory_separator = DIRECTORY_SEPARATOR;
$this->languagesPath = App::langPath();
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return redirect('admin/translate/all/edit/de');
}
/**
* @param $language
* @param string $from
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function edit($language, $from = 'en')
{
$localisations = array_keys(config('localization.supportedLocales'));
$files = $this->json_files($localisations);
$translations = $this->translationsJson($language, $from);
$show = "all";
return view('translation.index', compact('files','translations', 'language', 'from', 'show'));
}
/**
* @param $lang
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function update($language)
{
$path = $this->resourcePath($this->languagesPath);
$file = $path.$language.".json";
$data = Request::all();
$this->backup($path, $language.".json");
unset($data['_token']);
$ret = [];
//file make keys
$source = json_decode(File::get($path."de.json"));
foreach ($source as $key => $v){
$skey = $this->sanitize($key);
if(!empty($data[$skey])) {
$ret[$key] = $data[$skey];
}
}
$jsonData = json_encode($ret, TRUE);
file_put_contents($file, $jsonData);
return redirect()
->route('admin_translate_all_edit', [$language])
->with('message', 'Translation added successfully');
}
/**
* @param $langs
* @return array
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function json_files($localisations){
$path = $this->resourcePath($this->languagesPath);
$content = array();
foreach ($localisations as $local){
$file = File::get($path.$local.".json");
if($file){
$content[$local] = array('path'=>$path.$local.".json", 'content'=>json_encode($file));
}
}
return $content;
}
/**
* @param $language
* @param $from
* @return array
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function translationsJson($language, $from)
{
$path = $this->resourcePath($this->languagesPath);
$file = array();
$file['keys'] = (array) json_decode(File::get($path."de.json"));
$file['keys'] = $this->sanitizeKey($file['keys']);
$file['from'] = (array) json_decode(File::get($path.$from.".json"));
$file['from'] = $this->sanitizeKey($file['from']);
$file['dest'] = (array) json_decode(File::get($path.$language.".json"));
$file['dest'] = $this->sanitizeKey($file['dest']);
return $file;
}
private function backup($path, $file)
{
if (!File::exists(storage_path('language/'))) {
File::makeDirectory(storage_path('language/'), 0755, true);
}
return File::copy($path.$file, storage_path('language/'.time()."-".$file));
}
/**
* @param $path
* @return string
*/
protected function resourcePath($path)
{
return "{$path}{$this->directory_separator}";
}
/**
* @param $arr
* @return mixed
*/
protected function sanitizeKey($arr){
foreach ($arr as $key => $val){
unset($arr[$key]);
$arr[$this->sanitize($key)] = $val;
}
return $arr;
}
/**
* @param $string
* @param bool $force_lowercase
* @param bool $anal
* @return mixed|null|string|string[]
*/
protected function sanitize($string, $force_lowercase = true, $anal = false)
{
$strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]",
"}", "\\", "|", ";", ":", "\"", "'", "&#8216;", "&#8217;", "&#8220;", "&#8221;", "&#8211;", "&#8212;",
"—", "–", ",", "<", ".", ">", "/", "?");
$clean = trim(str_replace($strip, "", strip_tags($string)));
$clean = preg_replace('/\s+/', "_", $clean);
$clean = ($anal) ? preg_replace("/[^a-zA-Z0-9]/", "", $clean) : $clean ;
return ($force_lowercase) ?
(function_exists('mb_strtolower')) ?
mb_strtolower($clean, 'UTF-8') :
strtolower($clean) :
$clean;
}
}

View file

@ -0,0 +1,282 @@
<?php
namespace App\Http\Controllers;
use App;
use File;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Lang;
use Illuminate\Support\Collection;
use App\Requests\TranslationRequest;
class TranslationFileController extends Controller
{
/**
* Translator
*
* @var \Illuminate\Translation\Translator
*/
protected $translator;
/**
* Translation loader
*
* @var \Illuminate\Translation\LoaderInterface
*/
protected $loader;
/**
* @var \League\Flysystem\Adapter\Local
*/
protected $filesystem;
/**
* @var string
*/
protected $languagesPath;
protected $languageRead;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->directory_separator = DIRECTORY_SEPARATOR;
$this->translator = App::make('translator');
$this->loader = Lang::getLoader();
$this->languagesPath = App::langPath();
$this->directory_separator = DIRECTORY_SEPARATOR;
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$language = App::getLocale();
$langsource = 'de';
$this->languageRead = $language;
$langs = array_keys(config('localization.supportedLocales'));
$files = $this->files();
$translations = null;
$edit = false;
$show = 'all';
return view('translation.index_file', compact('files', 'translations', 'language', 'langsource', 'langs', 'edit', 'show'));
//return view('admin.transitions', $data);
}
/**
* Display edit form page
*
* @param string $language
* @param string $file
* @param string|null $namespace
*
* @return \Illuminate\Http\Response
*/
public function edit($file, $language = 'en', $langsource = 'de', $show = 'all')
{
$this->languageRead = $language;
$langs = array_keys(config('localization.supportedLocales'));
$files = $this->files();
$translations = $this->translations($file, $langsource);
$prefix = $this->groupName($file);
$langsource = $langsource;
$edit = $file;
$show = $show;
return view('translation.index_file', compact('files', 'language', 'langsource', 'file', 'translations', 'prefix', 'langs', 'edit', 'show'));
}
/**
* Save translation file
*
* @param \GeniusTS\TranslationManager\Requests\TranslationRequest $request
* @param string $language
* @param string $file
*
* @return \Illuminate\Http\Response
*/
public function update(TranslationRequest $request, $file, $language, $langsource, $show)
{
$keys = array_keys($this->translations($file));
$this->exportFile($request->only($keys), $file, $language);
return redirect()
->route('admin_translate_file_edit', [$file, $language, $langsource, $show])
->with('message', 'Translation added successfully');
}
/**
* Save a translation file
*
* @param array $translation
* @param $filename
* @param $language
*
* @return bool
*/
public function exportFile($translation, $filename, $language)
{
$path = "{$this->languagesPath}{$this->directory_separator}{$language}{$this->directory_separator}{$filename}.php";
$this->backup($path, $language, $filename);
$content = "<?php \n\n return " . var_export($translation, true) . ";";
return (bool) file_put_contents($path, $content);
//return (bool) $this->filesystem->write($path, $content, new Config);
}
/**
* Backup the existing translation files
*/
private function backup($path, $language, $filename)
{
if(!File::exists($path)){
return;
}
if (!File::exists(storage_path('language/'.time().'/'.$language))) {
File::makeDirectory(storage_path('language/'.time().'/'.$language), 0755, true);
}
return File::copy($path, storage_path('language/'.time().'/'.$language.'/'.$filename.'.php'));
}
/**
* Get the translation of a group and name space
*
* @param string $file
* @param string|null $namespace
* @param string|null $language
*
* @return array
*/
public function translations($file, $language = null)
{
$group = $this->groupName($file);
$key = $group;
return $this->translator->trans($key, [], $language ?: $this->defaultLanguage());
}
public function files($lang = false)
{
$path = $this->namespacePath($this->languagesPath, $lang);
$content = $this->pathContent($path);
return $content
->map(function ($file) use ($path) {
$path = ltrim($path . DIRECTORY_SEPARATOR, '/');
//read file empty entries
$count = $this->countEmptyEntries(Str::replaceLast($path, '', $file));
//var_dump($translations);
return array(ltrim($this->groupName(Str::replaceLast($path, '', $file)), '/') => ltrim($this->groupName(Str::replaceLast($path, '', $file)), '/')." (".$count.")");
})
->flatten();
}
public function countEmptyEntries($file){
$translation = $this->translations($file);
$group = $this->groupName($file);
$entries = 0;
$count = 0;
foreach ($translation as $key => $value)
{
$this->searchForEmpty($key, $value, null, $count, $entries, $group);
}
return $entries."/".$count;
}
protected function searchForEmpty($key, $value, $prefix, &$count, &$entries, $group)
{
$prefix = $prefix ? "{$prefix}.{$key}" : $group.".".$key;
if (is_array($value))
{
foreach ($value as $subKey => $subValue)
{
$this->searchForEmpty($subKey, $subValue, $prefix, $count,$entries, $group);
}
}
else
{
if(Lang::has($prefix, $this->languageRead, false)){
$count++;
}
if(Lang::has($prefix, 'de', false)){
$entries ++;
}
}
}
/**
* Get default language
*
* @return string
*/
public function defaultLanguage()
{
return config('app.fallback_locale', 'de');
}
/**
* Get the group name from a filename
*
* @param $filename
*
* @return mixed
*/
public function groupName($filename)
{
return preg_replace('/\.php$/', '', $filename);
}
/**
* Get default language
*
* @param string $path
* @param string $language
*
* @return string
*/
protected function namespacePath($path, $language = null)
{
return "{$path}{$this->directory_separator}" . ($language ?: $this->defaultLanguage());
}
/**
* List content of a path
*
* @param null $path
* @param bool $recursive
*
* @return \Illuminate\Support\Collection
*/
protected function pathContent($path = null, $recursive = false)
{
//var_dump($this->filesystem->listContents($path, $recursive));
//return new Collection(($this->filesystem->listContents($path, $recursive)));
return new Collection(File::files($path));
}
}

View file

@ -0,0 +1,533 @@
<?php
namespace App\Http\Controllers\User;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Pay\PayController;
use App\Http\Controllers\Pay\PayoneController;
use App\Models\Homeparty;
use App\Models\PaymentMethod;
use App\Models\PaymentTransaction;
use App\Models\ShippingCountry;
use App\Models\ShoppingOrder;
use App\Models\ShoppingOrderItem;
use App\Models\ShoppingPayment;
use App\Models\ShoppingUser;
use App\Services\CustomerPriority;
use App\Services\Payment;
use App\Services\Shop;
use App\User;
use Illuminate\Session\SessionManager;
use Illuminate\Support\Collection;
use Validator;
use App\Services\Util;
use Yard;
use Request;
class CheckoutController extends Controller
{
private $session;
private $instance;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct(SessionManager $session)
{
$this->session = $session;
$this->instance = sprintf('%s.%s', 'cart', 'payments');
}
public function checkout($identifier){
// dump(Request::all());
// $user_shop = Util::getUserShop();
//user shop
/*
$user_shop = $shopping_instance->user_shop;
if($user_shop && $user_shop->active == 1 && $user_shop->user->isActiveShop()){
Util::setPostRoute('user/');
\Session::put('user_shop', $user_shop);
\Session::put('user_shop_domain', $shopping_instance->subdomain);
\Session::put('user_shop_payment', $shopping_instance->payment);
\Session::put('user_shop_identifier', $shopping_instance->identifier);
\Session::put('isCheckout', true);
if($shopping_instance->auth_user_id){
\Session::put('auth_user', $shopping_instance->auth_user);
}
}
if($shopping_instance->back){
\Session::put('back_link', $shopping_instance->back);
}
\Session::put('new_session', true);
Yard::instance('shopping')->destroy();
//restore yard
Yard::instance('shopping')->restore($request->route('identifier'));
Yard::instance('shopping')->putYardExtra('user_shop_payment', $shopping_instance->payment);
Yard::instance('shopping')->putYardExtra('shopping_data', $shopping_instance->shopping_data);
$is_for = isset($shopping_instance->shopping_data['is_for']) ? $shopping_instance->shopping_data['is_for'] : 'ot';
Yard::instance('shopping')->setShippingCountryWithPrice($shopping_instance->country_id, $is_for);
*/
$shopping_data = Yard::instance('shopping')->getYardExtra('shopping_data');
$is_from = isset($shopping_data['is_from']) ? $shopping_data['is_from'] : 'shopping';
$is_for = isset($shopping_data['is_for']) ? $shopping_data['is_for'] : false;
$shopping_user = null;
if(\Session::has('new_session')){
$this->destroy();
\Session::forget('new_session');
}
if(!$this->getPayments('shopping_user_id')){
if($shopping_data && $is_from !== 'shopping'){
//can wizard membership user_order
//$shopping_user_id = isset($shopping_data['shopping_user_id']) ? $shopping_data['shopping_user_id'] : false;
$shopping_user = $this->shoppingUserAuthData($is_from, $is_for, $shopping_data);
$shopping_user->save();
$this->putPayments('shopping_user_id', $shopping_user->id);
}elseif($is_from === 'shopping') {
$shopping_user = new ShoppingUser();
$shopping_user->is_for = $is_for;
$shopping_user->is_from = $is_from;
$shopping_user->homeparty_id = $homeparty_id;
$shopping_user->mode = 'prev';
}
}else{
$shopping_user = ShoppingUser::findOrFail($this->getPayments('shopping_user_id'));
$shopping_user->billing_state = Shop::getCountryShippingCountryId($shopping_user->billing_country_id);
$shopping_user->shipping_state = Shop::getCountryShippingCountryId($shopping_user->shipping_country_id);
}
if($shopping_user->same_as_billing === NULL){
$shopping_user->same_as_billing = false;
}
if(old('selected_country') && old('selected_country') === 'change'){
\Session::forget('_old_input.selected_country');
$shopping_user->billing_state = old('billing_state');
$shopping_user->shipping_state = old('shipping_state');
}else{
$shopping_user->billing_state = Yard::instance('shopping')->getShippingCountryId();
$shopping_user->shipping_state = Yard::instance('shopping')->getShippingCountryId();
}
/*if(Util::getAuthUser()){
$shopping_user->abo_options = Util::getUserHistoryValue('abo_options');
//$shopping_user->save();
}*/
if($is_from !== 'shopping' && Util::getAuthUser()){
$user = Util::getAuthUser();
$payment_methods = $user->payment_methods;
$payment_data = $user->account->payment_data;
}else{
$payment_methods = PaymentMethod::getDefaultAsArray()->toArray();
$payment_data = false;
}
$payment_methods_active = \App\Models\PaymentMethod::where('active', true)->get()->pluck( 'id', 'short')->toArray();
$data = [
'is_from' => $is_from,
'is_for' => $is_for,
'shopping_data' => $shopping_data,
'user_shop' => Util::getUserShop(),
'shopping_user' => $shopping_user,
'shopping_mode' => Util::getUserShoppingMode(),
'payment_methods' => $payment_methods,
'payment_methods_active' => $payment_methods_active,
'identifier' => $identifier,
'payment_data' => $payment_data,
'back' => url()->previous(),
];
return view('user.checkout.checkout', $data);
}
private function shoppingUserAuthData($is_from, $is_for, $data = []){
$user = Util::getAuthUser();
$shopping_user = new ShoppingUser();
$shopping_user->auth_user_id = $user->id;
$shopping_user->mode = 'prev';
$shopping_user->billing_salutation = $user->account->salutation;
$shopping_user->billing_company = $user->account->company;
$shopping_user->billing_firstname = $user->account->first_name;
$shopping_user->billing_lastname = $user->account->last_name;
$shopping_user->billing_address = $user->account->address;
$shopping_user->billing_address_2 = $user->account->address_2;
$shopping_user->billing_zipcode = $user->account->zipcode;
$shopping_user->billing_city = $user->account->city;
$shopping_user->billing_country_id = $user->account->country_id;
$shopping_user->billing_phone = $user->account->phone;
$shopping_user->billing_email = $user->email;
$shopping_user->faker_mail = false;
$shopping_user->shipping_email = $user->email;
$shopping_user->accepted_data_checkbox = 1;
$shopping_user->is_for = $is_for;
$shopping_user->is_from = $is_from;
//Lieferadresse
if($is_from === 'user_order'){
if(isset($data['shopping_user_id']) && $data['is_for'] === 'ot'){
$s_user = ShoppingUser::findOrFail($data['shopping_user_id']);
/* $shopping_user->billing_salutation = $s_user->billing_salutation;
$shopping_user->billing_company = $s_user->billing_company;
$shopping_user->billing_firstname = $s_user->billing_firstname;
$shopping_user->billing_lastname = $s_user->billing_lastname;
$shopping_user->billing_address = $s_user->billing_address;
$shopping_user->billing_address_2 = $s_user->billing_address_2;
$shopping_user->billing_zipcode = $s_user->billing_zipcode;
$shopping_user->billing_city = $s_user->billing_city;
$shopping_user->billing_country_id = $s_user->billing_country_id;
$shopping_user->billing_phone = $s_user->billing_phone;
$shopping_user->billing_email = $s_user->billing_email;
;*/
$shopping_user->faker_mail = $s_user->faker_mail;
if(!$s_user->faker_mail){
$shopping_user->shipping_email = $s_user->billing_email;
}
$shopping_user->shopping_user_id = $data['shopping_user_id'];
$shopping_user->member_id = $s_user->member_id;
}
$shopping_user->same_as_billing = true;
$shopping_user->shipping_salutation = isset($data['shipping_salutation']) ? $data['shipping_salutation'] : '';
$shopping_user->shipping_company = isset($data['shipping_company']) ? $data['shipping_company'] : '';
$shopping_user->shipping_firstname = isset($data['shipping_firstname']) ? $data['shipping_firstname'] : '';
$shopping_user->shipping_lastname = isset($data['shipping_lastname']) ? $data['shipping_lastname'] : '';
$shopping_user->shipping_address = isset($data['shipping_address']) ? $data['shipping_address'] : '';
$shopping_user->shipping_address_2 = isset($data['shipping_address_2']) ? $data['shipping_address_2'] : '';
$shopping_user->shipping_zipcode = isset($data['shipping_zipcode']) ? $data['shipping_zipcode'] : '';
$shopping_user->shipping_city = isset($data['shipping_city']) ? $data['shipping_city'] : '';
$shopping_user->shipping_country_id = Yard::instance('shopping')->getShippingCountryCountryId();
$shopping_user->shipping_phone = isset($data['shipping_phone']) ? $data['shipping_phone'] : '';
}else{
$shopping_user->same_as_billing = $user->account->same_as_billing ? false : true;
$shopping_user->shipping_salutation = $user->account->shipping_salutation;
$shopping_user->shipping_company = $user->account->shipping_company;
$shopping_user->shipping_firstname = $user->account->shipping_firstname;
$shopping_user->shipping_lastname = $user->account->shipping_lastname;
$shopping_user->shipping_address = $user->account->shipping_address;
$shopping_user->shipping_address_2 = $user->account->shipping_address_2;
$shopping_user->shipping_zipcode = $user->account->shipping_zipcode;
$shopping_user->shipping_city = $user->account->shipping_city;
$shopping_user->shipping_country_id = $user->account->shipping_country_id;
$shopping_user->shipping_phone = $user->account->shipping_phone;
}
return $shopping_user;
}
public function store($identifier){
$data = Request::all();
//change selected Country
/*if(isset($data['selected_country']) && $data['selected_country'] === 'change'){
if(!Request::get('same_as_billing')){
Yard::instance('shopping')->setShippingCountryWithPrice($data['billing_state'], $data['is_for']);
}else{
Yard::instance('shopping')->setShippingCountryWithPrice($data['shipping_state'], $data['is_for']);
}
return back()->withInput(Request::all());
}*/
$rules = array(
'billing_salutation' => 'required',
'billing_firstname'=>'required',
'billing_lastname'=>'required',
'billing_email'=>'required|email',
'billing_address'=>'required',
'billing_zipcode'=>'required',
'billing_city' => 'required',
'accepted_data_checkbox' => 'accepted',
);
if(Request::get('same_as_billing')){
$rules = array_merge($rules, [
'shipping_firstname'=>'required',
'shipping_lastname'=>'required',
'shipping_address'=>'required',
'shipping_zipcode'=>'required',
'shipping_city' => 'required',
'shipping_salutation' => 'required'
]);
}
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
return back()->withErrors($validator)->withInput(Request::all());
}
$data = Request::all();
//make User
$shopping_user = $this->makeShoppingUser($data);
//make Order and Items
$shopping_order = $this->makeShoppingOrder($shopping_user);
//CustomerPriority
if($shopping_user->is_from === 'shopping'){
CustomerPriority::checkOne(ShoppingUser::find($shopping_user->id), true);
}
Util::setUserHistoryValue(['status'=>2, 'shopping_order_id'=>$shopping_order->id]);
//check credit Card
if(Request::get('payment_method')){
$ret = [];
//Rechnungskauf ohne PAYONE
if(Request::get('payment_method') === 'fnc#MIV'){
}
//other
$pay = new PayController();
$pay->init($shopping_user, $shopping_order);
$amount = Yard::instance('shopping')->totalWithShipping(2, '.', '') * 100;
$reference = $pay->setPrePayment(Request::get('payment_method'), $amount, 'EUR', $ret);
$this->putPayments('payment_reference', $reference);
$pay->setPersonalData();
return $pay->ResponseData($identifier);
}
return redirect()->back();
}
public function transactionStatus($status, $reference){
$shopping_order_id = $this->getPayments('shopping_order_id');
$ShoppingPayment = ShoppingPayment::where('shopping_order_id', $shopping_order_id)->where('reference', $reference)->first();
if(!$ShoppingPayment){
//TODO log this
Util::setUserHistoryValue(['status'=>21]);
\Session::flash('checkout-error', 'Der Zahlungsvorgang konnte nicht abgeschlossen werden, die Zahlung wurde nicht gefunden: '.$reference);
return redirect(route('checkout.checkout_card'));
}
$ShoppingPayment->status = $status;
$ShoppingPayment->save();
if($status === "success"){
Yard::instance('shopping')->destroy();
$this->destroy();
$payt = $ShoppingPayment->payment_transactions->last();
$data = [
'user_shop' => Util::getUserShop(),
'order_reference' => $reference,
'pay_trans' => $payt,
];
return view('web.templates.checkout-final', $data);
}
if($status === "cancel"){
Util::setUserHistoryValue(['status'=>22]);
\Session::flash('checkout-error', 'Der Zahlungsvorgang wurde abgebrochen, die Bestellung konnte nicht ausgeführt werden.');
return redirect(route('checkout.checkout_card'));
}
if($status === "error"){
Util::setUserHistoryValue(['status'=>23]);
\Session::flash('checkout-error', 'Der Zahlungsvorgang wurde abgebrochen, die Bestellung konnte nicht ausgeführt werden.');
return redirect(route('checkout.checkout_card'));
}
}
public function final($transactionId, $reference, $identifier) {
$payt = PaymentTransaction::findOrFail($transactionId);
if($payt->shopping_payment->reference != $reference){
abort(404);
}
Yard::instance('shopping')->destroy();
$this->destroy();
if($payt->status === 'fnc' || $payt->status === 'vor'){
$this->directPaymentStatus($payt);
}
$data = [
'order_reference' => $payt->shopping_payment->reference,
'pay_trans' => $payt,
];
return view('user.checkout.final', $data);
}
/*private function storeUserPaymentsData($shopping_user, $ret){
if($shopping_user->auth_user_id){
$user = User::find($shopping_user->auth_user_id);
if($user && $user->account){
if(isset($ret['elv']) && is_array($ret['elv'])){
$user->account->payment_data = $ret['elv'];
$user->account->save();
}
}
}
}*/
private function makeShoppingUser($data){
$data['same_as_billing'] = isset($data['same_as_billing']) ? false : true; //reinvert
$data['accepted_data_checkbox'] = isset($data['accepted_data_checkbox']) ? true : false;
$shopping_user = false;
if($this->getPayments('shopping_user_id')){
$shopping_user = ShoppingUser::find($this->getPayments('shopping_user_id'));
if($shopping_user){
$shopping_user->fill($data);
$shopping_user->mode = null;
$shopping_user->save();
}
}
if(!$shopping_user){
$shopping_user = ShoppingUser::create($data);
}
$this->putPayments('shopping_user_id', $shopping_user->id);
return $shopping_user;
}
private function makeShoppingOrder($shopping_user){
$user_shop = Util::getUserShop();
$data = [
'shopping_user_id' => $shopping_user->id,
'auth_user_id' => $shopping_user->auth_user_id,
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
'payment_for' => Util::getUserPaymentFor(),
'total' => Yard::instance('shopping')->total(2, '.', ''),
'subtotal' => Yard::instance('shopping')->subtotal(2, '.', ''),
'shipping' => Yard::instance('shopping')->shipping(2, '.', ','),
'shipping_net' => Yard::instance('shopping')->shippingNet(2, '.', ''),
'subtotal_ws' => Yard::instance('shopping')->subtotalWithShipping(2, '.', ''),
'tax' => Yard::instance('shopping')->taxWithShipping(2, '.', ''),
'total_shipping' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
'points' => Yard::instance('shopping')->points(),
'weight' => Yard::instance('shopping')->weight(),
'txaction' => 'prev',
'mode' => Util::getUserShoppingMode(),
];
$shopping_order= false;
if($this->getPayments('shopping_order_id')){
$shopping_order = ShoppingOrder::find($this->getPayments('shopping_order_id'));
if($shopping_order){
$shopping_order->fill($data);
$shopping_order->save();
}
}
if(!$shopping_order){
$shopping_order = ShoppingOrder::create($data);
}
$this->putPayments('shopping_order_id', $shopping_order->id);
$items = Yard::instance('shopping')->getContentByOrder();
$shopping_order->shopping_order_items()->each(function($model) use ($items, $shopping_order, $shopping_user) {
foreach ($items as $item) {
if ($model->row_id === $item->rowId) {
$data = [
'shopping_order_id' => $shopping_order->id,
'row_id' => $item->rowId,
'product_id' => $item->id,
'comp' => $item->options->comp,
'qty' => $item->qty,
'price' => $item->price,
'price_net' => Yard::instance('shopping')->rowPriceNet($item, 3, '.', ''),
'tax_rate' => $item->taxRate,
'slug' => $item->options->slug,
];
$model->fill($data)->save();
return false;
}
}
return $model->delete();
});
foreach ($items as $item) {
if (!ShoppingOrderItem::where('shopping_order_id', $shopping_order->id)->where('row_id', $item->rowId)->count()){
$data = [
'shopping_order_id' => $shopping_order->id,
'row_id' => $item->rowId,
'product_id' => $item->id,
'comp' => $item->options->comp,
'qty' => $item->qty,
'price' => $item->price,
'price_net' => Yard::instance('shopping')->rowPriceNet($item, 3, '.', ''),
'tax_rate' => $item->taxRate,
'slug' => $item->options->slug
];
$shopping_order_item = ShoppingOrderItem::create($data);
}
}
return $shopping_order;
}
private function putPayments($key, $value){
$content = $this->getContent();
$content->put($key, $value);
$this->session->put($this->instance, $content);
}
private function getPayments($key){
$content = $this->getContent();
if ($content->has($key)){
return $content->get($key);
}
return false;
}
private function getContent()
{
if (is_null($this->session->get($this->instance))) {
return new Collection([]);
}
return $this->session->get($this->instance);
}
public function destroy()
{
$this->session->remove($this->instance);
}
private function directPaymentStatus(PaymentTransaction $payt){
if(isset($payt->transmitted_data['param'])){
$shopping_order = ShoppingOrder::find($payt->transmitted_data['param']);
$shopping_order->txaction = 'open';
$shopping_order->save();
$shopping_payment = ShoppingPayment::where('reference', $payt->transmitted_data['reference'])->first();
if($shopping_payment){
$shopping_payment->txaction = 'open';
$shopping_payment->save();
}
//$send_link = Payment::paymentStatusPaidAction($shopping_order, false);
//$payt->request = "approved";
//$payt->save();
$data = [
'mode' => $payt->transmitted_data['mode'],
'txaction' => $payt->txaction,
'send_link' => false,
];
Payment::paymentStatusSendMail($shopping_order, $shopping_payment, $data);
}
}
}

View file

@ -0,0 +1,270 @@
<?php
namespace App\Http\Controllers\User;
use App\Http\Controllers\Controller;
use App\Models\ShoppingUser;
use App\Repositories\CustomerRepository;
use App\Services\CustomerPriority;
use App\Services\HTMLHelper;
use App\User;
use Illuminate\Support\Collection;
use Request;
use Validator;
class CustomerController extends Controller
{
protected $customerRepository;
public function __construct(CustomerRepository $customerRepository)
{
$this->middleware('active.account');
$this->customerRepository = $customerRepository;
}
public function index()
{
if(Request::get('reset') === 'filter'){
// set_user_attr('filter_member_id', null);
// set_user_attr('filter_customer_member', null);
return redirect(route('admin_customers'));
}
$data = [
];
return view('user.customer.index', $data);
}
public function detail($id)
{
$shopping_user = ShoppingUser::findOrFail($id);
if($shopping_user->member_id != \Auth::user()->id){
abort(404);
}
$data = [
'shopping_user' => $shopping_user,
'isAdmin' => false,
'isView' => 'customer',
];
return view('user.customer.detail', $data);
}
public function edit($id)
{
$shopping_user = ShoppingUser::findOrFail($id);
if($shopping_user->member_id != \Auth::user()->id){
abort(404);
}
$data = [
'shopping_user' => $shopping_user,
'isAdmin' => false,
'isView' => 'customer',
];
return view('user.customer.edit', $data);
}
public function add($id, $step=0)
{
if($id === "new"){
$shopping_user = new ShoppingUser();
$shopping_user->id = "new";
}else{
$shopping_user = ShoppingUser::findOrFail($id);
if($shopping_user->member_id != \Auth::user()->id){
abort(404);
}
}
$billing_email = null;
if(!session('errors')){
if(old('email') || old('billing_email')){
$step = 1;
$shopping_user->same_as_billing = true;
$billing_email = old('email');
}
if(old('switcher-without-email') === 'true'){
$step = 1;
$shopping_user->same_as_billing = true;
$shopping_user->faker_mail = true;
$billing_email = time()."-faker@mivita.care";
}
}
$data = [
'shopping_user' => $shopping_user,
'isAdmin' => false,
'isView' => $step === 0 ? 'customer' : 'customer-add',
'step' => $step,
'billing_email' => $billing_email,
];
return view('user.customer.add', $data);
}
private function checkShoppingUsersEmail($data){
$rules = array(
'email' => 'required|string|email|max:255|unique:shopping_users,billing_email',
);
$messages = [
'unique' => __('validation.custom.unique_email_client'),
];
$validator = Validator::make(Request::all(), $rules, $messages);
if ($validator->fails()) {
return back()->withErrors($validator)->withInput(Request::all());
}
$rules = array(
'email' => 'required|string|email|max:255|unique:users,email',
);
$messages = [
'unique' => __('validation.custom.unique_email_member'),
];
$validator = Validator::make(Request::all(), $rules, $messages);
if ($validator->fails()) {
return back()->withErrors($validator)->withInput(Request::all());
}
return back()->withInput(Request::all());
}
public function store($id)
{
$data = Request::all();
if($id === 'new' && $data['action'] === 'add_customer_with_email'){
return $this->checkShoppingUsersEmail($data);
}
if($id === 'new' && $data['action'] === 'add_customer_without_email'){
return back()->withInput(Request::all());
}
if($data['action'] === 'shopping-user-store-new' || $data['action']==='shopping-user-store'){
$rules = array(
'billing_salutation' => 'required',
'billing_firstname'=>'required',
'billing_lastname'=>'required',
'billing_email'=>'required|email',
'billing_address'=>'required',
'billing_zipcode'=>'required',
'billing_city' => 'required',
'billing_country_id' => 'required',
);
if(!Request::get('same_as_billing')){
$rules = array_merge($rules, [
'shipping_firstname'=>'required',
'shipping_lastname'=>'required',
'shipping_address'=>'required',
'shipping_zipcode'=>'required',
'shipping_city' => 'required',
'shipping_salutation' => 'required',
'shipping_country_id' => 'required'
]);
}
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
return back()->withErrors($validator)->withInput(Request::all());
}
}
$data['faker_mail'] = isset($data['faker_mail']) ? true : false;
$data['has_buyed'] = isset($data['has_buyed']) ? true : false;
$data['subscribed'] = isset($data['subscribed']) ? true : false;
//subscribed can only true when has_buyed ist active
$data['subscribed'] = $data['has_buyed'] ? $data['subscribed'] : false;
$data['same_as_billing'] = isset($data['same_as_billing']) ? true : false;
$data['shipping_country_id'] = isset($data['shipping_country_id']) ? $data['shipping_country_id'] : $data['billing_country_id'];
if($id > 0 && $data['action'] === 'shopping-user-store'){
$shopping_user = ShoppingUser::findOrFail($id);
if($shopping_user->member_id != \Auth::user()->id){
abort(404);
}
CustomerPriority::checkChangeOne($shopping_user, $data, true);
$shopping_user->fill($data);
$shopping_user->save();
}
if($id === 'new' && $data['action'] === 'shopping-user-store-new') {
$shopping_user = ShoppingUser::create($data);
$shopping_user->member_id = \Auth::user()->id;
$shopping_user->save();
CustomerPriority::checkNewOne($shopping_user, true);
}
\App\Services\Shop::newUserOrder($shopping_user->number);
if($shopping_user->is_like){
\Session()->flash('custom-error', __('validation.custom.match_found'));
}
\Session()->flash('alert-save', true);
return redirect(route('user_customer_detail', [$shopping_user->id]));
}
public function getCustomers()
{
$user = User::find(\Auth::user()->id);
$query = ShoppingUser::select(['id', 'billing_company', 'billing_salutation', 'billing_firstname', 'billing_lastname', 'billing_email', 'faker_mail', 'billing_zipcode', 'billing_city', 'billing_country_id', 'orders', 'subscribed', 'created_at', 'number', 'mode', 'is_like', 'wp_order_number'])
->where('shopping_users.member_id', '=', $user->id);
//->groupBy('shopping_users.number');
/*set_user_attr('filter_member_id', Request::get('filter_member_id'));
if(Request::get('filter_member_id') != ""){
$query->where('member_id', '=', Request::get('filter_member_id'));
}*/
return \DataTables::eloquent($query)
->addColumn('send_to', function (ShoppingUser $ShoppingUser) {
return $ShoppingUser->is_like ? '<span class="badge badge-pill badge-warning"><i class="fa fa-clock"></i> in Prüfung</span>' : '<a href="' . route('user_order_my_delivery', ['ot', $ShoppingUser->id]) . '" class="btn btn-sm btn-secondary"><span class="fa fa-shopping-cart"></span> wählen</a>';
})
->addColumn('billing_email', function (ShoppingUser $ShoppingUser) {
return $ShoppingUser->faker_mail ? "-" : $ShoppingUser->billing_email;
})
->addColumn('id', function (ShoppingUser $ShoppingUser) {
return '<a href="' . route('user_customer_detail', [$ShoppingUser->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
})
->addColumn('billing_salutation', function (ShoppingUser $ShoppingUser) {
return HTMLHelper::getSalutationLang($ShoppingUser->billing_salutation);
})
->addColumn('billing_country_id', function (ShoppingUser $ShoppingUser) {
return $ShoppingUser->billing_country ? $ShoppingUser->billing_country->getLocated() : '';
})
->addColumn('first_created_at', function (ShoppingUser $ShoppingUser) {
return $ShoppingUser->firstEntryByNumber()->created_at->format('d.m.Y');
})
->addColumn('orders', function (ShoppingUser $ShoppingUser) {
return $ShoppingUser->lastEntryByNumber()->orders;
})
->addColumn('subscribed', function (ShoppingUser $ShoppingUser) {
return get_active_badge($ShoppingUser->subscribed);
})
->addColumn('status', function (ShoppingUser $ShoppingUser) {
return $ShoppingUser->is_like ? '<span class="badge badge-pill badge-warning"><i class="fa fa-clock"></i> in Prüfung</span> ' : '<span class="badge badge-pill badge-success"><i class="fa fa-check-circle"></i> zugewiesen</span>';
})
->addColumn('extras', function (ShoppingUser $ShoppingUser) {
return $ShoppingUser->wp_order_number.($ShoppingUser->mode==='dev' ? ' <span class="badge badge-warning">dev</span>' : '');
})
->filterColumn('billing_email', function($query, $keyword) {
if($keyword != ""){
$query->where('billing_email', 'LIKE', '%'.$keyword.'%');
}
})
->orderColumn('send_to', 'id $1')
->orderColumn('id', 'id $1')
->orderColumn('billing_email', 'billing_email $1')
->orderColumn('billing_country_id', 'billing_country_id $1')
->orderColumn('billing_salutation', 'billing_salutation $1')
->orderColumn('first_created_at', 'created_at $1')
->orderColumn('orders', 'orders $1')
->orderColumn('subscribed', 'subscribed $1')
->rawColumns(['send_to', 'id', 'subscribed', 'extras', 'status'])
->make(true);
}
}

View file

@ -0,0 +1,501 @@
<?php
namespace App\Http\Controllers\User;
use App\Http\Controllers\Controller;
use App\Models\Homeparty;
use App\Models\HomepartyUser;
use App\Models\HomepartyUserOrderItem;
use App\Models\Product;
use App\Models\ShippingCountry;
use App\Models\ShoppingInstance;
use App\Models\ShoppingOrder;
use App\Models\ShoppingUser;
use App\Models\UserHistory;
use App\Models\UserShop;
use App\Services\HomepartyCart;
use App\Services\Payment;
use App\Services\Util;
use App\User;
use Auth;
use Request;
use Validator;
use Yard;
class HomepartyController extends Controller
{
public function __construct()
{
$this->middleware('superadmin');
$this->middleware('active.account');
}
public function index()
{
$data = [
'homepartys' => Homeparty::where('auth_user_id', '=', \Auth::user()->id)->get(),
];
return view('user.homeparty.index', $data);
}
public function detail($id)
{
if($id === 'new'){
$homeparty = new Homeparty();
}else{
$homeparty = $this->getHomparty($id);
}
if($homeparty->homeparty_host){
$homeparty_user = $homeparty->homeparty_host;
}else{
$homeparty_user = new HomepartyUser();
$homeparty_user->is_host = true;
}
if($homeparty->completed){
abort(404);
}
$data = [
'homeparty' => $homeparty,
'homeparty_user' => $homeparty_user,
];
return view('user.homeparty.detail', $data);
}
public function store($id = null)
{
$data = Request::all();
if($data['action'] === 'homeparty-party-store'){
$rules = array(
'date' => 'required',
'name' => 'required',
'place' => 'required'
);
}
if($data['action'] === 'homeparty-user-store'){
$rules = array(
'billing_salutation' => 'required',
'billing_firstname' => 'required',
'billing_lastname' => 'required',
'billing_address' => 'required',
'billing_zipcode' => 'required',
'billing_city' => 'required',
'billing_country_id' => 'required',
);
if (!Request::get('same_as_billing')) {
$rules = array_merge($rules, [
'shipping_firstname' => 'required',
'shipping_lastname' => 'required',
'shipping_address' => 'required',
'shipping_zipcode' => 'required',
'shipping_city' => 'required',
'shipping_salutation' => 'required',
'shipping_country_id' => 'required'
]);
}
}
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
return back()->withErrors($validator)->withInput(Request::all());
}
if($data['action'] === 'homeparty-party-store'){
if(!$id){
//first save create and empty user/host
do {
$token = Util::uuidToken();
} while( Homeparty::where('token', $token)->count() );
$data['token'] = $token;
$data['auth_user_id'] = \Auth::user()->id;
$homeparty = Homeparty::create($data);
$homeparty_user = HomepartyUser::create([
'homeparty_id' => $homeparty->id,
'auth_user_id' => \Auth::user()->id,
'is_host' => true,
]);
}else {
$homeparty = $this->getHomparty($id);
$homeparty->fill($data)->save();
}
}
if($data['action'] === 'homeparty-user-store'){
$homeparty = $this->getHomparty($id);
$data['same_as_billing'] = isset($data['same_as_billing']) ? true : false;
$data['shipping_country_id'] = isset($data['shipping_country_id']) ? $data['shipping_country_id'] : $data['billing_country_id'];
$homeparty_user = $homeparty->homeparty_host;
$homeparty_user->fill($data)->save();
}
\Session()->flash('alert-save', '1');
return redirect(route('user_homeparty_detail', $homeparty->id));
}
public function guests($id = null)
{
$homeparty = $this->getHomparty($id);
$data = [
'homeparty' => $homeparty,
];
return view('user.homeparty.guests', $data);
}
public function guestDetail($id = null, $gid = null)
{
$homeparty = $this->getHomparty($id);
if($gid === 'new'){
$homeparty_user = new HomepartyUser();
}else{
$homeparty_user = HomepartyUser::findOrFail($gid);
if($homeparty->id !== $homeparty_user->homeparty_id){
abort(404);
}
}
if($homeparty->completed){
abort(404);
}
$data = [
'homeparty' => $homeparty,
'homeparty_user' => $homeparty_user,
];
return view('user.homeparty.guest_detail', $data);
}
public function guestStore($id = null, $gid = null)
{
$data = Request::all();
$rules = array(
'billing_salutation' => 'required',
'billing_firstname' => 'required',
'billing_lastname' => 'required',
'billing_address' => 'required',
'billing_zipcode' => 'required',
'billing_city' => 'required',
'billing_country_id' => 'required',
);
if (!Request::get('same_as_billing')) {
$rules = array_merge($rules, [
'shipping_firstname' => 'required',
'shipping_lastname' => 'required',
'shipping_address' => 'required',
'shipping_zipcode' => 'required',
'shipping_city' => 'required',
'shipping_salutation' => 'required',
'shipping_country_id' => 'required'
]);
}
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
return back()->withErrors($validator)->withInput(Request::all());
}
$homeparty = $this->getHomparty($id);
if($gid === null){
$homeparty_user = HomepartyUser::create([
'homeparty_id' => $homeparty->id,
'auth_user_id' => \Auth::user()->id,
'is_host' => false,
]);
}else{
$homeparty_user = HomepartyUser::findOrFail($gid);
}
if($homeparty->id !== $homeparty_user->homeparty_id){
abort(404);
}
$data['same_as_billing'] = isset($data['same_as_billing']) ? true : false;
$data['shipping_country_id'] = isset($data['shipping_country_id']) ? $data['shipping_country_id'] : $data['billing_country_id'];
$homeparty_user->fill($data)->save();
\Session()->flash('alert-save', '1');
return redirect(route('user_homeparty_guests', [$homeparty->id]));
}
public function order($id = null)
{
$user = User::find(Auth::user()->id);
$homeparty = $this->getHomparty($id);
HomepartyCart::calculateHomeparty($homeparty);
$userHistoryPaymentOrder = UserHistory::whereUserId($user->id)->whereAction('payment_homeparty')->where('referenz', $homeparty->id)->get()->last();
$data = [
'homeparty' => $homeparty,
'userHistoryPaymentOrder' => $userHistoryPaymentOrder,
];
return view('user.homeparty.order', $data);
}
//perform Request
public function orderStore($id = null)
{
$homeparty = $this->getHomparty($id);
if(Request::ajax()) {
$data = Request::all();
if($data['action'] === 'addProduct') {
if($data['homeparty_id'] == $homeparty->id){
$homeparty_user = HomepartyUser::findOrFail($data['homeparty_user_id']);
if($homeparty_user->homeparty_id !== $homeparty->id){
abort(404);
}
if($product = Product::find($data['product_id'])){
$margin = 0;
if(\Auth::user() && \Auth::user()->user_level){
$margin = \Auth::user()->user_level->margin;
}
$HomepartyUserOrderItem = HomepartyUserOrderItem::where('homeparty_user_id', $homeparty_user->id)->where('product_id', $product->id)->first();
if($HomepartyUserOrderItem){
$HomepartyUserOrderItem->qty = $HomepartyUserOrderItem->qty+1;
$HomepartyUserOrderItem->save();
}else{
$HomepartyUserOrderItem = HomepartyUserOrderItem::create([
'homeparty_id' => $homeparty->id,
'homeparty_user_id' => $homeparty_user->id,
'product_id' => $product->id,
'qty' => 1,
'price' => $product->price,
'price_net' => $product->getPriceWith(true, false),
'tax_rate' => $product->tax,
'points' => $product->points,
'margin' => $margin,
'ek-price' => $product->getPriceWith(false, true),
'slug' => $product->slug
]);
}
}
}
$homeparty_user = HomepartyUser::findOrFail($data['homeparty_user_id']);
HomepartyCart::calculateHomeparty($homeparty);
$html_user_cart = view("user.homeparty.show_products_order", ['homeparty' => $homeparty, 'homeparty_guest' => $homeparty_user])->render();
$html_bonus = view("user.homeparty.show_bonus", ['homeparty' => $homeparty])->render();
$html_host_bonus = view("user.homeparty.show_calc_bonus_host")->render();
$html_total = view("user.homeparty.show_total_order", ['homeparty' => $homeparty])->render();
return response()->json(['response' => true, 'data'=>$data, 'html_user_cart'=>$html_user_cart, 'html_bonus'=>$html_bonus, 'html_host_bonus'=>$html_host_bonus, 'html_total'=>$html_total]);
}
if($data['action'] === 'updateCart') {
if($data['homeparty_id'] == $homeparty->id){
$homeparty_user = HomepartyUser::findOrFail($data['homeparty_user_id']);
if($homeparty_user->homeparty_id !== $homeparty->id){
abort(404);
}
if(isset($data['product_id']) && $product = Product::find($data['product_id'])){
if(isset($data['order_item_id']) && $HomepartyUserOrderItem = HomepartyUserOrderItem::find($data['order_item_id'])){
if(isset($data['qty'])){
$qty = (int) $data['qty'];
$qty = $qty < 1 ? 1 : $qty;
$qty = $qty > 100 ? 100 : $qty;
$HomepartyUserOrderItem->qty = $qty;
$HomepartyUserOrderItem->save();
}
}
}
}
$homeparty_user = HomepartyUser::findOrFail($data['homeparty_user_id']);
HomepartyCart::calculateHomeparty($homeparty);
$html_user_cart = view("user.homeparty.show_products_order", ['homeparty' => $homeparty, 'homeparty_guest' => $homeparty_user])->render();
$html_bonus = view("user.homeparty.show_bonus", ['homeparty' => $homeparty])->render();
$html_host_bonus = view("user.homeparty.show_calc_bonus_host")->render();
$html_total = view("user.homeparty.show_total_order", ['homeparty' => $homeparty])->render();
return response()->json(['response' => true, 'data'=>$data, 'html_user_cart'=>$html_user_cart, 'html_bonus'=>$html_bonus, 'html_host_bonus'=>$html_host_bonus, 'html_total'=>$html_total]);
}
if($data['action'] === 'removeFromCart') {
if($data['homeparty_id'] == $homeparty->id){
$homeparty_user = HomepartyUser::findOrFail($data['homeparty_user_id']);
if($homeparty_user->homeparty_id !== $homeparty->id){
abort(404);
}
if(isset($data['product_id']) && $product = Product::find($data['product_id'])){
if(isset($data['order_item_id']) && $HomepartyUserOrderItem = HomepartyUserOrderItem::find($data['order_item_id'])){
$HomepartyUserOrderItem->delete();
}
}
}
$homeparty_user = HomepartyUser::findOrFail($data['homeparty_user_id']);
HomepartyCart::calculateHomeparty($homeparty);
$html_user_cart = view("user.homeparty.show_products_order", ['homeparty' => $homeparty, 'homeparty_guest' => $homeparty_user])->render();
$html_bonus = view("user.homeparty.show_bonus", ['homeparty' => $homeparty])->render();
$html_host_bonus = view("user.homeparty.show_calc_bonus_host")->render();
$html_total = view("user.homeparty.show_total_order", ['homeparty' => $homeparty])->render();
return response()->json(['response' => true, 'data'=>$data, 'html_user_cart'=>$html_user_cart, 'html_bonus'=>$html_bonus, 'html_host_bonus'=>$html_host_bonus, 'html_total'=>$html_total]);
}
if($data['action'] === 'updateDeliveryOption') {
if($data['homeparty_id'] == $homeparty->id){
$homeparty_user = HomepartyUser::findOrFail($data['homeparty_user_id']);
if($homeparty_user->homeparty_id !== $homeparty->id){
abort(404);
}
if(isset($data['delivery'])){
$homeparty_user->delivery = $data['delivery'];
$homeparty_user->save();
}
}
$homeparty_user = HomepartyUser::findOrFail($data['homeparty_user_id']);
HomepartyCart::calculateHomeparty($homeparty);
$html_user_cart = view("user.homeparty.show_products_order", ['homeparty' => $homeparty, 'homeparty_guest' => $homeparty_user])->render();
$html_bonus = view("user.homeparty.show_bonus", ['homeparty' => $homeparty])->render();
$html_host_bonus = view("user.homeparty.show_calc_bonus_host")->render();
$html_total = view("user.homeparty.show_total_order", ['homeparty' => $homeparty])->render();
return response()->json(['response' => true, 'data'=>$data, 'html_user_cart'=>$html_user_cart, 'html_bonus'=>$html_bonus, 'html_host_bonus'=>$html_host_bonus, 'html_total'=>$html_total]);
}
return response()->json(['response' => false, 'data'=>$data]);
}
HomepartyCart::calculateHomeparty($homeparty);
if(\App\Services\HomepartyCart::$price === 0){
\Session()->flash('alert-error', 'Dein Warenkorb ist leer, bitte füge erst Produkte hinzu.');
return redirect(route('user_homeparty_order', [$homeparty->id]));
}
//save the calucalte card!
$time = time();
$date = date('d.m.Y H:i:s', $time);
$user = User::find(Auth::user()->id);
Yard::instance('shopping')->destroy();
Yard::instance('shopping')->add($homeparty->id, 'Bestellung Homeparty '.$date, 1, \App\Services\HomepartyCart::$price, ['image' => "", 'slug' => $time, 'weight' => 0]);
do {
$identifier = Util::getToken();
} while( ShoppingInstance::where('identifier', $identifier)->count() );
HomepartyCart::store($identifier, $date);
$data = [];
$data['is_from'] = 'homeparty';
$data['shop_price_net'] = HomepartyCart::getFormattedPriceNet();
$data['shop_price_tax'] = HomepartyCart::getFormattedPriceTax();
$data['homeparty_id'] = $homeparty->id;
$data['is_for'] = 'hp';
ShoppingInstance::create([
'identifier' => $identifier,
'user_shop_id' => 1, //is first faker shop for nuy intern
'auth_user_id' => Auth::user()->id,
'payment' => 5, //Berater Membership
'subdomain' => url('/'),
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
'shopping_data' => $data,
'back' => url()->previous(),
]);
HomepartyCart::store($identifier, $date);
Yard::instance('shopping')->store($identifier);
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
UserHistory::create(['user_id' => $user->id, 'action'=>'payment_homeparty', 'status'=>1, 'referenz'=>$homeparty->id, 'identifier'=>$identifier]);
//$path = str_replace('http', 'https', $path);
return redirect()->secure($path);
}
public function delete($do, $id = null, $gid=null)
{
$homeparty = $this->getHomparty($id);
if($do === 'hpu'){
$homeparty_user = HomepartyUser::findOrFail($gid);
if($homeparty->id !== $homeparty_user->homeparty_id){
abort(404);
}
$homeparty_user->save();
$homeparty_user->delete();
\Session()->flash('alert-success', "Homeparty Gast gelöscht");
return redirect(route('user_homeparty_guests', [$homeparty->id]));
}
if($do === 'hp') {
foreach ($homeparty->homeparty_users as $homeparty_user){
if ($homeparty->id !== $homeparty_user->homeparty_id) {
abort(404);
}
$homeparty_user->save();
$homeparty_user->delete();
}
$homeparty->delete();
\Session()->flash('alert-success', "Homeparty gelöscht");
return redirect(route('user_homepartys'));
}
abort(404);
}
private function getHomparty($id){
$homeparty = Homeparty::findOrFail($id);
if($homeparty->auth_user_id !== \Auth::user()->id){
abort(404);
}
return $homeparty;
}
public function datatable(){
$query = Product::select('products.*')->where('active', true)->where(function ($q) {
$q->where('show_at', '=', 0)
->orWhere('show_at', '=', 1);
});
return \DataTables::eloquent($query)
->addColumn('add_card', function (Product $product) {
return '<button type="button" class="btn btn-sm btn-md-extra btn-secondary add-product-basket" data-product-id="'.$product->id.'">
<strong>&euro; '.$product->getFormattedPriceWith(false, false).'</strong>&nbsp; +<span class="ion ion-md-cart"></span>
</button>';
})
->addColumn('picture', function (Product $product) {
if(count($product->images)){
return '<img class="img-fluid img-extra" alt="" src="'.route('product_image', [$product->images->first()->slug]).'">';
}
return "";
})
->addColumn('price_net', function (Product $product) {
return $product->getFormattedPriceWith(true, true). "";
})
->addColumn('price_gross', function (Product $product) {
return $product->getFormattedPriceWith(false, true). "";
})
->addColumn('price_vk_gross', function (Product $product) {
return $product->getFormattedPriceWith(false, false). "";
})
->addColumn('action', function (Product $product) {
return '<button class="btn btn-default btn-sm icon-btn md-btn-flat product-tooltip" title="details" data-modal="modal-lg"
data-toggle="modal" data-target="#modals-load-content" data-id="'.$product->id.'" data-route="'.route('modal_load').'"
data-action="user-order-show-product" data-view="customer"><i class="ion ion-md-eye"></i></button>';
})
->filterColumn('product', function($query, $keyword) {
if($keyword != ""){
$query->where('name', 'LIKE', '%'.$keyword.'%');
}
})
->orderColumn('name', 'name $1')
->orderColumn('product', 'name $1')
->orderColumn('number', 'number $1')
->orderColumn('points', 'points $1')
->orderColumn('price_net', 'price_net $1')
->orderColumn('price_gross', 'price_gross $1')
->orderColumn('price_vk_gross', 'price $1')
->orderColumn('contents_total', 'contents_total $1')
->orderColumn('weight', 'weight $1')
->rawColumns(['add_card', 'product', 'quantity', 'picture', 'action'])
->make(true);
}
}

View file

@ -0,0 +1,495 @@
<?php
namespace App\Http\Controllers\User;
use App\Http\Controllers\Controller;
use App\Models\Product;
use App\Models\ShippingCountry;
use App\Models\ShoppingInstance;
use App\Models\ShoppingOrder;
use App\Models\ShoppingUser;
use App\Models\UserHistory;
use App\Models\UserShop;
use App\Services\Payment;
use App\Services\Util;
use App\User;
use Auth;
use Request;
use Validator;
use Yard;
class OrderController extends Controller
{
public function __construct()
{
$this->middleware('superadmin');
$this->middleware('active.account');
}
public function index()
{
$data = [
];
return view('user.order.index', $data);
}
public function detail($id)
{
$user = User::find(\Auth::user()->id);
$shopping_order = ShoppingOrder::findOrFail($id);
if($shopping_order->auth_user_id !== $user->id){
abort(404);
}
$shopping_order->getLastShoppingPayment();
$data = [
'shopping_order' => $shopping_order,
'isAdmin' => false,
];
return view('user.order.detail', $data);
}
public function ordersDatatable(){
$user = User::find(\Auth::user()->id);
$query = ShoppingOrder::with('shopping_user', 'shopping_payments')->select('shopping_orders.*')->where('auth_user_id', '=', $user->id)->where('txaction', '!=', NULL);
return \DataTables::eloquent($query)
->addColumn('id', function (ShoppingOrder $ShoppingOrder) {
return '<a href="' . route('user_order_detail', [$ShoppingOrder->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
})
->addColumn('created_at', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->created_at->format("d.m.Y");
})
->addColumn('txaction', function (ShoppingOrder $ShoppingOrder) {
return Payment::getShoppingOrderBadge($ShoppingOrder);
})
->addColumn('total_shipping', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->getFormattedTotalShipping()."";
})
->addColumn('payment', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->getLastShoppingPayment('getPaymentType');
})
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>';
})
->addColumn('is_for', function (ShoppingOrder $ShoppingOrder) {
if($ShoppingOrder->shopping_user->is_for === 'me'){
return '<span class="badge badge-pill badge-secondary">Beraterbestellung</span>';
}
if($ShoppingOrder->shopping_user->is_for === 'ot'){
return '<span class="badge badge-pill badge-info">Kundenbestellung</span>';
}
if($ShoppingOrder->shopping_user->is_for === 'hp'){
return '<span class="badge badge-pill badge-dark">Homepartybestellung</span>';
}
return '-';
})
->addColumn('reference', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->getLastShoppingPayment('reference');
})
->orderColumn('id', 'id $1')
->orderColumn('txaction', 'txaction $1')
->orderColumn('shipped', 'shipped $1')
->orderColumn('total_shipping', 'total_shipping $1')
->rawColumns(['id', 'txaction', 'is_for', 'shipped'])
->make(true);
}
public function delivery($for, $id=null)
{
$user = User::find(\Auth::user()->id);
$shopping_user = null;
$delivery_id = null;
if($for === 'ot'){
$shopping_user = $this->checkShoppingUser($id, $user);
$delivery_id = $shopping_user->id;
if(!$this->checkShoppingCountry($for, $delivery_id) && !\Session()->has('custom-error')){
\Session()->flash('custom-error', __('validation.custom.shipping_not_found'));
return redirect(route('user_order_my_delivery', [$for, $delivery_id]));
}
}
if(Request::get('action') === 'next'){
Yard::instance('shopping')->destroy();
if(Request::get('switchers-radio-is-for') === 'ot'){
$delivery_id = $id;
}
return redirect(route('user_order_my_list', [Request::get('switchers-radio-is-for'), $delivery_id]));
}
$data = [
'shopping_user' => $shopping_user,
'isAdmin' => false,
'isView' => 'customer',
'for' => $for,
'delivery_id' => $delivery_id,
];
return view('user.order.delivery', $data);
}
public function list($for, $id=null)
{
$user = User::find(\Auth::user()->id);
$shopping_user = null;
$delivery_id = null;
if($for === 'ot'){
$shopping_user = $this->checkShoppingUser($id, $user);
$delivery_id = $shopping_user->id;
}
$shipping_country_id = $this->checkShoppingCountry($for, $id);
if(!$shipping_country_id){
\Session()->flash('custom-error', __('validation.custom.shipping_not_found'));
return redirect(route('user_order_my_delivery', [$for, $delivery_id]));
}
Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country_id, $for);
$data = [
'shopping_user' => $shopping_user,
'user' => $user,
'isAdmin' => false,
'isView' => 'customer',
'for' => $for,
'delivery_id' => $delivery_id,
'comp_products' => $this->getCompProducts($for),
];
return view('user.order.list', $data);
}
public function payment($for, $id=null){
$data = Request::all();
$user = User::find(Auth::user()->id);
$rules = array(
'shipping_salutation' => 'required',
'shipping_firstname'=>'required',
'shipping_lastname'=>'required',
'shipping_address'=>'required',
'shipping_zipcode'=>'required',
'shipping_city' => 'required',
'shipping_state' => 'required',
);
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
return back()->withErrors($validator)->withInput(Request::all());
}
if(Yard::instance('shopping')->getNumComp() > 0){
if(!isset($data['switchers-comp-product'])){
$validator->errors()->add('switchers-comp-product', __('Bitte wähle ein Kompensationsprodukt aus'));
}else{
if(!is_array($data['switchers-comp-product'])){
$validator->errors()->add('switchers-comp-product', __('Bitte wähle ein Kompensationsprodukt aus'));
}else{
if(count($data['switchers-comp-product']) !== Yard::instance('shopping')->getNumComp()){
$validator->errors()->add('switchers-comp-product', __('Bitte wähle :count Kompensationsprodukte aus', ['count'=>Yard::instance('shopping')->getNumComp()]));
}
}
}
if ($validator->errors()->count()) {
return back()->withErrors($validator)->withInput(Request::all());
}
}
do {
$identifier = Util::getToken();
} while( ShoppingInstance::where('identifier', $identifier)->count() );
$data['is_from'] = 'user_order';
$data['is_for'] = $for;
$data['shopping_user_id'] = $id;
unset($data['quantity']);
unset($data['_token']);
ShoppingInstance::create([
'identifier' => $identifier,
'user_shop_id' => 1, //is first faker shop for buy intern
'auth_user_id' => Auth::user()->id,
'payment' => 2, //Berater Shop
'subdomain' => url('/'),
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
'shopping_data' => $data,
'back' => url()->previous(),
]);
Yard::instance('shopping')->store($identifier);
//add to DB
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
UserHistory::create(['user_id' => $user->id, 'action'=>'user_order_payment', 'status'=>1, 'product_id'=>null, 'identifier'=>$identifier, 'abo_options'=>0]);
//$path = str_replace('http', 'https', $path);
return redirect()->secure($path);
}
private function checkShoppingCountry($for, $id=null){
$country_id = null;
if($for === 'me'){
$user = User::find(\Auth::user()->id);
if($user->same_as_billing){
$country_id = $user->account->country_id;
}else{
$country_id = $user->account->shipping_country_id;
}
}
if($for === 'ot' && $id){
$shopping_user = ShoppingUser::findOrFail($id);
if($shopping_user->same_as_billing){
$country_id = $shopping_user->billing_country_id;
}else{
$country_id = $shopping_user->shipping_country_id;
}
}
if($country_id){
if($shipping_country = ShippingCountry::whereCountryId($country_id)->first()){
return $shipping_country->id;
}
}
return false;
}
private function checkShoppingUser($id, $user){
if($id === null){
abort(403, 'Error: Keine User ID');
}
$shopping_user = ShoppingUser::findOrFail($id);
if($shopping_user->member_id !== $user->id){
abort(403, 'Error: Falsche User ID');
}
$shopping_user = ShoppingUser::findOrFail($id);
if($shopping_user->is_like){
abort(403, 'Error: Kunde in Prüfung');
}
return $shopping_user;
}
public function datatable(){
$show_at = 1;
// $user = User::find(\Auth::user()->id);
;
if(Request::get('shipping_is_for') === 'me'){
$query = Product::select('products.*')->where('active', true)->where(function ($q) {
$q->where('show_at', '=', 1)
->orWhere('show_at', '=', 2)
->orWhere('show_at', '=', 6);
});
}else{
$query = Product::select('products.*')->where('active', true)->where(function ($q) {
$q->where('show_at', '=', 0)
->orWhere('show_at', '=', 1);
});
}
//Kunden und Berater
//->orWhere('show_at', '=', 2); // Nur Berater
//->orderBy('pos', 'DESC')
//->orderBy('id', 'DESC');
return \DataTables::eloquent($query)
->addColumn('product', function (Product $product) {
$cartItem = Yard::instance('shopping')->getCartItemByProduct($product->id);
$qty = isset($cartItem->qty) ? $cartItem->qty : 0;
$rowId = isset($cartItem->rowId) ? $cartItem->rowId : '';
return '<strong>'.$product->name.'</strong><br><div class="no-line-break input-group-min-w">
<div class="input-group d-inline-flex w-auto">
<span class="input-group-prepend">
<button type="button" class="btn btn-secondary icon-btn md-btn-extra remove-product-basket" data-row-id="'.$rowId.'" data-product-id="'.$product->id.'">-</button>
</span>
<input type="text" class="form-control text-center input-extra table-input-event-onchange" name="product_qty_'.$product->id.'" data-row-id="'.$rowId.'" data-product-id="'.$product->id.'" value="'.$qty.'">
<span class="input-group-append">
<button type="button" class="btn btn-secondary icon-btn md-btn-extra add-product-basket" data-row-id="'.$rowId.'" data-product-id="'.$product->id.'">+</button>
</span>
</div>
</div>';
})
/*
->addColumn('add_card', function (Product $product) {
return '<button type="button" class="btn btn-sm btn-md-extra btn-secondary add-product-basket" data-product-id="'.$product->id.'">
<strong>&euro; '.$product->getFormattedPriceWith().'</strong>&nbsp; +<span class="ion ion-md-cart"></span>
</button>';
})
->addColumn('quantity', function (Product $product) {
$cartItem = Yard::instance('shopping')->getCartItemByProduct($product->id);
$qty = isset($cartItem->qty) ? $cartItem->qty : 0;
$rowId = isset($cartItem->rowId) ? $cartItem->rowId : '';
return '<div class="no-line-break input-group-min-w">
<div class="input-group d-inline-flex w-auto">
<span class="input-group-prepend">
<button type="button" class="btn btn-secondary icon-btn md-btn-extra remove-product-basket" data-row-id="'.$rowId.'" data-product-id="'.$product->id.'">-</button>
</span>
<input type="text" class="form-control text-center input-extra table-input-event-onchange" name="product_qty_'.$product->id.'" data-row-id="'.$rowId.'" data-product-id="'.$product->id.'" value="'.$qty.'">
<span class="input-group-append">
<button type="button" class="btn btn-secondary icon-btn md-btn-extra add-product-basket" data-row-id="'.$rowId.'" data-product-id="'.$product->id.'">+</button>
</span>
</div>
</div>';
})*/
->addColumn('picture', function (Product $product) {
if(count($product->images)){
return '<img class="img-fluid img-extra" alt="" src="'.route('product_image', [$product->images->first()->slug]).'">';
}
return "";
})
->addColumn('price_net', function (Product $product) {
return $product->getFormattedPriceWith(true, true). "";
})
->addColumn('price_gross', function (Product $product) {
return $product->getFormattedPriceWith(false, true). "";
})
->addColumn('price_vk_gross', function (Product $product) {
return $product->getFormattedPriceWith(false, false). "";
})
->addColumn('action', function (Product $product) {
return '<button class="btn btn-default btn-sm icon-btn md-btn-flat product-tooltip" title="details" data-modal="modal-lg"
data-toggle="modal" data-target="#modals-load-content" data-id="'.$product->id.'" data-route="'.route('modal_load').'"
data-action="user-order-show-product" data-view="customer"><i class="ion ion-md-eye"></i></button>';
})
->filterColumn('product', function($query, $keyword) {
if($keyword != ""){
$query->where('name', 'LIKE', '%'.$keyword.'%');
}
})
->orderColumn('name', 'name $1')
->orderColumn('product', 'name $1')
->orderColumn('number', 'number $1')
->orderColumn('points', 'points $1')
->orderColumn('price_net', 'price_net $1')
->orderColumn('price_gross', 'price_gross $1')
->orderColumn('price_vk_gross', 'price $1')
->orderColumn('contents_total', 'contents_total $1')
->orderColumn('weight', 'weight $1')
->rawColumns(['add_card', 'product', 'quantity', 'picture', 'action'])
->make(true);
}
public function performRequest(){
if(Request::ajax()) {
$data = Request::all();
$is_for = isset($data['shipping_is_for']) ? $data['shipping_is_for'] : 'ot';
$data['comp_products'] = $this->getCompProducts($is_for);
if($data['action'] === 'updateCart' && isset($data['product_id'])){
if($product = Product::find($data['product_id'])){
$image = "";
if($product->images->count()){
$image = $product->images->first()->slug;
}
//get the card item
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->getPriceWith(false, true), ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points]);
Yard::setTax($cartItem->rowId, $product->tax);
if(isset($data['qty']) && $data['qty'] > 0){
Yard::instance('shopping')->update($cartItem->rowId, $data['qty']);
}else{
//if 0 get the item by qty:1 and remove it
Yard::instance('shopping')->remove($cartItem->rowId);
}
//
Yard::instance('shopping')->reCalculateShippingPrice();
$this->checkCompProduct(Yard::instance('shopping')->getNumComp());
$html_card = view("user.order.yard_view_form", $data)->render();
$html_comp = view("user.order.comp_product", $data)->render();
return response()->json(['response' => true, 'data'=>$data, 'html_card'=>$html_card, 'html_comp'=>$html_comp]);
}
}
if($data['action'] === 'clearCart') {
Yard::instance('shopping')->destroy();
return response()->json(['response' => true, 'data'=>Yard::instance('shopping')->count(), 'html_card'=>'', 'html_comp'=>'']);
}
if($data['action'] === 'updateShippingCountry') {
if(isset($data['shipping_country_id'])){
if($shipping_country = ShippingCountry::find($data['shipping_country_id'])){
Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country->id, $is_for);
$this->checkCompProduct(Yard::instance('shopping')->getNumComp());
}
}
$html_card = view("user.order.yard_view_form", $data)->render();
$html_comp = view("user.order.comp_product", $data)->render();
return response()->json(['response' => true, 'data'=>$data, 'html_card'=>$html_card, 'html_comp'=>$html_comp]);
}
if($data['action'] === 'updateCompProduct'){
// $data['comp_product_id']
// $data['comp_num']
//count_comp_products
$this->updateCompProduct($data);
Yard::instance('shopping')->reCalculateShippingPrice();
$html_card = view("user.order.yard_view_form", $data)->render();
$html_comp = view("user.order.comp_product", $data)->render();
return response()->json(['response' => true, 'data'=>$data, 'html_card'=>$html_card, 'html_comp'=>$html_comp]);
}
return response()->json(['response' => false, 'data'=>$data]);
}
}
private function checkCompProduct($count_comp_products){
foreach (Yard::instance('shopping')->content() as $row) {
//wenn gleich löschen, da neue Versandkosten
if($row->options->comp > $count_comp_products) {
Yard::instance('shopping')->remove($row->rowId);
}
}
}
private function updateCompProduct($data){
//clear old
foreach (Yard::instance('shopping')->content() as $row) {
//wenn kleiner wurde ein produkt entfernt aufgrund der Anzahl
//wenn gleich löschen, da neue Versandkosten
if($row->options->comp === $data['comp_num'] || $row->options->comp > $data['count_comp_products']) {
Yard::instance('shopping')->remove($row->rowId);
}
}
if(isset($data['comp_product_id'])) {
if ($product = Product::find($data['comp_product_id'])) {
$image = "";
if ($product->images->count()) {
$image = $product->images->first()->slug;
}
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, 0,
['image' => $image, 'slug' => $product->slug, 'weight' => 0, 'points' => 0,
'comp' => $data['comp_num'], 'product_id' => $product->id]);
Yard::setTax($cartItem->rowId, 0);
}
}
}
private function getCompProducts($for){
if($for === 'me'){
return Product::whereActive(true)->where('show_at', '=', 1)->where('shipping_addon', true)->orderBy('pos', 'DESC')->get();
}
return null;
}
}

View file

@ -0,0 +1,74 @@
<?php
namespace App\Http\Controllers\User;
use App\Http\Controllers\Controller;
use App\Models\ShoppingOrder;
use App\Services\Payment;
use App\User;
class ShopSalesController extends Controller
{
public function __construct()
{
$this->middleware('active.shop');
}
public function orders()
{
$data = [
];
return view('user.shop.sales.orders', $data);
}
public function orderDetail($id)
{
$user = User::find(\Auth::user()->id);
$shopping_order = ShoppingOrder::findOrFail($id);
if($shopping_order->member_id !== $user->id){
abort(404);
}
$data = [
'shopping_order' => $shopping_order,
'isAdmin' => false,
];
return view('user.shop.sales.order_detail', $data);
}
public function ordersDatatable(){
$user = User::find(\Auth::user()->id);
$query = ShoppingOrder::with('shopping_user')->select('shopping_orders.*')->where('member_id', $user->id);
return \DataTables::eloquent($query)
->addColumn('id', function (ShoppingOrder $ShoppingOrder) {
return '<a href="' . route('user_shop_order_detail', [$ShoppingOrder->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
})
->addColumn('created_at', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->created_at->format("d.m.Y");
})
->addColumn('txaction', function (ShoppingOrder $ShoppingOrder) {
return Payment::getShoppingOrderBadge($ShoppingOrder);
})
->addColumn('total_shipping', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->getFormattedTotalShipping();
})
->addColumn('orders', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->shopping_user ? $ShoppingOrder->shopping_user->orders : '';
})
->addColumn('user_shop_id', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->user_shop ? '<a href="'.$ShoppingOrder->user_shop->getSubdomain(false).'" target="_blank">'.$ShoppingOrder->user_shop->getSubdomain(false).'</span>' : '';
})
->orderColumn('id', 'id $1')
->orderColumn('txaction', 'txaction $1')
->orderColumn('user_shop_id', 'user_shop_id $1')
->rawColumns(['id', 'txaction', 'user_shop_id'])
->make(true);
}
}

View file

@ -0,0 +1,31 @@
<?php
namespace App\Http\Controllers\User;
use App\Http\Controllers\Controller;
use App\User;
class TeamController extends Controller
{
public function __construct()
{
$this->middleware('active.account');
}
public function members()
{
$user = User::find(\Auth::user()->id);
if($user->isActiveShop() && $user->shop){
$shop_register_link = $user->shop->getSubdomain(false)."/reg";
}else{
$member_id = 'm'.($user->id + config('mivita.add_number_id'));
$shop_register_link = config('app.protocol').config('app.domain').config('app.tld_care').'/reg/'.$member_id;
}
$data = [
'shop_register_link' => $shop_register_link
];
return view('user.team.members', $data);
}
}

View file

@ -0,0 +1,221 @@
<?php
namespace App\Http\Controllers;
use App\Repositories\UserRepository;
use App\User;
use Auth;
use Request;
use Validator;
class UserDataController extends Controller
{
protected $userRepo;
public function __construct(UserRepository $userRepo)
{
$this->middleware('auth');
$this->userRepo = $userRepo;
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function userEdit(){
$user = Auth::user();
/*if(!$user->account){
$user->account = new UserAccount();
}*/
$data = [
'user' => $user,
];
return view('user.edit', $data);
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*/
public function userEditStore(){
$user = Auth::user();
/*if(!$user->account){
$user->account = new UserAccount();
}*/
$rules = array(
'salutation' => 'required',
'first_name'=>'required',
'last_name'=>'required',
'address'=>'required',
'zipcode'=>'required',
'city' => 'required',
'email' => 'required|string|email|max:255|exists:users,email',
'email-confirm' => 'required|same:email',
);
if(!Request::get('same_as_billing')){
$rules = array_merge($rules, [
'shipping_firstname'=>'required',
'shipping_lastname'=>'required',
'shipping_address'=>'required',
'shipping_zipcode'=>'required',
'shipping_city' => 'required',
'shipping_salutation' => 'required'
]);
}
$data = [
'user' => $user,
];
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
return view('user.edit', $data)->withErrors($validator);
} else {
$this->userRepo->update(Request::all());
\Session()->flash('alert-save', true);
return redirect('/user/edit');
}
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*/
public function userDataStore(){
$user = User::findOrFail(Auth::user()->id);
if(!$user->account){
$user->account = new UserAccount();
}
$rules = array(
'salutation' => 'required',
'last_name' => 'required|max:255',
'country_id' => 'required|integer|min:1',
'email' => 'required|string|email|max:255|exists:users,email',
'email-confirm' => 'required|same:email',
);
if($user->active == 0){
$rules['accepted_data_protection'] = 'required';
$rules['accepted_active'] = 'required';
}
if(Request::get('company') == 1){
$rules['company_name'] = 'required|max:255';
$rules['company_country_id'] = 'required|integer|min:1';
}
$data = [
'user' => $user,
];
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
// get the error messages from the validator
$messages = $validator->messages();
// redirect our user back to the form with the errors from the validator
return view('user.edit', $data)->withErrors($validator);
} else {
$this->userRepo->update(Request::all());
if($user->active == 0) {
$account = $user->account;
$account->data_protection = now();
$account->save();
$user->active = 1;
$user->active_date = now();
$user->save();
}
if(Request::get('accepted_active') == "on"){
$user->agreement = now();
}else{
$user->agreement = null;
}
\Session()->flash('alert-save', true);
return redirect('/home');
}
}
/**
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function userDataAcceptedForm(){
$user = Auth::user();
if(Request::get('accepted_active') == "on"){
$user->agreement = now();
}else {
$user->agreement = null;
}
$user->save();
\Session()->flash('alert-save', true);
return redirect('/home');
}
/**
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function userDataFree(){
$user = Auth::user();
$user->active = 1;
$user->active_date = now();
$user->save();
return redirect('/home');
}
/**
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function userDataFreeForm(){
$user = Auth::user();
$rules = array(
'accepted_data_protection' => 'required'
);
$data = [
'user' => $user,
];
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
// get the error messages from the validator
$messages = $validator->messages();
// redirect our user back to the form with the errors from the validator
return view('home', $data)->withErrors($validator);
} else {
$account = $user->account;
$account->data_protection = now();
$account->save();
if(Request::get('accepted_active') == "on"){
$user->agreement = now();
}else{
$user->agreement = null;
}
$user->active = 1;
$user->active_date = now();
$user->save();
}
return redirect('/home');
}
}

View file

@ -0,0 +1,72 @@
<?php
namespace App\Http\Controllers;
use Auth;
use Validator;
use Request;
use Illuminate\Support\Facades\Hash;
use App\Repositories\UserRepository;
class UserDeleteController extends Controller
{
protected $userRepo;
/**
* UserController constructor.
* @param UserRepository $userRepo
*/
public function __construct(UserRepository $userRepo)
{
$this->middleware('auth');
$this->userRepo = $userRepo;
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function deleteAccount(){
return view('user.delete_account');
}
/**
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*/
public function deleteAccountAction(Request $request)
{
$user = Auth::user();
$rules = array(
'old_password' => 'required|old_password:' . Auth::user()->password,
);
Validator::extend('old_password', function ($attribute, $value, $parameters, $validator) {
return Hash::check($value, current($parameters));
});
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
// get the error messages from the validator
$messages = $validator->messages();
// redirect our user back to the form with the errors from the validator
return view('user.delete_account')->withErrors($validator);
}else{
$this->userRepo->deleteUser($user);
//make delete
Auth::logout();
\Session()->flash('alert-danger', __('account deleted'));
return redirect(route('home'));
}
}
}

View file

@ -0,0 +1,84 @@
<?php
namespace App\Http\Controllers;
use App\Models\Attribute;
use App\Models\ProductAttribute;
use App\Models\UserLevel;
use Request;
class UserLevelController extends Controller
{
public function __construct()
{
$this->middleware('admin');
}
public function index()
{
$data = [
'values' => UserLevel::all(),
'trans' => array_keys(config('localization.supportedLocales')),
];
return view('admin.level.index', $data);
}
public function store()
{
$data = Request::all();
if($data['id'] == "new"){
$model = UserLevel::create([
'name' => $data['name'],
'pos' => $data['pos'],
'content' => $data['content'],
'active' => isset($data['active']) ? true : false,
]);
}else{
$model = UserLevel::find($data['id']);
$model->name = $data['name'];
$model->pos = $data['pos'];
$model->content = $data['content'];
$model->active = isset($data['active']) ? true : false;
$model->save();
}
if(!empty($data['trans'])){
$trans = [];
foreach ($data['trans'] as $lang => $value){
if($value && $value != null){
$trans[$lang] = $value;
}
}
if(count($trans)){
$model->trans_name = $trans;
$model->save();
}
}
\Session()->flash('alert-save', '1');
return redirect(route('admin_levels'));
}
/*public function delete($id){
if(ProductAttribute::where('attribute_id', $id)->count()){
\Session()->flash('alert-error', 'Eintrag wird als Produktattribute verwendet');
return redirect(route('admin_product_attributes'));
}
$model = Attribute::findOrFail($id);
$model->delete();
\Session()->flash('alert-success', 'Eintrag gelöscht');
return redirect(route('admin_product_attributes'));
}
*/
}

View file

@ -0,0 +1,408 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Api\KasController;
use App\Http\Controllers\Api\KasSLLController;
use App\Models\UserShop;
use App\Models\UserShopOnSite;
use App\Repositories\UserRepository;
use Auth;
use Cviebrock\EloquentSluggable\Services\SlugService;
use Request;
use Response;
use Validator;
class UserShopController extends Controller
{
protected $db;
protected $userRepo;
public function __construct(UserRepository $userRepo)
{
$this->middleware('active.shop');
$this->userRepo = $userRepo;
}
public function index()
{
$user = Auth::user();
if ($user->shop && !$user->shop->set_defaults) {
if ($user->account) {
$user->shop->title = $user->account->first_name . " " . $user->account->last_name;
}
if ($user->account) {
$user->shop->contact = $this->generate_contact($user);
} else {
$user->shop->contact = "Deine Straße/Nr • Dein PLZ Ort\nFestnetz: Deine Festnetz-Nummer\nMobil: Deine Mobil-Nummer\nDeine E-Mail-Adresse";
}
$user->shop->accessibility = "Mo-Fr: 9.00 - 19.00 Uhr\nSa-So: 11.00 - 18.00 Uhr";
}
$data = [
'user' => $user,
];
return view('user.shop', $data);
}
public function store()
{
$user = Auth::user();
$data = Request::all();
if (!$user->shop) {
abort(404);
}
$user->shop->title = $data['title'];
$user->shop->contact = trim(preg_replace('/\s*\n+/',"\n", $data['contact']));
$user->shop->accessibility = trim(preg_replace('/\s*\n+/',"\n", $data['accessibility']));
$user->shop->about = trim(preg_replace('/\s+/', ' ',$data['about']));
$user->shop->active = isset($data['active']) ? true : false;
$user->shop->set_defaults = true;
$user->shop->save();
\Session()->flash('alert-save', true);
return redirect(route('user_shop'));
}
private function generate_contact($user)
{
$ret = "";
$sep = "\n";
$ret = $user->account->street != "" ? $user->account->street : "Deine Straße/Nr";
$ret .= "";
$ret.= $user->account->postal_code != "" ? $user->account->postal_code." " : "Dein PLZ ";
$ret.= $user->account->city != "" ? $user->account->city : "Dein Ort";
$ret.= $sep;
$pre = $user->account->pre_phone_id != "" ? $user->account->pre_phone->phone." " : "";
$ret.= "Festnetz: ".($user->account->phone != "" ? $pre.$user->account->phone : "Deine Festnetz-Nummer");
$ret.= $sep;
$pre = $user->account->pre_mobil_id != "" ? $user->account->pre_mobil->phone." " : "";
$ret.= "Mobil: ".($user->account->mobil != "" ? $pre.$user->account->mobil : "Deine Mobil-Nummer");
$ret.= $sep;
$ret.= $user->email;
return $ret;
}
// Upload FILE -----------------------------------------------------------------------------------------------------------------------
public function uploadImage(){
$user = Auth::user();
if(!$user->shop){
abort(404);
}
try {
$image = \App\Services\Slim::getImages('images')[0];
if ( isset($image['output']['data']) )
{
// Base64 of the image
$data = $image['output']['data'];
$file_ex = array( 'image/jpeg' => 'jpg', 'image/png' => 'png');
if (!isset($file_ex[$image['output']['type']])) {
\Session()->flash('alert-danger', 'File is not jpg or png!');
return redirect(route('user_shop'));
}
$ext = $file_ex[$image['output']['type']];
// Original file name
$name = $image['output']['name'];
$name = \App\Services\Slim::sanitizeFileName($name);
$name = uniqid() . '_' . $name;
$data = \Storage::disk('public')->put(
'images/shop/'.$name,
$data
);
$user->shop->filename = $name;
$user->shop->originalname = $image['output']['name'];
$user->shop->ext = $ext;
$user->shop->mine = $image['output']['type'];
$user->shop->size = $image['input']['size'];
$user->shop->save();
\Session()->flash('alert-success', "Datei hochgeladen");
return redirect(route('user_shop'));
}
\Session()->flash('alert-danger', "Datei leer");
return redirect(route('user_shop'));
}
catch (Exception $e) {
\Session()->flash('alert-danger', "Fehler".$e);
return redirect(route('user_shop'));
}
}
public function deleteImage(){
$user = Auth::user();
if(!$user->shop){
abort(404);
}
if($user->shop->filename){
$file = 'images/shop/'.$user->shop->filename;
\Storage::disk('public')->delete($file);
$user->shop->filename = null;
$user->shop->originalname = null;
$user->shop->ext = null;
$user->shop->mine = null;
$user->shop->size = null;
$user->shop->save();
\Session()->flash('alert-success', "Datei gelöscht");
return redirect(route('user_shop'));
}
\Session()->flash('alert-danger', "Datei nicht gefunden");
return redirect(route('user_shop'));
}
public function uploadOnSiteImage(){
$user = Auth::user();
$user_shop_id = Request::get('user_shop_id');
if(!$user->shop || $user->shop->id != $user_shop_id){
abort(404);
}
try {
$image = \App\Services\Slim::getImages('images')[0];
if ( isset($image['output']['data']) )
{
// Base64 of the image
$data = $image['output']['data'];
$file_ex = array( 'image/jpeg' => 'jpg', 'image/png' => 'png');
if (!isset($file_ex[$image['output']['type']])) {
\Session()->flash('alert-danger', 'File is not jpg or png!');
return redirect(route('user_shop'));
}
$ext = $file_ex[$image['output']['type']];
// Original file name
$name = $image['output']['name'];
$name = \App\Services\Slim::sanitizeFileName($name);
$name = uniqid() . '_' . $name;
$data = \Storage::disk('public')->put(
'images/user_shop/'.$user->shop->id.'/'.$name,
$data
);
UserShopOnSite::create([
'user_shop_id' => $user->shop->id,
'filename' => $name,
'original_name' => $image['output']['name'],
'ext' => $ext,
'mine' => $image['output']['type'],
'size' => $image['input']['size']
]);
\Session()->flash('alert-success', "Datei hochgeladen");
return redirect(route('user_shop'));
}
\Session()->flash('alert-danger', "Datei leer");
return redirect(route('user_shop'));
}
catch (Exception $e) {
\Session()->flash('alert-danger', "Fehler".$e);
return redirect(route('user_shop'));
}
}
public function deleteOnSiteImage($image_id, $user_shop_id){
$user = Auth::user();
if(!$user->shop || $user->shop->id != $user_shop_id){
abort(404);
}
$image = UserShopOnSite::findOrFail($image_id);
if($image->user_shop_id == $user_shop_id){
$file = 'images/user_shop/'.$user_shop_id.'/'.$image->filename;
\Storage::disk('public')->delete($file);
$image->delete();
\Session()->flash('alert-success', "Datei gelöscht");
return redirect(route('user_shop'));
}
\Session()->flash('alert-danger', "Datei nicht gefunden");
return redirect(route('user_shop'));
}
/**
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function userShopRegisterForm(){
if(Request::get('shop_submit') == 'check'){
$rules = array(
'user_shop_name' => ' required|alpha_dash|profanity|unique:user_shops,name|min:4|max:20|full_word_check',
);
Validator::extend('full_word_check', function ($attribute, $value, $parameters, $validator) {
if(in_array($value, config('profanity.full_word_check'))){
return false;
}
return true;
});
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
\Session()->flash('shop-name-error', 'error');
return redirect()->back()->withErrors($validator)->withRequest();
}
\Session()->flash('shop-name-error', 'check');
return redirect(route('user_shop'))->withRequest();
}
if(Request::get('shop_submit') == 'action') {
$rules = array(
'user_shop_name' => ' required|alpha_dash|profanity|unique:user_shops,name|min:4|max:20|full_word_check',
);
Validator::extend('full_word_check', function ($attribute, $value, $parameters, $validator) {
if(in_array($value, config('profanity.full_word_check'))){
return false;
}
return true;
});
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
\Session()->flash('shop-name-error', 'error');
}else{
\Session()->flash('shop-name-error', 'check');
}
$rules = array(
'user_shop_active' => 'accepted',
);
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
return redirect()->back()->withErrors($validator)->withRequest();
}
//all is right - save
$user = Auth::user();
$data = Request::all();
$user_shop = UserShop::create([
'user_id' => $user->id,
'name' => $data['user_shop_name'],
'active' => true,
'active_date' => now(),
]
);
$ret = $this->userShopRegisterSubDomain($user_shop->slug);
if($ret['success'] === true){
\Session()->flash('alert-save', true);
}else{
$user_shop->forceDelete();
\Session()->flash('alert-error', $ret['error']);
}
return redirect(route('user_shop'));
}
}
public function userShopRegisterSubDomain($slug){
$kas = new KasController();
$domain = 'mivita.care';
//check if exisist
$subdomains = $kas->action('get_subdomains');
foreach ($subdomains as $subdomain){
$sub = str_replace(".".$domain, '', $subdomain['subdomain_name']);
if($sub == $slug){
return ['success' => false, 'error' => 'Fehler: Subdomain existierts bereits, bitte einen neues Namen wählen'];
}
}
//add
$full_subdomain_name = $slug.".".$domain;
$pra = array(
'subdomain_name' => $slug,
'domain_name' => $domain,
'subdomain_path' => '/mein.mivita.care/public/',
'php_version' => '7.3',
//'ssl_proxy' => 'Y',
//'redirect_status' => 0
);
$add_subdomain = $kas->action('add_subdomain', $pra);
if($add_subdomain == $full_subdomain_name){
return ['success' => true];
}
return ['success' => false, 'error' => $add_subdomain];
}
/**
* @return string to ajax
*/
public function checkUserShopName(){
$rules = array(
'user_shop_name' => ' required|alpha_dash|profanity|unique:user_shops,name|min:4|max:20|full_word_check',
);
Validator::extend('full_word_check', function ($attribute, $value, $parameters, $validator) {
if(in_array($value, config('profanity.full_word_check'))){
return false;
}
return true;
});
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
//$messages = $validator->messages();
return Response::json(array(
'success' => false,
'errors' => $validator->getMessageBag()->toArray()
));
}
$slug = SlugService::createSlug(UserShop::class, 'slug', Request::get('user_shop_name'));
return Response::json(array(
'success' => true,
'preview_user_shop_name' => "https://".$slug.".".config('app.domain').config('app.tld_care'),
));
}
}

View file

@ -0,0 +1,209 @@
<?php
namespace App\Http\Controllers;
use App\User;
use Auth;
use Validator;
use Request;
use Carbon\Carbon;
use Illuminate\Database\Connection;
use App\Mail\MailActivateUser;
use Illuminate\Support\Facades\Mail;
class UserUpdateEmailController extends Controller
{
protected $db;
protected $table = 'user_update_emails';
protected $resendAfter = 60; //1min
public function __construct(Connection $db)
{
$this->db = $db;
}
public function index()
{
return view('user.update_email');
}
public function update(Request $request)
{
$user = Auth::user();
$rules = array(
'email' => 'required|string|email|max:255|unique:users|confirmed|users_update_email:' . Auth::user()->id,
//'email-confirm' => 'required|same:email',
);
Validator::extend('users_update_email', function ($attribute, $value, $parameters, $validator) {
if($this->db->table($this->table)->where('email', '=', $value)->where('user_id', '!=', $parameters[0])->count()){
return false;
}
return true;
});
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
// redirect our user back to the form with the errors from the validator
$messages = $validator->messages();
return view('user.update_email')->withErrors($validator);
}else{
$this->sendActivationMail($user, Request::all());
\Session()->flash('alert-success', __('We sent you an activation code. Check your email!'));
return redirect(route('user_update_email'));
}
}
public function adminChangeMail($user_id)
{
if(!Auth::user()->isAdmin()){
abort(404);
}
$data = [
'user' => User::findOrFail($user_id),
];
return view('admin.change_email', $data);
}
public function adminUpdateMail(Request $request, $user_id)
{
if(!Auth::user()->isAdmin()){
abort(404);
}
$user = User::findOrFail($user_id);
$data = [
'user' => $user,
];
$rules = array(
'email' => 'required|string|email|max:255|unique:users|confirmed|users_update_email:' . $user->id,
//'email-confirm' => 'required|same:email',
);
Validator::extend('users_update_email', function ($attribute, $value, $parameters, $validator) {
if($this->db->table($this->table)->where('email', '=', $value)->where('user_id', '!=', $parameters[0])->count()){
return false;
}
return true;
});
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
// redirect our user back to the form with the errors from the validator
$messages = $validator->messages();
return view('admin.change_email', $data)->withErrors($validator);
}else{
$this->sendActivationMail($user, Request::all());
\Session()->flash('alert-success', __('An activation code was sent to the account by e-mail!'));
return redirect(route('admin_lead_edit', [$user->id]));
}
}
public function activateMail($token)
{
if ($updateEmail = $this->getUpdateEmailByToken($token)) {
$user = User::findOrFail($updateEmail->user_id);
if($user->id == $updateEmail->user_id){
$user->fill([
'email' => $updateEmail->email
])->save();
$this->deleteUpdateEmail($token);
//Login!
Auth::login($user);
\Session()->flash('alert-success', __('Your e-mail has been changed.'));
return redirect('/home');
}
}
return redirect('/home');
abort(404);
}
public function sendActivationMail($user, array $data)
{
$token = $this->createActivation($user, $data);
Mail::to($data['email'])->send(new MailActivateUser($token, $user));
}
protected function getToken()
{
return hash_hmac('sha256', str_random(40), config('app.key'));
}
public function createActivation($user, array $data)
{
$updateEmail = $this->getUpdateEmail($user);
if (!$updateEmail) {
return $this->createToken($user, $data);
}
return $this->regenerateToken($user, $data);
}
private function regenerateToken($user, array $data)
{
$token = $this->getToken();
$this->db->table($this->table)->where('user_id', $user->id)->update([
'email' => $data['email'],
'token' => $token,
'created_at' => new Carbon()
]);
return $token;
}
private function createToken($user, array $data)
{
$token = $this->getToken();
$this->db->table($this->table)->insert([
'user_id' => $user->id,
'email' => $data['email'],
'token' => $token,
'created_at' => new Carbon()
]);
return $token;
}
public function getUpdateEmail($user)
{
return $this->db->table($this->table)->where('user_id', $user->id)->first();
}
public function getUpdateEmailByToken($token)
{
return $this->db->table($this->table)->where('token', $token)->first();
}
public function deleteUpdateEmail($token)
{
$this->db->table($this->table)->where('token', $token)->delete();
}
}

View file

@ -0,0 +1,108 @@
<?php
namespace App\Http\Controllers;
use Auth;
use Illuminate\Support\Facades\Hash;
use Validator;
use Request;
class UserUpdatePasswordController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function updatePassword()
{
return view('user.update_password');
}
/**
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*/
public function updatePasswordStore(Request $request)
{
$rules = array(
'old_password' => 'required|old_password:' . Auth::user()->password,
'password' => 'required|string|min:8|confirmed',
);
Validator::extend('old_password', function ($attribute, $value, $parameters, $validator) {
return Hash::check($value, current($parameters));
});
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
// get the error messages from the validator
$messages = $validator->messages();
// redirect our user back to the form with the errors from the validator
return view('user.update_password')->withErrors($validator);
}
$request->user()->fill([
'password' => Hash::make($request->password)
])->save();
\Session()->flash('alert-save', '1');
return redirect(route('user_update_password'));
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*/
public function updatePasswordFirst(){
if(!Auth::user()->isPasswort()){
return view('user.update_password_first');
}
return redirect(route('user_update_password'));
}
/**
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*/
public function updatePasswordFirstStore(Request $request)
{
$rules = array(
'password' => 'required|string|min:6|confirmed',
);
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
// get the error messages from the validator
$messages = $validator->messages();
// redirect our user back to the form with the errors from the validator
return view('user.update_password_first')->withErrors($validator);
}
$request->user()->fill([
'password' => Hash::make($request->password)
])->save();
\Session()->flash('alert-save', '1');
return redirect('/home');
}
}

View file

@ -0,0 +1,99 @@
<?php
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Mail\MailContact;
use App\Mail\MailVerifyAccount;
use App\Repositories\UserRepository;
use App\Services\UserService;
use App\User;
use GuzzleHttp\Client;
use Request;
use Illuminate\Support\Facades\Mail;
use App\Services\Util;
use Validator;
class RegisterController extends Controller
{
protected $userRepo;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct(UserRepository $userRepo)
{
$this->middleware('guest');
$this->userRepo = $userRepo;
}
/* public function member($member_id = false)
{
if(!$member_id){
return redirect('/registrierung');
}
$user_id = (int) str_replace('m', '', $member_id) - config('mivita.add_number_id');
$user = User::find($user_id);
if(!$user || !$user->isActive() || !$user->isActiveAccount()){
return redirect('/registrierung');
}
$data = [
'GOOGLE_ReCAPTCHA_KEY' => $this->GOOGLE_ReCAPTCHA_KEY,
'user_shop' => Util::getUserShop(),
'from_member_id' => $member_id
];
return view('web.templates.registrierung', $data);
}*/
public function register(){
$rules = array(
'salutation' => 'required',
'first_name'=>'required',
'last_name'=>'required',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
'password_confirmation' => 'required|string|min:6',
'accepted_data_protection' => 'required',
);
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
return back()->withErrors($validator)->withInput(Request::all());
}
$data = Request::all();
$user = $this->userRepo->create($data);
$confirmation_code = UserService::createConfirmationCode();
$user->lang = !empty(\App::getLocale()) ? \App::getLocale() : "de";
$user->confirmation_code = $confirmation_code;
$user->confirmation_code_to = date('Y-m-d H:i:s', strtotime('+1 week'));
$user->confirmation_code_remider = 0;
if(isset($data['from_member_id'])){
$user->m_sponsor = (int) str_replace('m', '', $data['from_member_id']) - config('main.add_number_id');
}
$user->save();
$user = User::find($user->id);
Mail::to($user->email)->send(new MailVerifyAccount($confirmation_code, $user));
return redirect('/user_register/finish');
}
public function finish()
{
$data = [
];
return view('auth.finish', $data);
}
}

View file

@ -0,0 +1,520 @@
<?php
namespace App\Http\Controllers;
use App\Mail\MailReleaseAccount;
use App\Models\File;
use App\Models\Product;
use App\Models\ShoppingInstance;
use App\Models\UserAccount;
use App\Models\UserHistory;
use App\Models\UserLevel;
use App\Repositories\FileRepository;
use App\Services\Util;
use App\User;
use Auth;
use Hash;
use Illuminate\Support\Facades\Mail;
use Request;
use Validator;
use Yard;
class WizardController extends Controller
{
protected $fileRepo;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct(FileRepository $fileRepo)
{
$this->fileRepo = $fileRepo;
}
public function create()
{
if(!Auth::check()){
return redirect('login');
}
$user = User::findOrFail(Auth::user()->id);
if(!$user->account){
$account = UserAccount::create([]);
$user->account_id = $account->id;
$user->save();
return redirect(route('wizard_create'));
}
$step = !$user->wizard ? 0 : $user->wizard;
if($step >= 20){
return redirect('/home');
}
$userHistoryWizardPayment = UserHistory::whereUserId($user->id)->whereAction('wizard_payment')->get()->last();
$data = [
'user' => Auth::user(),
'step' => $step,
'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
'products_on_board' => Product::where('active', true)->where('show_at', '=', 5)->orderBy('pos', 'ASC')->get(),
'userHistoryWizardPayment' => $userHistoryWizardPayment,
];
if($step == 15){
return view('user.wizard.create_release', $data);
}
return view('user.wizard.create', $data);
}
public function register()
{
if(!Auth::check()){
return redirect('login');
}
$user = User::findOrFail(Auth::user()->id);
if(!$user->account){
$account = UserAccount::create([]);
$user->account_id = $account->id;
$user->save();
return redirect(route('wizard_register'));
}
$step = !$user->wizard ? 0 : $user->wizard;
if($step >= 10){
return redirect('/home');
}
$data = [
'user' => Auth::user(),
'step' => $step,
'user_levels' => UserLevel::where('active', true)->get(),
//'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
//'products_on_board' => Product::where('active', true)->where('show_at', '=', 5)->orderBy('pos', 'ASC')->get(),
];
if($step == 5){
return view('user.wizard.register_release', $data);
}
return view('user.wizard.register', $data);
}
public function payment()
{
if(!Auth::check()){
return redirect('login');
}
$user = User::findOrFail(Auth::user()->id);
if(!$user->account){
$account = UserAccount::create([]);
$user->account_id = $account->id;
$user->save();
return redirect(route('wizard_payment'));
}
$userHistoryWizardPayment = UserHistory::whereUserId($user->id)->whereAction('wizard_payment')->get()->last();
$data = [
'user' => Auth::user(),
'step' => 0,
'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
'products_on_board' => Product::where('active', true)->where('show_at', '=', 5)->orderBy('pos', 'ASC')->get(),
'userHistoryWizardPayment' => $userHistoryWizardPayment,
];
if($user->wizard == 20){
return view('user.wizard.register_payment', $data);
}
return redirect(route('/'));
}
public function storeRegister($step = false)
{
if (!Auth::check()) {
return redirect('login');
}
$user = User::findOrFail(Auth::user()->id);
if (!$user->account) {
$user->account = new UserAccount();
}
if ($step == 0) {
$rules = array(
'accepted_data_protection' => 'required',
'accepted_active' => 'required',
'accepted_contract' => 'required'
);
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
$data = [
'user' => Auth::user(),
'step' => $step,
'user_levels' => UserLevel::where('active', true)->get(),
//'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
//'products_on_board' => Product::where('active', true)->where('show_at', '=', 5)->orderBy('pos', 'ASC')->get(),
];
$user->wizard = 0;
$user->save();
return view('user.wizard.register', $data)->withErrors($validator);
}
$account = $user->account;
if($account->accepted_contract === null){
$account->accepted_contract = now();
}
if($account->data_protection === null){
$account->data_protection = now();
}
$account->save();
if($user->agreement === null){
$user->agreement = now();
}
$user->wizard = 1;
$user->save();
return redirect(route('wizard_register'));
}
if ($step == 1) {
$rules = array(
'salutation' => 'required',
'first_name' => 'required',
'last_name' => 'required',
'address' => 'required',
'zipcode' => 'required',
'city' => 'required',
'phone' => 'required_without:mobil',
'mobil' => 'required_without:phone',
'country_id' => 'required|integer|min:1',
'birthday' => 'required',
);
if (!Request::get('same_as_billing')) {
$rules = array_merge($rules, [
'shipping_firstname' => 'required',
'shipping_lastname' => 'required',
'shipping_address' => 'required',
'shipping_zipcode' => 'required',
'shipping_city' => 'required',
'shipping_salutation' => 'required',
'shipping_country_id' => 'required|integer|min:1',
]);
}
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
$user->wizard = 1;
$user->save();
return redirect(route('wizard_register', [1]))->withErrors($validator)->withInput(Request::all());
}
$data = Request::all();
$data['same_as_billing'] = Request::get('same_as_billing') == NULL ? 0 : 1;
$user->account->fill($data)->save();
$user->wizard = 2;
$user->save();
return redirect(route('wizard_register'));
}
if ($step == 2) {
if(Request::get('submit') === 'do'){
if(File::whereUserId($user->id)->whereIdentifier('id_card')->count() == 0){
$validator = Validator::make(Request::all(), []);
$validator->errors()->add('field', __('Kein Ausweis hinterlegt, bitte erst hochladen.'));
$user->wizard = 2;
$user->save();
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
}
$user->wizard = 3;
$user->save();
return redirect(route('wizard_register'));
}
$this->fileRepo->_set('disk', 'user');
$this->fileRepo->_set('dir', '/'.$user->id.'/verification/');
$this->fileRepo->_set('user_id', $user->id);
$this->fileRepo->_set('identifier', 'id_card');
return $this->fileRepo->uploadFile(Request::all());
}
if ($step == 3) {
if(Request::get('submit') === 'do'){
$data = Request::all();
if($data['business_license_choose'] === "now"){
if(File::whereUserId($user->id)->whereIdentifier('business_license')->count() == 0){
$validator = Validator::make(Request::all(), []);
$validator->errors()->add('field', __('Kein Gewerbeschein hinterlegt, bitte erst hochladen.'));
$user->wizard = 3;
$user->save();
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
}
}
if($data['business_license_choose'] === "later"){
}
if($data['business_license_choose'] === "non"){
if(!$data['non_business_license_reason'] || $data['non_business_license_reason'] == ""){
$validator = Validator::make(Request::all(), []);
$validator->errors()->add('field', __('Bitte gib eine Begründung ein, warum Du keinen Gewerbeschein benötigst.'));
$user->wizard = 3;
$user->save();
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
}else{
$user->account->setNotice('business_license_reason', $data['non_business_license_reason']);
}
}
$user->account->setNotice('business_license', $data['business_license_choose']);
$user->wizard = 4;
$user->save();
return redirect(route('wizard_register'));
}
$this->fileRepo->_set('disk', 'user');
$this->fileRepo->_set('dir', '/'.$user->id.'/verification/');
$this->fileRepo->_set('user_id', $user->id);
$this->fileRepo->_set('identifier', 'business_license');
return $this->fileRepo->uploadFile(Request::all());
}
if ($step == 4) {
$data = Request::all();
if(!isset($data['switchers-package-wizard'])){
$validator = Validator::make(Request::all(), []);
$validator->errors()->add('field', __('Bitte wähle erst Deine Mitgildschaft aus.'));
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
}
$user->m_level = $data['switchers-package-wizard'];
$user->next_m_level = $data['switchers-package-wizard'];
$user->wizard = 5;
$user->release_account = now();
UserHistory::create(['user_id' => $user->id, 'action'=>'release_account', 'status'=>0]);
$user->save();
if($user->isTestMode()){
$mail = config('app.info_test_mail');
}else{
$mail = config('app.info_mail');
}
Mail::to($mail)->send(new MailReleaseAccount($user));
return redirect(route('wizard_register'));
}
}
public function storeCreate($step = 0)
{
if(!Auth::check()){
return redirect('login');
}
$user = User::findOrFail(Auth::user()->id);
if(!$user->account){
$user->account = new UserAccount();
}
if($step == 10){
$rules = array(
'accepted_data_protection' => 'required',
'accepted_active' => 'required',
);
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
$data = [
'user' => Auth::user(),
'step' => $step,
'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
'products_on_board' => Product::where('active', true)->where('show_at', '=', 5)->orderBy('pos', 'ASC')->get(),
];
$user->wizard = 10;
$user->save();
return view('user.wizard.create', $data)->withErrors($validator);
}
$account = $user->account;
if($account->accepted_contract === null){
$account->accepted_contract = now();
}
if($account->data_protection === null){
$account->data_protection = now();
}
$account->save();
if($user->agreement === null){
$user->agreement = now();
}
$user->wizard = 11;
$user->save();
return redirect(route('wizard_create', [11]));
}
if($step == 11){
if($user->isPasswort()){
$user->wizard = 12;
$user->save();
return redirect(route('wizard_create', [12]));
}
$rules = array(
'password' => 'required|string|min:6|confirmed',
);
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
$data = [
'user' => Auth::user(),
'step' => $step,
'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
'products_on_board' => Product::where('active', true)->where('show_at', '=', 5)->orderBy('pos', 'ASC')->get(),
];
return view('user.wizard.create', $data)->withErrors($validator);
}
$user->fill([
'password' => Hash::make(Request::get('password'))
])->save();
$user->wizard = 12;
$user->save();
return redirect(route('wizard_create', [12]));
}
if($step == 12){
$rules = array(
'salutation' => 'required',
'first_name' => 'required',
'last_name' => 'required',
'address' => 'required',
'zipcode' => 'required',
'city' => 'required',
'phone' => 'required_without:mobil',
'mobil' => 'required_without:phone',
'country_id' => 'required|integer|min:1',
'birthday' => 'required',
);
if(!Request::get('same_as_billing')){
$rules = array_merge($rules, [
'shipping_firstname'=>'required',
'shipping_lastname'=>'required',
'shipping_address'=>'required',
'shipping_zipcode'=>'required',
'shipping_city' => 'required',
'shipping_salutation' => 'required'
]);
}
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
return redirect(route('wizard_create', [12]))->withErrors($validator)->withInput(Request::all());
}
$data = Request::all();
$data['same_as_billing'] = Request::get('same_as_billing') == NULL ? 0 : 1;
$user->account->fill($data)->save();
$user->wizard = 13;
$user->active_date = now();
$user->active = 1;
$user->confirmation_code = null;
$user->confirmation_code_to = null;
$user->confirmation_code_remider = 0;
$user->save();
return redirect(route('wizard_create', [13]));
}
}
public function storePayment($step = 0){
if(Request::get('switchers-package-wizard')){
$user = User::find(Auth::user()->id);
Yard::instance('shopping')->destroy();
$product = Product::find(Request::get('switchers-package-wizard'));
/*$showAboOptions = false;
if(Request::get('abo_options')){
$showAboOptions = true;
$user->abo_options = true;
$user->save();
}*/
if($product && $product->active && $product->show_at == 3){
//set membership product
$image = "";
if($product->images->count()){
$image = $product->images->first()->slug;
}
Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
//set onboarding products
if(Request::get('products_on_board')){
foreach (Request::get('products_on_board') as $product_on_board_id){
$product_on_board = Product::find($product_on_board_id);
$image = "";
if($product_on_board->images->count()){
$image = $product_on_board->images->first()->slug;
}
Yard::instance('shopping')->add($product_on_board->id, $product_on_board->getLang('name'), 1, $product_on_board->price, ['image' => $image, 'slug' => $product_on_board->slug, 'weight' => $product_on_board->weight]);
}
}
/*do {
$identifier = Util::getToken();
} while( ShoppingInstance::where('identifier', $identifier)->count() );
*/
$identifier = Util::getToken();
$data = [];
$data['is_from'] = 'wizard';
$data['is_for'] = 'me';
/*ShoppingInstance::create([
'identifier' => $identifier,
'user_shop_id' => 1, //is first faker shop for buy intern
'auth_user_id' => Auth::user()->id,
'payment' => 4, //Berater Wizard
'subdomain' => url('/'),
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
'shopping_data' => $data,
'back' => url()->previous(),
]);*/
Yard::instance('shopping')->putYardExtra('shopping_data', $data);
Yard::instance('shopping')->store($identifier);
//add to DB
//$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
UserHistory::create(['user_id' => $user->id, 'action'=>'wizard_payment', 'status'=>1, 'product_id'=>$product->id, 'identifier'=>$identifier]);
//$path = str_replace('http', 'https', $path);
//return redirect()->secure($path);
return redirect(route('user_checkout', [$identifier]));
}
}
\Session()->flash('alert-error', "Fehler beim Produkt");
return back();
}
public function delete($id, $relation){
if($relation === 'upload'){
$user = User::findOrFail(Auth::user()->id);
$file = $user->files()->findOrFail($id);
//remove file
\Storage::disk('user')->delete($file->dir.$file->filename);
$file->delete();
\Session()->flash('alert-success', "Datei gelöscht");
}
return back();
}
}

70
app/Http/Kernel.php Normal file
View file

@ -0,0 +1,70 @@
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array
*/
protected $middleware = [
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
'throttle:60,1',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'admin' => \App\Http\Middleware\Admin::class,
'superadmin' => \App\Http\Middleware\SuperAdmin::class,
'sysadmin' => \App\Http\Middleware\SysAdmin::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'active.account' => \App\Http\Middleware\ActiveAccount::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];
}

View file

@ -0,0 +1,26 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Auth;
class ActiveAccount
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ( Auth::check() && Auth::user()->isActiveAccount() )
{
return $next($request);
}
return redirect('/home');
}
}

26
app/Http/Middleware/Admin.php Executable file
View file

@ -0,0 +1,26 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Auth;
class Admin
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ( Auth::check() && Auth::user()->isAdmin() )
{
return $next($request);
}
return redirect('/home');
}
}

View file

@ -0,0 +1,97 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Contracts\Auth\Factory as Auth;
class Authenticate
{
/**
* The authentication factory instance.
*
* @var \Illuminate\Contracts\Auth\Factory
*/
protected $auth;
/**
* Create a new middleware instance.
*
* @param \Illuminate\Contracts\Auth\Factory $auth
* @return void
*/
public function __construct(Auth $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string[] ...$guards
* @return mixed
*
* @throws \Illuminate\Auth\AuthenticationException
*/
public function handle($request, Closure $next, ...$guards)
{
$this->authenticate($guards);
//is blocked
if(in_array('user', $guards) && $this->auth->user()->blocked == 1){
return redirect(route('user_blocked'));
}
//100 wizzard is finish
if(in_array('user', $guards) && $this->auth->user()->wizard !== 100){
//0-10 == start wizard form register
if(in_array('user', $guards) && $this->auth->user()->wizard < 10){
return redirect(route('wizard_register'));
}
//10-20 == start wizard form create Lead
if(in_array('user', $guards) && $this->auth->user()->wizard < 20){
return redirect(route('wizard_create'));
}
//20 is payment
if(in_array('user', $guards) && $this->auth->user()->wizard == 20){
$allow = [
'user_checkout',
'user_checkout_store',
'user_checkout_final',
];
if(in_array($request->route()->getName(), $allow)){
return $next($request);
}
return redirect(route('wizard_payment'));
}
}
return $next($request);
}
/**
* Determine if the user is logged in to any of the given guards.
*
* @param array $guards
* @return void
*
* @throws \Illuminate\Auth\AuthenticationException
*/
protected function authenticate(array $guards)
{
if (empty($guards)) {
return $this->auth->authenticate();
}
foreach ($guards as $guard) {
if ($this->auth->guard($guard)->check()) {
return $this->auth->shouldUse($guard);
}
}
throw new AuthenticationException('Unauthenticated.', $guards);
}
}

View file

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
class CheckForMaintenanceMode extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
//
];
}

View file

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array
*/
protected $except = [
//
];
}

View file

@ -0,0 +1,30 @@
<?php
namespace App\Http\Middleware;
use Carbon;
use Closure;
use Auth;
class Localization
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ( \Session::has('locale')) {
\App::setLocale(\Session::get('locale'));
Carbon::setLocale(\Session::get('locale'));
}
return $next($request);
}
}

View file

@ -0,0 +1,27 @@
<?php
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
return $next($request);
}
}

View file

@ -0,0 +1,26 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Auth;
class SuperAdmin
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ( Auth::check() && Auth::user()->isSuperAdmin() )
{
return $next($request);
}
return redirect('/home');
}
}

View file

@ -0,0 +1,26 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Auth;
class SysAdmin
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ( Auth::check() && Auth::user()->isSySAdmin() )
{
return $next($request);
}
return redirect('/home');
}
}

View file

@ -0,0 +1,18 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array
*/
protected $except = [
'password',
'password_confirmation',
];
}

View file

@ -0,0 +1,23 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array|string
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
}

View file

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
//
];
}

View file

@ -0,0 +1,29 @@
<?php
namespace App\Libraries;
use setasign\Fpdi\Fpdi;
class ContractPDF extends Fpdi
{
protected $_tplIdx;
protected $_site = 1;
public function Header()
{
if (null === $this->_tplIdx) {
$this->setSourceFile('./pdf/mivita_template_contract_de.pdf');
}
$this->_tplIdx = $this->importPage($this->_site++);
$this->useTemplate($this->_tplIdx);
}
function Footer() {
} // end of footer
}

View file

@ -0,0 +1,48 @@
<?php
namespace App\Mail;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class MailAccountActive extends Mailable
{
use Queueable, SerializesModels;
protected $confirmation_code;
protected $user;
public $subject;
public function __construct(User $user)
{
$this->user = $user;
$this->subject = __('email.account_active');
}
public function build()
{
$salutation = __('email.salutation').",";
if($this->user->account){
if($this->user->account->salutation === "mr"){
$salutation = __('email.dear_sir')." ".$this->user->account->first_name.",";
}else{
$salutation = __('email.dear_mrs')." ".$this->user->account->first_name.",";
}
}
return $this->view('emails.auth')->with([
'url' => route('login'),
'salutation' => $salutation,
'button' => __('Login'),
'copy1line' => __('email.account_active_copy1line'),
'copy2line' => __('email.copy2line'),
'copy3line' => __('email.copy3line'),
'greetings' => __('email.greetings'),
'sender' => __('email.sender'),
]);
}
}

View file

@ -0,0 +1,46 @@
<?php
namespace App\Mail;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class MailActivateUser extends Mailable
{
use Queueable, SerializesModels;
protected $token;
protected $user;
public $subject;
public function __construct($token, User $user)
{
$this->token = $token;
$this->user = $user;
$this->subject = __('email.change_e_mail');
}
public function build()
{
$salutation = __('email.salutation').",";
if($this->user->account){
if($this->user->account->salutation === "mr"){
$salutation = __('email.dear_sir')." ".$this->user->account->first_name.",";
}else{
$salutation = __('email.dear_mrs')." ".$this->user->account->first_name.",";
}
}
return $this->view('emails.auth')->with([
'url' => route('user_update_email_confirm', $this->token),
'salutation' => $salutation,
'button' => __('email.change_e_mail'),
'copy1line' => __('email.active_copy1line'),
'copy2line' => __('email.copy2line'),
'copy3line' => __('email.copy3line'),
'greetings' => __('email.greetings'),
'sender' => __('email.sender'),
]);
}
}

89
app/Mail/MailCheckout.php Normal file
View file

@ -0,0 +1,89 @@
<?php
namespace App\Mail;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Services\Util;
class MailCheckout extends Mailable
{
use Queueable, SerializesModels;
protected $txaction;
protected $shopping_order;
protected $shopping_payment;
protected $send_link;
protected $mode;
public $subject;
public $data;
public function __construct($txaction, $shopping_order, $shopping_payment, $send_link, $mode)
{
$this->txaction = $txaction;
$this->shopping_order = $shopping_order;
$this->shopping_payment = $shopping_payment;
$this->send_link = $send_link;
$this->mode = $mode;
if($this->txaction === 'paid'){
$this->subject = __('email.checkout_subject_paid')." ";
$this->subject .= ".gruene-seele.bio";
}elseif($this->txaction === 'extern'){
$this->subject = __('email.checkout_subject_extern').": ";
$this->subject .= $shopping_order->member->account->m_first_name." ".$shopping_order->member->account->m_last_name." - ";
$this->subject .= $shopping_order->shopping_user->billing_firstname." ".$shopping_order->shopping_user->billing_lastname;
}else{
$this->subject = __('email.checkout_subject')." ";
$this->subject .= ".gruene-seele.bio";
}
/*if($shopping_order->user_shop){
$this->subject .= $shopping_order->user_shop->slug.".";
}*/
}
public function build()
{
$salutation = __('email.hello').",";
if($this->txaction !== 'extern' && $this->shopping_order->shopping_user){
$salutation = __('email.hello')." ".$this->shopping_order->shopping_user->billing_firstname.",";
//make Adresse
}
if($this->txaction === 'paid' || $this->txaction === 'extern'){
return $this->view('emails.checkout')->with([
'salutation' => $salutation,
'copy1line' => __('email.checkout_copy1line'),
'shopping_order' => $this->shopping_order,
'shopping_payment' => $this->shopping_payment,
'copy3line' => __('email.checkout_copy3line'),
'greetings' => __('email.greetings'),
'sender' => __('email.sender'),
'send_link' => $this->send_link,
'url' => Util::getMyMivitaUrl(),
'button' => Util::getMyMivitaUrl(false),
'mode' => $this->mode
]);
}else{
return $this->view('emails.checkout_status')->with([
'salutation' => $salutation,
'copy1line' => __('email.status_copy1line'),
'txaction' => $this->txaction,
'shopping_order' => $this->shopping_order,
'shopping_payment' => $this->shopping_payment,
'copy3line' => __('email.checkout_copy3line'),
'greetings' => __('email.greetings'),
'sender' => __('email.sender'),
'send_link' => false,
'mode' => $this->mode
]);
}
}
}

59
app/Mail/MailContact.php Normal file
View file

@ -0,0 +1,59 @@
<?php
namespace App\Mail;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Services\Util;
class MailContact extends Mailable
{
use Queueable, SerializesModels;
public $user_shop;
public $subject;
public $data;
public function __construct($data)
{
$this->data = $data;
$this->user_shop = Util::getUserShop();
$this->subject = __('email.your_request_from').' mivita.care';
if($this->user_shop){
$this->subject = __('email.your_request_from')." ".$this->user_shop->slug.'.mivita.care';
}
}
public function build()
{
$salutation = __('email.hello');
if(isset($this->data['first_name'])){
$salutation .= " ".$this->data['first_name'];
}
if(isset($this->data['salutation'])){
if($this->data['salutation'] === 'mr'){
$this->data['salutation'] = 'Herr';
}
if($this->data['salutation'] === 'ms'){
$this->data['salutation'] = 'Frau';
}
}
$copy1line = __('email.your_request_from')." mivita.care";
if($this->user_shop){
$copy1line = __('email.your_request_from')." ".$this->user_shop->slug.'.mivita.care';
}
return $this->view('emails.contact')->with([
'salutation' => $salutation,
'copy1line' => $copy1line,
'data' => $this->data,
'copy3line' => __('email.copy3line'),
'greetings' => __('email.greetings'),
'sender' => __('email.sender'),
]);
}
}

View file

@ -0,0 +1,83 @@
<?php
namespace App\Mail;
use App\Models\UserMessage;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class MailCustomMessage extends Mailable
{
use Queueable, SerializesModels;
protected $data;
protected $user;
protected $sender;
public $subject;
public $message;
public $message_last;
protected $save;
public function __construct(User $user, $data, $sender, $save = false)
{
$this->save = $save;
$this->data = $data;
$this->user = $user;
$this->sender = $sender;
$this->subject = isset($data['subject']) ? $data['subject'] : __('email.email_subject');
$this->message = isset($data['message']) ? $data['message'] : '';
$this->message_last = isset($data['message_last']) ? $data['message_last'] : '';
}
public function build()
{
$salutation = __('email.salutation').",";
if($this->user->account){
if($this->user->account->salutation === "mr"){
$salutation = __('email.dear_sir')." ".$this->user->account->first_name.",";
}else{
$salutation = __('email.dear_mrs')." ".$this->user->account->first_name.",";
}
}
if($this->save){
UserMessage::create([
'user_id' => $this->user->id,
'send_user_id' => $this->sender->id,
'email' => $this->user->email,
'subject' => $this->subject,
'message' => $this->message." ".$this->message_last,
'send' => true,
'sent_at' => now(),
]);
}
$url = "";
$button = "";
if(isset($this->data['confirmation_code'])){
$url = route('register_verify', $this->data['confirmation_code']);
$button = __('email.button_account');
}
if(isset($this->data['url'])){
$url =$this->data['url'];
$button = $this->data['button'];
}
return $this->view('emails.custom')->with([
'url' => $url,
'title' => $salutation,
'button' => $button,
'content' => $this->message,
'content_last' => $this->message_last,
'copy2line' => __('email.copy2line'),
'copy3line' => __('email.copy3line'),
'greetings' => __('email.greetings'),
'sender' => __('email.sender'),
]);
}
}

116
app/Mail/MailInfo.php Normal file
View file

@ -0,0 +1,116 @@
<?php
namespace App\Mail;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class MailInfo extends Mailable
{
use Queueable, SerializesModels;
protected $user;
protected $action;
protected $data;
public $subject;
public function __construct($user, $action, $data = [])
{
$this->user = $user;
$this->action = $action;
$this->data = $data;
if($this->action === "delete_membership"){
$this->subject = 'Mitgliedschaft beenden - beantragt';
}
if($this->action === "check_is_like_customer"){
$this->subject = 'Kunden überprüfen - Kundenhoheit';
}
if($this->action === "change_is_like_customer"){
$this->subject = 'Kunden erneut überprüfen - Kundenhoheit';
}
}
public function build()
{
$content = "";
if($this->action === "delete_membership"){
$content .= __(strtoupper($this->user->account->salutation))." ";
$content .= $this->user->account->first_name." ".$this->user->account->last_name."\n";
$content .= $this->user->account->address."\n";
$content .= $this->user->account->zipcode." ".$this->user->account->city."\n";
$content .= $this->user->account->country_id ? $this->user->account->country->de."\n\n" : "\n\n";
if($this->user->account->phone){
$content .= "Telefon: ";
$content .= $this->user->account->pre_phone_id ? $this->user->account->pre_phone->phone." " : " ";
$content .= $this->user->account->phone;
}
if($this->user->account->mobil){
$content .= "Mobil: ";
$content .= $this->user->account->pre_mobil_id ? $this->user->account->pre_mobil->phone." " : " ";
$content .= $this->user->account->mobil;
}
$content .= "E-Mail: ".$this->user->email;
$copy1line = "Infos zum Berater:"."\n";
$button = "zum Berater";
$title = "Ein Berater möchte seine Mitgliedschaft beenden.";
$url = route('admin_lead_edit', $this->user->id).'?show=check_lead';
}
if($this->action === "check_is_like_customer") {
$copy1line = "Hier geht es zum Kunden:"."\n";
$button = "zum Kunden";
$title = "Ein Kunden muss überprüft werden und einem Berater zugeordnet werden, da die Adresse nicht eindeutig ist.";
$url = route('admin_customer_detail', $this->user->id);
$content .= $this->user ? 'Firma: '.$this->user->billing_company."\n" : '';
$content .= \App\Services\HTMLHelper::getSalutationLang($this->user->billing_salutation)." ";
$content .= $this->user->billing_firstname." ";
$content .= $this->user->billing_lastname."\n";
$content .= $this->user->billing_address;
$content .= $this->user->billing_address_2 ? '/ '.$this->user->billing_address_2."\n" : "\n";
$content .= $this->user->billing_zipcode." ";
$content .= $this->user->billing_city."\n";
$content .= $this->user->billing_email."\n";
$content .= $this->user->billing_phone."\n";
$content .= $this->user->billing_country->getLocated();
}
if($this->action === "change_is_like_customer"){
$copy1line = "Hier geht es zum Kunden:"."\n";
$button = "zum Kunden";
$title = "Ein Kunden muss erneut überprüft werden, da bei einer Änderung eine bestehende Kundenhoheit gefunden wurde.";
$url = route('admin_customer_detail', $this->user->id);
$content .= "Folgende Daten für die Kundenhoheit wurden geändert:"."\n";
foreach ($this->data as $key=>$value){
$content .= $this->user->{$key}." => ".$value."\n";
}
$content .= "\n"."\n"."Rechnungsadresse des Kunden vor der Änderung:"."\n";
$content .= $this->user ? 'Firma: '.$this->user->billing_company."\n" : '';
$content .= \App\Services\HTMLHelper::getSalutationLang($this->user->billing_salutation)." ";
$content .= $this->user->billing_firstname." ";
$content .= $this->user->billing_lastname."\n";
$content .= $this->user->billing_address;
$content .= $this->user->billing_address_2 ? '/ '.$this->user->billing_address_2."\n" : "\n";
$content .= $this->user->billing_zipcode." ";
$content .= $this->user->billing_city."\n";
$content .= $this->user->billing_email."\n";
$content .= $this->user->billing_phone."\n";
$content .= $this->user->billing_country->getLocated();
}
return $this->view('emails.info')->with([
'url' => $url,
'title' => $title,
'button' => $button,
'copy1line' => $copy1line,
'copy2line' => __('email.copy2line'),
'content' => $content,
]);
}
}

View file

@ -0,0 +1,63 @@
<?php
namespace App\Mail;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class MailReleaseAccount extends Mailable
{
use Queueable, SerializesModels;
protected $user;
public $subject;
public function __construct(User $user)
{
$this->user = $user;
$this->subject = 'Neuer Berater Registrierung prüfen';
}
public function build()
{
$content = __(strtoupper($this->user->account->salutation))." ";
$content .= $this->user->account->first_name." ".$this->user->account->last_name."\n";
$content .= $this->user->account->address."\n";
$content .= $this->user->account->zipcode." ".$this->user->account->city."\n";
$content .= $this->user->account->country_id ? $this->user->account->country->de."\n\n" : "\n\n";
if($this->user->account->phone){
$content .= "Telefon: ";
$content .= $this->user->account->pre_phone_id ? $this->user->account->pre_phone->phone." " : " ";
$content .= $this->user->account->phone;
}
if($this->user->account->mobil){
$content .= "Mobil: ";
$content .= $this->user->account->pre_mobil_id ? $this->user->account->pre_mobil->phone." " : " ";
$content .= $this->user->account->mobil;
}
$content .= "E-Mail: ".$this->user->email;
$copy1line = "Ein neuer Berater hat sich registriert und wartet auf die Überprüfung und Freigabe seiner Daten:"."\n";
$copy1line .= "+ Überprüfung der Ausweisdate"."\n";
$copy1line .= "+ Überprüfung des Gewerbenachweises"."\n";
$copy1line .= "+ Eintrag Account ID"."\n";
$copy1line .= "+ Überprüfung / Kenntnisnahme Sponsor"."\n";
$copy1line .= "+ Überprüfung der Rechnungsdaten"."\n";
$copy1line .= 'Nach erfolgreicher Überprüfung mit dem Button „Daten vollständig => Berater freischalten“ den Berater freischalten.'."\n";
$copy1line .= 'Der Berater erhält eine Mail, dass sein Account freigeschaltet wurde. Der Vertrag wird automatisch mit den Daten des Vertriebspartners erstellt.'."\n";
return $this->view('emails.info')->with([
'url' => route('admin_lead_edit', $this->user->id).'?show=check_lead',
'title' => 'Berater Registrierung prüfen',
'button' => 'zur Berater Prüfung',
'copy1line' => $copy1line,
'copy2line' => __('email.copy2line'),
'content' => $content,
]);
}
}

View file

@ -0,0 +1,51 @@
<?php
namespace App\Mail;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class MailResetPassword extends Mailable
{
use Queueable, SerializesModels;
protected $token;
protected $user;
public $subject;
public function __construct($token, $user)
{
$this->token = $token;
$this->user = $user;
$this->subject = __('email.reset_passwort');
}
public function build()
{
$salutation = __('email.salutation').",";
if($this->user->account){
if($this->user->account->salutation === "mr"){
$salutation = __('email.dear_sir')." ".$this->user->account->first_name.",";
}else{
$salutation = __('email.dear_mrs')." ".$this->user->account->first_name.",";
}
}
return $this->view('emails.auth')->with([
'url' => route('password.reset', $this->token),
'salutation' => $salutation,
'button' => __('email.reset_passwort'),
'copy1line' => __('email.reset_pass_copy1line'),
'copy2line' => __('email.copy2line'),
'copy3line' => __('email.copy3line'),
'greetings' => __('email.greetings'),
'sender' => __('email.sender'),
]);
}
}

63
app/Mail/MailSyS.php Normal file
View file

@ -0,0 +1,63 @@
<?php
namespace App\Mail;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class MailSyS extends Mailable
{
use Queueable, SerializesModels;
protected $model;
protected $action;
public $subject;
public function __construct($model, $action)
{
$this->model = $model;
$this->action = $action;
if($this->action === "log"){
$this->subject = 'mivita Logger';
}
}
public function build()
{
$content = "";
if($this->action === "log"){
$title = "New Log";
if($this->model->user_id && $this->model->user){
$content .= "From User: ".$this->model->user->id." | ".$this->model->user->email."\n";
}
if($this->model->model && $this->model->model_id){
$content .= "Apply: ".$this->model->model." | ".$this->model->model_id."\n";
if($this->model->model === 'App\User'){
$apply = User::find($this->model->model_id);
$content .= $this->model->model.": ".$apply->email." | ".$this->model->model_id."\n";
}
}
$content .= "\n";
$content .= "Action: ".$this->model->action."\n";
$content .= "Message: ".$this->model->message."\n";
$content .= "\n";
$content .= "Channel: ".$this->model->channel."\n";
$content .= "Level: ".$this->model->getLevelType()."\n";
$content .= "\n";
$content .= "Time: ".$this->model->created_at->format("d.m.Y H:i");
}
return $this->view('emails.sys')->with([
'title' => $title,
'content' => $content,
]);
}
}

View file

@ -0,0 +1,49 @@
<?php
namespace App\Mail;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class MailVerifyAccount extends Mailable
{
use Queueable, SerializesModels;
protected $confirmation_code;
protected $user;
public $subject;
public function __construct($confirmation_code, User $user)
{
$this->confirmation_code = $confirmation_code;
$this->user = $user;
$this->subject = __('email.email_verify');
}
public function build()
{
$salutation = __('email.salutation').",";
if($this->user->account){
if($this->user->account->salutation === "mr"){
$salutation = __('email.dear_sir')." ".$this->user->account->first_name.",";
}else{
$salutation = __('email.dear_mrs')." ".$this->user->account->first_name.",";
}
}
return $this->view('emails.auth')->with([
'url' => route('register_verify', $this->confirmation_code),
'salutation' => $salutation,
'button' => __('email.email_verify'),
'copy1line' => __('email.email_verify_copy1line'),
'copy2line' => __('email.copy2line'),
'copy3line' => __('email.copy3line'),
'greetings' => __('email.greetings'),
'sender' => __('email.sender'),
]);
}
}

View file

@ -0,0 +1,48 @@
<?php
namespace App\Mail;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class MailVerifyContact extends Mailable
{
use Queueable, SerializesModels;
protected $confirmation_code;
protected $user;
public $subject;
public function __construct($confirmation_code, User $user)
{
$this->confirmation_code = $confirmation_code;
$this->user = $user;
$this->subject = __('email.verify_e_mail');
}
public function build()
{
$salutation = __('email.salutation').",";
if($this->user->account){
if($this->user->account->salutation === "mr"){
$salutation = __('email.dear_sir')." ".$this->user->account->first_name.",";
}else{
$salutation = __('email.dear_mrs')." ".$this->user->account->first_name.",";
}
}
return $this->view('emails.auth')->with([
'url' => route('register_verify', $this->confirmation_code),
'salutation' => $salutation,
'button' => __('email.verify_e_mail'),
'copy1line' => __('email.verify_copy1line'),
'copy2line' => __('email.copy2line'),
'copy3line' => __('email.copy3line'),
'greetings' => __('email.greetings'),
'sender' => __('email.sender'),
]);
}
}

91
app/Models/Attribute.php Normal file
View file

@ -0,0 +1,91 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\Attribute
*
* @property int $id
* @property int|null $parent_id
* @property string $name
* @property array|null $trans_name
* @property int|null $pos
* @property int $active
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Attribute[] $childrens
* @property-read \App\Models\Attribute|null $parent
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereParentId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereTransName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereUpdatedAt($value)
* @mixin \Eloquent
* @property string|null $slug
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute query()
* @property-read int|null $childrens_count
*/
class Attribute extends Model
{
protected $table = 'attributes';
protected $casts = ['trans_name' => 'array'];
protected $fillable = [
'parent_id', 'name', 'pos', 'active',
];
public function parent()
{
return $this->belongsTo('App\Models\Attribute', 'parent_id');
}
public function childrens()
{
return $this->hasMany('App\Models\Attribute', 'parent_id', 'id');
}
public function setPosAttribute($value){
$this->attributes['pos'] = is_numeric($value) ? $value : null;
}
public function getLang($key)
{
$lang = \App::getLocale();
if ($lang == 'de') {
return $this->{$key};
}
$trans = $this->getTrans($key, $lang);
if (!$trans || $trans == '') {
return $this->{$key};
}
return $trans;
}
public function getTrans($key, $lang)
{
$key = 'trans_' . $key;
if (!empty($this->{$key}[$lang])) {
return $this->{$key}[$lang];
}
}
public function getTranNames()
{
$ret = "";
foreach ((array) $this->trans_name as $value){
$ret .= $value.', ';
}
return rtrim($ret, ', ');
}
}

135
app/Models/Category.php Normal file
View file

@ -0,0 +1,135 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Cviebrock\EloquentSluggable\Sluggable;
/**
* App\Models\Category
*
* @property int $id
* @property int|null $parent_id
* @property string $name
* @property array|null $trans_name
* @property int|null $pos
* @property int $active
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Category[] $childrens
* @property-read \App\Models\Category|null $parent
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereParentId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereTransName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereUpdatedAt($value)
* @mixin \Eloquent
* @property string|null $slug
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductCategory[] $product_categories
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category findSimilarSlugs($attribute, $config, $slug)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category query()
* @property string|null $headline
* @property int|null $headline_image_id
* @property array|null $trans_headline
* @property-read int|null $childrens_count
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Image[] $image
* @property-read int|null $image_count
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereHeadline($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereHeadlineImageId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereTransHeadline($value)
* @property-read \App\Models\IqImage|null $iq_image
* @property-read int|null $product_categories_count
*/
class Category extends Model
{
use Sluggable;
protected $table = 'categories';
protected $casts = ['trans_name' => 'array', 'trans_headline' => 'array'];
protected $fillable = [
'parent_id', 'name', 'headline', 'pos', 'active',
];
public function sluggable()
{
return [
'slug' => [
'source' => 'name'
]
];
}
public function parent()
{
return $this->belongsTo('App\Models\Category', 'parent_id');
}
public function childrens()
{
return $this->hasMany('App\Models\Category', 'parent_id', 'id');
}
public function product_categories()
{
return $this->hasMany('App\Models\ProductCategory', 'category_id', 'id');
}
public function iq_image()
{
return $this->belongsTo('App\Models\IqImage', 'headline_image_id');
}
public function setPosAttribute($value){
$this->attributes['pos'] = is_numeric($value) ? $value : null;
}
public function getLang($key)
{
$lang = \App::getLocale();
if ($lang === 'de') {
return $this->{$key};
}
$trans = $this->getTrans($key, $lang);
if (!$trans || $trans == '') {
return $this->{$key};
}
return $trans;
}
public function getTrans($key, $lang)
{
$key = 'trans_' . $key;
if (!empty($this->{$key}[$lang])) {
return $this->{$key}[$lang];
}
return "";
}
public function getTranNames()
{
$ret = "";
foreach ((array) $this->trans_name as $value){
$ret .= $value.', ';
}
return rtrim($ret, ', ');
}
public function getTranHeadlines()
{
$ret = "";
foreach ((array) $this->trans_headline as $value){
$ret .= $value.', ';
}
return rtrim($ret, ', ');
}
}

169
app/Models/Country.php Normal file
View file

@ -0,0 +1,169 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use PHPUnit\Framework\Constraint\Count;
/**
* App\Models\Country
*
* @property int $id
* @property string $code
* @property string $phone
* @property string $en
* @property string $de
* @property string $es
* @property string $fr
* @property string $it
* @property string $ru
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCode($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereDe($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereEn($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereEs($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereFr($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereIt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country wherePhone($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereRu($value)
* @mixin \Eloquent
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country query()
* @property int|null $active
* @property array|null $trans
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereTrans($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereUpdatedAt($value)
* @property string|null $trans_name
* @property array|null $attr
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereAttr($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereTransName($value)
* @property bool|null $switch
* @property bool|null $own_eur
* @property bool|null $currency
* @property string|null $currency_unit
* @property bool|null $currency_calc
* @property float|null $currency_faktor
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCurrency($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCurrencyCalc($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCurrencyFaktor($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCurrencyName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereOwnEur($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereSwitch($value)
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\CountryPrice[] $country_prices
* @property-read int|null $country_prices_count
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCurrencyUnit($value)
*/
class Country extends Model
{
protected $table = 'countries';
protected $casts = [
'switch' => 'bool',
'own_eur' => 'bool',
'currency' => 'bool',
'currency_calc' => 'bool',
'trans_name' => 'array',
'attr' => 'array'
];
protected $fillable = [
'code', 'phone', 'en', 'de', 'es', 'fr', 'it', 'ru',
'switch', 'own_eur', 'currency', 'currency_unit', 'currency_calc', 'currency_faktor',
'active', 'trans_name', 'attr',
];
public function country_prices()
{
return $this->hasMany(CountryPrice::class, 'country_id');
}
public function getLocated($lang = false){
if(!$lang){
$lang = \App::getLocale();
}
if($lang === 'de'){
return $this->de;
}
if($lang === 'en'){
return $this->en;
}
if($lang === 'es'){
return $this->es;
}
if($lang === 'fr'){
return $this->fr;
}
if($lang === 'it'){
return $this->it;
}
if($lang === 'ru'){
return $this->ru;
}
//search by trans
if($val = $this->getTrans('name', $lang)){
return $val;
}
return $this->de;
}
public function getTrans($key, $lang)
{
$key = 'trans_' . $key;
if (!empty($this->{$key}[$lang])) {
return $this->{$key}[$lang];
}
return "";
}
public function getAttrByKey($key)
{
$name = 'attr';
if (!empty($this->{$name}[$key])) {
return $this->{$name}[$key];
}
return "";
}
public static function getCountryIdByCode($code){
if($code == null){
return null;
}
$r = Country::where('code', '=', $code)->first();
if($r){
return $r->id;
}
return null;
}
public static function getCountryIdByCodeOrOne($code){
if($code == null){
return 1;
}
$r = Country::where('code', '=', $code)->first();
if($r){
return $r->id;
}
return 1;
}
public static function getCountryIdByPhone($phone){
if($phone == null){
return null;
}
$r = Country::where('phone', '=', $phone)->first();
if($r){
return $r->id;
}
return null;
}
}

View file

@ -0,0 +1,73 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class CountryPrice
*
* @property int $id
* @property int $country_id
* @property int $product_id
* @property float $c_price
* @property float $c_tax
* @property float $c_price_old
* @property float $c_currency
* @property Carbon $created_at
* @property Carbon $updated_at
* @property Country $country
* @property Product $product
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereCOwnEur($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereCPrice($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereCPriceOld($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereCTax($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereUpdatedAt($value)
* @mixin \Eloquent
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereCCurrency($value)
*/
class CountryPrice extends Model
{
protected $table = 'country_prices';
protected $casts = [
'country_id' => 'int',
'product_id' => 'int',
'c_price' => 'float',
'c_tax' => 'float',
'c_price_old' => 'float',
'c_currency' => 'float'
];
protected $fillable = [
'country_id',
'product_id',
'c_price',
'c_tax',
'c_price_old',
'c_currency'
];
public function country()
{
return $this->belongsTo(Country::class);
}
public function product()
{
return $this->belongsTo(Product::class);
}
}

84
app/Models/File.php Normal file
View file

@ -0,0 +1,84 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use App\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class File
*
* @property int $id
* @property int $user_id
* @property string $filename
* @property string $dir
* @property string $original_name
* @property string $ext
* @property string $mine
* @property int $size
* @property Carbon $created_at
* @property Carbon $updated_at
* @property User $user
* @package App\Models
* @property string $identifier
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereDir($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereExt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereFilename($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereIdentifier($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereMine($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereOriginalName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereSize($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereUserId($value)
* @mixin \Eloquent
*/
class File extends Model
{
protected $table = 'files';
protected $casts = [
'user_id' => 'int',
'size' => 'int'
];
protected $fillable = [
'user_id',
'identifier',
'filename',
'dir',
'original_name',
'ext',
'mine',
'size'
];
public function user()
{
return $this->belongsTo(User::class);
}
public function formatBytes($precision = 2)
{
$size = $this->size;
if ($size > 0) {
$size = (int) $size;
$base = log($size) / log(1024);
$suffixes = array(' bytes', ' KB', ' MB', ' GB', ' TB');
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
} else {
return $size;
}
}
}

66
app/Models/Import.php Normal file
View file

@ -0,0 +1,66 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\Import
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Import newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Import newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Import query()
* @mixin \Eloquent
*/
class Import extends Model
{
public static $start;
public static $max_time;
public static $rules = [
'file' => 'required|mimes:xls,xlsx'
];
public static $messages = [
'file.mimes' => 'Datei ist kein Excel Format',
'file.required' => 'Excel is required'
];
protected static $row = [];
public static function setRow($row){
// self::checkTime();
self::$row[] = $row;
}
public static function checkTime(){
if(round((microtime(true) - self::$start), 2) > 29){
echo 'Total execution time in seconds: ' . round((microtime(true) - self::$start), 2);
die();
return true;
}
return false;
}
public static function countRows(){
return count(self::$row);
}
public static function break(){
echo count(self::$row)."<br>";
echo 'Total execution time in seconds: ' . round((microtime(true) - self::$start), 2);
die();
}
}

80
app/Models/Ingredient.php Normal file
View file

@ -0,0 +1,80 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* Class Ingredient
*
* @property int $id
* @property string $name
* @property string $trans_name
* @property string $inci
* @property string $trans_inci
* @property string $effect
* @property string $trans_effect
* @property bool $active
* @property int $pos
* @property Carbon $created_at
* @property Carbon $updated_at
* @property Collection|Product[] $products
* @package App\Models
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductIngredient[] $product_ingredients
* @property-read int|null $product_ingredients_count
* @property-read int|null $products_count
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereEffect($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereInci($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereTransEffect($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereTransInci($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereTransName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereUpdatedAt($value)
* @mixin \Eloquent
*/
class Ingredient extends Model
{
protected $table = 'ingredients';
protected $casts = [
'active' => 'bool',
'pos' => 'int'
];
protected $fillable = [
'name',
'trans_name',
'inci',
'trans_inci',
'effect',
'trans_effect',
'active',
'pos'
];
public function products()
{
return $this->belongsToMany(Product::class, 'product_ingredients')
->withPivot('id')
->withTimestamps();
}
public function product_ingredients()
{
return $this->hasMany(ProductIngredient::class, 'product_ingredients', 'id');
}
}

77
app/Models/IqImage.php Normal file
View file

@ -0,0 +1,77 @@
<?php
namespace App\Models;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\ProductImage
*
* @property int $id
* @property int|null $product_id
* @property string $filename
* @property string $original_name
* @property string $ext
* @property string $mine
* @property int $size
* @property int $active
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\Product|null $product
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereExt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereFilename($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereMine($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereOriginalName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereSize($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereUpdatedAt($value)
* @mixin \Eloquent
* @property string|null $slug
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage findSimilarSlugs($attribute, $config, $slug)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage query()
* @property int|null $pos
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqImage wherePos($value)
*/
class IqImage extends Model
{
use Sluggable;
protected $table = 'iq_images';
protected $fillable = [
'filename', 'original_name', 'ext', 'mine', 'size'
];
public function sluggable()
{
return [
'slug' => [
'source' => 'original_name'
]
];
}
public function formatBytes($precision = 2)
{
$size = $this->size;
if ($size > 0) {
$size = (int) $size;
$base = log($size) / log(1024);
$suffixes = array(' bytes', ' KB', ' MB', ' GB', ' TB');
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
} else {
return $size;
}
}
}

102
app/Models/IqSite.php Normal file
View file

@ -0,0 +1,102 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\IqSite
*
* @property int $id
* @property string $slug
* @property string|null $headline
* @property string|null $copy
* @property array|null $products
* @property array|null $set_products
* @property int|null $iq_image_id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\IqImage|null $iq_image
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereCopy($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereHeadline($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereIqImageId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereProducts($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereSetProducts($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereUpdatedAt($value)
* @mixin \Eloquent
*/
class IqSite extends Model
{
protected $table = 'iq_sites';
protected $casts = ['products' => 'array', 'set_products' => 'array'];
protected $fillable = [
'slug', 'headline', 'copy', 'products', 'set_products',
];
public function iq_image()
{
return $this->belongsTo('App\Models\IqImage', 'iq_image_id');
}
public function getLang($key)
{
$lang = \App::getLocale();
if ($lang == 'de') {
return $this->{$key};
}
$trans = $this->getTrans($key, $lang);
if (!$trans || $trans == '') {
return $this->{$key};
}
return $trans;
}
public function getTrans($key, $lang)
{
$key = 'trans_' . $key;
if (!empty($this->{$key}[$lang])) {
return $this->{$key}[$lang];
}
return "";
}
public function getProductModels(){
$ret = [];
foreach($this->products as $product_id){
$ret[] = Product::findOrFail($product_id);
}
return $ret;
}
public function getProductSetModels(){
$ret = [];
foreach($this->set_products as $product_id){
$ret[] = Product::findOrFail($product_id);
}
return $ret;
}
public function hasImage(){
if($this->iq_image_id){
if($this->iq_image && isset($this->iq_image->slug) && $this->iq_image->active){
return true;
}
}
return false;
}
}

83
app/Models/Logger.php Normal file
View file

@ -0,0 +1,83 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use App\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class Logger
*
* @property int $id
* @property int $user_id
* @property int $model_id
* @property string $model
* @property string $action
* @property string $channel
* @property string $message
* @property int $level
* @property Carbon $created_at
* @property Carbon $updated_at
* @property User $user
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereAction($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereChannel($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereLevel($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereMessage($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereModel($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereModelId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereUserId($value)
* @mixin \Eloquent
*/
class Logger extends Model
{
protected $table = 'loggers';
protected $casts = [
'user_id' => 'int',
'model_id' => 'int',
'level' => 'int'
];
protected $fillable = [
'user_id',
'model_id',
'model',
'action',
'channel',
'message',
'level'
];
public $levelTypes = [
1 => 'debug',
2 => 'info',
3 => 'notice',
4 => 'warning',
5 => 'error',
6 => 'critical',
7 => 'alert',
];
public function user()
{
return $this->belongsTo(User::class);
}
public function getLevelType(){
return isset($this->levelTypes[$this->level]) ? $this->levelTypes[$this->level] : "";
}
}

Some files were not shown because too many files have changed in this diff Show more