From 3f5ce31d055e56d2425a287a94c585cbf447add4 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 6 May 2024 11:00:32 +0200 Subject: [PATCH 001/115] laravel added --- .editorconfig | 18 + .env.example | 64 + .gitattributes | 11 + .gitignore | 19 + app/Http/Controllers/Controller.php | 8 + app/Models/User.php | 47 + app/Providers/AppServiceProvider.php | 24 + artisan | 15 + bootstrap/app.php | 18 + bootstrap/cache/.gitignore | 2 + bootstrap/providers.php | 5 + composer.json | 66 + composer.lock | 8153 +++++++++++++++++ config/app.php | 126 + config/auth.php | 115 + config/cache.php | 107 + config/database.php | 170 + config/filesystems.php | 76 + config/logging.php | 132 + config/mail.php | 111 + config/queue.php | 112 + config/services.php | 34 + config/session.php | 217 + database/.gitignore | 1 + database/factories/UserFactory.php | 44 + .../0001_01_01_000000_create_users_table.php | 49 + .../0001_01_01_000001_create_cache_table.php | 35 + .../0001_01_01_000002_create_jobs_table.php | 57 + database/seeders/DatabaseSeeder.php | 23 + laravel | 0 package.json | 13 + phpunit.xml | 33 + public/.htaccess | 21 + public/favicon.ico | 0 public/index.php | 17 + public/robots.txt | 2 + resources/css/app.css | 0 resources/js/app.js | 1 + resources/js/bootstrap.js | 4 + resources/views/welcome.blade.php | 172 + routes/console.php | 8 + routes/web.php | 7 + storage/app/.gitignore | 3 + storage/app/public/.gitignore | 2 + storage/framework/.gitignore | 9 + storage/framework/cache/.gitignore | 3 + storage/framework/cache/data/.gitignore | 2 + storage/framework/sessions/.gitignore | 2 + storage/framework/testing/.gitignore | 2 + storage/framework/views/.gitignore | 2 + storage/logs/.gitignore | 2 + tests/Feature/ExampleTest.php | 19 + tests/TestCase.php | 10 + tests/Unit/ExampleTest.php | 16 + vite.config.js | 11 + 55 files changed, 10220 insertions(+) create mode 100644 .editorconfig create mode 100644 .env.example create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 app/Http/Controllers/Controller.php create mode 100644 app/Models/User.php create mode 100644 app/Providers/AppServiceProvider.php create mode 100755 artisan create mode 100644 bootstrap/app.php create mode 100644 bootstrap/cache/.gitignore create mode 100644 bootstrap/providers.php create mode 100644 composer.json create mode 100644 composer.lock create mode 100644 config/app.php create mode 100644 config/auth.php create mode 100644 config/cache.php create mode 100644 config/database.php create mode 100644 config/filesystems.php create mode 100644 config/logging.php create mode 100644 config/mail.php create mode 100644 config/queue.php create mode 100644 config/services.php create mode 100644 config/session.php create mode 100644 database/.gitignore create mode 100644 database/factories/UserFactory.php create mode 100644 database/migrations/0001_01_01_000000_create_users_table.php create mode 100644 database/migrations/0001_01_01_000001_create_cache_table.php create mode 100644 database/migrations/0001_01_01_000002_create_jobs_table.php create mode 100644 database/seeders/DatabaseSeeder.php create mode 100644 laravel create mode 100644 package.json create mode 100644 phpunit.xml create mode 100644 public/.htaccess create mode 100644 public/favicon.ico create mode 100644 public/index.php create mode 100644 public/robots.txt create mode 100644 resources/css/app.css create mode 100644 resources/js/app.js create mode 100644 resources/js/bootstrap.js create mode 100644 resources/views/welcome.blade.php create mode 100644 routes/console.php create mode 100644 routes/web.php create mode 100644 storage/app/.gitignore create mode 100644 storage/app/public/.gitignore create mode 100644 storage/framework/.gitignore create mode 100644 storage/framework/cache/.gitignore create mode 100644 storage/framework/cache/data/.gitignore create mode 100644 storage/framework/sessions/.gitignore create mode 100644 storage/framework/testing/.gitignore create mode 100644 storage/framework/views/.gitignore create mode 100644 storage/logs/.gitignore create mode 100644 tests/Feature/ExampleTest.php create mode 100644 tests/TestCase.php create mode 100644 tests/Unit/ExampleTest.php create mode 100644 vite.config.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8f0de65 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{yml,yaml}] +indent_size = 2 + +[docker-compose.yml] +indent_size = 4 diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..7b49625 --- /dev/null +++ b/.env.example @@ -0,0 +1,64 @@ +APP_NAME=Laravel +APP_ENV=local +APP_KEY= +APP_DEBUG=true +APP_TIMEZONE=UTC +APP_URL=http://localhost + +APP_LOCALE=en +APP_FALLBACK_LOCALE=en +APP_FAKER_LOCALE=en_US + +APP_MAINTENANCE_DRIVER=file +APP_MAINTENANCE_STORE=database + +BCRYPT_ROUNDS=12 + +LOG_CHANNEL=stack +LOG_STACK=single +LOG_DEPRECATIONS_CHANNEL=null +LOG_LEVEL=debug + +DB_CONNECTION=sqlite +# DB_HOST=127.0.0.1 +# DB_PORT=3306 +# DB_DATABASE=laravel +# DB_USERNAME=root +# DB_PASSWORD= + +SESSION_DRIVER=database +SESSION_LIFETIME=120 +SESSION_ENCRYPT=false +SESSION_PATH=/ +SESSION_DOMAIN=null + +BROADCAST_CONNECTION=log +FILESYSTEM_DISK=local +QUEUE_CONNECTION=database + +CACHE_STORE=database +CACHE_PREFIX= + +MEMCACHED_HOST=127.0.0.1 + +REDIS_CLIENT=phpredis +REDIS_HOST=127.0.0.1 +REDIS_PASSWORD=null +REDIS_PORT=6379 + +MAIL_MAILER=log +MAIL_HOST=127.0.0.1 +MAIL_PORT=2525 +MAIL_USERNAME=null +MAIL_PASSWORD=null +MAIL_ENCRYPTION=null +MAIL_FROM_ADDRESS="hello@example.com" +MAIL_FROM_NAME="${APP_NAME}" + +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +AWS_DEFAULT_REGION=us-east-1 +AWS_BUCKET= +AWS_USE_PATH_STYLE_ENDPOINT=false + +VITE_APP_NAME="${APP_NAME}" diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..fcb21d3 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,11 @@ +* text=auto eol=lf + +*.blade.php diff=html +*.css diff=css +*.html diff=html +*.md diff=markdown +*.php diff=php + +/.github export-ignore +CHANGELOG.md export-ignore +.styleci.yml export-ignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7fe978f --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +/.phpunit.cache +/node_modules +/public/build +/public/hot +/public/storage +/storage/*.key +/vendor +.env +.env.backup +.env.production +.phpunit.result.cache +Homestead.json +Homestead.yaml +auth.json +npm-debug.log +yarn-error.log +/.fleet +/.idea +/.vscode diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php new file mode 100644 index 0000000..8677cd5 --- /dev/null +++ b/app/Http/Controllers/Controller.php @@ -0,0 +1,8 @@ + + */ + protected $fillable = [ + 'name', + 'email', + 'password', + ]; + + /** + * The attributes that should be hidden for serialization. + * + * @var array + */ + protected $hidden = [ + 'password', + 'remember_token', + ]; + + /** + * Get the attributes that should be cast. + * + * @return array + */ + protected function casts(): array + { + return [ + 'email_verified_at' => 'datetime', + 'password' => 'hashed', + ]; + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php new file mode 100644 index 0000000..452e6b6 --- /dev/null +++ b/app/Providers/AppServiceProvider.php @@ -0,0 +1,24 @@ +handleCommand(new ArgvInput); + +exit($status); diff --git a/bootstrap/app.php b/bootstrap/app.php new file mode 100644 index 0000000..7b162da --- /dev/null +++ b/bootstrap/app.php @@ -0,0 +1,18 @@ +withRouting( + web: __DIR__.'/../routes/web.php', + commands: __DIR__.'/../routes/console.php', + health: '/up', + ) + ->withMiddleware(function (Middleware $middleware) { + // + }) + ->withExceptions(function (Exceptions $exceptions) { + // + })->create(); diff --git a/bootstrap/cache/.gitignore b/bootstrap/cache/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/bootstrap/cache/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/bootstrap/providers.php b/bootstrap/providers.php new file mode 100644 index 0000000..38b258d --- /dev/null +++ b/bootstrap/providers.php @@ -0,0 +1,5 @@ +=5.0.0" + }, + "require-dev": { + "doctrine/dbal": "^4.0.0", + "nesbot/carbon": "^2.71.0 || ^3.0.0", + "phpunit/phpunit": "^10.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Carbon\\Doctrine\\": "src/Carbon/Doctrine/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "KyleKatarn", + "email": "kylekatarnls@gmail.com" + } + ], + "description": "Types to use Carbon in Doctrine", + "keywords": [ + "carbon", + "date", + "datetime", + "doctrine", + "time" + ], + "support": { + "issues": "https://github.com/CarbonPHP/carbon-doctrine-types/issues", + "source": "https://github.com/CarbonPHP/carbon-doctrine-types/tree/3.2.0" + }, + "funding": [ + { + "url": "https://github.com/kylekatarnls", + "type": "github" + }, + { + "url": "https://opencollective.com/Carbon", + "type": "open_collective" + }, + { + "url": "https://tidelift.com/funding/github/packagist/nesbot/carbon", + "type": "tidelift" + } + ], + "time": "2024-02-09T16:56:22+00:00" + }, + { + "name": "dflydev/dot-access-data", + "version": "v3.0.2", + "source": { + "type": "git", + "url": "https://github.com/dflydev/dflydev-dot-access-data.git", + "reference": "f41715465d65213d644d3141a6a93081be5d3549" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dflydev/dflydev-dot-access-data/zipball/f41715465d65213d644d3141a6a93081be5d3549", + "reference": "f41715465d65213d644d3141a6a93081be5d3549", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^0.12.42", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.3", + "scrutinizer/ocular": "1.6.0", + "squizlabs/php_codesniffer": "^3.5", + "vimeo/psalm": "^4.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Dflydev\\DotAccessData\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Dragonfly Development Inc.", + "email": "info@dflydev.com", + "homepage": "http://dflydev.com" + }, + { + "name": "Beau Simensen", + "email": "beau@dflydev.com", + "homepage": "http://beausimensen.com" + }, + { + "name": "Carlos Frutos", + "email": "carlos@kiwing.it", + "homepage": "https://github.com/cfrutos" + }, + { + "name": "Colin O'Dell", + "email": "colinodell@gmail.com", + "homepage": "https://www.colinodell.com" + } + ], + "description": "Given a deep data structure, access data by dot notation.", + "homepage": "https://github.com/dflydev/dflydev-dot-access-data", + "keywords": [ + "access", + "data", + "dot", + "notation" + ], + "support": { + "issues": "https://github.com/dflydev/dflydev-dot-access-data/issues", + "source": "https://github.com/dflydev/dflydev-dot-access-data/tree/v3.0.2" + }, + "time": "2022-10-27T11:44:00+00:00" + }, + { + "name": "doctrine/inflector", + "version": "2.0.10", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "5817d0659c5b50c9b950feb9af7b9668e2c436bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/5817d0659c5b50c9b950feb9af7b9668e2c436bc", + "reference": "5817d0659c5b50c9b950feb9af7b9668e2c436bc", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^11.0", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-phpunit": "^1.1", + "phpstan/phpstan-strict-rules": "^1.3", + "phpunit/phpunit": "^8.5 || ^9.5", + "vimeo/psalm": "^4.25 || ^5.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Inflector\\": "lib/Doctrine/Inflector" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.", + "homepage": "https://www.doctrine-project.org/projects/inflector.html", + "keywords": [ + "inflection", + "inflector", + "lowercase", + "manipulation", + "php", + "plural", + "singular", + "strings", + "uppercase", + "words" + ], + "support": { + "issues": "https://github.com/doctrine/inflector/issues", + "source": "https://github.com/doctrine/inflector/tree/2.0.10" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finflector", + "type": "tidelift" + } + ], + "time": "2024-02-18T20:23:39+00:00" + }, + { + "name": "doctrine/lexer", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "31ad66abc0fc9e1a1f2d9bc6a42668d2fbbcd6dd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/31ad66abc0fc9e1a1f2d9bc6a42668d2fbbcd6dd", + "reference": "31ad66abc0fc9e1a1f2d9bc6a42668d2fbbcd6dd", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "require-dev": { + "doctrine/coding-standard": "^12", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^10.5", + "psalm/plugin-phpunit": "^0.18.3", + "vimeo/psalm": "^5.21" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\Lexer\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "https://www.doctrine-project.org/projects/lexer.html", + "keywords": [ + "annotations", + "docblock", + "lexer", + "parser", + "php" + ], + "support": { + "issues": "https://github.com/doctrine/lexer/issues", + "source": "https://github.com/doctrine/lexer/tree/3.0.1" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Flexer", + "type": "tidelift" + } + ], + "time": "2024-02-05T11:56:58+00:00" + }, + { + "name": "dragonmantank/cron-expression", + "version": "v3.3.3", + "source": { + "type": "git", + "url": "https://github.com/dragonmantank/cron-expression.git", + "reference": "adfb1f505deb6384dc8b39804c5065dd3c8c8c0a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/adfb1f505deb6384dc8b39804c5065dd3c8c8c0a", + "reference": "adfb1f505deb6384dc8b39804c5065dd3c8c8c0a", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0", + "webmozart/assert": "^1.0" + }, + "replace": { + "mtdowling/cron-expression": "^1.0" + }, + "require-dev": { + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-webmozart-assert": "^1.0", + "phpunit/phpunit": "^7.0|^8.0|^9.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Cron\\": "src/Cron/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Chris Tankersley", + "email": "chris@ctankersley.com", + "homepage": "https://github.com/dragonmantank" + } + ], + "description": "CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due", + "keywords": [ + "cron", + "schedule" + ], + "support": { + "issues": "https://github.com/dragonmantank/cron-expression/issues", + "source": "https://github.com/dragonmantank/cron-expression/tree/v3.3.3" + }, + "funding": [ + { + "url": "https://github.com/dragonmantank", + "type": "github" + } + ], + "time": "2023-08-10T19:36:49+00:00" + }, + { + "name": "egulias/email-validator", + "version": "4.0.2", + "source": { + "type": "git", + "url": "https://github.com/egulias/EmailValidator.git", + "reference": "ebaaf5be6c0286928352e054f2d5125608e5405e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/ebaaf5be6c0286928352e054f2d5125608e5405e", + "reference": "ebaaf5be6c0286928352e054f2d5125608e5405e", + "shasum": "" + }, + "require": { + "doctrine/lexer": "^2.0 || ^3.0", + "php": ">=8.1", + "symfony/polyfill-intl-idn": "^1.26" + }, + "require-dev": { + "phpunit/phpunit": "^10.2", + "vimeo/psalm": "^5.12" + }, + "suggest": { + "ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Egulias\\EmailValidator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eduardo Gulias Davis" + } + ], + "description": "A library for validating emails against several RFCs", + "homepage": "https://github.com/egulias/EmailValidator", + "keywords": [ + "email", + "emailvalidation", + "emailvalidator", + "validation", + "validator" + ], + "support": { + "issues": "https://github.com/egulias/EmailValidator/issues", + "source": "https://github.com/egulias/EmailValidator/tree/4.0.2" + }, + "funding": [ + { + "url": "https://github.com/egulias", + "type": "github" + } + ], + "time": "2023-10-06T06:47:41+00:00" + }, + { + "name": "fruitcake/php-cors", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/fruitcake/php-cors.git", + "reference": "3d158f36e7875e2f040f37bc0573956240a5a38b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fruitcake/php-cors/zipball/3d158f36e7875e2f040f37bc0573956240a5a38b", + "reference": "3d158f36e7875e2f040f37bc0573956240a5a38b", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0", + "symfony/http-foundation": "^4.4|^5.4|^6|^7" + }, + "require-dev": { + "phpstan/phpstan": "^1.4", + "phpunit/phpunit": "^9", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2-dev" + } + }, + "autoload": { + "psr-4": { + "Fruitcake\\Cors\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fruitcake", + "homepage": "https://fruitcake.nl" + }, + { + "name": "Barryvdh", + "email": "barryvdh@gmail.com" + } + ], + "description": "Cross-origin resource sharing library for the Symfony HttpFoundation", + "homepage": "https://github.com/fruitcake/php-cors", + "keywords": [ + "cors", + "laravel", + "symfony" + ], + "support": { + "issues": "https://github.com/fruitcake/php-cors/issues", + "source": "https://github.com/fruitcake/php-cors/tree/v1.3.0" + }, + "funding": [ + { + "url": "https://fruitcake.nl", + "type": "custom" + }, + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], + "time": "2023-10-12T05:21:21+00:00" + }, + { + "name": "graham-campbell/result-type", + "version": "v1.1.2", + "source": { + "type": "git", + "url": "https://github.com/GrahamCampbell/Result-Type.git", + "reference": "fbd48bce38f73f8a4ec8583362e732e4095e5862" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/fbd48bce38f73f8a4ec8583362e732e4095e5862", + "reference": "fbd48bce38f73f8a4ec8583362e732e4095e5862", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "phpoption/phpoption": "^1.9.2" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "GrahamCampbell\\ResultType\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + } + ], + "description": "An Implementation Of The Result Type", + "keywords": [ + "Graham Campbell", + "GrahamCampbell", + "Result Type", + "Result-Type", + "result" + ], + "support": { + "issues": "https://github.com/GrahamCampbell/Result-Type/issues", + "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.2" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type", + "type": "tidelift" + } + ], + "time": "2023-11-12T22:16:48+00:00" + }, + { + "name": "guzzlehttp/guzzle", + "version": "7.8.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "41042bc7ab002487b876a0683fc8dce04ddce104" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/41042bc7ab002487b876a0683fc8dce04ddce104", + "reference": "41042bc7ab002487b876a0683fc8dce04ddce104", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/promises": "^1.5.3 || ^2.0.1", + "guzzlehttp/psr7": "^1.9.1 || ^2.5.1", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "ext-curl": "*", + "php-http/client-integration-tests": "dev-master#2c025848417c1135031fdf9c728ee53d0a7ceaee as 3.0.999", + "php-http/message-factory": "^1.1", + "phpunit/phpunit": "^8.5.36 || ^9.6.15", + "psr/log": "^1.1 || ^2.0 || ^3.0" + }, + "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "psr-18", + "psr-7", + "rest", + "web service" + ], + "support": { + "issues": "https://github.com/guzzle/guzzle/issues", + "source": "https://github.com/guzzle/guzzle/tree/7.8.1" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" + } + ], + "time": "2023-12-03T20:35:24+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "bbff78d96034045e58e13dedd6ad91b5d1253223" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/bbff78d96034045e58e13dedd6ad91b5d1253223", + "reference": "bbff78d96034045e58e13dedd6ad91b5d1253223", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.36 || ^9.6.15" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/2.0.2" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "time": "2023-12-03T20:19:20+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "2.6.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/45b30f99ac27b5ca93cb4831afe16285f57b8221", + "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "http-interop/http-factory-tests": "^0.9", + "phpunit/phpunit": "^8.5.36 || ^9.6.15" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.6.2" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "time": "2023-12-03T20:05:35+00:00" + }, + { + "name": "guzzlehttp/uri-template", + "version": "v1.0.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/uri-template.git", + "reference": "ecea8feef63bd4fef1f037ecb288386999ecc11c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/uri-template/zipball/ecea8feef63bd4fef1f037ecb288386999ecc11c", + "reference": "ecea8feef63bd4fef1f037ecb288386999ecc11c", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "symfony/polyfill-php80": "^1.24" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.36 || ^9.6.15", + "uri-template/tests": "1.0.0" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\UriTemplate\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + } + ], + "description": "A polyfill class for uri_template of PHP", + "keywords": [ + "guzzlehttp", + "uri-template" + ], + "support": { + "issues": "https://github.com/guzzle/uri-template/issues", + "source": "https://github.com/guzzle/uri-template/tree/v1.0.3" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/uri-template", + "type": "tidelift" + } + ], + "time": "2023-12-03T19:50:20+00:00" + }, + { + "name": "laravel/framework", + "version": "v11.6.0", + "source": { + "type": "git", + "url": "https://github.com/laravel/framework.git", + "reference": "e090ee638ebd4ce221d8bad43b49bbf59ea70ae5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/framework/zipball/e090ee638ebd4ce221d8bad43b49bbf59ea70ae5", + "reference": "e090ee638ebd4ce221d8bad43b49bbf59ea70ae5", + "shasum": "" + }, + "require": { + "brick/math": "^0.9.3|^0.10.2|^0.11|^0.12", + "composer-runtime-api": "^2.2", + "doctrine/inflector": "^2.0.5", + "dragonmantank/cron-expression": "^3.3.2", + "egulias/email-validator": "^3.2.1|^4.0", + "ext-ctype": "*", + "ext-filter": "*", + "ext-hash": "*", + "ext-mbstring": "*", + "ext-openssl": "*", + "ext-session": "*", + "ext-tokenizer": "*", + "fruitcake/php-cors": "^1.3", + "guzzlehttp/guzzle": "^7.8", + "guzzlehttp/uri-template": "^1.0", + "laravel/prompts": "^0.1.18", + "laravel/serializable-closure": "^1.3", + "league/commonmark": "^2.2.1", + "league/flysystem": "^3.8.0", + "monolog/monolog": "^3.0", + "nesbot/carbon": "^2.72.2|^3.0", + "nunomaduro/termwind": "^2.0", + "php": "^8.2", + "psr/container": "^1.1.1|^2.0.1", + "psr/log": "^1.0|^2.0|^3.0", + "psr/simple-cache": "^1.0|^2.0|^3.0", + "ramsey/uuid": "^4.7", + "symfony/console": "^7.0", + "symfony/error-handler": "^7.0", + "symfony/finder": "^7.0", + "symfony/http-foundation": "^7.0", + "symfony/http-kernel": "^7.0", + "symfony/mailer": "^7.0", + "symfony/mime": "^7.0", + "symfony/polyfill-php83": "^1.28", + "symfony/process": "^7.0", + "symfony/routing": "^7.0", + "symfony/uid": "^7.0", + "symfony/var-dumper": "^7.0", + "tijsverkoyen/css-to-inline-styles": "^2.2.5", + "vlucas/phpdotenv": "^5.4.1", + "voku/portable-ascii": "^2.0" + }, + "conflict": { + "mockery/mockery": "1.6.8", + "tightenco/collect": "<5.5.33" + }, + "provide": { + "psr/container-implementation": "1.1|2.0", + "psr/simple-cache-implementation": "1.0|2.0|3.0" + }, + "replace": { + "illuminate/auth": "self.version", + "illuminate/broadcasting": "self.version", + "illuminate/bus": "self.version", + "illuminate/cache": "self.version", + "illuminate/collections": "self.version", + "illuminate/conditionable": "self.version", + "illuminate/config": "self.version", + "illuminate/console": "self.version", + "illuminate/container": "self.version", + "illuminate/contracts": "self.version", + "illuminate/cookie": "self.version", + "illuminate/database": "self.version", + "illuminate/encryption": "self.version", + "illuminate/events": "self.version", + "illuminate/filesystem": "self.version", + "illuminate/hashing": "self.version", + "illuminate/http": "self.version", + "illuminate/log": "self.version", + "illuminate/macroable": "self.version", + "illuminate/mail": "self.version", + "illuminate/notifications": "self.version", + "illuminate/pagination": "self.version", + "illuminate/pipeline": "self.version", + "illuminate/process": "self.version", + "illuminate/queue": "self.version", + "illuminate/redis": "self.version", + "illuminate/routing": "self.version", + "illuminate/session": "self.version", + "illuminate/support": "self.version", + "illuminate/testing": "self.version", + "illuminate/translation": "self.version", + "illuminate/validation": "self.version", + "illuminate/view": "self.version", + "spatie/once": "*" + }, + "require-dev": { + "ably/ably-php": "^1.0", + "aws/aws-sdk-php": "^3.235.5", + "ext-gmp": "*", + "fakerphp/faker": "^1.23", + "league/flysystem-aws-s3-v3": "^3.0", + "league/flysystem-ftp": "^3.0", + "league/flysystem-path-prefixing": "^3.3", + "league/flysystem-read-only": "^3.3", + "league/flysystem-sftp-v3": "^3.0", + "mockery/mockery": "^1.6", + "nyholm/psr7": "^1.2", + "orchestra/testbench-core": "^9.0.15", + "pda/pheanstalk": "^5.0", + "phpstan/phpstan": "^1.4.7", + "phpunit/phpunit": "^10.5|^11.0", + "predis/predis": "^2.0.2", + "resend/resend-php": "^0.10.0", + "symfony/cache": "^7.0", + "symfony/http-client": "^7.0", + "symfony/psr-http-message-bridge": "^7.0" + }, + "suggest": { + "ably/ably-php": "Required to use the Ably broadcast driver (^1.0).", + "aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage, and SES mail driver (^3.235.5).", + "brianium/paratest": "Required to run tests in parallel (^7.0|^8.0).", + "ext-apcu": "Required to use the APC cache driver.", + "ext-fileinfo": "Required to use the Filesystem class.", + "ext-ftp": "Required to use the Flysystem FTP driver.", + "ext-gd": "Required to use Illuminate\\Http\\Testing\\FileFactory::image().", + "ext-memcached": "Required to use the memcache cache driver.", + "ext-pcntl": "Required to use all features of the queue worker and console signal trapping.", + "ext-pdo": "Required to use all database features.", + "ext-posix": "Required to use all features of the queue worker.", + "ext-redis": "Required to use the Redis cache and queue drivers (^4.0|^5.0).", + "fakerphp/faker": "Required to use the eloquent factory builder (^1.9.1).", + "filp/whoops": "Required for friendly error pages in development (^2.14.3).", + "laravel/tinker": "Required to use the tinker console command (^2.0).", + "league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^3.0).", + "league/flysystem-ftp": "Required to use the Flysystem FTP driver (^3.0).", + "league/flysystem-path-prefixing": "Required to use the scoped driver (^3.3).", + "league/flysystem-read-only": "Required to use read-only disks (^3.3)", + "league/flysystem-sftp-v3": "Required to use the Flysystem SFTP driver (^3.0).", + "mockery/mockery": "Required to use mocking (^1.6).", + "nyholm/psr7": "Required to use PSR-7 bridging features (^1.2).", + "pda/pheanstalk": "Required to use the beanstalk queue driver (^5.0).", + "phpunit/phpunit": "Required to use assertions and run tests (^10.5|^11.0).", + "predis/predis": "Required to use the predis connector (^2.0.2).", + "psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).", + "pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^6.0|^7.0).", + "resend/resend-php": "Required to enable support for the Resend mail transport (^0.10.0).", + "symfony/cache": "Required to PSR-6 cache bridge (^7.0).", + "symfony/filesystem": "Required to enable support for relative symbolic links (^7.0).", + "symfony/http-client": "Required to enable support for the Symfony API mail transports (^7.0).", + "symfony/mailgun-mailer": "Required to enable support for the Mailgun mail transport (^7.0).", + "symfony/postmark-mailer": "Required to enable support for the Postmark mail transport (^7.0).", + "symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^7.0)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "11.x-dev" + } + }, + "autoload": { + "files": [ + "src/Illuminate/Collections/helpers.php", + "src/Illuminate/Events/functions.php", + "src/Illuminate/Filesystem/functions.php", + "src/Illuminate/Foundation/helpers.php", + "src/Illuminate/Support/helpers.php" + ], + "psr-4": { + "Illuminate\\": "src/Illuminate/", + "Illuminate\\Support\\": [ + "src/Illuminate/Macroable/", + "src/Illuminate/Collections/", + "src/Illuminate/Conditionable/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Laravel Framework.", + "homepage": "https://laravel.com", + "keywords": [ + "framework", + "laravel" + ], + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "time": "2024-04-30T13:30:08+00:00" + }, + { + "name": "laravel/prompts", + "version": "v0.1.21", + "source": { + "type": "git", + "url": "https://github.com/laravel/prompts.git", + "reference": "23ea808e8a145653e0ab29e30d4385e49f40a920" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/prompts/zipball/23ea808e8a145653e0ab29e30d4385e49f40a920", + "reference": "23ea808e8a145653e0ab29e30d4385e49f40a920", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "illuminate/collections": "^10.0|^11.0", + "php": "^8.1", + "symfony/console": "^6.2|^7.0" + }, + "conflict": { + "illuminate/console": ">=10.17.0 <10.25.0", + "laravel/framework": ">=10.17.0 <10.25.0" + }, + "require-dev": { + "mockery/mockery": "^1.5", + "pestphp/pest": "^2.3", + "phpstan/phpstan": "^1.11", + "phpstan/phpstan-mockery": "^1.1" + }, + "suggest": { + "ext-pcntl": "Required for the spinner to be animated." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "0.1.x-dev" + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Laravel\\Prompts\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Add beautiful and user-friendly forms to your command-line applications.", + "support": { + "issues": "https://github.com/laravel/prompts/issues", + "source": "https://github.com/laravel/prompts/tree/v0.1.21" + }, + "time": "2024-04-30T12:46:16+00:00" + }, + { + "name": "laravel/serializable-closure", + "version": "v1.3.3", + "source": { + "type": "git", + "url": "https://github.com/laravel/serializable-closure.git", + "reference": "3dbf8a8e914634c48d389c1234552666b3d43754" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/3dbf8a8e914634c48d389c1234552666b3d43754", + "reference": "3dbf8a8e914634c48d389c1234552666b3d43754", + "shasum": "" + }, + "require": { + "php": "^7.3|^8.0" + }, + "require-dev": { + "nesbot/carbon": "^2.61", + "pestphp/pest": "^1.21.3", + "phpstan/phpstan": "^1.8.2", + "symfony/var-dumper": "^5.4.11" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Laravel\\SerializableClosure\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + }, + { + "name": "Nuno Maduro", + "email": "nuno@laravel.com" + } + ], + "description": "Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.", + "keywords": [ + "closure", + "laravel", + "serializable" + ], + "support": { + "issues": "https://github.com/laravel/serializable-closure/issues", + "source": "https://github.com/laravel/serializable-closure" + }, + "time": "2023-11-08T14:08:06+00:00" + }, + { + "name": "laravel/tinker", + "version": "v2.9.0", + "source": { + "type": "git", + "url": "https://github.com/laravel/tinker.git", + "reference": "502e0fe3f0415d06d5db1f83a472f0f3b754bafe" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/tinker/zipball/502e0fe3f0415d06d5db1f83a472f0f3b754bafe", + "reference": "502e0fe3f0415d06d5db1f83a472f0f3b754bafe", + "shasum": "" + }, + "require": { + "illuminate/console": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/contracts": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", + "php": "^7.2.5|^8.0", + "psy/psysh": "^0.11.1|^0.12.0", + "symfony/var-dumper": "^4.3.4|^5.0|^6.0|^7.0" + }, + "require-dev": { + "mockery/mockery": "~1.3.3|^1.4.2", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^8.5.8|^9.3.3" + }, + "suggest": { + "illuminate/database": "The Illuminate Database package (^6.0|^7.0|^8.0|^9.0|^10.0|^11.0)." + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Laravel\\Tinker\\TinkerServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Laravel\\Tinker\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "Powerful REPL for the Laravel framework.", + "keywords": [ + "REPL", + "Tinker", + "laravel", + "psysh" + ], + "support": { + "issues": "https://github.com/laravel/tinker/issues", + "source": "https://github.com/laravel/tinker/tree/v2.9.0" + }, + "time": "2024-01-04T16:10:04+00:00" + }, + { + "name": "league/commonmark", + "version": "2.4.2", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/commonmark.git", + "reference": "91c24291965bd6d7c46c46a12ba7492f83b1cadf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/91c24291965bd6d7c46c46a12ba7492f83b1cadf", + "reference": "91c24291965bd6d7c46c46a12ba7492f83b1cadf", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "league/config": "^1.1.1", + "php": "^7.4 || ^8.0", + "psr/event-dispatcher": "^1.0", + "symfony/deprecation-contracts": "^2.1 || ^3.0", + "symfony/polyfill-php80": "^1.16" + }, + "require-dev": { + "cebe/markdown": "^1.0", + "commonmark/cmark": "0.30.3", + "commonmark/commonmark.js": "0.30.0", + "composer/package-versions-deprecated": "^1.8", + "embed/embed": "^4.4", + "erusev/parsedown": "^1.0", + "ext-json": "*", + "github/gfm": "0.29.0", + "michelf/php-markdown": "^1.4 || ^2.0", + "nyholm/psr7": "^1.5", + "phpstan/phpstan": "^1.8.2", + "phpunit/phpunit": "^9.5.21 || ^10.5.9 || ^11.0.0", + "scrutinizer/ocular": "^1.8.1", + "symfony/finder": "^5.3 | ^6.0 || ^7.0", + "symfony/yaml": "^2.3 | ^3.0 | ^4.0 | ^5.0 | ^6.0 || ^7.0", + "unleashedtech/php-coding-standard": "^3.1.1", + "vimeo/psalm": "^4.24.0 || ^5.0.0" + }, + "suggest": { + "symfony/yaml": "v2.3+ required if using the Front Matter extension" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.5-dev" + } + }, + "autoload": { + "psr-4": { + "League\\CommonMark\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Colin O'Dell", + "email": "colinodell@gmail.com", + "homepage": "https://www.colinodell.com", + "role": "Lead Developer" + } + ], + "description": "Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)", + "homepage": "https://commonmark.thephpleague.com", + "keywords": [ + "commonmark", + "flavored", + "gfm", + "github", + "github-flavored", + "markdown", + "md", + "parser" + ], + "support": { + "docs": "https://commonmark.thephpleague.com/", + "forum": "https://github.com/thephpleague/commonmark/discussions", + "issues": "https://github.com/thephpleague/commonmark/issues", + "rss": "https://github.com/thephpleague/commonmark/releases.atom", + "source": "https://github.com/thephpleague/commonmark" + }, + "funding": [ + { + "url": "https://www.colinodell.com/sponsor", + "type": "custom" + }, + { + "url": "https://www.paypal.me/colinpodell/10.00", + "type": "custom" + }, + { + "url": "https://github.com/colinodell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/league/commonmark", + "type": "tidelift" + } + ], + "time": "2024-02-02T11:59:32+00:00" + }, + { + "name": "league/config", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/config.git", + "reference": "754b3604fb2984c71f4af4a9cbe7b57f346ec1f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/config/zipball/754b3604fb2984c71f4af4a9cbe7b57f346ec1f3", + "reference": "754b3604fb2984c71f4af4a9cbe7b57f346ec1f3", + "shasum": "" + }, + "require": { + "dflydev/dot-access-data": "^3.0.1", + "nette/schema": "^1.2", + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.8.2", + "phpunit/phpunit": "^9.5.5", + "scrutinizer/ocular": "^1.8.1", + "unleashedtech/php-coding-standard": "^3.1", + "vimeo/psalm": "^4.7.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.2-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Config\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Colin O'Dell", + "email": "colinodell@gmail.com", + "homepage": "https://www.colinodell.com", + "role": "Lead Developer" + } + ], + "description": "Define configuration arrays with strict schemas and access values with dot notation", + "homepage": "https://config.thephpleague.com", + "keywords": [ + "array", + "config", + "configuration", + "dot", + "dot-access", + "nested", + "schema" + ], + "support": { + "docs": "https://config.thephpleague.com/", + "issues": "https://github.com/thephpleague/config/issues", + "rss": "https://github.com/thephpleague/config/releases.atom", + "source": "https://github.com/thephpleague/config" + }, + "funding": [ + { + "url": "https://www.colinodell.com/sponsor", + "type": "custom" + }, + { + "url": "https://www.paypal.me/colinpodell/10.00", + "type": "custom" + }, + { + "url": "https://github.com/colinodell", + "type": "github" + } + ], + "time": "2022-12-11T20:36:23+00:00" + }, + { + "name": "league/flysystem", + "version": "3.27.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/flysystem.git", + "reference": "4729745b1ab737908c7d055148c9a6b3e959832f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/4729745b1ab737908c7d055148c9a6b3e959832f", + "reference": "4729745b1ab737908c7d055148c9a6b3e959832f", + "shasum": "" + }, + "require": { + "league/flysystem-local": "^3.0.0", + "league/mime-type-detection": "^1.0.0", + "php": "^8.0.2" + }, + "conflict": { + "async-aws/core": "<1.19.0", + "async-aws/s3": "<1.14.0", + "aws/aws-sdk-php": "3.209.31 || 3.210.0", + "guzzlehttp/guzzle": "<7.0", + "guzzlehttp/ringphp": "<1.1.1", + "phpseclib/phpseclib": "3.0.15", + "symfony/http-client": "<5.2" + }, + "require-dev": { + "async-aws/s3": "^1.5 || ^2.0", + "async-aws/simple-s3": "^1.1 || ^2.0", + "aws/aws-sdk-php": "^3.295.10", + "composer/semver": "^3.0", + "ext-fileinfo": "*", + "ext-ftp": "*", + "ext-zip": "*", + "friendsofphp/php-cs-fixer": "^3.5", + "google/cloud-storage": "^1.23", + "microsoft/azure-storage-blob": "^1.1", + "phpseclib/phpseclib": "^3.0.36", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.5.11|^10.0", + "sabre/dav": "^4.6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "League\\Flysystem\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frankdejonge.nl" + } + ], + "description": "File storage abstraction for PHP", + "keywords": [ + "WebDAV", + "aws", + "cloud", + "file", + "files", + "filesystem", + "filesystems", + "ftp", + "s3", + "sftp", + "storage" + ], + "support": { + "issues": "https://github.com/thephpleague/flysystem/issues", + "source": "https://github.com/thephpleague/flysystem/tree/3.27.0" + }, + "funding": [ + { + "url": "https://ecologi.com/frankdejonge", + "type": "custom" + }, + { + "url": "https://github.com/frankdejonge", + "type": "github" + } + ], + "time": "2024-04-07T19:17:50+00:00" + }, + { + "name": "league/flysystem-local", + "version": "3.25.1", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/flysystem-local.git", + "reference": "61a6a90d6e999e4ddd9ce5adb356de0939060b92" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/61a6a90d6e999e4ddd9ce5adb356de0939060b92", + "reference": "61a6a90d6e999e4ddd9ce5adb356de0939060b92", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "league/flysystem": "^3.0.0", + "league/mime-type-detection": "^1.0.0", + "php": "^8.0.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "League\\Flysystem\\Local\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frankdejonge.nl" + } + ], + "description": "Local filesystem adapter for Flysystem.", + "keywords": [ + "Flysystem", + "file", + "files", + "filesystem", + "local" + ], + "support": { + "source": "https://github.com/thephpleague/flysystem-local/tree/3.25.1" + }, + "funding": [ + { + "url": "https://ecologi.com/frankdejonge", + "type": "custom" + }, + { + "url": "https://github.com/frankdejonge", + "type": "github" + } + ], + "time": "2024-03-15T19:58:44+00:00" + }, + { + "name": "league/mime-type-detection", + "version": "1.15.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/mime-type-detection.git", + "reference": "ce0f4d1e8a6f4eb0ddff33f57c69c50fd09f4301" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/ce0f4d1e8a6f4eb0ddff33f57c69c50fd09f4301", + "reference": "ce0f4d1e8a6f4eb0ddff33f57c69c50fd09f4301", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.2", + "phpstan/phpstan": "^0.12.68", + "phpunit/phpunit": "^8.5.8 || ^9.3 || ^10.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "League\\MimeTypeDetection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frankdejonge.nl" + } + ], + "description": "Mime-type detection for Flysystem", + "support": { + "issues": "https://github.com/thephpleague/mime-type-detection/issues", + "source": "https://github.com/thephpleague/mime-type-detection/tree/1.15.0" + }, + "funding": [ + { + "url": "https://github.com/frankdejonge", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/league/flysystem", + "type": "tidelift" + } + ], + "time": "2024-01-28T23:22:08+00:00" + }, + { + "name": "monolog/monolog", + "version": "3.6.0", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/monolog.git", + "reference": "4b18b21a5527a3d5ffdac2fd35d3ab25a9597654" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/4b18b21a5527a3d5ffdac2fd35d3ab25a9597654", + "reference": "4b18b21a5527a3d5ffdac2fd35d3ab25a9597654", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "psr/log": "^2.0 || ^3.0" + }, + "provide": { + "psr/log-implementation": "3.0.0" + }, + "require-dev": { + "aws/aws-sdk-php": "^3.0", + "doctrine/couchdb": "~1.0@dev", + "elasticsearch/elasticsearch": "^7 || ^8", + "ext-json": "*", + "graylog2/gelf-php": "^1.4.2 || ^2.0", + "guzzlehttp/guzzle": "^7.4.5", + "guzzlehttp/psr7": "^2.2", + "mongodb/mongodb": "^1.8", + "php-amqplib/php-amqplib": "~2.4 || ^3", + "phpstan/phpstan": "^1.9", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-strict-rules": "^1.4", + "phpunit/phpunit": "^10.5.17", + "predis/predis": "^1.1 || ^2", + "ruflin/elastica": "^7", + "symfony/mailer": "^5.4 || ^6", + "symfony/mime": "^5.4 || ^6" + }, + "suggest": { + "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", + "doctrine/couchdb": "Allow sending log messages to a CouchDB server", + "elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client", + "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", + "ext-curl": "Required to send log messages using the IFTTTHandler, the LogglyHandler, the SendGridHandler, the SlackWebhookHandler or the TelegramBotHandler", + "ext-mbstring": "Allow to work properly with unicode symbols", + "ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)", + "ext-openssl": "Required to send log messages using SSL", + "ext-sockets": "Allow sending log messages to a Syslog server (via UDP driver)", + "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", + "mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)", + "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", + "rollbar/rollbar": "Allow sending log messages to Rollbar", + "ruflin/elastica": "Allow sending log messages to an Elastic Search server" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Monolog\\": "src/Monolog" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "https://seld.be" + } + ], + "description": "Sends your logs to files, sockets, inboxes, databases and various web services", + "homepage": "https://github.com/Seldaek/monolog", + "keywords": [ + "log", + "logging", + "psr-3" + ], + "support": { + "issues": "https://github.com/Seldaek/monolog/issues", + "source": "https://github.com/Seldaek/monolog/tree/3.6.0" + }, + "funding": [ + { + "url": "https://github.com/Seldaek", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/monolog/monolog", + "type": "tidelift" + } + ], + "time": "2024-04-12T21:02:21+00:00" + }, + { + "name": "nesbot/carbon", + "version": "3.3.1", + "source": { + "type": "git", + "url": "https://github.com/briannesbitt/Carbon.git", + "reference": "8ff64b92c1b1ec84fcde9f8bb9ff2ca34cb8a77a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/8ff64b92c1b1ec84fcde9f8bb9ff2ca34cb8a77a", + "reference": "8ff64b92c1b1ec84fcde9f8bb9ff2ca34cb8a77a", + "shasum": "" + }, + "require": { + "carbonphp/carbon-doctrine-types": "*", + "ext-json": "*", + "php": "^8.1", + "psr/clock": "^1.0", + "symfony/clock": "^6.3 || ^7.0", + "symfony/polyfill-mbstring": "^1.0", + "symfony/translation": "^4.4.18 || ^5.2.1|| ^6.0 || ^7.0" + }, + "provide": { + "psr/clock-implementation": "1.0" + }, + "require-dev": { + "doctrine/dbal": "^3.6.3 || ^4.0", + "doctrine/orm": "^2.15.2 || ^3.0", + "friendsofphp/php-cs-fixer": "^3.52.1", + "kylekatarnls/multi-tester": "^2.5.3", + "ondrejmirtes/better-reflection": "^6.25.0.4", + "phpmd/phpmd": "^2.15.0", + "phpstan/extension-installer": "^1.3.1", + "phpstan/phpstan": "^1.10.65", + "phpunit/phpunit": "^10.5.15", + "squizlabs/php_codesniffer": "^3.9.0" + }, + "bin": [ + "bin/carbon" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev", + "dev-2.x": "2.x-dev" + }, + "laravel": { + "providers": [ + "Carbon\\Laravel\\ServiceProvider" + ] + }, + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "Carbon\\": "src/Carbon/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brian Nesbitt", + "email": "brian@nesbot.com", + "homepage": "https://markido.com" + }, + { + "name": "kylekatarnls", + "homepage": "https://github.com/kylekatarnls" + } + ], + "description": "An API extension for DateTime that supports 281 different languages.", + "homepage": "https://carbon.nesbot.com", + "keywords": [ + "date", + "datetime", + "time" + ], + "support": { + "docs": "https://carbon.nesbot.com/docs", + "issues": "https://github.com/briannesbitt/Carbon/issues", + "source": "https://github.com/briannesbitt/Carbon" + }, + "funding": [ + { + "url": "https://github.com/sponsors/kylekatarnls", + "type": "github" + }, + { + "url": "https://opencollective.com/Carbon#sponsor", + "type": "opencollective" + }, + { + "url": "https://tidelift.com/subscription/pkg/packagist-nesbot-carbon?utm_source=packagist-nesbot-carbon&utm_medium=referral&utm_campaign=readme", + "type": "tidelift" + } + ], + "time": "2024-05-01T06:54:22+00:00" + }, + { + "name": "nette/schema", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/nette/schema.git", + "reference": "a6d3a6d1f545f01ef38e60f375d1cf1f4de98188" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/schema/zipball/a6d3a6d1f545f01ef38e60f375d1cf1f4de98188", + "reference": "a6d3a6d1f545f01ef38e60f375d1cf1f4de98188", + "shasum": "" + }, + "require": { + "nette/utils": "^4.0", + "php": "8.1 - 8.3" + }, + "require-dev": { + "nette/tester": "^2.4", + "phpstan/phpstan-nette": "^1.0", + "tracy/tracy": "^2.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0-only", + "GPL-3.0-only" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "📐 Nette Schema: validating data structures against a given Schema.", + "homepage": "https://nette.org", + "keywords": [ + "config", + "nette" + ], + "support": { + "issues": "https://github.com/nette/schema/issues", + "source": "https://github.com/nette/schema/tree/v1.3.0" + }, + "time": "2023-12-11T11:54:22+00:00" + }, + { + "name": "nette/utils", + "version": "v4.0.4", + "source": { + "type": "git", + "url": "https://github.com/nette/utils.git", + "reference": "d3ad0aa3b9f934602cb3e3902ebccf10be34d218" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/utils/zipball/d3ad0aa3b9f934602cb3e3902ebccf10be34d218", + "reference": "d3ad0aa3b9f934602cb3e3902ebccf10be34d218", + "shasum": "" + }, + "require": { + "php": ">=8.0 <8.4" + }, + "conflict": { + "nette/finder": "<3", + "nette/schema": "<1.2.2" + }, + "require-dev": { + "jetbrains/phpstorm-attributes": "dev-master", + "nette/tester": "^2.5", + "phpstan/phpstan": "^1.0", + "tracy/tracy": "^2.9" + }, + "suggest": { + "ext-gd": "to use Image", + "ext-iconv": "to use Strings::webalize(), toAscii(), chr() and reverse()", + "ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()", + "ext-json": "to use Nette\\Utils\\Json", + "ext-mbstring": "to use Strings::lower() etc...", + "ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0-only", + "GPL-3.0-only" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.", + "homepage": "https://nette.org", + "keywords": [ + "array", + "core", + "datetime", + "images", + "json", + "nette", + "paginator", + "password", + "slugify", + "string", + "unicode", + "utf-8", + "utility", + "validation" + ], + "support": { + "issues": "https://github.com/nette/utils/issues", + "source": "https://github.com/nette/utils/tree/v4.0.4" + }, + "time": "2024-01-17T16:50:36+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v5.0.2", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/139676794dc1e9231bf7bcd123cfc0c99182cb13", + "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-json": "*", + "ext-tokenizer": "*", + "php": ">=7.4" + }, + "require-dev": { + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v5.0.2" + }, + "time": "2024-03-05T20:51:40+00:00" + }, + { + "name": "nunomaduro/termwind", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/nunomaduro/termwind.git", + "reference": "58c4c58cf23df7f498daeb97092e34f5259feb6a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/58c4c58cf23df7f498daeb97092e34f5259feb6a", + "reference": "58c4c58cf23df7f498daeb97092e34f5259feb6a", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^8.2", + "symfony/console": "^7.0.4" + }, + "require-dev": { + "ergebnis/phpstan-rules": "^2.2.0", + "illuminate/console": "^11.0.0", + "laravel/pint": "^1.14.0", + "mockery/mockery": "^1.6.7", + "pestphp/pest": "^2.34.1", + "phpstan/phpstan": "^1.10.59", + "phpstan/phpstan-strict-rules": "^1.5.2", + "symfony/var-dumper": "^7.0.4", + "thecodingmachine/phpstan-strict-rules": "^1.0.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Termwind\\Laravel\\TermwindServiceProvider" + ] + }, + "branch-alias": { + "dev-2.x": "2.x-dev" + } + }, + "autoload": { + "files": [ + "src/Functions.php" + ], + "psr-4": { + "Termwind\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "Its like Tailwind CSS, but for the console.", + "keywords": [ + "cli", + "console", + "css", + "package", + "php", + "style" + ], + "support": { + "issues": "https://github.com/nunomaduro/termwind/issues", + "source": "https://github.com/nunomaduro/termwind/tree/v2.0.1" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + }, + { + "url": "https://github.com/xiCO2k", + "type": "github" + } + ], + "time": "2024-03-06T16:17:14+00:00" + }, + { + "name": "phpoption/phpoption", + "version": "1.9.2", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/php-option.git", + "reference": "80735db690fe4fc5c76dfa7f9b770634285fa820" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/80735db690fe4fc5c76dfa7f9b770634285fa820", + "reference": "80735db690fe4fc5c76dfa7f9b770634285fa820", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": true + }, + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "PhpOption\\": "src/PhpOption/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh" + }, + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + } + ], + "description": "Option Type for PHP", + "keywords": [ + "language", + "option", + "php", + "type" + ], + "support": { + "issues": "https://github.com/schmittjoh/php-option/issues", + "source": "https://github.com/schmittjoh/php-option/tree/1.9.2" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption", + "type": "tidelift" + } + ], + "time": "2023-11-12T21:59:55+00:00" + }, + { + "name": "psr/clock", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/clock.git", + "reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/clock/zipball/e41a24703d4560fd0acb709162f73b8adfc3aa0d", + "reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Psr\\Clock\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for reading the clock.", + "homepage": "https://github.com/php-fig/clock", + "keywords": [ + "clock", + "now", + "psr", + "psr-20", + "time" + ], + "support": { + "issues": "https://github.com/php-fig/clock/issues", + "source": "https://github.com/php-fig/clock/tree/1.0.0" + }, + "time": "2022-11-25T14:36:26+00:00" + }, + { + "name": "psr/container", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/2.0.2" + }, + "time": "2021-11-05T16:47:00+00:00" + }, + { + "name": "psr/event-dispatcher", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/event-dispatcher.git", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\EventDispatcher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Standard interfaces for event handling.", + "keywords": [ + "events", + "psr", + "psr-14" + ], + "support": { + "issues": "https://github.com/php-fig/event-dispatcher/issues", + "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" + }, + "time": "2019-01-08T18:20:26+00:00" + }, + { + "name": "psr/http-client", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client" + }, + "time": "2023-09-23T14:17:50+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "e616d01114759c4c489f93b099585439f795fe35" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35", + "reference": "e616d01114759c4c489f93b099585439f795fe35", + "shasum": "" + }, + "require": { + "php": ">=7.0.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory/tree/1.0.2" + }, + "time": "2023-04-10T20:10:41+00:00" + }, + { + "name": "psr/http-message", + "version": "2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/2.0" + }, + "time": "2023-04-04T09:54:51+00:00" + }, + { + "name": "psr/log", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/3.0.0" + }, + "time": "2021-07-14T16:46:02+00:00" + }, + { + "name": "psr/simple-cache", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "support": { + "source": "https://github.com/php-fig/simple-cache/tree/3.0.0" + }, + "time": "2021-10-29T13:26:27+00:00" + }, + { + "name": "psy/psysh", + "version": "v0.12.3", + "source": { + "type": "git", + "url": "https://github.com/bobthecow/psysh.git", + "reference": "b6b6cce7d3ee8fbf31843edce5e8f5a72eff4a73" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/b6b6cce7d3ee8fbf31843edce5e8f5a72eff4a73", + "reference": "b6b6cce7d3ee8fbf31843edce5e8f5a72eff4a73", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-tokenizer": "*", + "nikic/php-parser": "^5.0 || ^4.0", + "php": "^8.0 || ^7.4", + "symfony/console": "^7.0 || ^6.0 || ^5.0 || ^4.0 || ^3.4", + "symfony/var-dumper": "^7.0 || ^6.0 || ^5.0 || ^4.0 || ^3.4" + }, + "conflict": { + "symfony/console": "4.4.37 || 5.3.14 || 5.3.15 || 5.4.3 || 5.4.4 || 6.0.3 || 6.0.4" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.2" + }, + "suggest": { + "ext-pcntl": "Enabling the PCNTL extension makes PsySH a lot happier :)", + "ext-pdo-sqlite": "The doc command requires SQLite to work.", + "ext-posix": "If you have PCNTL, you'll want the POSIX extension as well." + }, + "bin": [ + "bin/psysh" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "0.12.x-dev" + }, + "bamarni-bin": { + "bin-links": false, + "forward-command": false + } + }, + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Psy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Justin Hileman", + "email": "justin@justinhileman.info", + "homepage": "http://justinhileman.com" + } + ], + "description": "An interactive shell for modern PHP.", + "homepage": "http://psysh.org", + "keywords": [ + "REPL", + "console", + "interactive", + "shell" + ], + "support": { + "issues": "https://github.com/bobthecow/psysh/issues", + "source": "https://github.com/bobthecow/psysh/tree/v0.12.3" + }, + "time": "2024-04-02T15:57:53+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "time": "2019-03-08T08:55:37+00:00" + }, + { + "name": "ramsey/collection", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/ramsey/collection.git", + "reference": "a4b48764bfbb8f3a6a4d1aeb1a35bb5e9ecac4a5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ramsey/collection/zipball/a4b48764bfbb8f3a6a4d1aeb1a35bb5e9ecac4a5", + "reference": "a4b48764bfbb8f3a6a4d1aeb1a35bb5e9ecac4a5", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "require-dev": { + "captainhook/plugin-composer": "^5.3", + "ergebnis/composer-normalize": "^2.28.3", + "fakerphp/faker": "^1.21", + "hamcrest/hamcrest-php": "^2.0", + "jangregor/phpstan-prophecy": "^1.0", + "mockery/mockery": "^1.5", + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.3", + "phpcsstandards/phpcsutils": "^1.0.0-rc1", + "phpspec/prophecy-phpunit": "^2.0", + "phpstan/extension-installer": "^1.2", + "phpstan/phpstan": "^1.9", + "phpstan/phpstan-mockery": "^1.1", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5", + "psalm/plugin-mockery": "^1.1", + "psalm/plugin-phpunit": "^0.18.4", + "ramsey/coding-standard": "^2.0.3", + "ramsey/conventional-commits": "^1.3", + "vimeo/psalm": "^5.4" + }, + "type": "library", + "extra": { + "captainhook": { + "force-install": true + }, + "ramsey/conventional-commits": { + "configFile": "conventional-commits.json" + } + }, + "autoload": { + "psr-4": { + "Ramsey\\Collection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ben Ramsey", + "email": "ben@benramsey.com", + "homepage": "https://benramsey.com" + } + ], + "description": "A PHP library for representing and manipulating collections.", + "keywords": [ + "array", + "collection", + "hash", + "map", + "queue", + "set" + ], + "support": { + "issues": "https://github.com/ramsey/collection/issues", + "source": "https://github.com/ramsey/collection/tree/2.0.0" + }, + "funding": [ + { + "url": "https://github.com/ramsey", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/ramsey/collection", + "type": "tidelift" + } + ], + "time": "2022-12-31T21:50:55+00:00" + }, + { + "name": "ramsey/uuid", + "version": "4.7.6", + "source": { + "type": "git", + "url": "https://github.com/ramsey/uuid.git", + "reference": "91039bc1faa45ba123c4328958e620d382ec7088" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/91039bc1faa45ba123c4328958e620d382ec7088", + "reference": "91039bc1faa45ba123c4328958e620d382ec7088", + "shasum": "" + }, + "require": { + "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12", + "ext-json": "*", + "php": "^8.0", + "ramsey/collection": "^1.2 || ^2.0" + }, + "replace": { + "rhumsaa/uuid": "self.version" + }, + "require-dev": { + "captainhook/captainhook": "^5.10", + "captainhook/plugin-composer": "^5.3", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "doctrine/annotations": "^1.8", + "ergebnis/composer-normalize": "^2.15", + "mockery/mockery": "^1.3", + "paragonie/random-lib": "^2", + "php-mock/php-mock": "^2.2", + "php-mock/php-mock-mockery": "^1.3", + "php-parallel-lint/php-parallel-lint": "^1.1", + "phpbench/phpbench": "^1.0", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-mockery": "^1.1", + "phpstan/phpstan-phpunit": "^1.1", + "phpunit/phpunit": "^8.5 || ^9", + "ramsey/composer-repl": "^1.4", + "slevomat/coding-standard": "^8.4", + "squizlabs/php_codesniffer": "^3.5", + "vimeo/psalm": "^4.9" + }, + "suggest": { + "ext-bcmath": "Enables faster math with arbitrary-precision integers using BCMath.", + "ext-gmp": "Enables faster math with arbitrary-precision integers using GMP.", + "ext-uuid": "Enables the use of PeclUuidTimeGenerator and PeclUuidRandomGenerator.", + "paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter", + "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type." + }, + "type": "library", + "extra": { + "captainhook": { + "force-install": true + } + }, + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Ramsey\\Uuid\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A PHP library for generating and working with universally unique identifiers (UUIDs).", + "keywords": [ + "guid", + "identifier", + "uuid" + ], + "support": { + "issues": "https://github.com/ramsey/uuid/issues", + "source": "https://github.com/ramsey/uuid/tree/4.7.6" + }, + "funding": [ + { + "url": "https://github.com/ramsey", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/ramsey/uuid", + "type": "tidelift" + } + ], + "time": "2024-04-27T21:32:50+00:00" + }, + { + "name": "symfony/clock", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/clock.git", + "reference": "2008671acb4a30b01c453de193cf9c80549ebda6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/clock/zipball/2008671acb4a30b01c453de193cf9c80549ebda6", + "reference": "2008671acb4a30b01c453de193cf9c80549ebda6", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "psr/clock": "^1.0", + "symfony/polyfill-php83": "^1.28" + }, + "provide": { + "psr/clock-implementation": "1.0" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/now.php" + ], + "psr-4": { + "Symfony\\Component\\Clock\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Decouples applications from the system clock", + "homepage": "https://symfony.com", + "keywords": [ + "clock", + "psr20", + "time" + ], + "support": { + "source": "https://github.com/symfony/clock/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:29:19+00:00" + }, + { + "name": "symfony/console", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "c981e0e9380ce9f146416bde3150c79197ce9986" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/c981e0e9380ce9f146416bde3150c79197ce9986", + "reference": "c981e0e9380ce9f146416bde3150c79197ce9986", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-mbstring": "~1.0", + "symfony/service-contracts": "^2.5|^3", + "symfony/string": "^6.4|^7.0" + }, + "conflict": { + "symfony/dependency-injection": "<6.4", + "symfony/dotenv": "<6.4", + "symfony/event-dispatcher": "<6.4", + "symfony/lock": "<6.4", + "symfony/process": "<6.4" + }, + "provide": { + "psr/log-implementation": "1.0|2.0|3.0" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^6.4|^7.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/event-dispatcher": "^6.4|^7.0", + "symfony/http-foundation": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/lock": "^6.4|^7.0", + "symfony/messenger": "^6.4|^7.0", + "symfony/process": "^6.4|^7.0", + "symfony/stopwatch": "^6.4|^7.0", + "symfony/var-dumper": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Eases the creation of beautiful and testable command line interfaces", + "homepage": "https://symfony.com", + "keywords": [ + "cli", + "command-line", + "console", + "terminal" + ], + "support": { + "source": "https://github.com/symfony/console/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:29:19+00:00" + }, + { + "name": "symfony/css-selector", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/css-selector.git", + "reference": "b08a4ad89e84b29cec285b7b1f781a7ae51cf4bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/b08a4ad89e84b29cec285b7b1f781a7ae51cf4bc", + "reference": "b08a4ad89e84b29cec285b7b1f781a7ae51cf4bc", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\CssSelector\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Jean-François Simon", + "email": "jeanfrancois.simon@sensiolabs.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Converts CSS selectors to XPath expressions", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/css-selector/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:29:19+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v3.5.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:32:20+00:00" + }, + { + "name": "symfony/error-handler", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/error-handler.git", + "reference": "cf97429887e40480c847bfeb6c3991e1e2c086ab" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/error-handler/zipball/cf97429887e40480c847bfeb6c3991e1e2c086ab", + "reference": "cf97429887e40480c847bfeb6c3991e1e2c086ab", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "psr/log": "^1|^2|^3", + "symfony/var-dumper": "^6.4|^7.0" + }, + "conflict": { + "symfony/deprecation-contracts": "<2.5", + "symfony/http-kernel": "<6.4" + }, + "require-dev": { + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/serializer": "^6.4|^7.0" + }, + "bin": [ + "Resources/bin/patch-type-declarations" + ], + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\ErrorHandler\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools to manage errors and ease debugging PHP code", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/error-handler/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:29:19+00:00" + }, + { + "name": "symfony/event-dispatcher", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "db2a7fab994d67d92356bb39c367db115d9d30f9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/db2a7fab994d67d92356bb39c367db115d9d30f9", + "reference": "db2a7fab994d67d92356bb39c367db115d9d30f9", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/event-dispatcher-contracts": "^2.5|^3" + }, + "conflict": { + "symfony/dependency-injection": "<6.4", + "symfony/service-contracts": "<2.5" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0", + "symfony/event-dispatcher-implementation": "2.0|3.0" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^6.4|^7.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/error-handler": "^6.4|^7.0", + "symfony/expression-language": "^6.4|^7.0", + "symfony/http-foundation": "^6.4|^7.0", + "symfony/service-contracts": "^2.5|^3", + "symfony/stopwatch": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/event-dispatcher/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:29:19+00:00" + }, + { + "name": "symfony/event-dispatcher-contracts", + "version": "v3.5.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "8f93aec25d41b72493c6ddff14e916177c9efc50" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/8f93aec25d41b72493c6ddff14e916177c9efc50", + "reference": "8f93aec25d41b72493c6ddff14e916177c9efc50", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "psr/event-dispatcher": "^1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to dispatching event", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.5.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:32:20+00:00" + }, + { + "name": "symfony/finder", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "4d58f0f4fe95a30d7b538d71197135483560b97c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/4d58f0f4fe95a30d7b538d71197135483560b97c", + "reference": "4d58f0f4fe95a30d7b538d71197135483560b97c", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "symfony/filesystem": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Finds files and directories via an intuitive fluent interface", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/finder/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-28T11:44:19+00:00" + }, + { + "name": "symfony/http-foundation", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-foundation.git", + "reference": "0194e064b8bdc29381462f790bab04e1cac8fdc8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/0194e064b8bdc29381462f790bab04e1cac8fdc8", + "reference": "0194e064b8bdc29381462f790bab04e1cac8fdc8", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-mbstring": "~1.1", + "symfony/polyfill-php83": "^1.27" + }, + "conflict": { + "doctrine/dbal": "<3.6", + "symfony/cache": "<6.4" + }, + "require-dev": { + "doctrine/dbal": "^3.6|^4", + "predis/predis": "^1.1|^2.0", + "symfony/cache": "^6.4|^7.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/expression-language": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/mime": "^6.4|^7.0", + "symfony/rate-limiter": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\HttpFoundation\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Defines an object-oriented layer for the HTTP specification", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/http-foundation/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:29:19+00:00" + }, + { + "name": "symfony/http-kernel", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-kernel.git", + "reference": "e07bb9bd86e7cd8ba2d3d9c618eec9d1bbe06d25" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/e07bb9bd86e7cd8ba2d3d9c618eec9d1bbe06d25", + "reference": "e07bb9bd86e7cd8ba2d3d9c618eec9d1bbe06d25", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "psr/log": "^1|^2|^3", + "symfony/error-handler": "^6.4|^7.0", + "symfony/event-dispatcher": "^6.4|^7.0", + "symfony/http-foundation": "^6.4|^7.0", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "symfony/browser-kit": "<6.4", + "symfony/cache": "<6.4", + "symfony/config": "<6.4", + "symfony/console": "<6.4", + "symfony/dependency-injection": "<6.4", + "symfony/doctrine-bridge": "<6.4", + "symfony/form": "<6.4", + "symfony/http-client": "<6.4", + "symfony/http-client-contracts": "<2.5", + "symfony/mailer": "<6.4", + "symfony/messenger": "<6.4", + "symfony/translation": "<6.4", + "symfony/translation-contracts": "<2.5", + "symfony/twig-bridge": "<6.4", + "symfony/validator": "<6.4", + "symfony/var-dumper": "<6.4", + "twig/twig": "<3.0.4" + }, + "provide": { + "psr/log-implementation": "1.0|2.0|3.0" + }, + "require-dev": { + "psr/cache": "^1.0|^2.0|^3.0", + "symfony/browser-kit": "^6.4|^7.0", + "symfony/clock": "^6.4|^7.0", + "symfony/config": "^6.4|^7.0", + "symfony/console": "^6.4|^7.0", + "symfony/css-selector": "^6.4|^7.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/dom-crawler": "^6.4|^7.0", + "symfony/expression-language": "^6.4|^7.0", + "symfony/finder": "^6.4|^7.0", + "symfony/http-client-contracts": "^2.5|^3", + "symfony/process": "^6.4|^7.0", + "symfony/property-access": "^6.4|^7.0", + "symfony/routing": "^6.4|^7.0", + "symfony/serializer": "^6.4.4|^7.0.4", + "symfony/stopwatch": "^6.4|^7.0", + "symfony/translation": "^6.4|^7.0", + "symfony/translation-contracts": "^2.5|^3", + "symfony/uid": "^6.4|^7.0", + "symfony/validator": "^6.4|^7.0", + "symfony/var-dumper": "^6.4|^7.0", + "symfony/var-exporter": "^6.4|^7.0", + "twig/twig": "^3.0.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\HttpKernel\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides a structured process for converting a Request into a Response", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/http-kernel/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-29T12:20:25+00:00" + }, + { + "name": "symfony/mailer", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/mailer.git", + "reference": "4ff41a7c7998a88cfdc31b5841ef64d9246fc56a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/mailer/zipball/4ff41a7c7998a88cfdc31b5841ef64d9246fc56a", + "reference": "4ff41a7c7998a88cfdc31b5841ef64d9246fc56a", + "shasum": "" + }, + "require": { + "egulias/email-validator": "^2.1.10|^3|^4", + "php": ">=8.2", + "psr/event-dispatcher": "^1", + "psr/log": "^1|^2|^3", + "symfony/event-dispatcher": "^6.4|^7.0", + "symfony/mime": "^6.4|^7.0", + "symfony/service-contracts": "^2.5|^3" + }, + "conflict": { + "symfony/http-client-contracts": "<2.5", + "symfony/http-kernel": "<6.4", + "symfony/messenger": "<6.4", + "symfony/mime": "<6.4", + "symfony/twig-bridge": "<6.4" + }, + "require-dev": { + "symfony/console": "^6.4|^7.0", + "symfony/http-client": "^6.4|^7.0", + "symfony/messenger": "^6.4|^7.0", + "symfony/twig-bridge": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Mailer\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Helps sending emails", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/mailer/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:29:19+00:00" + }, + { + "name": "symfony/mime", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/mime.git", + "reference": "3adbf110c306546f6f00337f421d2edca0e8d3c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/mime/zipball/3adbf110c306546f6f00337f421d2edca0e8d3c0", + "reference": "3adbf110c306546f6f00337f421d2edca0e8d3c0", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-intl-idn": "^1.10", + "symfony/polyfill-mbstring": "^1.0" + }, + "conflict": { + "egulias/email-validator": "~3.0.0", + "phpdocumentor/reflection-docblock": "<3.2.2", + "phpdocumentor/type-resolver": "<1.4.0", + "symfony/mailer": "<6.4", + "symfony/serializer": "<6.4" + }, + "require-dev": { + "egulias/email-validator": "^2.1.10|^3.1|^4", + "league/html-to-markdown": "^5.0", + "phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/process": "^6.4|^7.0", + "symfony/property-access": "^6.4|^7.0", + "symfony/property-info": "^6.4|^7.0", + "symfony/serializer": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Mime\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Allows manipulating MIME messages", + "homepage": "https://symfony.com", + "keywords": [ + "mime", + "mime-type" + ], + "support": { + "source": "https://github.com/symfony/mime/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:29:19+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-ctype": "*" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, + { + "name": "symfony/polyfill-intl-grapheme", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-grapheme.git", + "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/32a9da87d7b3245e09ac426c83d334ae9f06f80f", + "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's grapheme_* functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "grapheme", + "intl", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, + { + "name": "symfony/polyfill-intl-idn", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-idn.git", + "reference": "a287ed7475f85bf6f61890146edbc932c0fff919" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/a287ed7475f85bf6f61890146edbc932c0fff919", + "reference": "a287ed7475f85bf6f61890146edbc932c0fff919", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "symfony/polyfill-intl-normalizer": "^1.10", + "symfony/polyfill-php72": "^1.10" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Idn\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Laurent Bassin", + "email": "laurent@bassin.info" + }, + { + "name": "Trevor Rowbotham", + "email": "trevor.rowbotham@pm.me" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "idn", + "intl", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, + { + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "bc45c394692b948b4d383a08d7753968bed9a83d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/bc45c394692b948b4d383a08d7753968bed9a83d", + "reference": "bc45c394692b948b4d383a08d7753968bed9a83d", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, + { + "name": "symfony/polyfill-php72", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php72.git", + "reference": "861391a8da9a04cbad2d232ddd9e4893220d6e25" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/861391a8da9a04cbad2d232ddd9e4893220d6e25", + "reference": "861391a8da9a04cbad2d232ddd9e4893220d6e25", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php72\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php72/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, + { + "name": "symfony/polyfill-php83", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php83.git", + "reference": "86fcae159633351e5fd145d1c47de6c528f8caff" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php83/zipball/86fcae159633351e5fd145d1c47de6c528f8caff", + "reference": "86fcae159633351e5fd145d1c47de6c528f8caff", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "symfony/polyfill-php80": "^1.14" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php83\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php83/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, + { + "name": "symfony/polyfill-uuid", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-uuid.git", + "reference": "3abdd21b0ceaa3000ee950097bc3cf9efc137853" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-uuid/zipball/3abdd21b0ceaa3000ee950097bc3cf9efc137853", + "reference": "3abdd21b0ceaa3000ee950097bc3cf9efc137853", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-uuid": "*" + }, + "suggest": { + "ext-uuid": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Uuid\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Grégoire Pineau", + "email": "lyrixx@lyrixx.info" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for uuid functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "uuid" + ], + "support": { + "source": "https://github.com/symfony/polyfill-uuid/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, + { + "name": "symfony/process", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "3839e56b94dd1dbd13235d27504e66baf23faba0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/3839e56b94dd1dbd13235d27504e66baf23faba0", + "reference": "3839e56b94dd1dbd13235d27504e66baf23faba0", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Executes commands in sub-processes", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/process/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:29:19+00:00" + }, + { + "name": "symfony/routing", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/routing.git", + "reference": "9f82bf7766ccc9c22ab7aeb9bebb98351483fa5b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/routing/zipball/9f82bf7766ccc9c22ab7aeb9bebb98351483fa5b", + "reference": "9f82bf7766ccc9c22ab7aeb9bebb98351483fa5b", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/deprecation-contracts": "^2.5|^3" + }, + "conflict": { + "symfony/config": "<6.4", + "symfony/dependency-injection": "<6.4", + "symfony/yaml": "<6.4" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^6.4|^7.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/expression-language": "^6.4|^7.0", + "symfony/http-foundation": "^6.4|^7.0", + "symfony/yaml": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Routing\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Maps an HTTP request to a set of configuration variables", + "homepage": "https://symfony.com", + "keywords": [ + "router", + "routing", + "uri", + "url" + ], + "support": { + "source": "https://github.com/symfony/routing/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:29:19+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v3.5.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", + "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "psr/container": "^1.1|^2.0", + "symfony/deprecation-contracts": "^2.5|^3" + }, + "conflict": { + "ext-psr": "<1.1|>=2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + }, + "exclude-from-classmap": [ + "/Test/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v3.5.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:32:20+00:00" + }, + { + "name": "symfony/string", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "e405b5424dc2528e02e31ba26b83a79fd4eb8f63" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/e405b5424dc2528e02e31ba26b83a79fd4eb8f63", + "reference": "e405b5424dc2528e02e31ba26b83a79fd4eb8f63", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-intl-grapheme": "~1.0", + "symfony/polyfill-intl-normalizer": "~1.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/translation-contracts": "<2.5" + }, + "require-dev": { + "symfony/error-handler": "^6.4|^7.0", + "symfony/http-client": "^6.4|^7.0", + "symfony/intl": "^6.4|^7.0", + "symfony/translation-contracts": "^2.5|^3.0", + "symfony/var-exporter": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/functions.php" + ], + "psr-4": { + "Symfony\\Component\\String\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", + "homepage": "https://symfony.com", + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "support": { + "source": "https://github.com/symfony/string/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:29:19+00:00" + }, + { + "name": "symfony/translation", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/translation.git", + "reference": "1515e03afaa93e6419aba5d5c9d209159317100b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/translation/zipball/1515e03afaa93e6419aba5d5c9d209159317100b", + "reference": "1515e03afaa93e6419aba5d5c9d209159317100b", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-mbstring": "~1.0", + "symfony/translation-contracts": "^2.5|^3.0" + }, + "conflict": { + "symfony/config": "<6.4", + "symfony/console": "<6.4", + "symfony/dependency-injection": "<6.4", + "symfony/http-client-contracts": "<2.5", + "symfony/http-kernel": "<6.4", + "symfony/service-contracts": "<2.5", + "symfony/twig-bundle": "<6.4", + "symfony/yaml": "<6.4" + }, + "provide": { + "symfony/translation-implementation": "2.3|3.0" + }, + "require-dev": { + "nikic/php-parser": "^4.18|^5.0", + "psr/log": "^1|^2|^3", + "symfony/config": "^6.4|^7.0", + "symfony/console": "^6.4|^7.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/finder": "^6.4|^7.0", + "symfony/http-client-contracts": "^2.5|^3.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/intl": "^6.4|^7.0", + "symfony/polyfill-intl-icu": "^1.21", + "symfony/routing": "^6.4|^7.0", + "symfony/service-contracts": "^2.5|^3", + "symfony/yaml": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/functions.php" + ], + "psr-4": { + "Symfony\\Component\\Translation\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools to internationalize your application", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/translation/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:29:19+00:00" + }, + { + "name": "symfony/translation-contracts", + "version": "v3.5.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/translation-contracts.git", + "reference": "b9d2189887bb6b2e0367a9fc7136c5239ab9b05a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/b9d2189887bb6b2e0367a9fc7136c5239ab9b05a", + "reference": "b9d2189887bb6b2e0367a9fc7136c5239ab9b05a", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Translation\\": "" + }, + "exclude-from-classmap": [ + "/Test/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to translation", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/translation-contracts/tree/v3.5.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:32:20+00:00" + }, + { + "name": "symfony/uid", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/uid.git", + "reference": "4f3a5d181999e25918586c8369de09e7814e7be2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/uid/zipball/4f3a5d181999e25918586c8369de09e7814e7be2", + "reference": "4f3a5d181999e25918586c8369de09e7814e7be2", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-uuid": "^1.15" + }, + "require-dev": { + "symfony/console": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Uid\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Grégoire Pineau", + "email": "lyrixx@lyrixx.info" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to generate and represent UIDs", + "homepage": "https://symfony.com", + "keywords": [ + "UID", + "ulid", + "uuid" + ], + "support": { + "source": "https://github.com/symfony/uid/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:29:19+00:00" + }, + { + "name": "symfony/var-dumper", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/var-dumper.git", + "reference": "d1627b66fd87c8b4d90cabe5671c29d575690924" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/d1627b66fd87c8b4d90cabe5671c29d575690924", + "reference": "d1627b66fd87c8b4d90cabe5671c29d575690924", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/console": "<6.4" + }, + "require-dev": { + "ext-iconv": "*", + "symfony/console": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/process": "^6.4|^7.0", + "symfony/uid": "^6.4|^7.0", + "twig/twig": "^3.0.4" + }, + "bin": [ + "Resources/bin/var-dump-server" + ], + "type": "library", + "autoload": { + "files": [ + "Resources/functions/dump.php" + ], + "psr-4": { + "Symfony\\Component\\VarDumper\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides mechanisms for walking through any arbitrary PHP variable", + "homepage": "https://symfony.com", + "keywords": [ + "debug", + "dump" + ], + "support": { + "source": "https://github.com/symfony/var-dumper/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:29:19+00:00" + }, + { + "name": "tijsverkoyen/css-to-inline-styles", + "version": "v2.2.7", + "source": { + "type": "git", + "url": "https://github.com/tijsverkoyen/CssToInlineStyles.git", + "reference": "83ee6f38df0a63106a9e4536e3060458b74ccedb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/83ee6f38df0a63106a9e4536e3060458b74ccedb", + "reference": "83ee6f38df0a63106a9e4536e3060458b74ccedb", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "php": "^5.5 || ^7.0 || ^8.0", + "symfony/css-selector": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0 || ^7.5 || ^8.5.21 || ^9.5.10" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "TijsVerkoyen\\CssToInlineStyles\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Tijs Verkoyen", + "email": "css_to_inline_styles@verkoyen.eu", + "role": "Developer" + } + ], + "description": "CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.", + "homepage": "https://github.com/tijsverkoyen/CssToInlineStyles", + "support": { + "issues": "https://github.com/tijsverkoyen/CssToInlineStyles/issues", + "source": "https://github.com/tijsverkoyen/CssToInlineStyles/tree/v2.2.7" + }, + "time": "2023-12-08T13:03:43+00:00" + }, + { + "name": "vlucas/phpdotenv", + "version": "v5.6.0", + "source": { + "type": "git", + "url": "https://github.com/vlucas/phpdotenv.git", + "reference": "2cf9fb6054c2bb1d59d1f3817706ecdb9d2934c4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/2cf9fb6054c2bb1d59d1f3817706ecdb9d2934c4", + "reference": "2cf9fb6054c2bb1d59d1f3817706ecdb9d2934c4", + "shasum": "" + }, + "require": { + "ext-pcre": "*", + "graham-campbell/result-type": "^1.1.2", + "php": "^7.2.5 || ^8.0", + "phpoption/phpoption": "^1.9.2", + "symfony/polyfill-ctype": "^1.24", + "symfony/polyfill-mbstring": "^1.24", + "symfony/polyfill-php80": "^1.24" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "ext-filter": "*", + "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2" + }, + "suggest": { + "ext-filter": "Required to use the boolean validator." + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": true + }, + "branch-alias": { + "dev-master": "5.6-dev" + } + }, + "autoload": { + "psr-4": { + "Dotenv\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Vance Lucas", + "email": "vance@vancelucas.com", + "homepage": "https://github.com/vlucas" + } + ], + "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", + "keywords": [ + "dotenv", + "env", + "environment" + ], + "support": { + "issues": "https://github.com/vlucas/phpdotenv/issues", + "source": "https://github.com/vlucas/phpdotenv/tree/v5.6.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", + "type": "tidelift" + } + ], + "time": "2023-11-12T22:43:29+00:00" + }, + { + "name": "voku/portable-ascii", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/voku/portable-ascii.git", + "reference": "b56450eed252f6801410d810c8e1727224ae0743" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/voku/portable-ascii/zipball/b56450eed252f6801410d810c8e1727224ae0743", + "reference": "b56450eed252f6801410d810c8e1727224ae0743", + "shasum": "" + }, + "require": { + "php": ">=7.0.0" + }, + "require-dev": { + "phpunit/phpunit": "~6.0 || ~7.0 || ~9.0" + }, + "suggest": { + "ext-intl": "Use Intl for transliterator_transliterate() support" + }, + "type": "library", + "autoload": { + "psr-4": { + "voku\\": "src/voku/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Lars Moelleken", + "homepage": "http://www.moelleken.org/" + } + ], + "description": "Portable ASCII library - performance optimized (ascii) string functions for php.", + "homepage": "https://github.com/voku/portable-ascii", + "keywords": [ + "ascii", + "clean", + "php" + ], + "support": { + "issues": "https://github.com/voku/portable-ascii/issues", + "source": "https://github.com/voku/portable-ascii/tree/2.0.1" + }, + "funding": [ + { + "url": "https://www.paypal.me/moelleken", + "type": "custom" + }, + { + "url": "https://github.com/voku", + "type": "github" + }, + { + "url": "https://opencollective.com/portable-ascii", + "type": "open_collective" + }, + { + "url": "https://www.patreon.com/voku", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/voku/portable-ascii", + "type": "tidelift" + } + ], + "time": "2022-03-08T17:03:00+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.11.0", + "source": { + "type": "git", + "url": "https://github.com/webmozarts/assert.git", + "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991", + "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "php": "^7.2 || ^8.0" + }, + "conflict": { + "phpstan/phpstan": "<0.12.20", + "vimeo/psalm": "<4.6.1 || 4.6.2" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.13" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.10-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "support": { + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/1.11.0" + }, + "time": "2022-06-03T18:03:27+00:00" + } + ], + "packages-dev": [ + { + "name": "fakerphp/faker", + "version": "v1.23.1", + "source": { + "type": "git", + "url": "https://github.com/FakerPHP/Faker.git", + "reference": "bfb4fe148adbf78eff521199619b93a52ae3554b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/bfb4fe148adbf78eff521199619b93a52ae3554b", + "reference": "bfb4fe148adbf78eff521199619b93a52ae3554b", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "psr/container": "^1.0 || ^2.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "conflict": { + "fzaninotto/faker": "*" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "doctrine/persistence": "^1.3 || ^2.0", + "ext-intl": "*", + "phpunit/phpunit": "^9.5.26", + "symfony/phpunit-bridge": "^5.4.16" + }, + "suggest": { + "doctrine/orm": "Required to use Faker\\ORM\\Doctrine", + "ext-curl": "Required by Faker\\Provider\\Image to download images.", + "ext-dom": "Required by Faker\\Provider\\HtmlLorem for generating random HTML.", + "ext-iconv": "Required by Faker\\Provider\\ru_RU\\Text::realText() for generating real Russian text.", + "ext-mbstring": "Required for multibyte Unicode string functionality." + }, + "type": "library", + "autoload": { + "psr-4": { + "Faker\\": "src/Faker/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "François Zaninotto" + } + ], + "description": "Faker is a PHP library that generates fake data for you.", + "keywords": [ + "data", + "faker", + "fixtures" + ], + "support": { + "issues": "https://github.com/FakerPHP/Faker/issues", + "source": "https://github.com/FakerPHP/Faker/tree/v1.23.1" + }, + "time": "2024-01-02T13:46:09+00:00" + }, + { + "name": "filp/whoops", + "version": "2.15.4", + "source": { + "type": "git", + "url": "https://github.com/filp/whoops.git", + "reference": "a139776fa3f5985a50b509f2a02ff0f709d2a546" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/filp/whoops/zipball/a139776fa3f5985a50b509f2a02ff0f709d2a546", + "reference": "a139776fa3f5985a50b509f2a02ff0f709d2a546", + "shasum": "" + }, + "require": { + "php": "^5.5.9 || ^7.0 || ^8.0", + "psr/log": "^1.0.1 || ^2.0 || ^3.0" + }, + "require-dev": { + "mockery/mockery": "^0.9 || ^1.0", + "phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.3", + "symfony/var-dumper": "^2.6 || ^3.0 || ^4.0 || ^5.0" + }, + "suggest": { + "symfony/var-dumper": "Pretty print complex values better with var-dumper available", + "whoops/soap": "Formats errors as SOAP responses" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Whoops\\": "src/Whoops/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Filipe Dobreira", + "homepage": "https://github.com/filp", + "role": "Developer" + } + ], + "description": "php error handling for cool kids", + "homepage": "https://filp.github.io/whoops/", + "keywords": [ + "error", + "exception", + "handling", + "library", + "throwable", + "whoops" + ], + "support": { + "issues": "https://github.com/filp/whoops/issues", + "source": "https://github.com/filp/whoops/tree/2.15.4" + }, + "funding": [ + { + "url": "https://github.com/denis-sokolov", + "type": "github" + } + ], + "time": "2023-11-03T12:00:00+00:00" + }, + { + "name": "hamcrest/hamcrest-php", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/hamcrest/hamcrest-php.git", + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "shasum": "" + }, + "require": { + "php": "^5.3|^7.0|^8.0" + }, + "replace": { + "cordoval/hamcrest-php": "*", + "davedevelopment/hamcrest-php": "*", + "kodova/hamcrest-php": "*" + }, + "require-dev": { + "phpunit/php-file-iterator": "^1.4 || ^2.0", + "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "classmap": [ + "hamcrest" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": [ + "test" + ], + "support": { + "issues": "https://github.com/hamcrest/hamcrest-php/issues", + "source": "https://github.com/hamcrest/hamcrest-php/tree/v2.0.1" + }, + "time": "2020-07-09T08:09:16+00:00" + }, + { + "name": "laravel/pint", + "version": "v1.15.3", + "source": { + "type": "git", + "url": "https://github.com/laravel/pint.git", + "reference": "3600b5d17aff52f6100ea4921849deacbbeb8656" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/pint/zipball/3600b5d17aff52f6100ea4921849deacbbeb8656", + "reference": "3600b5d17aff52f6100ea4921849deacbbeb8656", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-mbstring": "*", + "ext-tokenizer": "*", + "ext-xml": "*", + "php": "^8.1.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.54.0", + "illuminate/view": "^10.48.8", + "larastan/larastan": "^2.9.5", + "laravel-zero/framework": "^10.3.0", + "mockery/mockery": "^1.6.11", + "nunomaduro/termwind": "^1.15.1", + "pestphp/pest": "^2.34.7" + }, + "bin": [ + "builds/pint" + ], + "type": "project", + "autoload": { + "psr-4": { + "App\\": "app/", + "Database\\Seeders\\": "database/seeders/", + "Database\\Factories\\": "database/factories/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "An opinionated code formatter for PHP.", + "homepage": "https://laravel.com", + "keywords": [ + "format", + "formatter", + "lint", + "linter", + "php" + ], + "support": { + "issues": "https://github.com/laravel/pint/issues", + "source": "https://github.com/laravel/pint" + }, + "time": "2024-04-30T15:02:26+00:00" + }, + { + "name": "laravel/sail", + "version": "v1.29.1", + "source": { + "type": "git", + "url": "https://github.com/laravel/sail.git", + "reference": "8be4a31150eab3b46af11a2e7b2c4632eefaad7e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/sail/zipball/8be4a31150eab3b46af11a2e7b2c4632eefaad7e", + "reference": "8be4a31150eab3b46af11a2e7b2c4632eefaad7e", + "shasum": "" + }, + "require": { + "illuminate/console": "^9.52.16|^10.0|^11.0", + "illuminate/contracts": "^9.52.16|^10.0|^11.0", + "illuminate/support": "^9.52.16|^10.0|^11.0", + "php": "^8.0", + "symfony/console": "^6.0|^7.0", + "symfony/yaml": "^6.0|^7.0" + }, + "require-dev": { + "orchestra/testbench": "^7.0|^8.0|^9.0", + "phpstan/phpstan": "^1.10" + }, + "bin": [ + "bin/sail" + ], + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Laravel\\Sail\\SailServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Laravel\\Sail\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "Docker files for running a basic Laravel application.", + "keywords": [ + "docker", + "laravel" + ], + "support": { + "issues": "https://github.com/laravel/sail/issues", + "source": "https://github.com/laravel/sail" + }, + "time": "2024-03-20T20:09:31+00:00" + }, + { + "name": "mockery/mockery", + "version": "1.6.11", + "source": { + "type": "git", + "url": "https://github.com/mockery/mockery.git", + "reference": "81a161d0b135df89951abd52296adf97deb0723d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mockery/mockery/zipball/81a161d0b135df89951abd52296adf97deb0723d", + "reference": "81a161d0b135df89951abd52296adf97deb0723d", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "^2.0.1", + "lib-pcre": ">=7.0", + "php": ">=7.3" + }, + "conflict": { + "phpunit/phpunit": "<8.0" + }, + "require-dev": { + "phpunit/phpunit": "^8.5 || ^9.6.17", + "symplify/easy-coding-standard": "^12.1.14" + }, + "type": "library", + "autoload": { + "files": [ + "library/helpers.php", + "library/Mockery.php" + ], + "psr-4": { + "Mockery\\": "library/Mockery" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com", + "homepage": "https://github.com/padraic", + "role": "Author" + }, + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "https://davedevelopment.co.uk", + "role": "Developer" + }, + { + "name": "Nathanael Esayeas", + "email": "nathanael.esayeas@protonmail.com", + "homepage": "https://github.com/ghostwriter", + "role": "Lead Developer" + } + ], + "description": "Mockery is a simple yet flexible PHP mock object framework", + "homepage": "https://github.com/mockery/mockery", + "keywords": [ + "BDD", + "TDD", + "library", + "mock", + "mock objects", + "mockery", + "stub", + "test", + "test double", + "testing" + ], + "support": { + "docs": "https://docs.mockery.io/", + "issues": "https://github.com/mockery/mockery/issues", + "rss": "https://github.com/mockery/mockery/releases.atom", + "security": "https://github.com/mockery/mockery/security/advisories", + "source": "https://github.com/mockery/mockery" + }, + "time": "2024-03-21T18:34:15+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.11.1", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3,<3.2.2" + }, + "require-dev": { + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" + }, + "type": "library", + "autoload": { + "files": [ + "src/DeepCopy/deep_copy.php" + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2023-03-08T13:26:56+00:00" + }, + { + "name": "nunomaduro/collision", + "version": "v8.1.1", + "source": { + "type": "git", + "url": "https://github.com/nunomaduro/collision.git", + "reference": "13e5d538b95a744d85f447a321ce10adb28e9af9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/13e5d538b95a744d85f447a321ce10adb28e9af9", + "reference": "13e5d538b95a744d85f447a321ce10adb28e9af9", + "shasum": "" + }, + "require": { + "filp/whoops": "^2.15.4", + "nunomaduro/termwind": "^2.0.1", + "php": "^8.2.0", + "symfony/console": "^7.0.4" + }, + "conflict": { + "laravel/framework": "<11.0.0 || >=12.0.0", + "phpunit/phpunit": "<10.5.1 || >=12.0.0" + }, + "require-dev": { + "larastan/larastan": "^2.9.2", + "laravel/framework": "^11.0.0", + "laravel/pint": "^1.14.0", + "laravel/sail": "^1.28.2", + "laravel/sanctum": "^4.0.0", + "laravel/tinker": "^2.9.0", + "orchestra/testbench-core": "^9.0.0", + "pestphp/pest": "^2.34.1 || ^3.0.0", + "sebastian/environment": "^6.0.1 || ^7.0.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider" + ] + }, + "branch-alias": { + "dev-8.x": "8.x-dev" + } + }, + "autoload": { + "files": [ + "./src/Adapters/Phpunit/Autoload.php" + ], + "psr-4": { + "NunoMaduro\\Collision\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "Cli error handling for console/command-line PHP applications.", + "keywords": [ + "artisan", + "cli", + "command-line", + "console", + "error", + "handling", + "laravel", + "laravel-zero", + "php", + "symfony" + ], + "support": { + "issues": "https://github.com/nunomaduro/collision/issues", + "source": "https://github.com/nunomaduro/collision" + }, + "funding": [ + { + "url": "https://www.paypal.com/paypalme/enunomaduro", + "type": "custom" + }, + { + "url": "https://github.com/nunomaduro", + "type": "github" + }, + { + "url": "https://www.patreon.com/nunomaduro", + "type": "patreon" + } + ], + "time": "2024-03-06T16:20:09+00:00" + }, + { + "name": "phar-io/manifest", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "54750ef60c58e43759730615a392c31c80e23176" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:33:53+00:00" + }, + { + "name": "phar-io/version", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.2.1" + }, + "time": "2022-02-21T01:04:05+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "11.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "7e35a2cbcabac0e6865fd373742ea432a3c34f92" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7e35a2cbcabac0e6865fd373742ea432a3c34f92", + "reference": "7e35a2cbcabac0e6865fd373742ea432a3c34f92", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^5.0", + "php": ">=8.2", + "phpunit/php-file-iterator": "^5.0", + "phpunit/php-text-template": "^4.0", + "sebastian/code-unit-reverse-lookup": "^4.0", + "sebastian/complexity": "^4.0", + "sebastian/environment": "^7.0", + "sebastian/lines-of-code": "^3.0", + "sebastian/version": "^5.0", + "theseer/tokenizer": "^1.2.0" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "suggest": { + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "11.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-12T15:35:40+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "5.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "99e95c94ad9500daca992354fa09d7b99abe2210" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/99e95c94ad9500daca992354fa09d7b99abe2210", + "reference": "99e95c94ad9500daca992354fa09d7b99abe2210", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/5.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-02-02T06:05:04+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "5.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "5d8d9355a16d8cc5a1305b0a85342cfa420612be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5d8d9355a16d8cc5a1305b0a85342cfa420612be", + "reference": "5d8d9355a16d8cc5a1305b0a85342cfa420612be", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^11.0" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "security": "https://github.com/sebastianbergmann/php-invoker/security/policy", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/5.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-02-02T06:05:50+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "d38f6cbff1cdb6f40b03c9811421561668cc133e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/d38f6cbff1cdb6f40b03c9811421561668cc133e", + "reference": "d38f6cbff1cdb6f40b03c9811421561668cc133e", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "security": "https://github.com/sebastianbergmann/php-text-template/security/policy", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/4.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-02-02T06:06:56+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "7.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "8a59d9e25720482ee7fcdf296595e08795b84dc5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/8a59d9e25720482ee7fcdf296595e08795b84dc5", + "reference": "8a59d9e25720482ee7fcdf296595e08795b84dc5", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "7.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "security": "https://github.com/sebastianbergmann/php-timer/security/policy", + "source": "https://github.com/sebastianbergmann/php-timer/tree/7.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-02-02T06:08:01+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "11.1.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "d475be032238173ca3b0a516f5cc291d174708ae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d475be032238173ca3b0a516f5cc291d174708ae", + "reference": "d475be032238173ca3b0a516f5cc291d174708ae", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.10.1", + "phar-io/manifest": "^2.0.3", + "phar-io/version": "^3.0.2", + "php": ">=8.2", + "phpunit/php-code-coverage": "^11.0", + "phpunit/php-file-iterator": "^5.0", + "phpunit/php-invoker": "^5.0", + "phpunit/php-text-template": "^4.0", + "phpunit/php-timer": "^7.0", + "sebastian/cli-parser": "^3.0", + "sebastian/code-unit": "^3.0", + "sebastian/comparator": "^6.0", + "sebastian/diff": "^6.0", + "sebastian/environment": "^7.0", + "sebastian/exporter": "^6.0", + "sebastian/global-state": "^7.0", + "sebastian/object-enumerator": "^6.0", + "sebastian/type": "^5.0", + "sebastian/version": "^5.0" + }, + "suggest": { + "ext-soap": "To be able to generate mocks based on WSDL files" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "11.1-dev" + } + }, + "autoload": { + "files": [ + "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/11.1.3" + }, + "funding": [ + { + "url": "https://phpunit.de/sponsors.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" + } + ], + "time": "2024-04-24T06:34:25+00:00" + }, + { + "name": "sebastian/cli-parser", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "00a74d5568694711f0222e54fb281e1d15fdf04a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/00a74d5568694711f0222e54fb281e1d15fdf04a", + "reference": "00a74d5568694711f0222e54fb281e1d15fdf04a", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "security": "https://github.com/sebastianbergmann/cli-parser/security/policy", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/3.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T07:26:58+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "6634549cb8d702282a04a774e36a7477d2bd9015" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/6634549cb8d702282a04a774e36a7477d2bd9015", + "reference": "6634549cb8d702282a04a774e36a7477d2bd9015", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "security": "https://github.com/sebastianbergmann/code-unit/security/policy", + "source": "https://github.com/sebastianbergmann/code-unit/tree/3.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-02-02T05:50:41+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "df80c875d3e459b45c6039e4d9b71d4fbccae25d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/df80c875d3e459b45c6039e4d9b71d4fbccae25d", + "reference": "df80c875d3e459b45c6039e4d9b71d4fbccae25d", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "security": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/security/policy", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/4.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-02-02T05:52:17+00:00" + }, + { + "name": "sebastian/comparator", + "version": "6.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "bd0f2fa5b9257c69903537b266ccb80fcf940db8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/bd0f2fa5b9257c69903537b266ccb80fcf940db8", + "reference": "bd0f2fa5b9257c69903537b266ccb80fcf940db8", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-mbstring": "*", + "php": ">=8.2", + "sebastian/diff": "^6.0", + "sebastian/exporter": "^6.0" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "security": "https://github.com/sebastianbergmann/comparator/security/policy", + "source": "https://github.com/sebastianbergmann/comparator/tree/6.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-02-02T05:53:45+00:00" + }, + { + "name": "sebastian/complexity", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "88a434ad86150e11a606ac4866b09130712671f0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/88a434ad86150e11a606ac4866b09130712671f0", + "reference": "88a434ad86150e11a606ac4866b09130712671f0", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^5.0", + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "security": "https://github.com/sebastianbergmann/complexity/security/policy", + "source": "https://github.com/sebastianbergmann/complexity/tree/4.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-02-02T05:55:19+00:00" + }, + { + "name": "sebastian/diff", + "version": "6.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "ab83243ecc233de5655b76f577711de9f842e712" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ab83243ecc233de5655b76f577711de9f842e712", + "reference": "ab83243ecc233de5655b76f577711de9f842e712", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "security": "https://github.com/sebastianbergmann/diff/security/policy", + "source": "https://github.com/sebastianbergmann/diff/tree/6.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T07:30:33+00:00" + }, + { + "name": "sebastian/environment", + "version": "7.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "4eb3a442574d0e9d141aab209cd4aaf25701b09a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/4eb3a442574d0e9d141aab209cd4aaf25701b09a", + "reference": "4eb3a442574d0e9d141aab209cd4aaf25701b09a", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "7.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "https://github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "security": "https://github.com/sebastianbergmann/environment/security/policy", + "source": "https://github.com/sebastianbergmann/environment/tree/7.1.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-23T08:56:34+00:00" + }, + { + "name": "sebastian/exporter", + "version": "6.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "f291e5a317c321c0381fa9ecc796fa2d21b186da" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/f291e5a317c321c0381fa9ecc796fa2d21b186da", + "reference": "f291e5a317c321c0381fa9ecc796fa2d21b186da", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": ">=8.2", + "sebastian/recursion-context": "^6.0" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "https://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "security": "https://github.com/sebastianbergmann/exporter/security/policy", + "source": "https://github.com/sebastianbergmann/exporter/tree/6.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T07:28:20+00:00" + }, + { + "name": "sebastian/global-state", + "version": "7.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "c3a307e832f2e69c7ef869e31fc644fde0e7cb3e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c3a307e832f2e69c7ef869e31fc644fde0e7cb3e", + "reference": "c3a307e832f2e69c7ef869e31fc644fde0e7cb3e", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "sebastian/object-reflector": "^4.0", + "sebastian/recursion-context": "^6.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "7.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "https://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "security": "https://github.com/sebastianbergmann/global-state/security/policy", + "source": "https://github.com/sebastianbergmann/global-state/tree/7.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T07:32:10+00:00" + }, + { + "name": "sebastian/lines-of-code", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "376c5b3f6b43c78fdc049740bca76a7c846706c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/376c5b3f6b43c78fdc049740bca76a7c846706c0", + "reference": "376c5b3f6b43c78fdc049740bca76a7c846706c0", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^5.0", + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/3.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-02-02T06:00:36+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "6.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "f75f6c460da0bbd9668f43a3dde0ec0ba7faa678" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/f75f6c460da0bbd9668f43a3dde0ec0ba7faa678", + "reference": "f75f6c460da0bbd9668f43a3dde0ec0ba7faa678", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "sebastian/object-reflector": "^4.0", + "sebastian/recursion-context": "^6.0" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "security": "https://github.com/sebastianbergmann/object-enumerator/security/policy", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/6.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-02-02T06:01:29+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "bb2a6255d30853425fd38f032eb64ced9f7f132d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/bb2a6255d30853425fd38f032eb64ced9f7f132d", + "reference": "bb2a6255d30853425fd38f032eb64ced9f7f132d", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "security": "https://github.com/sebastianbergmann/object-reflector/security/policy", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/4.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-02-02T06:02:18+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "6.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "b75224967b5a466925c6d54e68edd0edf8dd4ed4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/b75224967b5a466925c6d54e68edd0edf8dd4ed4", + "reference": "b75224967b5a466925c6d54e68edd0edf8dd4ed4", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "https://github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "security": "https://github.com/sebastianbergmann/recursion-context/security/policy", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/6.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-02-02T06:08:48+00:00" + }, + { + "name": "sebastian/type", + "version": "5.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "b8502785eb3523ca0dd4afe9ca62235590020f3f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b8502785eb3523ca0dd4afe9ca62235590020f3f", + "reference": "b8502785eb3523ca0dd4afe9ca62235590020f3f", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "security": "https://github.com/sebastianbergmann/type/security/policy", + "source": "https://github.com/sebastianbergmann/type/tree/5.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-02-02T06:09:34+00:00" + }, + { + "name": "sebastian/version", + "version": "5.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "13999475d2cb1ab33cb73403ba356a814fdbb001" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/13999475d2cb1ab33cb73403ba356a814fdbb001", + "reference": "13999475d2cb1ab33cb73403ba356a814fdbb001", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "security": "https://github.com/sebastianbergmann/version/security/policy", + "source": "https://github.com/sebastianbergmann/version/tree/5.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-02-02T06:10:47+00:00" + }, + { + "name": "spatie/backtrace", + "version": "1.6.1", + "source": { + "type": "git", + "url": "https://github.com/spatie/backtrace.git", + "reference": "8373b9d51638292e3bfd736a9c19a654111b4a23" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/backtrace/zipball/8373b9d51638292e3bfd736a9c19a654111b4a23", + "reference": "8373b9d51638292e3bfd736a9c19a654111b4a23", + "shasum": "" + }, + "require": { + "php": "^7.3|^8.0" + }, + "require-dev": { + "ext-json": "*", + "laravel/serializable-closure": "^1.3", + "phpunit/phpunit": "^9.3", + "spatie/phpunit-snapshot-assertions": "^4.2", + "symfony/var-dumper": "^5.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\Backtrace\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van de Herten", + "email": "freek@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "A better backtrace", + "homepage": "https://github.com/spatie/backtrace", + "keywords": [ + "Backtrace", + "spatie" + ], + "support": { + "source": "https://github.com/spatie/backtrace/tree/1.6.1" + }, + "funding": [ + { + "url": "https://github.com/sponsors/spatie", + "type": "github" + }, + { + "url": "https://spatie.be/open-source/support-us", + "type": "other" + } + ], + "time": "2024-04-24T13:22:11+00:00" + }, + { + "name": "spatie/flare-client-php", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/spatie/flare-client-php.git", + "reference": "e27977d534eefe04c154c6fd8460217024054c05" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/flare-client-php/zipball/e27977d534eefe04c154c6fd8460217024054c05", + "reference": "e27977d534eefe04c154c6fd8460217024054c05", + "shasum": "" + }, + "require": { + "illuminate/pipeline": "^8.0|^9.0|^10.0|^11.0", + "php": "^8.0", + "spatie/backtrace": "^1.5.2", + "symfony/http-foundation": "^5.2|^6.0|^7.0", + "symfony/mime": "^5.2|^6.0|^7.0", + "symfony/process": "^5.2|^6.0|^7.0", + "symfony/var-dumper": "^5.2|^6.0|^7.0" + }, + "require-dev": { + "dms/phpunit-arraysubset-asserts": "^0.5.0", + "pestphp/pest": "^1.20|^2.0", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-phpunit": "^1.0", + "spatie/phpunit-snapshot-assertions": "^4.0|^5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.3.x-dev" + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Spatie\\FlareClient\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Send PHP errors to Flare", + "homepage": "https://github.com/spatie/flare-client-php", + "keywords": [ + "exception", + "flare", + "reporting", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/flare-client-php/issues", + "source": "https://github.com/spatie/flare-client-php/tree/1.5.1" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2024-05-03T15:43:14+00:00" + }, + { + "name": "spatie/ignition", + "version": "1.14.1", + "source": { + "type": "git", + "url": "https://github.com/spatie/ignition.git", + "reference": "c23cc018c5f423d2f413b99f84655fceb6549811" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/ignition/zipball/c23cc018c5f423d2f413b99f84655fceb6549811", + "reference": "c23cc018c5f423d2f413b99f84655fceb6549811", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-mbstring": "*", + "php": "^8.0", + "spatie/backtrace": "^1.5.3", + "spatie/flare-client-php": "^1.4.0", + "symfony/console": "^5.4|^6.0|^7.0", + "symfony/var-dumper": "^5.4|^6.0|^7.0" + }, + "require-dev": { + "illuminate/cache": "^9.52|^10.0|^11.0", + "mockery/mockery": "^1.4", + "pestphp/pest": "^1.20|^2.0", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-phpunit": "^1.0", + "psr/simple-cache-implementation": "*", + "symfony/cache": "^5.4|^6.0|^7.0", + "symfony/process": "^5.4|^6.0|^7.0", + "vlucas/phpdotenv": "^5.5" + }, + "suggest": { + "openai-php/client": "Require get solutions from OpenAI", + "simple-cache-implementation": "To cache solutions from OpenAI" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.5.x-dev" + } + }, + "autoload": { + "psr-4": { + "Spatie\\Ignition\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Spatie", + "email": "info@spatie.be", + "role": "Developer" + } + ], + "description": "A beautiful error page for PHP applications.", + "homepage": "https://flareapp.io/ignition", + "keywords": [ + "error", + "flare", + "laravel", + "page" + ], + "support": { + "docs": "https://flareapp.io/docs/ignition-for-laravel/introduction", + "forum": "https://twitter.com/flareappio", + "issues": "https://github.com/spatie/ignition/issues", + "source": "https://github.com/spatie/ignition" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2024-05-03T15:56:16+00:00" + }, + { + "name": "spatie/laravel-ignition", + "version": "2.7.0", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-ignition.git", + "reference": "f52124d50122611e8a40f628cef5c19ff6cc5b57" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/f52124d50122611e8a40f628cef5c19ff6cc5b57", + "reference": "f52124d50122611e8a40f628cef5c19ff6cc5b57", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "illuminate/support": "^10.0|^11.0", + "php": "^8.1", + "spatie/flare-client-php": "^1.5", + "spatie/ignition": "^1.14", + "symfony/console": "^6.2.3|^7.0", + "symfony/var-dumper": "^6.2.3|^7.0" + }, + "require-dev": { + "livewire/livewire": "^2.11|^3.3.5", + "mockery/mockery": "^1.5.1", + "openai-php/client": "^0.8.1", + "orchestra/testbench": "8.22.3|^9.0", + "pestphp/pest": "^2.34", + "phpstan/extension-installer": "^1.3.1", + "phpstan/phpstan-deprecation-rules": "^1.1.1", + "phpstan/phpstan-phpunit": "^1.3.16", + "vlucas/phpdotenv": "^5.5" + }, + "suggest": { + "openai-php/client": "Require get solutions from OpenAI", + "psr/simple-cache-implementation": "Needed to cache solutions from OpenAI" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Spatie\\LaravelIgnition\\IgnitionServiceProvider" + ], + "aliases": { + "Flare": "Spatie\\LaravelIgnition\\Facades\\Flare" + } + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Spatie\\LaravelIgnition\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Spatie", + "email": "info@spatie.be", + "role": "Developer" + } + ], + "description": "A beautiful error page for Laravel applications.", + "homepage": "https://flareapp.io/ignition", + "keywords": [ + "error", + "flare", + "laravel", + "page" + ], + "support": { + "docs": "https://flareapp.io/docs/ignition-for-laravel/introduction", + "forum": "https://twitter.com/flareappio", + "issues": "https://github.com/spatie/laravel-ignition/issues", + "source": "https://github.com/spatie/laravel-ignition" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2024-05-02T13:42:49+00:00" + }, + { + "name": "symfony/yaml", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "0d3916ae69ea28b59d94b60c4f2b50f4e25adb5c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/0d3916ae69ea28b59d94b60c4f2b50f4e25adb5c", + "reference": "0d3916ae69ea28b59d94b60c4f2b50f4e25adb5c", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "symfony/console": "<6.4" + }, + "require-dev": { + "symfony/console": "^6.4|^7.0" + }, + "bin": [ + "Resources/bin/yaml-lint" + ], + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Loads and dumps YAML files", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/yaml/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-28T11:44:19+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.2.3", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.2.3" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:36:25+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": true, + "prefer-lowest": false, + "platform": { + "php": "^8.2" + }, + "platform-dev": [], + "plugin-api-version": "2.2.0" +} diff --git a/config/app.php b/config/app.php new file mode 100644 index 0000000..f467267 --- /dev/null +++ b/config/app.php @@ -0,0 +1,126 @@ + env('APP_NAME', 'Laravel'), + + /* + |-------------------------------------------------------------------------- + | Application Environment + |-------------------------------------------------------------------------- + | + | This value determines the "environment" your application is currently + | running in. This may determine how you prefer to configure various + | services the application utilizes. Set this in your ".env" file. + | + */ + + 'env' => env('APP_ENV', 'production'), + + /* + |-------------------------------------------------------------------------- + | Application Debug Mode + |-------------------------------------------------------------------------- + | + | When your application is in debug mode, detailed error messages with + | stack traces will be shown on every error that occurs within your + | application. If disabled, a simple generic error page is shown. + | + */ + + 'debug' => (bool) env('APP_DEBUG', false), + + /* + |-------------------------------------------------------------------------- + | Application URL + |-------------------------------------------------------------------------- + | + | This URL is used by the console to properly generate URLs when using + | the Artisan command line tool. You should set this to the root of + | the application so that it's available within Artisan commands. + | + */ + + 'url' => env('APP_URL', 'http://localhost'), + + /* + |-------------------------------------------------------------------------- + | Application Timezone + |-------------------------------------------------------------------------- + | + | Here you may specify the default timezone for your application, which + | will be used by the PHP date and date-time functions. The timezone + | is set to "UTC" by default as it is suitable for most use cases. + | + */ + + 'timezone' => env('APP_TIMEZONE', 'UTC'), + + /* + |-------------------------------------------------------------------------- + | Application Locale Configuration + |-------------------------------------------------------------------------- + | + | The application locale determines the default locale that will be used + | by Laravel's translation / localization methods. This option can be + | set to any locale for which you plan to have translation strings. + | + */ + + 'locale' => env('APP_LOCALE', 'en'), + + 'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'), + + 'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'), + + /* + |-------------------------------------------------------------------------- + | Encryption Key + |-------------------------------------------------------------------------- + | + | This key is utilized by Laravel's encryption services and should be set + | to a random, 32 character string to ensure that all encrypted values + | are secure. You should do this prior to deploying the application. + | + */ + + 'cipher' => 'AES-256-CBC', + + 'key' => env('APP_KEY'), + + 'previous_keys' => [ + ...array_filter( + explode(',', env('APP_PREVIOUS_KEYS', '')) + ), + ], + + /* + |-------------------------------------------------------------------------- + | Maintenance Mode Driver + |-------------------------------------------------------------------------- + | + | These configuration options determine the driver used to determine and + | manage Laravel's "maintenance mode" status. The "cache" driver will + | allow maintenance mode to be controlled across multiple machines. + | + | Supported drivers: "file", "cache" + | + */ + + 'maintenance' => [ + 'driver' => env('APP_MAINTENANCE_DRIVER', 'file'), + 'store' => env('APP_MAINTENANCE_STORE', 'database'), + ], + +]; diff --git a/config/auth.php b/config/auth.php new file mode 100644 index 0000000..0ba5d5d --- /dev/null +++ b/config/auth.php @@ -0,0 +1,115 @@ + [ + 'guard' => env('AUTH_GUARD', 'web'), + 'passwords' => env('AUTH_PASSWORD_BROKER', 'users'), + ], + + /* + |-------------------------------------------------------------------------- + | Authentication Guards + |-------------------------------------------------------------------------- + | + | Next, you may define every authentication guard for your application. + | Of course, a great default configuration has been defined for you + | which utilizes session storage plus the Eloquent user provider. + | + | All authentication guards have a user provider, which defines how the + | users are actually retrieved out of your database or other storage + | system used by the application. Typically, Eloquent is utilized. + | + | Supported: "session" + | + */ + + 'guards' => [ + 'web' => [ + 'driver' => 'session', + 'provider' => 'users', + ], + ], + + /* + |-------------------------------------------------------------------------- + | User Providers + |-------------------------------------------------------------------------- + | + | All authentication guards have a user provider, which defines how the + | users are actually retrieved out of your database or other storage + | system used by the application. Typically, Eloquent is utilized. + | + | If you have multiple user tables or models you may configure multiple + | providers to represent the model / table. These providers may then + | be assigned to any extra authentication guards you have defined. + | + | Supported: "database", "eloquent" + | + */ + + 'providers' => [ + 'users' => [ + 'driver' => 'eloquent', + 'model' => env('AUTH_MODEL', App\Models\User::class), + ], + + // 'users' => [ + // 'driver' => 'database', + // 'table' => 'users', + // ], + ], + + /* + |-------------------------------------------------------------------------- + | Resetting Passwords + |-------------------------------------------------------------------------- + | + | These configuration options specify the behavior of Laravel's password + | reset functionality, including the table utilized for token storage + | and the user provider that is invoked to actually retrieve users. + | + | The expiry time is the number of minutes that each reset token will be + | considered valid. This security feature keeps tokens short-lived so + | they have less time to be guessed. You may change this as needed. + | + | The throttle setting is the number of seconds a user must wait before + | generating more password reset tokens. This prevents the user from + | quickly generating a very large amount of password reset tokens. + | + */ + + 'passwords' => [ + 'users' => [ + 'provider' => 'users', + 'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'), + 'expire' => 60, + 'throttle' => 60, + ], + ], + + /* + |-------------------------------------------------------------------------- + | Password Confirmation Timeout + |-------------------------------------------------------------------------- + | + | Here you may define the amount of seconds before a password confirmation + | window expires and users are asked to re-enter their password via the + | confirmation screen. By default, the timeout lasts for three hours. + | + */ + + 'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800), + +]; diff --git a/config/cache.php b/config/cache.php new file mode 100644 index 0000000..3868091 --- /dev/null +++ b/config/cache.php @@ -0,0 +1,107 @@ + env('CACHE_STORE', 'database'), + + /* + |-------------------------------------------------------------------------- + | Cache Stores + |-------------------------------------------------------------------------- + | + | Here you may define all of the cache "stores" for your application as + | well as their drivers. You may even define multiple stores for the + | same cache driver to group types of items stored in your caches. + | + | Supported drivers: "apc", "array", "database", "file", "memcached", + | "redis", "dynamodb", "octane", "null" + | + */ + + 'stores' => [ + + 'array' => [ + 'driver' => 'array', + 'serialize' => false, + ], + + 'database' => [ + 'driver' => 'database', + 'table' => env('DB_CACHE_TABLE', 'cache'), + 'connection' => env('DB_CACHE_CONNECTION'), + 'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'), + ], + + 'file' => [ + 'driver' => 'file', + 'path' => storage_path('framework/cache/data'), + 'lock_path' => storage_path('framework/cache/data'), + ], + + 'memcached' => [ + 'driver' => 'memcached', + 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), + 'sasl' => [ + env('MEMCACHED_USERNAME'), + env('MEMCACHED_PASSWORD'), + ], + 'options' => [ + // Memcached::OPT_CONNECT_TIMEOUT => 2000, + ], + 'servers' => [ + [ + 'host' => env('MEMCACHED_HOST', '127.0.0.1'), + 'port' => env('MEMCACHED_PORT', 11211), + 'weight' => 100, + ], + ], + ], + + 'redis' => [ + 'driver' => 'redis', + 'connection' => env('REDIS_CACHE_CONNECTION', 'cache'), + 'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'), + ], + + 'dynamodb' => [ + 'driver' => 'dynamodb', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), + 'endpoint' => env('DYNAMODB_ENDPOINT'), + ], + + 'octane' => [ + 'driver' => 'octane', + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Cache Key Prefix + |-------------------------------------------------------------------------- + | + | When utilizing the APC, database, memcached, Redis, and DynamoDB cache + | stores, there might be other applications using the same cache. For + | that reason, you may prefix every cache key to avoid collisions. + | + */ + + 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'), + +]; diff --git a/config/database.php b/config/database.php new file mode 100644 index 0000000..f8e8dcb --- /dev/null +++ b/config/database.php @@ -0,0 +1,170 @@ + env('DB_CONNECTION', 'sqlite'), + + /* + |-------------------------------------------------------------------------- + | Database Connections + |-------------------------------------------------------------------------- + | + | Below are all of the database connections defined for your application. + | An example configuration is provided for each database system which + | is supported by Laravel. You're free to add / remove connections. + | + */ + + 'connections' => [ + + 'sqlite' => [ + 'driver' => 'sqlite', + 'url' => env('DB_URL'), + 'database' => env('DB_DATABASE', database_path('database.sqlite')), + 'prefix' => '', + 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), + ], + + 'mysql' => [ + 'driver' => 'mysql', + 'url' => env('DB_URL'), + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '3306'), + 'database' => env('DB_DATABASE', 'laravel'), + 'username' => env('DB_USERNAME', 'root'), + 'password' => env('DB_PASSWORD', ''), + 'unix_socket' => env('DB_SOCKET', ''), + 'charset' => env('DB_CHARSET', 'utf8mb4'), + 'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'), + 'prefix' => '', + 'prefix_indexes' => true, + 'strict' => true, + 'engine' => null, + 'options' => extension_loaded('pdo_mysql') ? array_filter([ + PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), + ]) : [], + ], + + 'mariadb' => [ + 'driver' => 'mariadb', + 'url' => env('DB_URL'), + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '3306'), + 'database' => env('DB_DATABASE', 'laravel'), + 'username' => env('DB_USERNAME', 'root'), + 'password' => env('DB_PASSWORD', ''), + 'unix_socket' => env('DB_SOCKET', ''), + 'charset' => env('DB_CHARSET', 'utf8mb4'), + 'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'), + 'prefix' => '', + 'prefix_indexes' => true, + 'strict' => true, + 'engine' => null, + 'options' => extension_loaded('pdo_mysql') ? array_filter([ + PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), + ]) : [], + ], + + 'pgsql' => [ + 'driver' => 'pgsql', + 'url' => env('DB_URL'), + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '5432'), + 'database' => env('DB_DATABASE', 'laravel'), + 'username' => env('DB_USERNAME', 'root'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => env('DB_CHARSET', 'utf8'), + 'prefix' => '', + 'prefix_indexes' => true, + 'search_path' => 'public', + 'sslmode' => 'prefer', + ], + + 'sqlsrv' => [ + 'driver' => 'sqlsrv', + 'url' => env('DB_URL'), + 'host' => env('DB_HOST', 'localhost'), + 'port' => env('DB_PORT', '1433'), + 'database' => env('DB_DATABASE', 'laravel'), + 'username' => env('DB_USERNAME', 'root'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => env('DB_CHARSET', 'utf8'), + 'prefix' => '', + 'prefix_indexes' => true, + // 'encrypt' => env('DB_ENCRYPT', 'yes'), + // 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'), + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Migration Repository Table + |-------------------------------------------------------------------------- + | + | This table keeps track of all the migrations that have already run for + | your application. Using this information, we can determine which of + | the migrations on disk haven't actually been run on the database. + | + */ + + 'migrations' => [ + 'table' => 'migrations', + 'update_date_on_publish' => true, + ], + + /* + |-------------------------------------------------------------------------- + | Redis Databases + |-------------------------------------------------------------------------- + | + | Redis is an open source, fast, and advanced key-value store that also + | provides a richer body of commands than a typical key-value system + | such as Memcached. You may define your connection settings here. + | + */ + + 'redis' => [ + + 'client' => env('REDIS_CLIENT', 'phpredis'), + + 'options' => [ + 'cluster' => env('REDIS_CLUSTER', 'redis'), + 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), + ], + + 'default' => [ + 'url' => env('REDIS_URL'), + 'host' => env('REDIS_HOST', '127.0.0.1'), + 'username' => env('REDIS_USERNAME'), + 'password' => env('REDIS_PASSWORD'), + 'port' => env('REDIS_PORT', '6379'), + 'database' => env('REDIS_DB', '0'), + ], + + 'cache' => [ + 'url' => env('REDIS_URL'), + 'host' => env('REDIS_HOST', '127.0.0.1'), + 'username' => env('REDIS_USERNAME'), + 'password' => env('REDIS_PASSWORD'), + 'port' => env('REDIS_PORT', '6379'), + 'database' => env('REDIS_CACHE_DB', '1'), + ], + + ], + +]; diff --git a/config/filesystems.php b/config/filesystems.php new file mode 100644 index 0000000..44fe9c8 --- /dev/null +++ b/config/filesystems.php @@ -0,0 +1,76 @@ + env('FILESYSTEM_DISK', 'local'), + + /* + |-------------------------------------------------------------------------- + | Filesystem Disks + |-------------------------------------------------------------------------- + | + | Below you may configure as many filesystem disks as necessary, and you + | may even configure multiple disks for the same driver. Examples for + | most supported storage drivers are configured here for reference. + | + | Supported Drivers: "local", "ftp", "sftp", "s3" + | + */ + + 'disks' => [ + + 'local' => [ + 'driver' => 'local', + 'root' => storage_path('app'), + 'throw' => false, + ], + + 'public' => [ + 'driver' => 'local', + 'root' => storage_path('app/public'), + 'url' => env('APP_URL').'/storage', + 'visibility' => 'public', + 'throw' => false, + ], + + 's3' => [ + 'driver' => 's3', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'region' => env('AWS_DEFAULT_REGION'), + 'bucket' => env('AWS_BUCKET'), + 'url' => env('AWS_URL'), + 'endpoint' => env('AWS_ENDPOINT'), + 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), + 'throw' => false, + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Symbolic Links + |-------------------------------------------------------------------------- + | + | Here you may configure the symbolic links that will be created when the + | `storage:link` Artisan command is executed. The array keys should be + | the locations of the links and the values should be their targets. + | + */ + + 'links' => [ + public_path('storage') => storage_path('app/public'), + ], + +]; diff --git a/config/logging.php b/config/logging.php new file mode 100644 index 0000000..d526b64 --- /dev/null +++ b/config/logging.php @@ -0,0 +1,132 @@ + env('LOG_CHANNEL', 'stack'), + + /* + |-------------------------------------------------------------------------- + | Deprecations Log Channel + |-------------------------------------------------------------------------- + | + | This option controls the log channel that should be used to log warnings + | regarding deprecated PHP and library features. This allows you to get + | your application ready for upcoming major versions of dependencies. + | + */ + + 'deprecations' => [ + 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), + 'trace' => env('LOG_DEPRECATIONS_TRACE', false), + ], + + /* + |-------------------------------------------------------------------------- + | Log Channels + |-------------------------------------------------------------------------- + | + | Here you may configure the log channels for your application. Laravel + | utilizes the Monolog PHP logging library, which includes a variety + | of powerful log handlers and formatters that you're free to use. + | + | Available Drivers: "single", "daily", "slack", "syslog", + | "errorlog", "monolog", "custom", "stack" + | + */ + + 'channels' => [ + + 'stack' => [ + 'driver' => 'stack', + 'channels' => explode(',', env('LOG_STACK', 'single')), + 'ignore_exceptions' => false, + ], + + 'single' => [ + 'driver' => 'single', + 'path' => storage_path('logs/laravel.log'), + 'level' => env('LOG_LEVEL', 'debug'), + 'replace_placeholders' => true, + ], + + 'daily' => [ + 'driver' => 'daily', + 'path' => storage_path('logs/laravel.log'), + 'level' => env('LOG_LEVEL', 'debug'), + 'days' => env('LOG_DAILY_DAYS', 14), + 'replace_placeholders' => true, + ], + + 'slack' => [ + 'driver' => 'slack', + 'url' => env('LOG_SLACK_WEBHOOK_URL'), + 'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'), + 'emoji' => env('LOG_SLACK_EMOJI', ':boom:'), + 'level' => env('LOG_LEVEL', 'critical'), + 'replace_placeholders' => true, + ], + + 'papertrail' => [ + 'driver' => 'monolog', + 'level' => env('LOG_LEVEL', 'debug'), + 'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class), + 'handler_with' => [ + 'host' => env('PAPERTRAIL_URL'), + 'port' => env('PAPERTRAIL_PORT'), + 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), + ], + 'processors' => [PsrLogMessageProcessor::class], + ], + + 'stderr' => [ + 'driver' => 'monolog', + 'level' => env('LOG_LEVEL', 'debug'), + 'handler' => StreamHandler::class, + 'formatter' => env('LOG_STDERR_FORMATTER'), + 'with' => [ + 'stream' => 'php://stderr', + ], + 'processors' => [PsrLogMessageProcessor::class], + ], + + 'syslog' => [ + 'driver' => 'syslog', + 'level' => env('LOG_LEVEL', 'debug'), + 'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER), + 'replace_placeholders' => true, + ], + + 'errorlog' => [ + 'driver' => 'errorlog', + 'level' => env('LOG_LEVEL', 'debug'), + 'replace_placeholders' => true, + ], + + 'null' => [ + 'driver' => 'monolog', + 'handler' => NullHandler::class, + ], + + 'emergency' => [ + 'path' => storage_path('logs/laravel.log'), + ], + + ], + +]; diff --git a/config/mail.php b/config/mail.php new file mode 100644 index 0000000..8666659 --- /dev/null +++ b/config/mail.php @@ -0,0 +1,111 @@ + env('MAIL_MAILER', 'log'), + + /* + |-------------------------------------------------------------------------- + | Mailer Configurations + |-------------------------------------------------------------------------- + | + | Here you may configure all of the mailers used by your application plus + | their respective settings. Several examples have been configured for + | you and you are free to add your own as your application requires. + | + | Laravel supports a variety of mail "transport" drivers that can be used + | when delivering an email. You may specify which one you're using for + | your mailers below. You may also add additional mailers if needed. + | + | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2", + | "postmark", "log", "array", "failover", "roundrobin" + | + */ + + 'mailers' => [ + + 'smtp' => [ + 'transport' => 'smtp', + 'url' => env('MAIL_URL'), + 'host' => env('MAIL_HOST', '127.0.0.1'), + 'port' => env('MAIL_PORT', 2525), + 'encryption' => env('MAIL_ENCRYPTION', 'tls'), + 'username' => env('MAIL_USERNAME'), + 'password' => env('MAIL_PASSWORD'), + 'timeout' => null, + 'local_domain' => env('MAIL_EHLO_DOMAIN'), + ], + + 'ses' => [ + 'transport' => 'ses', + ], + + 'postmark' => [ + 'transport' => 'postmark', + // 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'), + // 'client' => [ + // 'timeout' => 5, + // ], + ], + + 'sendmail' => [ + 'transport' => 'sendmail', + 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'), + ], + + 'log' => [ + 'transport' => 'log', + 'channel' => env('MAIL_LOG_CHANNEL'), + ], + + 'array' => [ + 'transport' => 'array', + ], + + 'failover' => [ + 'transport' => 'failover', + 'mailers' => [ + 'smtp', + 'log', + ], + ], + + 'roundrobin' => [ + 'transport' => 'roundrobin', + 'mailers' => [ + 'ses', + 'postmark', + ], + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Global "From" Address + |-------------------------------------------------------------------------- + | + | You may wish for all emails sent by your application to be sent from + | the same address. Here you may specify a name and address that is + | used globally for all emails that are sent by your application. + | + */ + + 'from' => [ + 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), + 'name' => env('MAIL_FROM_NAME', 'Example'), + ], + +]; diff --git a/config/queue.php b/config/queue.php new file mode 100644 index 0000000..116bd8d --- /dev/null +++ b/config/queue.php @@ -0,0 +1,112 @@ + env('QUEUE_CONNECTION', 'database'), + + /* + |-------------------------------------------------------------------------- + | Queue Connections + |-------------------------------------------------------------------------- + | + | Here you may configure the connection options for every queue backend + | used by your application. An example configuration is provided for + | each backend supported by Laravel. You're also free to add more. + | + | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" + | + */ + + 'connections' => [ + + 'sync' => [ + 'driver' => 'sync', + ], + + 'database' => [ + 'driver' => 'database', + 'connection' => env('DB_QUEUE_CONNECTION'), + 'table' => env('DB_QUEUE_TABLE', 'jobs'), + 'queue' => env('DB_QUEUE', 'default'), + 'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90), + 'after_commit' => false, + ], + + 'beanstalkd' => [ + 'driver' => 'beanstalkd', + 'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'), + 'queue' => env('BEANSTALKD_QUEUE', 'default'), + 'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90), + 'block_for' => 0, + 'after_commit' => false, + ], + + 'sqs' => [ + 'driver' => 'sqs', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), + 'queue' => env('SQS_QUEUE', 'default'), + 'suffix' => env('SQS_SUFFIX'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'after_commit' => false, + ], + + 'redis' => [ + 'driver' => 'redis', + 'connection' => env('REDIS_QUEUE_CONNECTION', 'default'), + 'queue' => env('REDIS_QUEUE', 'default'), + 'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90), + 'block_for' => null, + 'after_commit' => false, + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Job Batching + |-------------------------------------------------------------------------- + | + | The following options configure the database and table that store job + | batching information. These options can be updated to any database + | connection and table which has been defined by your application. + | + */ + + 'batching' => [ + 'database' => env('DB_CONNECTION', 'sqlite'), + 'table' => 'job_batches', + ], + + /* + |-------------------------------------------------------------------------- + | Failed Queue Jobs + |-------------------------------------------------------------------------- + | + | These options configure the behavior of failed queue job logging so you + | can control how and where failed jobs are stored. Laravel ships with + | support for storing failed jobs in a simple file or in a database. + | + | Supported drivers: "database-uuids", "dynamodb", "file", "null" + | + */ + + 'failed' => [ + 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), + 'database' => env('DB_CONNECTION', 'sqlite'), + 'table' => 'failed_jobs', + ], + +]; diff --git a/config/services.php b/config/services.php new file mode 100644 index 0000000..6bb68f6 --- /dev/null +++ b/config/services.php @@ -0,0 +1,34 @@ + [ + 'token' => env('POSTMARK_TOKEN'), + ], + + 'ses' => [ + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + ], + + 'slack' => [ + 'notifications' => [ + 'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'), + 'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'), + ], + ], + +]; diff --git a/config/session.php b/config/session.php new file mode 100644 index 0000000..f0b6541 --- /dev/null +++ b/config/session.php @@ -0,0 +1,217 @@ + env('SESSION_DRIVER', 'database'), + + /* + |-------------------------------------------------------------------------- + | Session Lifetime + |-------------------------------------------------------------------------- + | + | Here you may specify the number of minutes that you wish the session + | to be allowed to remain idle before it expires. If you want them + | to expire immediately when the browser is closed then you may + | indicate that via the expire_on_close configuration option. + | + */ + + 'lifetime' => env('SESSION_LIFETIME', 120), + + 'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false), + + /* + |-------------------------------------------------------------------------- + | Session Encryption + |-------------------------------------------------------------------------- + | + | This option allows you to easily specify that all of your session data + | should be encrypted before it's stored. All encryption is performed + | automatically by Laravel and you may use the session like normal. + | + */ + + 'encrypt' => env('SESSION_ENCRYPT', false), + + /* + |-------------------------------------------------------------------------- + | Session File Location + |-------------------------------------------------------------------------- + | + | When utilizing the "file" session driver, the session files are placed + | on disk. The default storage location is defined here; however, you + | are free to provide another location where they should be stored. + | + */ + + 'files' => storage_path('framework/sessions'), + + /* + |-------------------------------------------------------------------------- + | Session Database Connection + |-------------------------------------------------------------------------- + | + | When using the "database" or "redis" session drivers, you may specify a + | connection that should be used to manage these sessions. This should + | correspond to a connection in your database configuration options. + | + */ + + 'connection' => env('SESSION_CONNECTION'), + + /* + |-------------------------------------------------------------------------- + | Session Database Table + |-------------------------------------------------------------------------- + | + | When using the "database" session driver, you may specify the table to + | be used to store sessions. Of course, a sensible default is defined + | for you; however, you're welcome to change this to another table. + | + */ + + 'table' => env('SESSION_TABLE', 'sessions'), + + /* + |-------------------------------------------------------------------------- + | Session Cache Store + |-------------------------------------------------------------------------- + | + | When using one of the framework's cache driven session backends, you may + | define the cache store which should be used to store the session data + | between requests. This must match one of your defined cache stores. + | + | Affects: "apc", "dynamodb", "memcached", "redis" + | + */ + + 'store' => env('SESSION_STORE'), + + /* + |-------------------------------------------------------------------------- + | Session Sweeping Lottery + |-------------------------------------------------------------------------- + | + | Some session drivers must manually sweep their storage location to get + | rid of old sessions from storage. Here are the chances that it will + | happen on a given request. By default, the odds are 2 out of 100. + | + */ + + 'lottery' => [2, 100], + + /* + |-------------------------------------------------------------------------- + | Session Cookie Name + |-------------------------------------------------------------------------- + | + | Here you may change the name of the session cookie that is created by + | the framework. Typically, you should not need to change this value + | since doing so does not grant a meaningful security improvement. + | + */ + + 'cookie' => env( + 'SESSION_COOKIE', + Str::slug(env('APP_NAME', 'laravel'), '_').'_session' + ), + + /* + |-------------------------------------------------------------------------- + | Session Cookie Path + |-------------------------------------------------------------------------- + | + | The session cookie path determines the path for which the cookie will + | be regarded as available. Typically, this will be the root path of + | your application, but you're free to change this when necessary. + | + */ + + 'path' => env('SESSION_PATH', '/'), + + /* + |-------------------------------------------------------------------------- + | Session Cookie Domain + |-------------------------------------------------------------------------- + | + | This value determines the domain and subdomains the session cookie is + | available to. By default, the cookie will be available to the root + | domain and all subdomains. Typically, this shouldn't be changed. + | + */ + + 'domain' => env('SESSION_DOMAIN'), + + /* + |-------------------------------------------------------------------------- + | HTTPS Only Cookies + |-------------------------------------------------------------------------- + | + | By setting this option to true, session cookies will only be sent back + | to the server if the browser has a HTTPS connection. This will keep + | the cookie from being sent to you when it can't be done securely. + | + */ + + 'secure' => env('SESSION_SECURE_COOKIE'), + + /* + |-------------------------------------------------------------------------- + | HTTP Access Only + |-------------------------------------------------------------------------- + | + | Setting this value to true will prevent JavaScript from accessing the + | value of the cookie and the cookie will only be accessible through + | the HTTP protocol. It's unlikely you should disable this option. + | + */ + + 'http_only' => env('SESSION_HTTP_ONLY', true), + + /* + |-------------------------------------------------------------------------- + | Same-Site Cookies + |-------------------------------------------------------------------------- + | + | This option determines how your cookies behave when cross-site requests + | take place, and can be used to mitigate CSRF attacks. By default, we + | will set this value to "lax" to permit secure cross-site requests. + | + | See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value + | + | Supported: "lax", "strict", "none", null + | + */ + + 'same_site' => env('SESSION_SAME_SITE', 'lax'), + + /* + |-------------------------------------------------------------------------- + | Partitioned Cookies + |-------------------------------------------------------------------------- + | + | Setting this value to true will tie the cookie to the top-level site for + | a cross-site context. Partitioned cookies are accepted by the browser + | when flagged "secure" and the Same-Site attribute is set to "none". + | + */ + + 'partitioned' => env('SESSION_PARTITIONED_COOKIE', false), + +]; diff --git a/database/.gitignore b/database/.gitignore new file mode 100644 index 0000000..9b19b93 --- /dev/null +++ b/database/.gitignore @@ -0,0 +1 @@ +*.sqlite* diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php new file mode 100644 index 0000000..584104c --- /dev/null +++ b/database/factories/UserFactory.php @@ -0,0 +1,44 @@ + + */ +class UserFactory extends Factory +{ + /** + * The current password being used by the factory. + */ + protected static ?string $password; + + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'name' => fake()->name(), + 'email' => fake()->unique()->safeEmail(), + 'email_verified_at' => now(), + 'password' => static::$password ??= Hash::make('password'), + 'remember_token' => Str::random(10), + ]; + } + + /** + * Indicate that the model's email address should be unverified. + */ + public function unverified(): static + { + return $this->state(fn (array $attributes) => [ + 'email_verified_at' => null, + ]); + } +} diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php new file mode 100644 index 0000000..05fb5d9 --- /dev/null +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -0,0 +1,49 @@ +id(); + $table->string('name'); + $table->string('email')->unique(); + $table->timestamp('email_verified_at')->nullable(); + $table->string('password'); + $table->rememberToken(); + $table->timestamps(); + }); + + Schema::create('password_reset_tokens', function (Blueprint $table) { + $table->string('email')->primary(); + $table->string('token'); + $table->timestamp('created_at')->nullable(); + }); + + Schema::create('sessions', function (Blueprint $table) { + $table->string('id')->primary(); + $table->foreignId('user_id')->nullable()->index(); + $table->string('ip_address', 45)->nullable(); + $table->text('user_agent')->nullable(); + $table->longText('payload'); + $table->integer('last_activity')->index(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('users'); + Schema::dropIfExists('password_reset_tokens'); + Schema::dropIfExists('sessions'); + } +}; diff --git a/database/migrations/0001_01_01_000001_create_cache_table.php b/database/migrations/0001_01_01_000001_create_cache_table.php new file mode 100644 index 0000000..b9c106b --- /dev/null +++ b/database/migrations/0001_01_01_000001_create_cache_table.php @@ -0,0 +1,35 @@ +string('key')->primary(); + $table->mediumText('value'); + $table->integer('expiration'); + }); + + Schema::create('cache_locks', function (Blueprint $table) { + $table->string('key')->primary(); + $table->string('owner'); + $table->integer('expiration'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('cache'); + Schema::dropIfExists('cache_locks'); + } +}; diff --git a/database/migrations/0001_01_01_000002_create_jobs_table.php b/database/migrations/0001_01_01_000002_create_jobs_table.php new file mode 100644 index 0000000..425e705 --- /dev/null +++ b/database/migrations/0001_01_01_000002_create_jobs_table.php @@ -0,0 +1,57 @@ +id(); + $table->string('queue')->index(); + $table->longText('payload'); + $table->unsignedTinyInteger('attempts'); + $table->unsignedInteger('reserved_at')->nullable(); + $table->unsignedInteger('available_at'); + $table->unsignedInteger('created_at'); + }); + + Schema::create('job_batches', function (Blueprint $table) { + $table->string('id')->primary(); + $table->string('name'); + $table->integer('total_jobs'); + $table->integer('pending_jobs'); + $table->integer('failed_jobs'); + $table->longText('failed_job_ids'); + $table->mediumText('options')->nullable(); + $table->integer('cancelled_at')->nullable(); + $table->integer('created_at'); + $table->integer('finished_at')->nullable(); + }); + + Schema::create('failed_jobs', function (Blueprint $table) { + $table->id(); + $table->string('uuid')->unique(); + $table->text('connection'); + $table->text('queue'); + $table->longText('payload'); + $table->longText('exception'); + $table->timestamp('failed_at')->useCurrent(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('jobs'); + Schema::dropIfExists('job_batches'); + Schema::dropIfExists('failed_jobs'); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php new file mode 100644 index 0000000..d01a0ef --- /dev/null +++ b/database/seeders/DatabaseSeeder.php @@ -0,0 +1,23 @@ +create(); + + User::factory()->create([ + 'name' => 'Test User', + 'email' => 'test@example.com', + ]); + } +} diff --git a/laravel b/laravel new file mode 100644 index 0000000..e69de29 diff --git a/package.json b/package.json new file mode 100644 index 0000000..4e934ca --- /dev/null +++ b/package.json @@ -0,0 +1,13 @@ +{ + "private": true, + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build" + }, + "devDependencies": { + "axios": "^1.6.4", + "laravel-vite-plugin": "^1.0", + "vite": "^5.0" + } +} diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..506b9a3 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,33 @@ + + + + + tests/Unit + + + tests/Feature + + + + + app + + + + + + + + + + + + + + + + diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..3aec5e2 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,21 @@ + + + Options -MultiViews -Indexes + + + RewriteEngine On + + # Handle Authorization Header + RewriteCond %{HTTP:Authorization} . + RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + + # Redirect Trailing Slashes If Not A Folder... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_URI} (.+)/$ + RewriteRule ^ %1 [L,R=301] + + # Send Requests To Front Controller... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [L] + diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..947d989 --- /dev/null +++ b/public/index.php @@ -0,0 +1,17 @@ +handleRequest(Request::capture()); diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..eb05362 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: diff --git a/resources/css/app.css b/resources/css/app.css new file mode 100644 index 0000000..e69de29 diff --git a/resources/js/app.js b/resources/js/app.js new file mode 100644 index 0000000..e59d6a0 --- /dev/null +++ b/resources/js/app.js @@ -0,0 +1 @@ +import './bootstrap'; diff --git a/resources/js/bootstrap.js b/resources/js/bootstrap.js new file mode 100644 index 0000000..5f1390b --- /dev/null +++ b/resources/js/bootstrap.js @@ -0,0 +1,4 @@ +import axios from 'axios'; +window.axios = axios; + +window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php new file mode 100644 index 0000000..a9898e3 --- /dev/null +++ b/resources/views/welcome.blade.php @@ -0,0 +1,172 @@ + + + + + + + Laravel + + + + + + + + + + + + diff --git a/routes/console.php b/routes/console.php new file mode 100644 index 0000000..eff2ed2 --- /dev/null +++ b/routes/console.php @@ -0,0 +1,8 @@ +comment(Inspiring::quote()); +})->purpose('Display an inspiring quote')->hourly(); diff --git a/routes/web.php b/routes/web.php new file mode 100644 index 0000000..86a06c5 --- /dev/null +++ b/routes/web.php @@ -0,0 +1,7 @@ +get('/'); + + $response->assertStatus(200); + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..fe1ffc2 --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,10 @@ +assertTrue(true); + } +} diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..421b569 --- /dev/null +++ b/vite.config.js @@ -0,0 +1,11 @@ +import { defineConfig } from 'vite'; +import laravel from 'laravel-vite-plugin'; + +export default defineConfig({ + plugins: [ + laravel({ + input: ['resources/css/app.css', 'resources/js/app.js'], + refresh: true, + }), + ], +}); From 2802c00359b2264deb38b190e61e51c50809f501 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 6 May 2024 12:48:54 +0200 Subject: [PATCH 002/115] login part 1 --- app/Http/Controllers/Auth/AuthController.php | 33 + app/Http/Requests/RegisterRequest.php | 28 + app/Models/User.php | 3 +- app/Providers/AppServiceProvider.php | 8 +- bootstrap/app.php | 1 + composer.json | 1 + composer.lock | 1071 ++++++++++++++++- config/auth.php | 4 + config/passport.php | 75 ++ ...90445_create_oauth_access_tokens_table.php | 33 + ...te_oauth_personal_access_clients_table.php | 28 + ...5_06_090447_create_oauth_clients_table.php | 35 + ...0448_create_oauth_refresh_tokens_table.php | 29 + ...6_090449_create_oauth_auth_codes_table.php | 31 + ...02719_create_oauth_access_tokens_table.php | 33 + ...te_oauth_personal_access_clients_table.php | 28 + ...5_06_102721_create_oauth_clients_table.php | 35 + ...2722_create_oauth_refresh_tokens_table.php | 29 + ...6_102723_create_oauth_auth_codes_table.php | 31 + routes/api.php | 12 + 20 files changed, 1534 insertions(+), 14 deletions(-) create mode 100644 app/Http/Controllers/Auth/AuthController.php create mode 100644 app/Http/Requests/RegisterRequest.php create mode 100644 config/passport.php create mode 100644 database/migrations/2024_05_06_090445_create_oauth_access_tokens_table.php create mode 100644 database/migrations/2024_05_06_090446_create_oauth_personal_access_clients_table.php create mode 100644 database/migrations/2024_05_06_090447_create_oauth_clients_table.php create mode 100644 database/migrations/2024_05_06_090448_create_oauth_refresh_tokens_table.php create mode 100644 database/migrations/2024_05_06_090449_create_oauth_auth_codes_table.php create mode 100644 database/migrations/2024_05_06_102719_create_oauth_access_tokens_table.php create mode 100644 database/migrations/2024_05_06_102720_create_oauth_personal_access_clients_table.php create mode 100644 database/migrations/2024_05_06_102721_create_oauth_clients_table.php create mode 100644 database/migrations/2024_05_06_102722_create_oauth_refresh_tokens_table.php create mode 100644 database/migrations/2024_05_06_102723_create_oauth_auth_codes_table.php create mode 100644 routes/api.php diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php new file mode 100644 index 0000000..3135465 --- /dev/null +++ b/app/Http/Controllers/Auth/AuthController.php @@ -0,0 +1,33 @@ +validate([ + 'name' => 'required|string|max:255', + 'email' => 'required|string|email|max:255|unique:users', + 'password' => 'required|string|min:8', + ]); + + + $user = User::create([ + 'name' => $request['name'], + 'email' => $validatedData['email'], + 'password' => bcrypt($request['password']), + ]); + + $token = $user->createToken(env('PASSPORT_PERSONAL_ACCESS_CLIENT_ID'))->accessToken; + + \Log::info('Token generated', ['token' => $token]); + + return response()->json(['token' => $token]); + } +} diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php new file mode 100644 index 0000000..f6fd6fe --- /dev/null +++ b/app/Http/Requests/RegisterRequest.php @@ -0,0 +1,28 @@ +|string> + */ + public function rules(): array + { + return [ + // + ]; + } +} diff --git a/app/Models/User.php b/app/Models/User.php index def621f..b2fa20c 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -6,10 +6,11 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; +use Laravel\Passport\HasApiTokens; class User extends Authenticatable { - use HasFactory, Notifiable; + use HasApiTokens,HasFactory, Notifiable; /** * The attributes that are mass assignable. diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 452e6b6..6ff5a72 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -3,6 +3,12 @@ namespace App\Providers; use Illuminate\Support\ServiceProvider; +use Laravel\Passport\AuthCode; +use Laravel\Passport\Client; +use Laravel\Passport\Passport; +use Laravel\Passport\PersonalAccessClient; +use Laravel\Passport\RefreshToken; +use Laravel\Passport\Token; class AppServiceProvider extends ServiceProvider { @@ -19,6 +25,6 @@ public function register(): void */ public function boot(): void { - // + } } diff --git a/bootstrap/app.php b/bootstrap/app.php index 7b162da..d654276 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -7,6 +7,7 @@ return Application::configure(basePath: dirname(__DIR__)) ->withRouting( web: __DIR__.'/../routes/web.php', + api: __DIR__.'/../routes/api.php', commands: __DIR__.'/../routes/console.php', health: '/up', ) diff --git a/composer.json b/composer.json index 15cebc1..843c609 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,7 @@ "require": { "php": "^8.2", "laravel/framework": "^11.0", + "laravel/passport": "^12.0", "laravel/tinker": "^2.9" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 8699755..4edb16b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "da9b7a1dc1dd923105198c572cc7df8d", + "content-hash": "1f530da1173813168d4a7273ae3dfeb0", "packages": [ { "name": "brick/math", @@ -135,6 +135,73 @@ ], "time": "2024-02-09T16:56:22+00:00" }, + { + "name": "defuse/php-encryption", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/defuse/php-encryption.git", + "reference": "f53396c2d34225064647a05ca76c1da9d99e5828" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/defuse/php-encryption/zipball/f53396c2d34225064647a05ca76c1da9d99e5828", + "reference": "f53396c2d34225064647a05ca76c1da9d99e5828", + "shasum": "" + }, + "require": { + "ext-openssl": "*", + "paragonie/random_compat": ">= 2", + "php": ">=5.6.0" + }, + "require-dev": { + "phpunit/phpunit": "^5|^6|^7|^8|^9|^10", + "yoast/phpunit-polyfills": "^2.0.0" + }, + "bin": [ + "bin/generate-defuse-key" + ], + "type": "library", + "autoload": { + "psr-4": { + "Defuse\\Crypto\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Hornby", + "email": "taylor@defuse.ca", + "homepage": "https://defuse.ca/" + }, + { + "name": "Scott Arciszewski", + "email": "info@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "Secure PHP Encryption Library", + "keywords": [ + "aes", + "authenticated encryption", + "cipher", + "crypto", + "cryptography", + "encrypt", + "encryption", + "openssl", + "security", + "symmetric key cryptography" + ], + "support": { + "issues": "https://github.com/defuse/php-encryption/issues", + "source": "https://github.com/defuse/php-encryption/tree/v2.4.0" + }, + "time": "2023-06-19T06:10:36+00:00" + }, { "name": "dflydev/dot-access-data", "version": "v3.0.2", @@ -506,6 +573,69 @@ ], "time": "2023-10-06T06:47:41+00:00" }, + { + "name": "firebase/php-jwt", + "version": "v6.10.0", + "source": { + "type": "git", + "url": "https://github.com/firebase/php-jwt.git", + "reference": "a49db6f0a5033aef5143295342f1c95521b075ff" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/firebase/php-jwt/zipball/a49db6f0a5033aef5143295342f1c95521b075ff", + "reference": "a49db6f0a5033aef5143295342f1c95521b075ff", + "shasum": "" + }, + "require": { + "php": "^7.4||^8.0" + }, + "require-dev": { + "guzzlehttp/guzzle": "^6.5||^7.4", + "phpspec/prophecy-phpunit": "^2.0", + "phpunit/phpunit": "^9.5", + "psr/cache": "^1.0||^2.0", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0" + }, + "suggest": { + "ext-sodium": "Support EdDSA (Ed25519) signatures", + "paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present" + }, + "type": "library", + "autoload": { + "psr-4": { + "Firebase\\JWT\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Neuman Vong", + "email": "neuman+pear@twilio.com", + "role": "Developer" + }, + { + "name": "Anant Narayanan", + "email": "anant@php.net", + "role": "Developer" + } + ], + "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.", + "homepage": "https://github.com/firebase/php-jwt", + "keywords": [ + "jwt", + "php" + ], + "support": { + "issues": "https://github.com/firebase/php-jwt/issues", + "source": "https://github.com/firebase/php-jwt/tree/v6.10.0" + }, + "time": "2023-12-01T16:26:39+00:00" + }, { "name": "fruitcake/php-cors", "version": "v1.3.0", @@ -1255,6 +1385,82 @@ }, "time": "2024-04-30T13:30:08+00:00" }, + { + "name": "laravel/passport", + "version": "v12.2.0", + "source": { + "type": "git", + "url": "https://github.com/laravel/passport.git", + "reference": "b24c6462835a16163141fbe588533d16603212b7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/passport/zipball/b24c6462835a16163141fbe588533d16603212b7", + "reference": "b24c6462835a16163141fbe588533d16603212b7", + "shasum": "" + }, + "require": { + "ext-json": "*", + "firebase/php-jwt": "^6.4", + "illuminate/auth": "^9.21|^10.0|^11.0", + "illuminate/console": "^9.21|^10.0|^11.0", + "illuminate/container": "^9.21|^10.0|^11.0", + "illuminate/contracts": "^9.21|^10.0|^11.0", + "illuminate/cookie": "^9.21|^10.0|^11.0", + "illuminate/database": "^9.21|^10.0|^11.0", + "illuminate/encryption": "^9.21|^10.0|^11.0", + "illuminate/http": "^9.21|^10.0|^11.0", + "illuminate/support": "^9.21|^10.0|^11.0", + "lcobucci/jwt": "^4.3|^5.0", + "league/oauth2-server": "^8.5.3", + "nyholm/psr7": "^1.5", + "php": "^8.0", + "phpseclib/phpseclib": "^2.0|^3.0", + "symfony/console": "^6.0|^7.0", + "symfony/psr-http-message-bridge": "^2.1|^6.0|^7.0" + }, + "require-dev": { + "mockery/mockery": "^1.0", + "orchestra/testbench": "^7.35|^8.14|^9.0", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.3|^10.5" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Laravel\\Passport\\PassportServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Laravel\\Passport\\": "src/", + "Laravel\\Passport\\Database\\Factories\\": "database/factories/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "Laravel Passport provides OAuth2 server support to Laravel.", + "keywords": [ + "laravel", + "oauth", + "passport" + ], + "support": { + "issues": "https://github.com/laravel/passport/issues", + "source": "https://github.com/laravel/passport" + }, + "time": "2024-04-17T17:56:14+00:00" + }, { "name": "laravel/prompts", "version": "v0.1.21", @@ -1439,6 +1645,143 @@ }, "time": "2024-01-04T16:10:04+00:00" }, + { + "name": "lcobucci/clock", + "version": "3.2.0", + "source": { + "type": "git", + "url": "https://github.com/lcobucci/clock.git", + "reference": "6f28b826ea01306b07980cb8320ab30b966cd715" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/lcobucci/clock/zipball/6f28b826ea01306b07980cb8320ab30b966cd715", + "reference": "6f28b826ea01306b07980cb8320ab30b966cd715", + "shasum": "" + }, + "require": { + "php": "~8.2.0 || ~8.3.0", + "psr/clock": "^1.0" + }, + "provide": { + "psr/clock-implementation": "1.0" + }, + "require-dev": { + "infection/infection": "^0.27", + "lcobucci/coding-standard": "^11.0.0", + "phpstan/extension-installer": "^1.3.1", + "phpstan/phpstan": "^1.10.25", + "phpstan/phpstan-deprecation-rules": "^1.1.3", + "phpstan/phpstan-phpunit": "^1.3.13", + "phpstan/phpstan-strict-rules": "^1.5.1", + "phpunit/phpunit": "^10.2.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Lcobucci\\Clock\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Luís Cobucci", + "email": "lcobucci@gmail.com" + } + ], + "description": "Yet another clock abstraction", + "support": { + "issues": "https://github.com/lcobucci/clock/issues", + "source": "https://github.com/lcobucci/clock/tree/3.2.0" + }, + "funding": [ + { + "url": "https://github.com/lcobucci", + "type": "github" + }, + { + "url": "https://www.patreon.com/lcobucci", + "type": "patreon" + } + ], + "time": "2023-11-17T17:00:27+00:00" + }, + { + "name": "lcobucci/jwt", + "version": "5.3.0", + "source": { + "type": "git", + "url": "https://github.com/lcobucci/jwt.git", + "reference": "08071d8d2c7f4b00222cc4b1fb6aa46990a80f83" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/lcobucci/jwt/zipball/08071d8d2c7f4b00222cc4b1fb6aa46990a80f83", + "reference": "08071d8d2c7f4b00222cc4b1fb6aa46990a80f83", + "shasum": "" + }, + "require": { + "ext-openssl": "*", + "ext-sodium": "*", + "php": "~8.1.0 || ~8.2.0 || ~8.3.0", + "psr/clock": "^1.0" + }, + "require-dev": { + "infection/infection": "^0.27.0", + "lcobucci/clock": "^3.0", + "lcobucci/coding-standard": "^11.0", + "phpbench/phpbench": "^1.2.9", + "phpstan/extension-installer": "^1.2", + "phpstan/phpstan": "^1.10.7", + "phpstan/phpstan-deprecation-rules": "^1.1.3", + "phpstan/phpstan-phpunit": "^1.3.10", + "phpstan/phpstan-strict-rules": "^1.5.0", + "phpunit/phpunit": "^10.2.6" + }, + "suggest": { + "lcobucci/clock": ">= 3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Lcobucci\\JWT\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Luís Cobucci", + "email": "lcobucci@gmail.com", + "role": "Developer" + } + ], + "description": "A simple library to work with JSON Web Token and JSON Web Signature", + "keywords": [ + "JWS", + "jwt" + ], + "support": { + "issues": "https://github.com/lcobucci/jwt/issues", + "source": "https://github.com/lcobucci/jwt/tree/5.3.0" + }, + "funding": [ + { + "url": "https://github.com/lcobucci", + "type": "github" + }, + { + "url": "https://www.patreon.com/lcobucci", + "type": "patreon" + } + ], + "time": "2024-04-11T23:07:54+00:00" + }, { "name": "league/commonmark", "version": "2.4.2", @@ -1627,6 +1970,60 @@ ], "time": "2022-12-11T20:36:23+00:00" }, + { + "name": "league/event", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/event.git", + "reference": "d2cc124cf9a3fab2bb4ff963307f60361ce4d119" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/event/zipball/d2cc124cf9a3fab2bb4ff963307f60361ce4d119", + "reference": "d2cc124cf9a3fab2bb4ff963307f60361ce4d119", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "henrikbjorn/phpspec-code-coverage": "~1.0.1", + "phpspec/phpspec": "^2.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Event\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frenky.net" + } + ], + "description": "Event package", + "keywords": [ + "emitter", + "event", + "listener" + ], + "support": { + "issues": "https://github.com/thephpleague/event/issues", + "source": "https://github.com/thephpleague/event/tree/master" + }, + "time": "2018-11-26T11:52:41+00:00" + }, { "name": "league/flysystem", "version": "3.27.0", @@ -1811,26 +2208,288 @@ ], "authors": [ { - "name": "Frank de Jonge", - "email": "info@frankdejonge.nl" + "name": "Frank de Jonge", + "email": "info@frankdejonge.nl" + } + ], + "description": "Mime-type detection for Flysystem", + "support": { + "issues": "https://github.com/thephpleague/mime-type-detection/issues", + "source": "https://github.com/thephpleague/mime-type-detection/tree/1.15.0" + }, + "funding": [ + { + "url": "https://github.com/frankdejonge", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/league/flysystem", + "type": "tidelift" + } + ], + "time": "2024-01-28T23:22:08+00:00" + }, + { + "name": "league/oauth2-server", + "version": "8.5.4", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/oauth2-server.git", + "reference": "ab7714d073844497fd222d5d0a217629089936bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/oauth2-server/zipball/ab7714d073844497fd222d5d0a217629089936bc", + "reference": "ab7714d073844497fd222d5d0a217629089936bc", + "shasum": "" + }, + "require": { + "defuse/php-encryption": "^2.3", + "ext-openssl": "*", + "lcobucci/clock": "^2.2 || ^3.0", + "lcobucci/jwt": "^4.3 || ^5.0", + "league/event": "^2.2", + "league/uri": "^6.7 || ^7.0", + "php": "^8.0", + "psr/http-message": "^1.0.1 || ^2.0" + }, + "replace": { + "league/oauth2server": "*", + "lncd/oauth2": "*" + }, + "require-dev": { + "laminas/laminas-diactoros": "^3.0.0", + "phpstan/phpstan": "^0.12.57", + "phpstan/phpstan-phpunit": "^0.12.16", + "phpunit/phpunit": "^9.6.6", + "roave/security-advisories": "dev-master" + }, + "type": "library", + "autoload": { + "psr-4": { + "League\\OAuth2\\Server\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alex Bilbie", + "email": "hello@alexbilbie.com", + "homepage": "http://www.alexbilbie.com", + "role": "Developer" + }, + { + "name": "Andy Millington", + "email": "andrew@noexceptions.io", + "homepage": "https://www.noexceptions.io", + "role": "Developer" + } + ], + "description": "A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.", + "homepage": "https://oauth2.thephpleague.com/", + "keywords": [ + "Authentication", + "api", + "auth", + "authorisation", + "authorization", + "oauth", + "oauth 2", + "oauth 2.0", + "oauth2", + "protect", + "resource", + "secure", + "server" + ], + "support": { + "issues": "https://github.com/thephpleague/oauth2-server/issues", + "source": "https://github.com/thephpleague/oauth2-server/tree/8.5.4" + }, + "funding": [ + { + "url": "https://github.com/sephster", + "type": "github" + } + ], + "time": "2023-08-25T22:35:12+00:00" + }, + { + "name": "league/uri", + "version": "7.4.1", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/uri.git", + "reference": "bedb6e55eff0c933668addaa7efa1e1f2c417cc4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/uri/zipball/bedb6e55eff0c933668addaa7efa1e1f2c417cc4", + "reference": "bedb6e55eff0c933668addaa7efa1e1f2c417cc4", + "shasum": "" + }, + "require": { + "league/uri-interfaces": "^7.3", + "php": "^8.1" + }, + "conflict": { + "league/uri-schemes": "^1.0" + }, + "suggest": { + "ext-bcmath": "to improve IPV4 host parsing", + "ext-fileinfo": "to create Data URI from file contennts", + "ext-gmp": "to improve IPV4 host parsing", + "ext-intl": "to handle IDN host with the best performance", + "jeremykendall/php-domain-parser": "to resolve Public Suffix and Top Level Domain", + "league/uri-components": "Needed to easily manipulate URI objects components", + "php-64bit": "to improve IPV4 host parsing", + "symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "7.x-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Uri\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignace Nyamagana Butera", + "email": "nyamsprod@gmail.com", + "homepage": "https://nyamsprod.com" + } + ], + "description": "URI manipulation library", + "homepage": "https://uri.thephpleague.com", + "keywords": [ + "data-uri", + "file-uri", + "ftp", + "hostname", + "http", + "https", + "middleware", + "parse_str", + "parse_url", + "psr-7", + "query-string", + "querystring", + "rfc3986", + "rfc3987", + "rfc6570", + "uri", + "uri-template", + "url", + "ws" + ], + "support": { + "docs": "https://uri.thephpleague.com", + "forum": "https://thephpleague.slack.com", + "issues": "https://github.com/thephpleague/uri-src/issues", + "source": "https://github.com/thephpleague/uri/tree/7.4.1" + }, + "funding": [ + { + "url": "https://github.com/sponsors/nyamsprod", + "type": "github" + } + ], + "time": "2024-03-23T07:42:40+00:00" + }, + { + "name": "league/uri-interfaces", + "version": "7.4.1", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/uri-interfaces.git", + "reference": "8d43ef5c841032c87e2de015972c06f3865ef718" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/8d43ef5c841032c87e2de015972c06f3865ef718", + "reference": "8d43ef5c841032c87e2de015972c06f3865ef718", + "shasum": "" + }, + "require": { + "ext-filter": "*", + "php": "^8.1", + "psr/http-factory": "^1", + "psr/http-message": "^1.1 || ^2.0" + }, + "suggest": { + "ext-bcmath": "to improve IPV4 host parsing", + "ext-gmp": "to improve IPV4 host parsing", + "ext-intl": "to handle IDN host with the best performance", + "php-64bit": "to improve IPV4 host parsing", + "symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "7.x-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Uri\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignace Nyamagana Butera", + "email": "nyamsprod@gmail.com", + "homepage": "https://nyamsprod.com" } ], - "description": "Mime-type detection for Flysystem", + "description": "Common interfaces and classes for URI representation and interaction", + "homepage": "https://uri.thephpleague.com", + "keywords": [ + "data-uri", + "file-uri", + "ftp", + "hostname", + "http", + "https", + "parse_str", + "parse_url", + "psr-7", + "query-string", + "querystring", + "rfc3986", + "rfc3987", + "rfc6570", + "uri", + "url", + "ws" + ], "support": { - "issues": "https://github.com/thephpleague/mime-type-detection/issues", - "source": "https://github.com/thephpleague/mime-type-detection/tree/1.15.0" + "docs": "https://uri.thephpleague.com", + "forum": "https://thephpleague.slack.com", + "issues": "https://github.com/thephpleague/uri-src/issues", + "source": "https://github.com/thephpleague/uri-interfaces/tree/7.4.1" }, "funding": [ { - "url": "https://github.com/frankdejonge", + "url": "https://github.com/sponsors/nyamsprod", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/league/flysystem", - "type": "tidelift" } ], - "time": "2024-01-28T23:22:08+00:00" + "time": "2024-03-23T07:42:40+00:00" }, { "name": "monolog/monolog", @@ -2333,6 +2992,201 @@ ], "time": "2024-03-06T16:17:14+00:00" }, + { + "name": "nyholm/psr7", + "version": "1.8.1", + "source": { + "type": "git", + "url": "https://github.com/Nyholm/psr7.git", + "reference": "aa5fc277a4f5508013d571341ade0c3886d4d00e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Nyholm/psr7/zipball/aa5fc277a4f5508013d571341ade0c3886d4d00e", + "reference": "aa5fc277a4f5508013d571341ade0c3886d4d00e", + "shasum": "" + }, + "require": { + "php": ">=7.2", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0" + }, + "provide": { + "php-http/message-factory-implementation": "1.0", + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "http-interop/http-factory-tests": "^0.9", + "php-http/message-factory": "^1.0", + "php-http/psr7-integration-tests": "^1.0", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.4", + "symfony/error-handler": "^4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8-dev" + } + }, + "autoload": { + "psr-4": { + "Nyholm\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com" + }, + { + "name": "Martijn van der Ven", + "email": "martijn@vanderven.se" + } + ], + "description": "A fast PHP7 implementation of PSR-7", + "homepage": "https://tnyholm.se", + "keywords": [ + "psr-17", + "psr-7" + ], + "support": { + "issues": "https://github.com/Nyholm/psr7/issues", + "source": "https://github.com/Nyholm/psr7/tree/1.8.1" + }, + "funding": [ + { + "url": "https://github.com/Zegnat", + "type": "github" + }, + { + "url": "https://github.com/nyholm", + "type": "github" + } + ], + "time": "2023-11-13T09:31:12+00:00" + }, + { + "name": "paragonie/constant_time_encoding", + "version": "v2.6.3", + "source": { + "type": "git", + "url": "https://github.com/paragonie/constant_time_encoding.git", + "reference": "58c3f47f650c94ec05a151692652a868995d2938" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/58c3f47f650c94ec05a151692652a868995d2938", + "reference": "58c3f47f650c94ec05a151692652a868995d2938", + "shasum": "" + }, + "require": { + "php": "^7|^8" + }, + "require-dev": { + "phpunit/phpunit": "^6|^7|^8|^9", + "vimeo/psalm": "^1|^2|^3|^4" + }, + "type": "library", + "autoload": { + "psr-4": { + "ParagonIE\\ConstantTime\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com", + "role": "Maintainer" + }, + { + "name": "Steve 'Sc00bz' Thomas", + "email": "steve@tobtu.com", + "homepage": "https://www.tobtu.com", + "role": "Original Developer" + } + ], + "description": "Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)", + "keywords": [ + "base16", + "base32", + "base32_decode", + "base32_encode", + "base64", + "base64_decode", + "base64_encode", + "bin2hex", + "encoding", + "hex", + "hex2bin", + "rfc4648" + ], + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/constant_time_encoding/issues", + "source": "https://github.com/paragonie/constant_time_encoding" + }, + "time": "2022-06-14T06:56:20+00:00" + }, + { + "name": "paragonie/random_compat", + "version": "v9.99.100", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a", + "shasum": "" + }, + "require": { + "php": ">= 7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/random_compat/issues", + "source": "https://github.com/paragonie/random_compat" + }, + "time": "2020-10-15T08:29:30+00:00" + }, { "name": "phpoption/phpoption", "version": "1.9.2", @@ -2408,6 +3262,116 @@ ], "time": "2023-11-12T21:59:55+00:00" }, + { + "name": "phpseclib/phpseclib", + "version": "3.0.37", + "source": { + "type": "git", + "url": "https://github.com/phpseclib/phpseclib.git", + "reference": "cfa2013d0f68c062055180dd4328cc8b9d1f30b8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/cfa2013d0f68c062055180dd4328cc8b9d1f30b8", + "reference": "cfa2013d0f68c062055180dd4328cc8b9d1f30b8", + "shasum": "" + }, + "require": { + "paragonie/constant_time_encoding": "^1|^2", + "paragonie/random_compat": "^1.4|^2.0|^9.99.99", + "php": ">=5.6.1" + }, + "require-dev": { + "phpunit/phpunit": "*" + }, + "suggest": { + "ext-dom": "Install the DOM extension to load XML formatted public keys.", + "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", + "ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.", + "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.", + "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations." + }, + "type": "library", + "autoload": { + "files": [ + "phpseclib/bootstrap.php" + ], + "psr-4": { + "phpseclib3\\": "phpseclib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jim Wigginton", + "email": "terrafrost@php.net", + "role": "Lead Developer" + }, + { + "name": "Patrick Monnerat", + "email": "pm@datasphere.ch", + "role": "Developer" + }, + { + "name": "Andreas Fischer", + "email": "bantu@phpbb.com", + "role": "Developer" + }, + { + "name": "Hans-Jürgen Petrich", + "email": "petrich@tronic-media.com", + "role": "Developer" + }, + { + "name": "Graham Campbell", + "email": "graham@alt-three.com", + "role": "Developer" + } + ], + "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.", + "homepage": "http://phpseclib.sourceforge.net", + "keywords": [ + "BigInteger", + "aes", + "asn.1", + "asn1", + "blowfish", + "crypto", + "cryptography", + "encryption", + "rsa", + "security", + "sftp", + "signature", + "signing", + "ssh", + "twofish", + "x.509", + "x509" + ], + "support": { + "issues": "https://github.com/phpseclib/phpseclib/issues", + "source": "https://github.com/phpseclib/phpseclib/tree/3.0.37" + }, + "funding": [ + { + "url": "https://github.com/terrafrost", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpseclib", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib", + "type": "tidelift" + } + ], + "time": "2024-03-03T02:14:58+00:00" + }, { "name": "psr/clock", "version": "1.0.0", @@ -4844,6 +5808,89 @@ ], "time": "2024-04-18T09:29:19+00:00" }, + { + "name": "symfony/psr-http-message-bridge", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/psr-http-message-bridge.git", + "reference": "727befd41438a8feb64066871d3656d8cbdcdbe2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/727befd41438a8feb64066871d3656d8cbdcdbe2", + "reference": "727befd41438a8feb64066871d3656d8cbdcdbe2", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "psr/http-message": "^1.0|^2.0", + "symfony/http-foundation": "^6.4|^7.0" + }, + "conflict": { + "php-http/discovery": "<1.15", + "symfony/http-kernel": "<6.4" + }, + "require-dev": { + "nyholm/psr7": "^1.1", + "php-http/discovery": "^1.15", + "psr/log": "^1.1.4|^2|^3", + "symfony/browser-kit": "^6.4|^7.0", + "symfony/config": "^6.4|^7.0", + "symfony/event-dispatcher": "^6.4|^7.0", + "symfony/framework-bundle": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0" + }, + "type": "symfony-bridge", + "autoload": { + "psr-4": { + "Symfony\\Bridge\\PsrHttpMessage\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "PSR HTTP message bridge", + "homepage": "https://symfony.com", + "keywords": [ + "http", + "http-message", + "psr-17", + "psr-7" + ], + "support": { + "source": "https://github.com/symfony/psr-http-message-bridge/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:29:19+00:00" + }, { "name": "symfony/routing", "version": "v7.0.7", diff --git a/config/auth.php b/config/auth.php index 0ba5d5d..d3c3651 100644 --- a/config/auth.php +++ b/config/auth.php @@ -40,6 +40,10 @@ 'driver' => 'session', 'provider' => 'users', ], + 'api' => [ + 'driver' => 'passport', + 'provider' => 'users', + ], ], /* diff --git a/config/passport.php b/config/passport.php new file mode 100644 index 0000000..972e4e1 --- /dev/null +++ b/config/passport.php @@ -0,0 +1,75 @@ + 'web', + + /* + |-------------------------------------------------------------------------- + | Encryption Keys + |-------------------------------------------------------------------------- + | + | Passport uses encryption keys while generating secure access tokens for + | your application. By default, the keys are stored as local files but + | can be set via environment variables when that is more convenient. + | + */ + + 'private_key' => env('PASSPORT_PRIVATE_KEY'), + + 'public_key' => env('PASSPORT_PUBLIC_KEY'), + + /* + |-------------------------------------------------------------------------- + | Passport Database Connection + |-------------------------------------------------------------------------- + | + | By default, Passport's models will utilize your application's default + | database connection. If you wish to use a different connection you + | may specify the configured name of the database connection here. + | + */ + + 'connection' => env('PASSPORT_CONNECTION'), + + /* + |-------------------------------------------------------------------------- + | Client UUIDs + |-------------------------------------------------------------------------- + | + | By default, Passport uses auto-incrementing primary keys when assigning + | IDs to clients. However, if Passport is installed using the provided + | --uuids switch, this will be set to "true" and UUIDs will be used. + | + */ + + 'client_uuids' => true, + + /* + |-------------------------------------------------------------------------- + | Personal Access Client + |-------------------------------------------------------------------------- + | + | If you enable client hashing, you should set the personal access client + | ID and unhashed secret within your environment file. The values will + | get used while issuing fresh personal access tokens to your users. + | + */ + + 'personal_access_client' => [ + 'id' => env('PASSPORT_PERSONAL_ACCESS_CLIENT_ID'), + 'secret' => env('PASSPORT_PERSONAL_ACCESS_CLIENT_SECRET'), + ], + +]; diff --git a/database/migrations/2024_05_06_090445_create_oauth_access_tokens_table.php b/database/migrations/2024_05_06_090445_create_oauth_access_tokens_table.php new file mode 100644 index 0000000..eef9c33 --- /dev/null +++ b/database/migrations/2024_05_06_090445_create_oauth_access_tokens_table.php @@ -0,0 +1,33 @@ +string('id', 100)->primary(); + $table->unsignedBigInteger('user_id')->nullable()->index(); + $table->uuid('client_id'); + $table->string('name')->nullable(); + $table->text('scopes')->nullable(); + $table->boolean('revoked'); + $table->timestamps(); + $table->dateTime('expires_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_access_tokens'); + } +}; diff --git a/database/migrations/2024_05_06_090446_create_oauth_personal_access_clients_table.php b/database/migrations/2024_05_06_090446_create_oauth_personal_access_clients_table.php new file mode 100644 index 0000000..15398c9 --- /dev/null +++ b/database/migrations/2024_05_06_090446_create_oauth_personal_access_clients_table.php @@ -0,0 +1,28 @@ +bigIncrements('id'); + $table->uuid('client_id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_personal_access_clients'); + } +}; diff --git a/database/migrations/2024_05_06_090447_create_oauth_clients_table.php b/database/migrations/2024_05_06_090447_create_oauth_clients_table.php new file mode 100644 index 0000000..8e437ea --- /dev/null +++ b/database/migrations/2024_05_06_090447_create_oauth_clients_table.php @@ -0,0 +1,35 @@ +uuid('id')->primary(); + $table->unsignedBigInteger('user_id')->nullable()->index(); + $table->string('name'); + $table->string('secret', 100)->nullable(); + $table->string('provider')->nullable(); + $table->text('redirect'); + $table->boolean('personal_access_client'); + $table->boolean('password_client'); + $table->boolean('revoked'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_clients'); + } +}; diff --git a/database/migrations/2024_05_06_090448_create_oauth_refresh_tokens_table.php b/database/migrations/2024_05_06_090448_create_oauth_refresh_tokens_table.php new file mode 100644 index 0000000..b007904 --- /dev/null +++ b/database/migrations/2024_05_06_090448_create_oauth_refresh_tokens_table.php @@ -0,0 +1,29 @@ +string('id', 100)->primary(); + $table->string('access_token_id', 100)->index(); + $table->boolean('revoked'); + $table->dateTime('expires_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_refresh_tokens'); + } +}; diff --git a/database/migrations/2024_05_06_090449_create_oauth_auth_codes_table.php b/database/migrations/2024_05_06_090449_create_oauth_auth_codes_table.php new file mode 100644 index 0000000..247a167 --- /dev/null +++ b/database/migrations/2024_05_06_090449_create_oauth_auth_codes_table.php @@ -0,0 +1,31 @@ +string('id', 100)->primary(); + $table->unsignedBigInteger('user_id')->index(); + $table->uuid('client_id'); + $table->text('scopes')->nullable(); + $table->boolean('revoked'); + $table->dateTime('expires_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_auth_codes'); + } +}; diff --git a/database/migrations/2024_05_06_102719_create_oauth_access_tokens_table.php b/database/migrations/2024_05_06_102719_create_oauth_access_tokens_table.php new file mode 100644 index 0000000..598798e --- /dev/null +++ b/database/migrations/2024_05_06_102719_create_oauth_access_tokens_table.php @@ -0,0 +1,33 @@ +string('id', 100)->primary(); + $table->unsignedBigInteger('user_id')->nullable()->index(); + $table->unsignedBigInteger('client_id'); + $table->string('name')->nullable(); + $table->text('scopes')->nullable(); + $table->boolean('revoked'); + $table->timestamps(); + $table->dateTime('expires_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_access_tokens'); + } +}; diff --git a/database/migrations/2024_05_06_102720_create_oauth_personal_access_clients_table.php b/database/migrations/2024_05_06_102720_create_oauth_personal_access_clients_table.php new file mode 100644 index 0000000..7c9d1e8 --- /dev/null +++ b/database/migrations/2024_05_06_102720_create_oauth_personal_access_clients_table.php @@ -0,0 +1,28 @@ +bigIncrements('id'); + $table->unsignedBigInteger('client_id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_personal_access_clients'); + } +}; diff --git a/database/migrations/2024_05_06_102721_create_oauth_clients_table.php b/database/migrations/2024_05_06_102721_create_oauth_clients_table.php new file mode 100644 index 0000000..776ccfa --- /dev/null +++ b/database/migrations/2024_05_06_102721_create_oauth_clients_table.php @@ -0,0 +1,35 @@ +bigIncrements('id'); + $table->unsignedBigInteger('user_id')->nullable()->index(); + $table->string('name'); + $table->string('secret', 100)->nullable(); + $table->string('provider')->nullable(); + $table->text('redirect'); + $table->boolean('personal_access_client'); + $table->boolean('password_client'); + $table->boolean('revoked'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_clients'); + } +}; diff --git a/database/migrations/2024_05_06_102722_create_oauth_refresh_tokens_table.php b/database/migrations/2024_05_06_102722_create_oauth_refresh_tokens_table.php new file mode 100644 index 0000000..b007904 --- /dev/null +++ b/database/migrations/2024_05_06_102722_create_oauth_refresh_tokens_table.php @@ -0,0 +1,29 @@ +string('id', 100)->primary(); + $table->string('access_token_id', 100)->index(); + $table->boolean('revoked'); + $table->dateTime('expires_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_refresh_tokens'); + } +}; diff --git a/database/migrations/2024_05_06_102723_create_oauth_auth_codes_table.php b/database/migrations/2024_05_06_102723_create_oauth_auth_codes_table.php new file mode 100644 index 0000000..7b93b40 --- /dev/null +++ b/database/migrations/2024_05_06_102723_create_oauth_auth_codes_table.php @@ -0,0 +1,31 @@ +string('id', 100)->primary(); + $table->unsignedBigInteger('user_id')->index(); + $table->unsignedBigInteger('client_id'); + $table->text('scopes')->nullable(); + $table->boolean('revoked'); + $table->dateTime('expires_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_auth_codes'); + } +}; diff --git a/routes/api.php b/routes/api.php new file mode 100644 index 0000000..b5ef24b --- /dev/null +++ b/routes/api.php @@ -0,0 +1,12 @@ +user(); +})->middleware('auth:api'); + +Route::post('/register', [AuthController::class, 'register']); + From 24dcd7fd62865a057eaebdbb07b6b7b407cc0e79 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 7 May 2024 09:01:20 +0200 Subject: [PATCH 003/115] update --- .env.example | 4 ++ app/Http/Controllers/Auth/AuthController.php | 41 +++++++++---------- app/Http/Requests/RegisterRequest.php | 9 ++-- app/Providers/AppServiceProvider.php | 2 +- config/database.php | 14 +++++++ ...02719_create_oauth_access_tokens_table.php | 33 --------------- ...te_oauth_personal_access_clients_table.php | 28 ------------- ...5_06_102721_create_oauth_clients_table.php | 35 ---------------- ...2722_create_oauth_refresh_tokens_table.php | 29 ------------- ...6_102723_create_oauth_auth_codes_table.php | 31 -------------- ...3933_create_oauth_access_tokens_table.php} | 0 ...e_oauth_personal_access_clients_table.php} | 0 ..._07_063935_create_oauth_clients_table.php} | 0 ...936_create_oauth_refresh_tokens_table.php} | 0 ..._063937_create_oauth_auth_codes_table.php} | 0 routes/api.php | 2 +- 16 files changed, 46 insertions(+), 182 deletions(-) delete mode 100644 database/migrations/2024_05_06_102719_create_oauth_access_tokens_table.php delete mode 100644 database/migrations/2024_05_06_102720_create_oauth_personal_access_clients_table.php delete mode 100644 database/migrations/2024_05_06_102721_create_oauth_clients_table.php delete mode 100644 database/migrations/2024_05_06_102722_create_oauth_refresh_tokens_table.php delete mode 100644 database/migrations/2024_05_06_102723_create_oauth_auth_codes_table.php rename database/migrations/{2024_05_06_090445_create_oauth_access_tokens_table.php => 2024_05_07_063933_create_oauth_access_tokens_table.php} (100%) rename database/migrations/{2024_05_06_090446_create_oauth_personal_access_clients_table.php => 2024_05_07_063934_create_oauth_personal_access_clients_table.php} (100%) rename database/migrations/{2024_05_06_090447_create_oauth_clients_table.php => 2024_05_07_063935_create_oauth_clients_table.php} (100%) rename database/migrations/{2024_05_06_090448_create_oauth_refresh_tokens_table.php => 2024_05_07_063936_create_oauth_refresh_tokens_table.php} (100%) rename database/migrations/{2024_05_06_090449_create_oauth_auth_codes_table.php => 2024_05_07_063937_create_oauth_auth_codes_table.php} (100%) diff --git a/.env.example b/.env.example index 7b49625..76c50e1 100644 --- a/.env.example +++ b/.env.example @@ -62,3 +62,7 @@ AWS_BUCKET= AWS_USE_PATH_STYLE_ENDPOINT=false VITE_APP_NAME="${APP_NAME}" + +PASSPORT_PERSONAL_ACCESS_CLIENT_ID="" +PASSPORT_SECRET="" +PASSPORT_TOKEN_NAME="" \ No newline at end of file diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 3135465..1d2f393 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -3,31 +3,30 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; +use App\Http\Requests\RegisterRequest; use App\Models\User; -use Illuminate\Http\Request; class AuthController extends Controller { - public function register(Request $request) + public function register(RegisterRequest $request) { - - $validatedData = $request->validate([ - 'name' => 'required|string|max:255', - 'email' => 'required|string|email|max:255|unique:users', - 'password' => 'required|string|min:8', - ]); - - - $user = User::create([ - 'name' => $request['name'], - 'email' => $validatedData['email'], - 'password' => bcrypt($request['password']), - ]); - - $token = $user->createToken(env('PASSPORT_PERSONAL_ACCESS_CLIENT_ID'))->accessToken; - - \Log::info('Token generated', ['token' => $token]); - - return response()->json(['token' => $token]); + try { + $user = User::create([ + 'name' => $request['name'], + 'email' => $request['email'], + 'password' => bcrypt($request['password']), + ]); + + $token = $user->createToken(env('PASSPORT_TOKEN_NAME'))->accessToken; + + return response()->json(['token' => $token],201); + } catch (\Exception $e) { + dd($e); + // Log the error internally + \Log::error($e); + + // Return a JSON response with the error message and a 500 status code + return response()->json(['error' => 'An error occurred while registering the user. Please try again later.'.$e], 500); } } +} diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index f6fd6fe..923896e 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -11,7 +11,7 @@ class RegisterRequest extends FormRequest */ public function authorize(): bool { - return false; + return true; } /** @@ -22,7 +22,10 @@ public function authorize(): bool public function rules(): array { return [ - // + 'name' => 'required|string|max:255', + 'email' => 'required|string|email|max:255|unique:users', + 'password' => 'required|string|min:8', ]; } -} + + } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 6ff5a72..ae8aee0 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -25,6 +25,6 @@ public function register(): void */ public function boot(): void { - + } } diff --git a/config/database.php b/config/database.php index f8e8dcb..9aab6cc 100644 --- a/config/database.php +++ b/config/database.php @@ -108,6 +108,20 @@ // 'encrypt' => env('DB_ENCRYPT', 'yes'), // 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'), ], + 'mysql_testing' => [ + 'driver' => 'mysql', + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '3306'), + 'database' => env('DB_DATABASE', 'laravel_testing'), + 'username' => env('DB_USERNAME', 'root'), + 'password' => env('DB_PASSWORD', ''), + 'unix_socket' => env('DB_SOCKET', ''), + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'prefix' => '', + 'strict' => true, + 'engine' => null, + ] ], diff --git a/database/migrations/2024_05_06_102719_create_oauth_access_tokens_table.php b/database/migrations/2024_05_06_102719_create_oauth_access_tokens_table.php deleted file mode 100644 index 598798e..0000000 --- a/database/migrations/2024_05_06_102719_create_oauth_access_tokens_table.php +++ /dev/null @@ -1,33 +0,0 @@ -string('id', 100)->primary(); - $table->unsignedBigInteger('user_id')->nullable()->index(); - $table->unsignedBigInteger('client_id'); - $table->string('name')->nullable(); - $table->text('scopes')->nullable(); - $table->boolean('revoked'); - $table->timestamps(); - $table->dateTime('expires_at')->nullable(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('oauth_access_tokens'); - } -}; diff --git a/database/migrations/2024_05_06_102720_create_oauth_personal_access_clients_table.php b/database/migrations/2024_05_06_102720_create_oauth_personal_access_clients_table.php deleted file mode 100644 index 7c9d1e8..0000000 --- a/database/migrations/2024_05_06_102720_create_oauth_personal_access_clients_table.php +++ /dev/null @@ -1,28 +0,0 @@ -bigIncrements('id'); - $table->unsignedBigInteger('client_id'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('oauth_personal_access_clients'); - } -}; diff --git a/database/migrations/2024_05_06_102721_create_oauth_clients_table.php b/database/migrations/2024_05_06_102721_create_oauth_clients_table.php deleted file mode 100644 index 776ccfa..0000000 --- a/database/migrations/2024_05_06_102721_create_oauth_clients_table.php +++ /dev/null @@ -1,35 +0,0 @@ -bigIncrements('id'); - $table->unsignedBigInteger('user_id')->nullable()->index(); - $table->string('name'); - $table->string('secret', 100)->nullable(); - $table->string('provider')->nullable(); - $table->text('redirect'); - $table->boolean('personal_access_client'); - $table->boolean('password_client'); - $table->boolean('revoked'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('oauth_clients'); - } -}; diff --git a/database/migrations/2024_05_06_102722_create_oauth_refresh_tokens_table.php b/database/migrations/2024_05_06_102722_create_oauth_refresh_tokens_table.php deleted file mode 100644 index b007904..0000000 --- a/database/migrations/2024_05_06_102722_create_oauth_refresh_tokens_table.php +++ /dev/null @@ -1,29 +0,0 @@ -string('id', 100)->primary(); - $table->string('access_token_id', 100)->index(); - $table->boolean('revoked'); - $table->dateTime('expires_at')->nullable(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('oauth_refresh_tokens'); - } -}; diff --git a/database/migrations/2024_05_06_102723_create_oauth_auth_codes_table.php b/database/migrations/2024_05_06_102723_create_oauth_auth_codes_table.php deleted file mode 100644 index 7b93b40..0000000 --- a/database/migrations/2024_05_06_102723_create_oauth_auth_codes_table.php +++ /dev/null @@ -1,31 +0,0 @@ -string('id', 100)->primary(); - $table->unsignedBigInteger('user_id')->index(); - $table->unsignedBigInteger('client_id'); - $table->text('scopes')->nullable(); - $table->boolean('revoked'); - $table->dateTime('expires_at')->nullable(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('oauth_auth_codes'); - } -}; diff --git a/database/migrations/2024_05_06_090445_create_oauth_access_tokens_table.php b/database/migrations/2024_05_07_063933_create_oauth_access_tokens_table.php similarity index 100% rename from database/migrations/2024_05_06_090445_create_oauth_access_tokens_table.php rename to database/migrations/2024_05_07_063933_create_oauth_access_tokens_table.php diff --git a/database/migrations/2024_05_06_090446_create_oauth_personal_access_clients_table.php b/database/migrations/2024_05_07_063934_create_oauth_personal_access_clients_table.php similarity index 100% rename from database/migrations/2024_05_06_090446_create_oauth_personal_access_clients_table.php rename to database/migrations/2024_05_07_063934_create_oauth_personal_access_clients_table.php diff --git a/database/migrations/2024_05_06_090447_create_oauth_clients_table.php b/database/migrations/2024_05_07_063935_create_oauth_clients_table.php similarity index 100% rename from database/migrations/2024_05_06_090447_create_oauth_clients_table.php rename to database/migrations/2024_05_07_063935_create_oauth_clients_table.php diff --git a/database/migrations/2024_05_06_090448_create_oauth_refresh_tokens_table.php b/database/migrations/2024_05_07_063936_create_oauth_refresh_tokens_table.php similarity index 100% rename from database/migrations/2024_05_06_090448_create_oauth_refresh_tokens_table.php rename to database/migrations/2024_05_07_063936_create_oauth_refresh_tokens_table.php diff --git a/database/migrations/2024_05_06_090449_create_oauth_auth_codes_table.php b/database/migrations/2024_05_07_063937_create_oauth_auth_codes_table.php similarity index 100% rename from database/migrations/2024_05_06_090449_create_oauth_auth_codes_table.php rename to database/migrations/2024_05_07_063937_create_oauth_auth_codes_table.php diff --git a/routes/api.php b/routes/api.php index b5ef24b..7d0261a 100644 --- a/routes/api.php +++ b/routes/api.php @@ -8,5 +8,5 @@ return $request->user(); })->middleware('auth:api'); -Route::post('/register', [AuthController::class, 'register']); +Route::post('/register', [AuthController::class, 'register'])->name('api.register'); From b7a30b5c3be92bc63417f509e2da8826afa23a95 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 7 May 2024 09:21:54 +0200 Subject: [PATCH 004/115] permission added --- app/Models/Permission.php | 13 ++ app/Models/Role.php | 14 ++ app/Models/User.php | 3 +- composer.json | 3 +- composer.lock | 84 +++++++- config/permission.php | 186 ++++++++++++++++++ ..._05_07_070437_create_permission_tables.php | 138 +++++++++++++ 7 files changed, 438 insertions(+), 3 deletions(-) create mode 100644 app/Models/Permission.php create mode 100644 app/Models/Role.php create mode 100644 config/permission.php create mode 100644 database/migrations/2024_05_07_070437_create_permission_tables.php diff --git a/app/Models/Permission.php b/app/Models/Permission.php new file mode 100644 index 0000000..3612b5c --- /dev/null +++ b/app/Models/Permission.php @@ -0,0 +1,13 @@ + [ + + /* + * When using the "HasPermissions" trait from this package, we need to know which + * Eloquent model should be used to retrieve your permissions. Of course, it + * is often just the "Permission" model but you may use whatever you like. + * + * The model you want to use as a Permission model needs to implement the + * `Spatie\Permission\Contracts\Permission` contract. + */ + + 'permission' => App\Models\Permission::class, + + /* + * When using the "HasRoles" trait from this package, we need to know which + * Eloquent model should be used to retrieve your roles. Of course, it + * is often just the "Role" model but you may use whatever you like. + * + * The model you want to use as a Role model needs to implement the + * `Spatie\Permission\Contracts\Role` contract. + */ + + 'role' => App\Models\Role::class, + + ], + + 'table_names' => [ + + /* + * When using the "HasRoles" trait from this package, we need to know which + * table should be used to retrieve your roles. We have chosen a basic + * default value but you may easily change it to any table you like. + */ + + 'roles' => 'roles', + + /* + * When using the "HasPermissions" trait from this package, we need to know which + * table should be used to retrieve your permissions. We have chosen a basic + * default value but you may easily change it to any table you like. + */ + + 'permissions' => 'permissions', + + /* + * When using the "HasPermissions" trait from this package, we need to know which + * table should be used to retrieve your models permissions. We have chosen a + * basic default value but you may easily change it to any table you like. + */ + + 'model_has_permissions' => 'model_has_permissions', + + /* + * When using the "HasRoles" trait from this package, we need to know which + * table should be used to retrieve your models roles. We have chosen a + * basic default value but you may easily change it to any table you like. + */ + + 'model_has_roles' => 'model_has_roles', + + /* + * When using the "HasRoles" trait from this package, we need to know which + * table should be used to retrieve your roles permissions. We have chosen a + * basic default value but you may easily change it to any table you like. + */ + + 'role_has_permissions' => 'role_has_permissions', + ], + + 'column_names' => [ + /* + * Change this if you want to name the related pivots other than defaults + */ + 'role_pivot_key' => null, //default 'role_id', + 'permission_pivot_key' => null, //default 'permission_id', + + /* + * Change this if you want to name the related model primary key other than + * `model_id`. + * + * For example, this would be nice if your primary keys are all UUIDs. In + * that case, name this `model_uuid`. + */ + + 'model_morph_key' => 'model_uuid', + + /* + * Change this if you want to use the teams feature and your related model's + * foreign key is other than `team_id`. + */ + + 'team_foreign_key' => 'team_id', + ], + + /* + * When set to true, the method for checking permissions will be registered on the gate. + * Set this to false if you want to implement custom logic for checking permissions. + */ + + 'register_permission_check_method' => true, + + /* + * When set to true, Laravel\Octane\Events\OperationTerminated event listener will be registered + * this will refresh permissions on every TickTerminated, TaskTerminated and RequestTerminated + * NOTE: This should not be needed in most cases, but an Octane/Vapor combination benefited from it. + */ + 'register_octane_reset_listener' => false, + + /* + * Teams Feature. + * When set to true the package implements teams using the 'team_foreign_key'. + * If you want the migrations to register the 'team_foreign_key', you must + * set this to true before doing the migration. + * If you already did the migration then you must make a new migration to also + * add 'team_foreign_key' to 'roles', 'model_has_roles', and 'model_has_permissions' + * (view the latest version of this package's migration file) + */ + + 'teams' => false, + + /* + * Passport Client Credentials Grant + * When set to true the package will use Passports Client to check permissions + */ + + 'use_passport_client_credentials' => false, + + /* + * When set to true, the required permission names are added to exception messages. + * This could be considered an information leak in some contexts, so the default + * setting is false here for optimum safety. + */ + + 'display_permission_in_exception' => false, + + /* + * When set to true, the required role names are added to exception messages. + * This could be considered an information leak in some contexts, so the default + * setting is false here for optimum safety. + */ + + 'display_role_in_exception' => false, + + /* + * By default wildcard permission lookups are disabled. + * See documentation to understand supported syntax. + */ + + 'enable_wildcard_permission' => false, + + /* + * The class to use for interpreting wildcard permissions. + * If you need to modify delimiters, override the class and specify its name here. + */ + // 'permission.wildcard_permission' => Spatie\Permission\WildcardPermission::class, + + /* Cache-specific settings */ + + 'cache' => [ + + /* + * By default all permissions are cached for 24 hours to speed up performance. + * When permissions or roles are updated the cache is flushed automatically. + */ + + 'expiration_time' => \DateInterval::createFromDateString('24 hours'), + + /* + * The cache key used to store all permissions. + */ + + 'key' => 'spatie.permission.cache', + + /* + * You may optionally indicate a specific cache driver to use for permission and + * role caching using any of the `store` drivers listed in the cache.php config + * file. Using 'default' here means to use the `default` set in cache.php. + */ + + 'store' => 'default', + ], +]; diff --git a/database/migrations/2024_05_07_070437_create_permission_tables.php b/database/migrations/2024_05_07_070437_create_permission_tables.php new file mode 100644 index 0000000..dd12efb --- /dev/null +++ b/database/migrations/2024_05_07_070437_create_permission_tables.php @@ -0,0 +1,138 @@ +uuid('uuid')->primary()->unique(); // permission id + $table->string('name'); // For MySQL 8.0 use string('name', 125); + $table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125); + $table->timestamps(); + + $table->unique(['name', 'guard_name']); + }); + + Schema::create($tableNames['roles'], function (Blueprint $table) use ($teams, $columnNames) { + $table->uuid('uuid')->primary()->unique(); // role id + if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing + $table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable(); + $table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index'); + } + $table->string('name'); // For MySQL 8.0 use string('name', 125); + $table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125); + $table->timestamps(); + if ($teams || config('permission.testing')) { + $table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']); + } else { + $table->unique(['name', 'guard_name']); + } + }); + + Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) { + $table->uuid($pivotPermission); + + $table->string('model_type'); + $table->uuid($columnNames['model_morph_key']); + $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index'); + + $table->foreign($pivotPermission) + ->references('uuid') // permission id + ->on($tableNames['permissions']) + ->onDelete('cascade'); + if ($teams) { + $table->unsignedBigInteger($columnNames['team_foreign_key']); + $table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index'); + + $table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'], + 'model_has_permissions_permission_model_type_primary'); + } else { + $table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'], + 'model_has_permissions_permission_model_type_primary'); + } + + }); + + Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) { + $table->uuid($pivotRole); + + $table->string('model_type'); + $table->unsignedBigInteger($columnNames['model_morph_key']); + $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index'); + + $table->foreign($pivotRole) + ->references('uuid') // role id + ->on($tableNames['roles']) + ->onDelete('cascade'); + if ($teams) { + $table->unsignedBigInteger($columnNames['team_foreign_key']); + $table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index'); + + $table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'], + 'model_has_roles_role_model_type_primary'); + } else { + $table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'], + 'model_has_roles_role_model_type_primary'); + } + }); + + Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) { + $table->uuid($pivotPermission); + $table->uuid($pivotRole); + + $table->foreign($pivotPermission) + ->references('uuid') // permission id + ->on($tableNames['permissions']) + ->onDelete('cascade'); + + $table->foreign($pivotRole) + ->references('uuid') // role id + ->on($tableNames['roles']) + ->onDelete('cascade'); + + $table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary'); + }); + + app('cache') + ->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null) + ->forget(config('permission.cache.key')); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + $tableNames = config('permission.table_names'); + + if (empty($tableNames)) { + throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.'); + } + + Schema::drop($tableNames['role_has_permissions']); + Schema::drop($tableNames['model_has_roles']); + Schema::drop($tableNames['model_has_permissions']); + Schema::drop($tableNames['roles']); + Schema::drop($tableNames['permissions']); + } +}; From 92beb580b5f01a13e1577e6ef58040b13e59c58c Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 7 May 2024 11:44:36 +0200 Subject: [PATCH 005/115] auth server added --- app/Http/Controllers/Auth/AuthController.php | 54 +++++++++++++------- app/Http/Requests/LoginRequest.php | 29 +++++++++++ app/Providers/AppServiceProvider.php | 10 +++- app/Services/UserService.php | 40 +++++++++++++++ routes/api.php | 2 + 5 files changed, 115 insertions(+), 20 deletions(-) create mode 100644 app/Http/Requests/LoginRequest.php create mode 100644 app/Services/UserService.php diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 1d2f393..b92278a 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -3,30 +3,48 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; +use App\Http\Requests\LoginRequest; use App\Http\Requests\RegisterRequest; -use App\Models\User; +use App\Services\UserService; + class AuthController extends Controller { + + protected $userService; + + public function __construct(UserService $userService) + { + $this->userService = $userService; + } public function register(RegisterRequest $request) { - try { - $user = User::create([ - 'name' => $request['name'], - 'email' => $request['email'], - 'password' => bcrypt($request['password']), - ]); - - $token = $user->createToken(env('PASSPORT_TOKEN_NAME'))->accessToken; - - return response()->json(['token' => $token],201); - } catch (\Exception $e) { - dd($e); - // Log the error internally - \Log::error($e); + try { + $user = $this->userService->createUser($request->validated()); + $user->makeHidden(['created_at', 'updated_at']); + return response()->json(['user' => $user], 201); + } catch (\Exception $e) { + // Log the error internally + \Log::error($e); + // Return a JSON response with the error message and a 500 status code + return response()->json(['error' => 'An error occurred while registering the user. Please try again later.' . $e], 500); + } + } - // Return a JSON response with the error message and a 500 status code - return response()->json(['error' => 'An error occurred while registering the user. Please try again later.'.$e], 500); + public function login(LoginRequest $request) + { + try { + $user = $this->userService->getUser($request->only('email', 'password')); + if($user){ + $user->makeHidden(['created_at', 'updated_at']); + return response()->json(['user' => $user], 201); + } + return response()->json(['error' => 'Unauthorized'], 401); + } catch (\Exception $e) { + // Handle general errors + \Log::error($e->getMessage()); + return response()->json(['error' => 'Server error occurred. Please try again later.'], 500); + } + } } -} diff --git a/app/Http/Requests/LoginRequest.php b/app/Http/Requests/LoginRequest.php new file mode 100644 index 0000000..4aae55a --- /dev/null +++ b/app/Http/Requests/LoginRequest.php @@ -0,0 +1,29 @@ +|string> + */ + public function rules(): array + { + return [ + 'email' => 'required|string|email|max:255', + 'password' => 'required|string|min:6', + ]; + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index ae8aee0..caf1561 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use App\Services\UserService; use Illuminate\Support\ServiceProvider; use Laravel\Passport\AuthCode; use Laravel\Passport\Client; @@ -17,7 +18,12 @@ class AppServiceProvider extends ServiceProvider */ public function register(): void { - // + $this->app->singleton(UserService::class, function ($app) { + return new UserService( + $app->make(\Illuminate\Contracts\Auth\Guard::class), + $app->make(\Illuminate\Contracts\Hashing\Hasher::class) + ); + }); } /** @@ -25,6 +31,6 @@ public function register(): void */ public function boot(): void { - + } } diff --git a/app/Services/UserService.php b/app/Services/UserService.php new file mode 100644 index 0000000..0c4340e --- /dev/null +++ b/app/Services/UserService.php @@ -0,0 +1,40 @@ +auth = $auth; + $this->hasher = $hasher; + } + + public function createUser(array $data) + { + $user = User::create([ + 'name' => $data['name'], + 'email' => $data['email'], + 'password' => $this->hasher->make($data['password']) + ]); + + $user->token = $user->createToken(env('PASSPORT_TOKEN_NAME'))->accessToken; + return $user; + } + + public function getUser(array $data) + { + $this->auth->attempt($data);; + $user = $this->auth->user(); + $user->token = $user->createToken(env('PASSPORT_TOKEN_NAME'))->accessToken; + return $user; + } +} diff --git a/routes/api.php b/routes/api.php index 7d0261a..ee26757 100644 --- a/routes/api.php +++ b/routes/api.php @@ -9,4 +9,6 @@ })->middleware('auth:api'); Route::post('/register', [AuthController::class, 'register'])->name('api.register'); +Route::post('/login', [AuthController::class, 'login'])->name('api.login'); + From 8987848728b990998eb6c2cd69112b8ffd670649 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 7 May 2024 21:51:00 +0200 Subject: [PATCH 006/115] update --- app/Http/Controllers/Auth/AuthController.php | 10 ++++++ .../Controllers/User/UserUpdateController.php | 35 +++++++++++++++++++ app/Models/User.php | 3 +- app/Services/UserService.php | 26 ++++++++++++-- .../0001_01_01_000000_create_users_table.php | 4 +-- ...63933_create_oauth_access_tokens_table.php | 2 +- ...5_07_063935_create_oauth_clients_table.php | 2 +- ...7_063937_create_oauth_auth_codes_table.php | 2 +- routes/api.php | 7 +--- 9 files changed, 76 insertions(+), 15 deletions(-) create mode 100644 app/Http/Controllers/User/UserUpdateController.php diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index b92278a..95d078b 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -47,4 +47,14 @@ public function login(LoginRequest $request) } } + + public function update(RegisterRequest $request) + { + return "hola"; + $data = $request->all(); + + $updatedUser = $this->userService->updateUser($data); + + return $updatedUser; + } } diff --git a/app/Http/Controllers/User/UserUpdateController.php b/app/Http/Controllers/User/UserUpdateController.php new file mode 100644 index 0000000..3f003b1 --- /dev/null +++ b/app/Http/Controllers/User/UserUpdateController.php @@ -0,0 +1,35 @@ +userService = $userService; + } + + public function updateUser($userId, array $userData) + { + try { + // Call the UserService method to update the user + $user = $this->userService->updateUser($userId, $userData); + + // Return a JSON response with the updated user data + return response()->json(['user' => $user], 200); + } catch (\Exception $e) { + // Log the error internally + \Log::error($e); + // Return a JSON response with the error message and a 500 status code + return response()->json(['error' => 'An error occurred while updating the user. Please try again later.'], 500); + } + } +} diff --git a/app/Models/User.php b/app/Models/User.php index 58b1b3a..d0bb685 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -12,13 +12,14 @@ class User extends Authenticatable { use HasApiTokens,HasFactory, Notifiable, HasRoles; - + protected $primaryKey = 'uuid'; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ + 'uuid', 'name', 'email', 'password', diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 0c4340e..46417ef 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -5,6 +5,7 @@ use App\Models\User; use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Hashing\Hasher; +use Ramsey\Uuid\Uuid; class UserService { @@ -17,23 +18,42 @@ public function __construct(Guard $auth, Hasher $hasher) $this->auth = $auth; $this->hasher = $hasher; } - + public function createUser(array $data) { + // Generate a UUID + $uuid = Uuid::uuid4(); + + // Create the user with the UUID $user = User::create([ + 'uuid' => $uuid, 'name' => $data['name'], 'email' => $data['email'], 'password' => $this->hasher->make($data['password']) ]); - $user->token = $user->createToken(env('PASSPORT_TOKEN_NAME'))->accessToken; + $user->token = $user->createToken('ximdex')->accessToken; return $user; } public function getUser(array $data) { - $this->auth->attempt($data);; + $this->auth->attempt($data); + $user = $this->auth->user(); + $user->token = $user->createToken(env('PASSPORT_TOKEN_NAME'))->accessToken; + return $user; + } + + public function updateUser(array $data) + { + $this->auth->attempt($data); $user = $this->auth->user(); + $user->update([ + 'name' => $data['name'], + 'email' => $data['email'], + 'password' => $this->hasher->make($data['password']) + ]); + $user->token = $user->createToken(env('PASSPORT_TOKEN_NAME'))->accessToken; return $user; } diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php index 05fb5d9..115a346 100644 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -12,7 +12,7 @@ public function up(): void { Schema::create('users', function (Blueprint $table) { - $table->id(); + $table->uuid('uuid')->primary()->default(Str::uuid()); $table->string('name'); $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); @@ -29,7 +29,7 @@ public function up(): void Schema::create('sessions', function (Blueprint $table) { $table->string('id')->primary(); - $table->foreignId('user_id')->nullable()->index(); + $table->foreignUuid('user_id')->nullable()->index(); $table->string('ip_address', 45)->nullable(); $table->text('user_agent')->nullable(); $table->longText('payload'); diff --git a/database/migrations/2024_05_07_063933_create_oauth_access_tokens_table.php b/database/migrations/2024_05_07_063933_create_oauth_access_tokens_table.php index eef9c33..2be48c4 100644 --- a/database/migrations/2024_05_07_063933_create_oauth_access_tokens_table.php +++ b/database/migrations/2024_05_07_063933_create_oauth_access_tokens_table.php @@ -13,7 +13,7 @@ public function up(): void { Schema::create('oauth_access_tokens', function (Blueprint $table) { $table->string('id', 100)->primary(); - $table->unsignedBigInteger('user_id')->nullable()->index(); + $table->uuid('user_id')->nullable()->index(); $table->uuid('client_id'); $table->string('name')->nullable(); $table->text('scopes')->nullable(); diff --git a/database/migrations/2024_05_07_063935_create_oauth_clients_table.php b/database/migrations/2024_05_07_063935_create_oauth_clients_table.php index 8e437ea..48e674e 100644 --- a/database/migrations/2024_05_07_063935_create_oauth_clients_table.php +++ b/database/migrations/2024_05_07_063935_create_oauth_clients_table.php @@ -13,7 +13,7 @@ public function up(): void { Schema::create('oauth_clients', function (Blueprint $table) { $table->uuid('id')->primary(); - $table->unsignedBigInteger('user_id')->nullable()->index(); + $table->uuid('user_id')->nullable()->index(); $table->string('name'); $table->string('secret', 100)->nullable(); $table->string('provider')->nullable(); diff --git a/database/migrations/2024_05_07_063937_create_oauth_auth_codes_table.php b/database/migrations/2024_05_07_063937_create_oauth_auth_codes_table.php index 247a167..3449598 100644 --- a/database/migrations/2024_05_07_063937_create_oauth_auth_codes_table.php +++ b/database/migrations/2024_05_07_063937_create_oauth_auth_codes_table.php @@ -13,7 +13,7 @@ public function up(): void { Schema::create('oauth_auth_codes', function (Blueprint $table) { $table->string('id', 100)->primary(); - $table->unsignedBigInteger('user_id')->index(); + $table->uuid('user_id')->index(); $table->uuid('client_id'); $table->text('scopes')->nullable(); $table->boolean('revoked'); diff --git a/routes/api.php b/routes/api.php index ee26757..122f57a 100644 --- a/routes/api.php +++ b/routes/api.php @@ -4,11 +4,6 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; -Route::get('/user', function (Request $request) { - return $request->user(); -})->middleware('auth:api'); - Route::post('/register', [AuthController::class, 'register'])->name('api.register'); Route::post('/login', [AuthController::class, 'login'])->name('api.login'); - - +Route::post('/user/update',[AuthController::class,'update'])->name('api.userupdate')->middleware('auth:api'); \ No newline at end of file From 18e7f184e09dd3b6373c320aee713ee0b26e4298 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Wed, 8 May 2024 09:00:14 +0200 Subject: [PATCH 007/115] userUpdate, updated --- app/Http/Controllers/Auth/AuthController.php | 28 ++++++++-- app/Models/User.php | 4 ++ app/Services/UserService.php | 56 ++++++++++++++++--- ...4759_create_oauth_access_tokens_table.php} | 0 ...e_oauth_personal_access_clients_table.php} | 0 ..._08_044801_create_oauth_clients_table.php} | 0 ...802_create_oauth_refresh_tokens_table.php} | 0 ..._044803_create_oauth_auth_codes_table.php} | 0 routes/api.php | 3 +- 9 files changed, 74 insertions(+), 17 deletions(-) rename database/migrations/{2024_05_07_063933_create_oauth_access_tokens_table.php => 2024_05_08_044759_create_oauth_access_tokens_table.php} (100%) rename database/migrations/{2024_05_07_063934_create_oauth_personal_access_clients_table.php => 2024_05_08_044800_create_oauth_personal_access_clients_table.php} (100%) rename database/migrations/{2024_05_07_063935_create_oauth_clients_table.php => 2024_05_08_044801_create_oauth_clients_table.php} (100%) rename database/migrations/{2024_05_07_063936_create_oauth_refresh_tokens_table.php => 2024_05_08_044802_create_oauth_refresh_tokens_table.php} (100%) rename database/migrations/{2024_05_07_063937_create_oauth_auth_codes_table.php => 2024_05_08_044803_create_oauth_auth_codes_table.php} (100%) diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 95d078b..df37ac3 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -6,7 +6,9 @@ use App\Http\Requests\LoginRequest; use App\Http\Requests\RegisterRequest; use App\Services\UserService; - +use Illuminate\Http\JsonResponse; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; class AuthController extends Controller { @@ -36,10 +38,10 @@ public function login(LoginRequest $request) try { $user = $this->userService->getUser($request->only('email', 'password')); if($user){ - $user->makeHidden(['created_at', 'updated_at']); + $user->makeHidden(['created_at', 'updated_at','uuid']); return response()->json(['user' => $user], 201); } - return response()->json(['error' => 'Unauthorized'], 401); + return response()->json(['error' => 'User not found'], 404); } catch (\Exception $e) { // Handle general errors \Log::error($e->getMessage()); @@ -48,13 +50,27 @@ public function login(LoginRequest $request) } - public function update(RegisterRequest $request) + public function update(Request $request) { - return "hola"; $data = $request->all(); $updatedUser = $this->userService->updateUser($data); + if ($updatedUser instanceof JsonResponse) { + return $updatedUser; + } + $updatedUser->makeHidden(['created_at', 'updated_at','uuid']); - return $updatedUser; + return response()->json(['user' => $updatedUser]); } + + public function validateToken(Request $request) + { + $user = Auth::guard('api')->user(); + + if ($user) { + return response()->json(['message' => 'Token is valid', 'user' => $user]); + } else { + return response()->json(['message' => 'Token is invalid'], 401); + } + } } diff --git a/app/Models/User.php b/app/Models/User.php index d0bb685..6344734 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -13,6 +13,9 @@ class User extends Authenticatable { use HasApiTokens,HasFactory, Notifiable, HasRoles; protected $primaryKey = 'uuid'; + public $incrementing = false; + protected $keyType = 'string'; + /** * The attributes that are mass assignable. * @@ -31,6 +34,7 @@ class User extends Authenticatable * @var array */ protected $hidden = [ + 'uuid', 'password', 'remember_token', ]; diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 46417ef..8b66fec 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -46,15 +46,53 @@ public function getUser(array $data) public function updateUser(array $data) { - $this->auth->attempt($data); - $user = $this->auth->user(); - $user->update([ - 'name' => $data['name'], - 'email' => $data['email'], - 'password' => $this->hasher->make($data['password']) - ]); + try { - $user->token = $user->createToken(env('PASSPORT_TOKEN_NAME'))->accessToken; - return $user; + $user = $this->auth->user(); + + if (isset($data['email']) && $this->checkEmail($data, $user->email)) { + $user->email = $data['email']; + } elseif (isset($data['email'])) { + return response()->json(['error' => 'Email already in use'], 409); + } + + // Update other user properties if they are included in the update request + if (isset($data['name'])) { + $user->name = $data['name']; + } + if (isset($data['password'])) { + $user->password = $this->hasher->make($data['password']); + } + + // Save the updated user + $user->save(); + + // Generate a new access token for the user + $user->token = $user->createToken(env('PASSPORT_TOKEN_NAME'))->accessToken; + + return $user; + } catch (\Exception $e) { + \Log::error($e->getMessage()); + return response()->json(['error' => 'An error occurred while updating user'], 500); + } + } + + protected function checkEmail(array $data, string $email) + { + // Check if the email is included in the update request + if (isset($data['email'])) { + // Check if the new email is different from the current email + if ($data['email'] !== $email) { + // Check if the new email already exists in the database + $existingUser = User::where('email', $data['email'])->first(); + if ($existingUser) { + // Handle the case where the new email already exists + return false; + } + // Update the email if it is different and not already in use + return true; + } + } + return false; } } diff --git a/database/migrations/2024_05_07_063933_create_oauth_access_tokens_table.php b/database/migrations/2024_05_08_044759_create_oauth_access_tokens_table.php similarity index 100% rename from database/migrations/2024_05_07_063933_create_oauth_access_tokens_table.php rename to database/migrations/2024_05_08_044759_create_oauth_access_tokens_table.php diff --git a/database/migrations/2024_05_07_063934_create_oauth_personal_access_clients_table.php b/database/migrations/2024_05_08_044800_create_oauth_personal_access_clients_table.php similarity index 100% rename from database/migrations/2024_05_07_063934_create_oauth_personal_access_clients_table.php rename to database/migrations/2024_05_08_044800_create_oauth_personal_access_clients_table.php diff --git a/database/migrations/2024_05_07_063935_create_oauth_clients_table.php b/database/migrations/2024_05_08_044801_create_oauth_clients_table.php similarity index 100% rename from database/migrations/2024_05_07_063935_create_oauth_clients_table.php rename to database/migrations/2024_05_08_044801_create_oauth_clients_table.php diff --git a/database/migrations/2024_05_07_063936_create_oauth_refresh_tokens_table.php b/database/migrations/2024_05_08_044802_create_oauth_refresh_tokens_table.php similarity index 100% rename from database/migrations/2024_05_07_063936_create_oauth_refresh_tokens_table.php rename to database/migrations/2024_05_08_044802_create_oauth_refresh_tokens_table.php diff --git a/database/migrations/2024_05_07_063937_create_oauth_auth_codes_table.php b/database/migrations/2024_05_08_044803_create_oauth_auth_codes_table.php similarity index 100% rename from database/migrations/2024_05_07_063937_create_oauth_auth_codes_table.php rename to database/migrations/2024_05_08_044803_create_oauth_auth_codes_table.php diff --git a/routes/api.php b/routes/api.php index 122f57a..35f0cd6 100644 --- a/routes/api.php +++ b/routes/api.php @@ -1,9 +1,8 @@ name('api.register'); Route::post('/login', [AuthController::class, 'login'])->name('api.login'); -Route::post('/user/update',[AuthController::class,'update'])->name('api.userupdate')->middleware('auth:api'); \ No newline at end of file +Route::post('/user/update',[AuthController::class,'update'])->name('api.user.update')->middleware('auth:api'); \ No newline at end of file From c363173d377a184771e23ae223169ed731dad8bd Mon Sep 17 00:00:00 2001 From: juandz13 Date: Wed, 8 May 2024 11:20:44 +0200 Subject: [PATCH 008/115] birthdate added --- app/Http/Requests/RegisterRequest.php | 1 + app/Models/User.php | 1 + app/Services/UserService.php | 5 ++++ ...08_090517_add_birthdate_to_users_table.php | 28 +++++++++++++++++++ routes/api.php | 2 +- 5 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2024_05_08_090517_add_birthdate_to_users_table.php diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 923896e..43a6817 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -25,6 +25,7 @@ public function rules(): array 'name' => 'required|string|max:255', 'email' => 'required|string|email|max:255|unique:users', 'password' => 'required|string|min:8', + 'birthdate' => 'date', ]; } diff --git a/app/Models/User.php b/app/Models/User.php index 6344734..c30a163 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -23,6 +23,7 @@ class User extends Authenticatable */ protected $fillable = [ 'uuid', + 'birthdate', 'name', 'email', 'password', diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 8b66fec..5d7a585 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -28,6 +28,7 @@ public function createUser(array $data) $user = User::create([ 'uuid' => $uuid, 'name' => $data['name'], + 'birthdate' => $data['birthdate'], 'email' => $data['email'], 'password' => $this->hasher->make($data['password']) ]); @@ -64,6 +65,10 @@ public function updateUser(array $data) $user->password = $this->hasher->make($data['password']); } + if(isset($data['birthdate'])){ + $user->birthdate = $data['birthdate']; + } + // Save the updated user $user->save(); diff --git a/database/migrations/2024_05_08_090517_add_birthdate_to_users_table.php b/database/migrations/2024_05_08_090517_add_birthdate_to_users_table.php new file mode 100644 index 0000000..f163815 --- /dev/null +++ b/database/migrations/2024_05_08_090517_add_birthdate_to_users_table.php @@ -0,0 +1,28 @@ +date('birthdate')->nullable(); // Add a nullable date column + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('birthdate'); // Rollback the migration + }); + } +}; diff --git a/routes/api.php b/routes/api.php index 35f0cd6..0ed8c2f 100644 --- a/routes/api.php +++ b/routes/api.php @@ -5,4 +5,4 @@ Route::post('/register', [AuthController::class, 'register'])->name('api.register'); Route::post('/login', [AuthController::class, 'login'])->name('api.login'); -Route::post('/user/update',[AuthController::class,'update'])->name('api.user.update')->middleware('auth:api'); \ No newline at end of file +Route::put('/user/update',[AuthController::class,'update'])->name('api.user.update')->middleware('auth:api'); \ No newline at end of file From 1919f92620fa6322172b1fdd1affb2fec9dffa6f Mon Sep 17 00:00:00 2001 From: juandz13 Date: Wed, 8 May 2024 14:34:26 +0200 Subject: [PATCH 009/115] permission create added --- .../Permissions/PermissionController.php | 61 +++++++++++++++++++ app/Http/Requests/PermissionRequest.php | 29 +++++++++ app/Services/PermissionService.php | 54 ++++++++++++++++ routes/api.php | 6 +- 4 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/Permissions/PermissionController.php create mode 100644 app/Http/Requests/PermissionRequest.php create mode 100644 app/Services/PermissionService.php diff --git a/app/Http/Controllers/Permissions/PermissionController.php b/app/Http/Controllers/Permissions/PermissionController.php new file mode 100644 index 0000000..ec5e643 --- /dev/null +++ b/app/Http/Controllers/Permissions/PermissionController.php @@ -0,0 +1,61 @@ +permissionService = $permissionService; + } + // Method to create a new permission + public function create(PermissionRequest $request) + { + + try { + $result = $this->permissionService->createPermission($request->all()); + + if (!$result['success']) { + return response()->json(['errors' => $result['errors']], 422); + } + + return response()->json(['message' => 'Permission created successfully', 'permission' => $result['permission']], 201); + } catch (\Exception $e) { + \Log::error($e->getMessage()); + return response()->json(['error' => 'An error occurred while updating user'], 500); + } + } + + // Method to update an existing permission + public function update(Request $request, Permission $permission) + { + $validator = Validator::make($request->all(), [ + 'name' => 'required|string|unique:permissions,name,' . $permission->id, + 'guard_name' => 'sometimes|string' + ]); + + if ($validator->fails()) { + return response()->json(['errors' => $validator->errors()], 422); + } + + $permission->update($validator->validated()); + + return response()->json(['message' => 'Permission updated successfully', 'permission' => $permission]); + } + + // Method to remove an existing permission + public function remove(Permission $permission) + { + $permission->delete(); + + return response()->json(['message' => 'Permission removed successfully']); + } +} diff --git a/app/Http/Requests/PermissionRequest.php b/app/Http/Requests/PermissionRequest.php new file mode 100644 index 0000000..a094f9d --- /dev/null +++ b/app/Http/Requests/PermissionRequest.php @@ -0,0 +1,29 @@ +|string> + */ + public function rules(): array + { + return [ + 'name' => 'required|string|unique:permissions,name', + 'guard_name' => 'sometimes|string' + ]; + } +} diff --git a/app/Services/PermissionService.php b/app/Services/PermissionService.php new file mode 100644 index 0000000..a539b09 --- /dev/null +++ b/app/Services/PermissionService.php @@ -0,0 +1,54 @@ + true, + 'permission' => $permission + ]; + } + + public function updatePermission(Permission $permission, array $data) + { + $validator = Validator::make($data, [ + 'name' => 'required|string|unique:permissions,name,' . $permission->id, + 'guard_name' => 'sometimes|string' + ]); + + if ($validator->fails()) { + return [ + 'success' => false, + 'errors' => $validator->errors() + ]; + } + + $permission->update($validator->validated()); + + return [ + 'success' => true, + 'permission' => $permission + ]; + } + + public function deletePermission(Permission $permission) + { + $permission->delete(); + + return [ + 'success' => true, + 'message' => 'Permission removed successfully' + ]; + } +} \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index 0ed8c2f..9ec876b 100644 --- a/routes/api.php +++ b/routes/api.php @@ -1,8 +1,12 @@ name('api.register'); Route::post('/login', [AuthController::class, 'login'])->name('api.login'); -Route::put('/user/update',[AuthController::class,'update'])->name('api.user.update')->middleware('auth:api'); \ No newline at end of file +Route::put('/user/update',[AuthController::class,'update'])->name('api.user.update')->middleware('auth:api'); + +Route::post('/permission/create',[PermissionController::class,'create'])->name('api.permission.create')->middleware('auth:api'); +//Route::post('/permission/remove',[PermissionController::class,'removePermission'])->name('api.permission.remove')->middleware('auth:api'); From 5259d04d7c9b72e775e6a6bf6c0766ca97298d46 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 9 May 2024 07:53:40 +0200 Subject: [PATCH 010/115] update user and permission crud --- .../Permissions/PermissionController.php | 44 +++++++++++++------ .../Controllers/User/UserUpdateController.php | 16 ++++--- app/Http/Requests/PermissionUpdateRequest.php | 30 +++++++++++++ app/Models/Role.php | 9 ++++ app/Services/PermissionService.php | 15 +------ routes/api.php | 6 ++- 6 files changed, 84 insertions(+), 36 deletions(-) create mode 100644 app/Http/Requests/PermissionUpdateRequest.php diff --git a/app/Http/Controllers/Permissions/PermissionController.php b/app/Http/Controllers/Permissions/PermissionController.php index ec5e643..07b883b 100644 --- a/app/Http/Controllers/Permissions/PermissionController.php +++ b/app/Http/Controllers/Permissions/PermissionController.php @@ -4,6 +4,7 @@ use App\Http\Controllers\Controller; use App\Http\Requests\PermissionRequest; +use App\Models\Permission; use App\Services\PermissionService; use Illuminate\Http\Request; @@ -16,10 +17,9 @@ public function __construct(PermissionService $permissionService) { $this->permissionService = $permissionService; } - // Method to create a new permission + public function create(PermissionRequest $request) { - try { $result = $this->permissionService->createPermission($request->all()); @@ -30,25 +30,29 @@ public function create(PermissionRequest $request) return response()->json(['message' => 'Permission created successfully', 'permission' => $result['permission']], 201); } catch (\Exception $e) { \Log::error($e->getMessage()); - return response()->json(['error' => 'An error occurred while updating user'], 500); + return response()->json(['error' => 'An error occurred while creating Permission'], 500); } } - // Method to update an existing permission - public function update(Request $request, Permission $permission) + + public function update(PermissionRequest $request, $permissionId) { - $validator = Validator::make($request->all(), [ - 'name' => 'required|string|unique:permissions,name,' . $permission->id, - 'guard_name' => 'sometimes|string' - ]); + try { + $permission = Permission::find($permissionId); - if ($validator->fails()) { - return response()->json(['errors' => $validator->errors()], 422); - } + $result = $this->permissionService->updatePermission($permission, $request->all()); - $permission->update($validator->validated()); + if (!$result['success']) { + return response()->json(['errors' => $result['errors']], 422); + } - return response()->json(['message' => 'Permission updated successfully', 'permission' => $permission]); + $permission = $result['permission']; + + return response()->json(['message' => 'Permission updated successfully', 'permission' => $permission]); + } catch (\Exception $e) { + \Log::error($e->getMessage()); + return response()->json(['error' => 'An error occurred while updating Permission'], 500); + } } // Method to remove an existing permission @@ -58,4 +62,16 @@ public function remove(Permission $permission) return response()->json(['message' => 'Permission removed successfully']); } + + public function getList() + { + try { + $permissions = Permission::all(); + $permissions->makeHidden(['created_at', 'updated_at', 'guard_name']); + return response()->json(['permissions' => $permissions]); + } catch (\Exception $e) { + \Log::error($e->getMessage()); + return response()->json(['error' => 'An error occurred while fetching permissions'], 500); + } + } } diff --git a/app/Http/Controllers/User/UserUpdateController.php b/app/Http/Controllers/User/UserUpdateController.php index 3f003b1..1df8ec2 100644 --- a/app/Http/Controllers/User/UserUpdateController.php +++ b/app/Http/Controllers/User/UserUpdateController.php @@ -6,7 +6,7 @@ use Illuminate\Http\Request; use App\Services\UserService; - +use Illuminate\Http\JsonResponse; class UserUpdateController extends Controller { @@ -17,14 +17,18 @@ public function __construct(UserService $userService) $this->userService = $userService; } - public function updateUser($userId, array $userData) + public function updateUser(Request $request) { try { - // Call the UserService method to update the user - $user = $this->userService->updateUser($userId, $userData); + $data = $request->all(); + + $updatedUser = $this->userService->updateUser($data); + if ($updatedUser instanceof JsonResponse) { + return $updatedUser; + } + $updatedUser->makeHidden(['created_at', 'updated_at', 'uuid']); - // Return a JSON response with the updated user data - return response()->json(['user' => $user], 200); + return response()->json(['user' => $updatedUser]); } catch (\Exception $e) { // Log the error internally \Log::error($e); diff --git a/app/Http/Requests/PermissionUpdateRequest.php b/app/Http/Requests/PermissionUpdateRequest.php new file mode 100644 index 0000000..5a065ef --- /dev/null +++ b/app/Http/Requests/PermissionUpdateRequest.php @@ -0,0 +1,30 @@ +|string> + */ + public function rules(): array + { + $permissionId = $this->route('permission')->id; // Assuming you are passing the permission model through the route + return [ + 'name' => 'required|string|unique:permissions,name,' . $permissionId, + 'guard_name' => 'sometimes|string' + ]; + } +} diff --git a/app/Models/Role.php b/app/Models/Role.php index 7c49d72..7384394 100644 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -11,4 +11,13 @@ class Role extends SpatieRole use HasFactory; use HasUuids; protected $primaryKey = 'uuid'; + + /** + * The attributes that are mass assignable. + * + * @var array + */ + protected $fillable = [ + 'name', + ]; } \ No newline at end of file diff --git a/app/Services/PermissionService.php b/app/Services/PermissionService.php index a539b09..83e5d61 100644 --- a/app/Services/PermissionService.php +++ b/app/Services/PermissionService.php @@ -22,20 +22,7 @@ public function createPermission(array $data) public function updatePermission(Permission $permission, array $data) { - $validator = Validator::make($data, [ - 'name' => 'required|string|unique:permissions,name,' . $permission->id, - 'guard_name' => 'sometimes|string' - ]); - - if ($validator->fails()) { - return [ - 'success' => false, - 'errors' => $validator->errors() - ]; - } - - $permission->update($validator->validated()); - + $permission->update($data); return [ 'success' => true, 'permission' => $permission diff --git a/routes/api.php b/routes/api.php index 9ec876b..729a7a6 100644 --- a/routes/api.php +++ b/routes/api.php @@ -2,11 +2,13 @@ use App\Http\Controllers\Auth\AuthController; use App\Http\Controllers\Permissions\PermissionController; +use App\Http\Controllers\User\UserUpdateController; use Illuminate\Support\Facades\Route; Route::post('/register', [AuthController::class, 'register'])->name('api.register'); Route::post('/login', [AuthController::class, 'login'])->name('api.login'); -Route::put('/user/update',[AuthController::class,'update'])->name('api.user.update')->middleware('auth:api'); +Route::put('/user/update',[UserUpdateController::class,'update'])->name('api.user.update')->middleware('auth:api'); Route::post('/permission/create',[PermissionController::class,'create'])->name('api.permission.create')->middleware('auth:api'); -//Route::post('/permission/remove',[PermissionController::class,'removePermission'])->name('api.permission.remove')->middleware('auth:api'); +Route::post('/permission/update/{permissionId}',[PermissionController::class,'update'])->name('api.permission.update')->middleware('auth:api'); +Route::get('/permissions', [PermissionController::class, 'getList'])->name('api.permissions.list')->middleware('auth:api'); From f2d6e96f7fdf51f780566d17a64ce26a2deee3a6 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 9 May 2024 09:28:44 +0200 Subject: [PATCH 011/115] RoleService --- app/Http/Controllers/Roles/RoleController.php | 11 ++++++++++ app/Providers/AppServiceProvider.php | 3 ++- app/Services/PermissionService.php | 18 ++++++++++++----- app/Services/RoleService.php | 20 +++++++++++++++++++ app/Services/UserService.php | 11 ++++++---- routes/api.php | 4 ++++ 6 files changed, 57 insertions(+), 10 deletions(-) create mode 100644 app/Http/Controllers/Roles/RoleController.php create mode 100644 app/Services/RoleService.php diff --git a/app/Http/Controllers/Roles/RoleController.php b/app/Http/Controllers/Roles/RoleController.php new file mode 100644 index 0000000..013f67b --- /dev/null +++ b/app/Http/Controllers/Roles/RoleController.php @@ -0,0 +1,11 @@ +app->singleton(UserService::class, function ($app) { return new UserService( $app->make(\Illuminate\Contracts\Auth\Guard::class), - $app->make(\Illuminate\Contracts\Hashing\Hasher::class) + $app->make(\Illuminate\Contracts\Hashing\Hasher::class), + $app->make(\App\Models\User::class) ); }); } diff --git a/app/Services/PermissionService.php b/app/Services/PermissionService.php index 83e5d61..9b6ebb1 100644 --- a/app/Services/PermissionService.php +++ b/app/Services/PermissionService.php @@ -3,16 +3,24 @@ namespace App\Services; use Spatie\Permission\Models\Permission; -use Illuminate\Support\Facades\Validator; -use Ramsey\Uuid\Uuid; + class PermissionService { - public function createPermission(array $data) + + protected $permission; + protected $uuidGenerator; + + public function __construct(Permission $permission) { - $data['uuid'] = Uuid::uuid4(); + $this->permission = $permission; - $permission = Permission::create($data); + } + + public function createPermission(array $data) + { + $data['uuid'] = $this->uuidGenerator->uuid4(); + $permission = $this->permission->create($data); return [ 'success' => true, diff --git a/app/Services/RoleService.php b/app/Services/RoleService.php new file mode 100644 index 0000000..9cf87fd --- /dev/null +++ b/app/Services/RoleService.php @@ -0,0 +1,20 @@ + true, + 'permission' => $permission + ]; + } +} \ No newline at end of file diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 5d7a585..f3c53ce 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -12,23 +12,26 @@ class UserService protected $auth; protected $hasher; + protected $uuid; + protected $user; - public function __construct(Guard $auth, Hasher $hasher) + public function __construct(Guard $auth, Hasher $hasher, User $user) { $this->auth = $auth; $this->hasher = $hasher; + $this->user = $user; } public function createUser(array $data) { - // Generate a UUID + $uuid = Uuid::uuid4(); // Create the user with the UUID - $user = User::create([ + $user = $this->user->create([ 'uuid' => $uuid, 'name' => $data['name'], - 'birthdate' => $data['birthdate'], + 'birthdate' => $data['birthdate'] ?? null, 'email' => $data['email'], 'password' => $this->hasher->make($data['password']) ]); diff --git a/routes/api.php b/routes/api.php index 729a7a6..a48f8f8 100644 --- a/routes/api.php +++ b/routes/api.php @@ -12,3 +12,7 @@ Route::post('/permission/create',[PermissionController::class,'create'])->name('api.permission.create')->middleware('auth:api'); Route::post('/permission/update/{permissionId}',[PermissionController::class,'update'])->name('api.permission.update')->middleware('auth:api'); Route::get('/permissions', [PermissionController::class, 'getList'])->name('api.permissions.list')->middleware('auth:api'); + +Route::post('/roles/create',[RoleController::class,'create'])->name('api.roles.create')->middleware('auth:api'); +Route::post('/roles/update/{roleId}',[RoleController::class,'update'])->name('api.roles.update')->middleware('auth:api'); +Route::get('/roles', [RoleController::class, 'getList'])->name('api.roles.list')->middleware('auth:api'); \ No newline at end of file From 53160130f65aa8a74de88dd3f2c155561c85f015 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 9 May 2024 11:55:14 +0200 Subject: [PATCH 012/115] create role added --- app/Http/Controllers/Roles/RoleController.php | 20 +++++++++++++++++++ app/Models/Role.php | 9 --------- app/Services/PermissionService.php | 3 ++- app/Services/RoleService.php | 16 +++++++++++---- routes/api.php | 5 +++-- 5 files changed, 37 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/Roles/RoleController.php b/app/Http/Controllers/Roles/RoleController.php index 013f67b..65a60a8 100644 --- a/app/Http/Controllers/Roles/RoleController.php +++ b/app/Http/Controllers/Roles/RoleController.php @@ -3,9 +3,29 @@ namespace App\Http\Controllers\Roles; use App\Http\Controllers\Controller; +use App\Services\RoleService; use Illuminate\Http\Request; class RoleController extends Controller { + protected $roleService; + + public function __construct(RoleService $roleService) + { + $this->roleService = $roleService; + } + +public function create(Request $request) +{ + $data = $request->all(); + $result = $this->roleService->createRole($data); + + if (!$result['success']) { + return response()->json(['errors' => $result['errors']], 422); + } + + return response()->json(['message' => 'Role created successfully', 'role' => $result['role']], 201); +} + } diff --git a/app/Models/Role.php b/app/Models/Role.php index 7384394..7c49d72 100644 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -11,13 +11,4 @@ class Role extends SpatieRole use HasFactory; use HasUuids; protected $primaryKey = 'uuid'; - - /** - * The attributes that are mass assignable. - * - * @var array - */ - protected $fillable = [ - 'name', - ]; } \ No newline at end of file diff --git a/app/Services/PermissionService.php b/app/Services/PermissionService.php index 9b6ebb1..95cca3d 100644 --- a/app/Services/PermissionService.php +++ b/app/Services/PermissionService.php @@ -2,6 +2,7 @@ namespace App\Services; +use Ramsey\Uuid\Uuid; use Spatie\Permission\Models\Permission; @@ -19,7 +20,7 @@ public function __construct(Permission $permission) public function createPermission(array $data) { - $data['uuid'] = $this->uuidGenerator->uuid4(); + $data['uuid'] = Uuid::uuid4(); $permission = $this->permission->create($data); return [ diff --git a/app/Services/RoleService.php b/app/Services/RoleService.php index 9cf87fd..2c6e083 100644 --- a/app/Services/RoleService.php +++ b/app/Services/RoleService.php @@ -2,19 +2,27 @@ namespace App\Services; +use App\Models\Role; use Illuminate\Http\Request; use Ramsey\Uuid\Uuid; class RoleService{ - public function createRole(Request $request){ - $data['uuid'] = Uuid::uuid4(); + protected $role; + + public function __construct(Role $role) + { + $this->role = $role; + } - $permission = Role::create($data); + public function createRole(Array $data){ + $data['uuid'] = Uuid::uuid4(); + //$data['guard_name'] = "api"; + $role = $this->role->create($data); return [ 'success' => true, - 'permission' => $permission + 'role' => $role ]; } } \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index a48f8f8..889323e 100644 --- a/routes/api.php +++ b/routes/api.php @@ -2,6 +2,7 @@ use App\Http\Controllers\Auth\AuthController; use App\Http\Controllers\Permissions\PermissionController; +use App\Http\Controllers\Roles\RoleController; use App\Http\Controllers\User\UserUpdateController; use Illuminate\Support\Facades\Route; @@ -13,6 +14,6 @@ Route::post('/permission/update/{permissionId}',[PermissionController::class,'update'])->name('api.permission.update')->middleware('auth:api'); Route::get('/permissions', [PermissionController::class, 'getList'])->name('api.permissions.list')->middleware('auth:api'); -Route::post('/roles/create',[RoleController::class,'create'])->name('api.roles.create')->middleware('auth:api'); -Route::post('/roles/update/{roleId}',[RoleController::class,'update'])->name('api.roles.update')->middleware('auth:api'); +Route::post('/role/create',[RoleController::class,'create'])->name('api.roles.create')->middleware('auth:api'); +Route::post('/role/update/{roleId}',[RoleController::class,'update'])->name('api.roles.update')->middleware('auth:api'); Route::get('/roles', [RoleController::class, 'getList'])->name('api.roles.list')->middleware('auth:api'); \ No newline at end of file From 43766b871a9fa3111173dd5f3e53e22b8fd4affb Mon Sep 17 00:00:00 2001 From: juandz13 Date: Fri, 10 May 2024 06:39:28 +0200 Subject: [PATCH 013/115] role update --- app/Http/Controllers/Roles/RoleController.php | 37 ++++++++++++++----- app/Services/RoleService.php | 10 +++++ ...2024_05_09_190808_add_surname_to_users.php | 28 ++++++++++++++ 3 files changed, 65 insertions(+), 10 deletions(-) create mode 100644 database/migrations/2024_05_09_190808_add_surname_to_users.php diff --git a/app/Http/Controllers/Roles/RoleController.php b/app/Http/Controllers/Roles/RoleController.php index 65a60a8..5d081c5 100644 --- a/app/Http/Controllers/Roles/RoleController.php +++ b/app/Http/Controllers/Roles/RoleController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Roles; use App\Http\Controllers\Controller; +use App\Models\Role; use App\Services\RoleService; use Illuminate\Http\Request; @@ -15,17 +16,33 @@ public function __construct(RoleService $roleService) $this->roleService = $roleService; } -public function create(Request $request) -{ - $data = $request->all(); - $result = $this->roleService->createRole($data); + public function create(Request $request) + { + $data = $request->all(); + $result = $this->roleService->createRole($data); - if (!$result['success']) { - return response()->json(['errors' => $result['errors']], 422); + if (!$result['success']) { + return response()->json(['errors' => $result['errors']], 422); + } + + return response()->json(['message' => 'Role created successfully', 'role' => $result['role']], 201); } - return response()->json(['message' => 'Role created successfully', 'role' => $result['role']], 201); -} + public function update(Request $request, $roleId) + { + $data = $request->all(); + $result = $this->roleService->updateRole($data, $roleId); + + if (!$result['success']) { + return response()->json(['errors' => $result['errors']], 422); + } + + return response()->json(['message' => 'Role update successfully', 'role' => $result['role']], 201); + } - -} + public function getList(){ + $roles = Role::all(); + $roles->makeHidden(['created_at', 'updated_at', 'guard_name']); + return response()->json(['roles' => $roles]); + } +} \ No newline at end of file diff --git a/app/Services/RoleService.php b/app/Services/RoleService.php index 2c6e083..26dd2b9 100644 --- a/app/Services/RoleService.php +++ b/app/Services/RoleService.php @@ -25,4 +25,14 @@ public function createRole(Array $data){ 'role' => $role ]; } + + public function updateRole(Array $data, $id){ + $role = $this->role->find($id); + $role->update($data); + + return [ + 'success' => true, + 'role' => $role + ]; + } } \ No newline at end of file diff --git a/database/migrations/2024_05_09_190808_add_surname_to_users.php b/database/migrations/2024_05_09_190808_add_surname_to_users.php new file mode 100644 index 0000000..c469ce3 --- /dev/null +++ b/database/migrations/2024_05_09_190808_add_surname_to_users.php @@ -0,0 +1,28 @@ +string('surname')->default('surname'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('surname'); + }); + } +}; From d0e24e8c547f1781804d98a906fdb497576952fb Mon Sep 17 00:00:00 2001 From: juandz13 Date: Fri, 10 May 2024 06:44:56 +0200 Subject: [PATCH 014/115] model has roles bugfix --- .../migrations/2024_05_07_070437_create_permission_tables.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/2024_05_07_070437_create_permission_tables.php b/database/migrations/2024_05_07_070437_create_permission_tables.php index dd12efb..4226310 100644 --- a/database/migrations/2024_05_07_070437_create_permission_tables.php +++ b/database/migrations/2024_05_07_070437_create_permission_tables.php @@ -77,7 +77,7 @@ public function up(): void $table->uuid($pivotRole); $table->string('model_type'); - $table->unsignedBigInteger($columnNames['model_morph_key']); + $table->uuid($columnNames['model_morph_key']); $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index'); $table->foreign($pivotRole) From 8a2b6f087636270a201161677c3c9959fe094006 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Fri, 10 May 2024 10:32:20 +0200 Subject: [PATCH 015/115] assing role --- .../Roles/AssignRoleController.php | 37 +++++++++++++++++++ app/Services/AssignRoleService.php | 29 +++++++++++++++ routes/api.php | 4 +- 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/Roles/AssignRoleController.php create mode 100644 app/Services/AssignRoleService.php diff --git a/app/Http/Controllers/Roles/AssignRoleController.php b/app/Http/Controllers/Roles/AssignRoleController.php new file mode 100644 index 0000000..4db1b0e --- /dev/null +++ b/app/Http/Controllers/Roles/AssignRoleController.php @@ -0,0 +1,37 @@ +assignRoleService = $assignRoleService; + } + + public function assignRoleToUser(Request $request) + { + try { + $user = User::find($request->user_id); + + if (!$user) { + return response()->json(['error' => 'User not found'], 404); + } + + $this->assignRoleService->assignRole($user, $request->role); + + return response()->json(['message' => 'Role assigned successfully'], 200); + } catch (Exception $e) { + + return response()->json(['error' => $e->getMessage()], 500); + } + } +} diff --git a/app/Services/AssignRoleService.php b/app/Services/AssignRoleService.php new file mode 100644 index 0000000..03f1109 --- /dev/null +++ b/app/Services/AssignRoleService.php @@ -0,0 +1,29 @@ +assignRole($role); + } catch (Exception $e) { + // Handle any exceptions that occur during role assignment + echo 'Error assigning role: ' . $e->getMessage(); + } + } + + public function revokeRole(User $user, $role) + { + try { + $user->removeRole($role); + } catch (Exception $e) { + // Handle any exceptions that occur during role revocation + echo 'Error revoking role: ' . $e->getMessage(); + } + } +} diff --git a/routes/api.php b/routes/api.php index 889323e..1ec69ad 100644 --- a/routes/api.php +++ b/routes/api.php @@ -16,4 +16,6 @@ Route::post('/role/create',[RoleController::class,'create'])->name('api.roles.create')->middleware('auth:api'); Route::post('/role/update/{roleId}',[RoleController::class,'update'])->name('api.roles.update')->middleware('auth:api'); -Route::get('/roles', [RoleController::class, 'getList'])->name('api.roles.list')->middleware('auth:api'); \ No newline at end of file +Route::get('/roles', [RoleController::class, 'getList'])->name('api.roles.list')->middleware('auth:api'); +Route::post( '/role/assign', [RoleController::class, 'assignRole'])->name('api.roles.assign')->middleware('auth:api'); +Route::post( '/role/unassign', [RoleController::class, 'unassignRole'])->name('api.roles.unassign')->middleware('auth:api'); From 88ed4168444ecd0fbea11e21e32c34fc5b25beab Mon Sep 17 00:00:00 2001 From: juandz13 Date: Fri, 10 May 2024 10:32:29 +0200 Subject: [PATCH 016/115] bugfix user not found --- app/Services/UserService.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Services/UserService.php b/app/Services/UserService.php index f3c53ce..3c04ed9 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -44,8 +44,11 @@ public function getUser(array $data) { $this->auth->attempt($data); $user = $this->auth->user(); - $user->token = $user->createToken(env('PASSPORT_TOKEN_NAME'))->accessToken; - return $user; + if ($user) { + $user->token = $user->createToken('ximdex')->accessToken; + return $user; + } + return null; } public function updateUser(array $data) From d3236a663b918a3106ea47444f4e798a8c581859 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 13 May 2024 08:07:54 +0200 Subject: [PATCH 017/115] roles and permissions --- .../Roles/AssignRoleController.php | 70 +++++++++++++++++++ app/Http/Controllers/Roles/RoleController.php | 2 + app/Services/AssignRoleService.php | 30 ++++++++ routes/api.php | 10 ++- 4 files changed, 109 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Roles/AssignRoleController.php b/app/Http/Controllers/Roles/AssignRoleController.php index 4db1b0e..731eecd 100644 --- a/app/Http/Controllers/Roles/AssignRoleController.php +++ b/app/Http/Controllers/Roles/AssignRoleController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Roles; use App\Http\Controllers\Controller; +use App\Models\Role; use App\Models\User; use App\Services\AssignRoleService; use Exception; @@ -25,6 +26,11 @@ public function assignRoleToUser(Request $request) if (!$user) { return response()->json(['error' => 'User not found'], 404); } + + $role = $request->role; + if (!Role::where('name', $role)->exists()) { + return response()->json(['error' => 'Role does not exist'], 404); + } $this->assignRoleService->assignRole($user, $request->role); @@ -34,4 +40,68 @@ public function assignRoleToUser(Request $request) return response()->json(['error' => $e->getMessage()], 500); } } + + public function unassignRole(Request $request) + { + try { + $user = User::find($request->user_id); + + if (!$user) { + return response()->json(['error' => 'User not found'], 404); + } + + $role = $request->role; + if (!Role::where('name', $role)->exists()) { + return response()->json(['error' => 'Role does not exist'], 404); + } + + if (!$user->hasRole($role)) { + return response()->json(['error' => 'User does not have the specified role'], 400); + } + + $this->assignRoleService->revokeRole($user, $request->role); + + return response()->json(['message' => 'Role unassigned successfully'], 200); + } catch (Exception $e) { + return response()->json(['error' => $e->getMessage()], 500); + } + } + + public function addPermissionToRole(Request $request) + { + try { + $role = Role::where('name', $request->role)->first(); + + if (!$role) { + return response()->json(['error' => 'Role not found'], 404); + } + + $this->assignRoleService->addPermissionToRole($role, $request->permission); + + return response()->json(['message' => 'Permission added to role successfully'], 200); + } catch (Exception $e) { + return response()->json(['error' => $e->getMessage()], 500); + } + } + + public function revokePermissionFromRole(Request $request) + { + try { + $role = Role::where('name', $request->role)->first(); + + if (!$role) { + return response()->json(['error' => 'Role not found'], 404); + } + + $this->assignRoleService->removePermissionFromRole($role, $request->permission); + + return response()->json(['message' => 'Permission revoked from role successfully'], 200); + } catch (Exception $e) { + return response()->json(['error' => $e->getMessage()], 500); + } + } + + + + } diff --git a/app/Http/Controllers/Roles/RoleController.php b/app/Http/Controllers/Roles/RoleController.php index 5d081c5..a3d6adf 100644 --- a/app/Http/Controllers/Roles/RoleController.php +++ b/app/Http/Controllers/Roles/RoleController.php @@ -45,4 +45,6 @@ public function getList(){ $roles->makeHidden(['created_at', 'updated_at', 'guard_name']); return response()->json(['roles' => $roles]); } + + } \ No newline at end of file diff --git a/app/Services/AssignRoleService.php b/app/Services/AssignRoleService.php index 03f1109..c890f62 100644 --- a/app/Services/AssignRoleService.php +++ b/app/Services/AssignRoleService.php @@ -2,6 +2,7 @@ namespace App\Services; +use App\Models\Role; use App\Models\User; use Exception; @@ -26,4 +27,33 @@ public function revokeRole(User $user, $role) echo 'Error revoking role: ' . $e->getMessage(); } } + + public function addPermissionToRole(Role $role, $permission) + { + if ($role->hasPermissionTo($permission)) { + throw new Exception('Role already has the specified permission'); + } + + try { + $role->givePermissionTo($permission); + } catch (Exception $e) { + // Handle any exceptions that occur during permission assignment + throw new Exception('Error assigning permission to role: ' . $e->getMessage()); + } + } + + public function removePermissionFromRole(Role $role, $permission) + { + if (!$role->hasPermissionTo($permission)) { + throw new Exception('Role does not have the specified permission'); + } + try { + $role->revokePermissionTo($permission); + } catch (Exception $e) { + // Handle any exceptions that occur during permission revocation + throw new Exception('Error revoking permission from role: ' . $e->getMessage()); + } + } + + } diff --git a/routes/api.php b/routes/api.php index 1ec69ad..d2eecb9 100644 --- a/routes/api.php +++ b/routes/api.php @@ -2,6 +2,7 @@ use App\Http\Controllers\Auth\AuthController; use App\Http\Controllers\Permissions\PermissionController; +use App\Http\Controllers\Roles\AssignRoleController; use App\Http\Controllers\Roles\RoleController; use App\Http\Controllers\User\UserUpdateController; use Illuminate\Support\Facades\Route; @@ -15,7 +16,10 @@ Route::get('/permissions', [PermissionController::class, 'getList'])->name('api.permissions.list')->middleware('auth:api'); Route::post('/role/create',[RoleController::class,'create'])->name('api.roles.create')->middleware('auth:api'); -Route::post('/role/update/{roleId}',[RoleController::class,'update'])->name('api.roles.update')->middleware('auth:api'); +Route::put('/role/update/{roleId}',[RoleController::class,'update'])->name('api.roles.update')->middleware('auth:api'); Route::get('/roles', [RoleController::class, 'getList'])->name('api.roles.list')->middleware('auth:api'); -Route::post( '/role/assign', [RoleController::class, 'assignRole'])->name('api.roles.assign')->middleware('auth:api'); -Route::post( '/role/unassign', [RoleController::class, 'unassignRole'])->name('api.roles.unassign')->middleware('auth:api'); +Route::post( '/role/assign', [AssignRoleController::class, 'assignRoleToUser'])->name('api.roles.assign')->middleware('auth:api'); +Route::post( '/role/unassign', [AssignRoleController::class, 'unassignRole'])->name('api.roles.unassign')->middleware('auth:api'); +Route::post('/role/assign/permission', [AssignRoleController::class, 'addPermissionToRole'])->name('api.roles.add.permission')->middleware('auth:api'); +Route::post('/role/unassign/permission', [AssignRoleController::class, 'removePermissionFromRole'])->name('api.roles.remove.permission')->middleware('auth:api'); + From bb6ee934096b28dbcfe26866d77025f814492cbc Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 13 May 2024 11:04:46 +0200 Subject: [PATCH 018/115] organizations --- app/Models/Organization.php | 28 +++++++++++++++++++ app/Models/User.php | 9 ++++++ ...5_13_062952_create_organizations_table.php | 19 +++++++++++++ ..._063010_create_organization_user_table.php | 21 ++++++++++++++ routes/api.php | 1 + 5 files changed, 78 insertions(+) create mode 100644 app/Models/Organization.php create mode 100644 database/migrations/2024_05_13_062952_create_organizations_table.php create mode 100644 database/migrations/2024_05_13_063010_create_organization_user_table.php diff --git a/app/Models/Organization.php b/app/Models/Organization.php new file mode 100644 index 0000000..ed3888e --- /dev/null +++ b/app/Models/Organization.php @@ -0,0 +1,28 @@ +belongsToMany(User::class, 'organization_user', 'organization_uuid', 'user_uuid'); + } +} diff --git a/app/Models/User.php b/app/Models/User.php index c30a163..9de844d 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -4,6 +4,7 @@ // use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Laravel\Passport\HasApiTokens; @@ -52,4 +53,12 @@ protected function casts(): array 'password' => 'hashed', ]; } + + /** + * The organizations that the user belongs to. + */ + public function organizations(): BelongsToMany + { + return $this->belongsToMany(Organization::class, 'organization_user', 'user_uuid', 'organization_uuid'); + } } diff --git a/database/migrations/2024_05_13_062952_create_organizations_table.php b/database/migrations/2024_05_13_062952_create_organizations_table.php new file mode 100644 index 0000000..3e9ac9e --- /dev/null +++ b/database/migrations/2024_05_13_062952_create_organizations_table.php @@ -0,0 +1,19 @@ +uuid('uuid')->primary(); + $table->string('name'); + $table->timestamps(); + }); + } + + public function down(): void { + Schema::dropIfExists('organizations'); + } +}; \ No newline at end of file diff --git a/database/migrations/2024_05_13_063010_create_organization_user_table.php b/database/migrations/2024_05_13_063010_create_organization_user_table.php new file mode 100644 index 0000000..5745b0e --- /dev/null +++ b/database/migrations/2024_05_13_063010_create_organization_user_table.php @@ -0,0 +1,21 @@ +uuid('organization_uuid'); + $table->uuid('user_uuid'); + $table->foreign('organization_uuid')->references('uuid')->on('organizations')->onDelete('cascade'); + $table->foreign('user_uuid')->references('uuid')->on('users')->onDelete('cascade'); + $table->primary(['organization_uuid', 'user_uuid']); + }); + } + + public function down(): void { + Schema::dropIfExists('organization_user'); + } +}; diff --git a/routes/api.php b/routes/api.php index d2eecb9..ee1eced 100644 --- a/routes/api.php +++ b/routes/api.php @@ -12,6 +12,7 @@ Route::put('/user/update',[UserUpdateController::class,'update'])->name('api.user.update')->middleware('auth:api'); Route::post('/permission/create',[PermissionController::class,'create'])->name('api.permission.create')->middleware('auth:api'); +Route::delete('/permission/delete/{permissionId}',[PermissionController::class,'delete'])->name('api.permission.delete')->middleware('auth:api'); Route::post('/permission/update/{permissionId}',[PermissionController::class,'update'])->name('api.permission.update')->middleware('auth:api'); Route::get('/permissions', [PermissionController::class, 'getList'])->name('api.permissions.list')->middleware('auth:api'); From ed39aaf1d41beb87a0b0766ecdaeba0946c8488e Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 14 May 2024 06:21:46 +0200 Subject: [PATCH 019/115] remove for role and permission --- .../Permissions/PermissionController.php | 20 ++++++++++++++---- app/Http/Controllers/Roles/RoleController.php | 15 +++++++++++++ app/Services/PermissionService.php | 21 ++++++++++++++++--- app/Services/RoleService.php | 13 ++++++++++++ routes/api.php | 3 ++- 5 files changed, 64 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Permissions/PermissionController.php b/app/Http/Controllers/Permissions/PermissionController.php index 07b883b..825310a 100644 --- a/app/Http/Controllers/Permissions/PermissionController.php +++ b/app/Http/Controllers/Permissions/PermissionController.php @@ -6,6 +6,7 @@ use App\Http\Requests\PermissionRequest; use App\Models\Permission; use App\Services\PermissionService; +use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Http\Request; class PermissionController extends Controller @@ -56,11 +57,22 @@ public function update(PermissionRequest $request, $permissionId) } // Method to remove an existing permission - public function remove(Permission $permission) + public function remove($permissionId) { - $permission->delete(); - - return response()->json(['message' => 'Permission removed successfully']); + try { + $permission = Permission::findOrFail($permissionId); + + if ($this->permissionService->isPermissionUnassigned($permissionId)) { + $this->permissionService->deletePermission($permission); + return response()->json(['message' => 'Permission removed successfully']); + } else { + return response()->json(['error' => 'Permission is assigned to a role'], 422); + } + } catch (ModelNotFoundException $e) { + return response()->json(['error' => 'Permission not found'], 404); + } catch (\Exception $e) { + return response()->json(['error' => 'An error occurred while processing the request'], 500); + } } public function getList() diff --git a/app/Http/Controllers/Roles/RoleController.php b/app/Http/Controllers/Roles/RoleController.php index a3d6adf..6ced2f5 100644 --- a/app/Http/Controllers/Roles/RoleController.php +++ b/app/Http/Controllers/Roles/RoleController.php @@ -40,6 +40,21 @@ public function update(Request $request, $roleId) return response()->json(['message' => 'Role update successfully', 'role' => $result['role']], 201); } + public function remove(Request $request, $roleId) +{ + try { + $result = $this->roleService->removeRole($roleId); + + if (!$result['success']) { + return response()->json(['errors' => $result['errors']], 422); + } + + return response()->json(['message' => 'Role removed successfully'], 200); + } catch (\Exception $e) { + return response()->json(['error' => $e->getMessage()], 500); + } +} + public function getList(){ $roles = Role::all(); $roles->makeHidden(['created_at', 'updated_at', 'guard_name']); diff --git a/app/Services/PermissionService.php b/app/Services/PermissionService.php index 95cca3d..d812b0a 100644 --- a/app/Services/PermissionService.php +++ b/app/Services/PermissionService.php @@ -2,6 +2,7 @@ namespace App\Services; +use Exception; use Ramsey\Uuid\Uuid; use Spatie\Permission\Models\Permission; @@ -14,8 +15,7 @@ class PermissionService public function __construct(Permission $permission) { - $this->permission = $permission; - + $this->permission = $permission; } public function createPermission(array $data) @@ -47,4 +47,19 @@ public function deletePermission(Permission $permission) 'message' => 'Permission removed successfully' ]; } -} \ No newline at end of file + + public function isPermissionUnassigned($permissionId) + { + $permission = Permission::findById($permissionId); + + if (!$permission) { + throw new Exception("Permission not found"); + } + + // Check if permission is not assigned to any role + $rolesCount = $permission->roles()->count(); + $usersCount = $permission->users()->count(); + + return $rolesCount === 0 && $usersCount === 0; + } +} diff --git a/app/Services/RoleService.php b/app/Services/RoleService.php index 26dd2b9..314568d 100644 --- a/app/Services/RoleService.php +++ b/app/Services/RoleService.php @@ -3,6 +3,7 @@ namespace App\Services; use App\Models\Role; +use Exception; use Illuminate\Http\Request; use Ramsey\Uuid\Uuid; @@ -35,4 +36,16 @@ public function updateRole(Array $data, $id){ 'role' => $role ]; } + + public function removePermissionFromRole(Role $role, $permission) + { + if (!$role->hasPermissionTo($permission)) { + throw new Exception('Role does not have the specified permission'); + } + try { + $role->revokePermissionTo($permission); + } catch (Exception $e) { + throw new Exception('Error revoking permission from role: ' . $e->getMessage()); + } + } } \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index ee1eced..f727ba4 100644 --- a/routes/api.php +++ b/routes/api.php @@ -12,12 +12,13 @@ Route::put('/user/update',[UserUpdateController::class,'update'])->name('api.user.update')->middleware('auth:api'); Route::post('/permission/create',[PermissionController::class,'create'])->name('api.permission.create')->middleware('auth:api'); -Route::delete('/permission/delete/{permissionId}',[PermissionController::class,'delete'])->name('api.permission.delete')->middleware('auth:api'); +Route::delete('/permission/remove/{permissionId}',[PermissionController::class,'delete'])->name('api.permission.delete')->middleware('auth:api'); Route::post('/permission/update/{permissionId}',[PermissionController::class,'update'])->name('api.permission.update')->middleware('auth:api'); Route::get('/permissions', [PermissionController::class, 'getList'])->name('api.permissions.list')->middleware('auth:api'); Route::post('/role/create',[RoleController::class,'create'])->name('api.roles.create')->middleware('auth:api'); Route::put('/role/update/{roleId}',[RoleController::class,'update'])->name('api.roles.update')->middleware('auth:api'); +Route::delete('/role/remove/{roleId}', [RoleController::class, 'remove'])->name('api.roles.remove')->middleware('auth:api'); Route::get('/roles', [RoleController::class, 'getList'])->name('api.roles.list')->middleware('auth:api'); Route::post( '/role/assign', [AssignRoleController::class, 'assignRoleToUser'])->name('api.roles.assign')->middleware('auth:api'); Route::post( '/role/unassign', [AssignRoleController::class, 'unassignRole'])->name('api.roles.unassign')->middleware('auth:api'); From 5e627a0103b58017f899b89e365651c7dd89d592 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 14 May 2024 06:52:02 +0200 Subject: [PATCH 020/115] role remove --- app/Services/RoleService.php | 93 +++++++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 23 deletions(-) diff --git a/app/Services/RoleService.php b/app/Services/RoleService.php index 314568d..0e61bcd 100644 --- a/app/Services/RoleService.php +++ b/app/Services/RoleService.php @@ -1,4 +1,4 @@ -role = $role; } - public function createRole(Array $data){ - $data['uuid'] = Uuid::uuid4(); - //$data['guard_name'] = "api"; - $role = $this->role->create($data); + public function createRole(array $data) + { + try { + $data['uuid'] = Uuid::uuid4(); + $role = $this->role->create($data); - return [ - 'success' => true, - 'role' => $role - ]; + return [ + 'success' => true, + 'role' => $role + ]; + } catch (Exception $e) { + return [ + 'success' => false, + 'error' => 'Failed to create role: ' . $e->getMessage() + ]; + } } - public function updateRole(Array $data, $id){ - $role = $this->role->find($id); - $role->update($data); - - return [ - 'success' => true, - 'role' => $role - ]; + public function updateRole(array $data, $id) + { + try { + $role = $this->role->find($id); + $role->update($data); + + return [ + 'success' => true, + 'role' => $role + ]; + } catch (Exception $e) { + return [ + 'success' => false, + 'error' => 'Failed to update role: ' . $e->getMessage() + ]; + } } public function removePermissionFromRole(Role $role, $permission) { - if (!$role->hasPermissionTo($permission)) { - throw new Exception('Role does not have the specified permission'); - } try { + if (!$role->hasPermissionTo($permission)) { + throw new Exception('Role does not have the specified permission'); + } $role->revokePermissionTo($permission); } catch (Exception $e) { throw new Exception('Error revoking permission from role: ' . $e->getMessage()); } } -} \ No newline at end of file + + public function removeRole($roleId) + { + try { + $role = $this->role->find($roleId); + if ($role) { + $role->delete(); + return [ + 'success' => true, + 'message' => 'Role removed successfully' + ]; + } else { + return [ + 'success' => false, + 'errors' => 'Role not found' + ]; + } + } catch (Exception $e) { + throw new Exception('Error removing role: ' . $e->getMessage()); + } + } + + public function checkIfRoleIsNotAssignedToPermission(Role $role) + { + return $role->permissions()->count() === 0; + } + + public function checkIfRoleIsNotAssignedToUser(Role $role) + { + return $role->users()->count() === 0; + } +} From d582149f700c5bdcc1cf25d902811eddff1c0c12 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 14 May 2024 07:24:20 +0200 Subject: [PATCH 021/115] permission delete --- app/Http/Controllers/Permissions/PermissionController.php | 4 ++-- app/Services/PermissionService.php | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Permissions/PermissionController.php b/app/Http/Controllers/Permissions/PermissionController.php index 825310a..fb67690 100644 --- a/app/Http/Controllers/Permissions/PermissionController.php +++ b/app/Http/Controllers/Permissions/PermissionController.php @@ -57,12 +57,12 @@ public function update(PermissionRequest $request, $permissionId) } // Method to remove an existing permission - public function remove($permissionId) + public function delete($permissionId) { try { $permission = Permission::findOrFail($permissionId); - if ($this->permissionService->isPermissionUnassigned($permissionId)) { + if ($this->permissionService->isPermissionUnassigned($permission)) { $this->permissionService->deletePermission($permission); return response()->json(['message' => 'Permission removed successfully']); } else { diff --git a/app/Services/PermissionService.php b/app/Services/PermissionService.php index d812b0a..7e4e4a3 100644 --- a/app/Services/PermissionService.php +++ b/app/Services/PermissionService.php @@ -48,10 +48,8 @@ public function deletePermission(Permission $permission) ]; } - public function isPermissionUnassigned($permissionId) + public function isPermissionUnassigned($permission) { - $permission = Permission::findById($permissionId); - if (!$permission) { throw new Exception("Permission not found"); } From 87eef999c607da6cbe666bb709abf74cda9e7860 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 14 May 2024 07:24:34 +0200 Subject: [PATCH 022/115] organization controller --- app/Http/Controllers/OrganizationController.php | 10 ++++++++++ routes/api.php | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/OrganizationController.php diff --git a/app/Http/Controllers/OrganizationController.php b/app/Http/Controllers/OrganizationController.php new file mode 100644 index 0000000..4805518 --- /dev/null +++ b/app/Http/Controllers/OrganizationController.php @@ -0,0 +1,10 @@ +name('api.roles.assign')->middleware('auth:api'); Route::post( '/role/unassign', [AssignRoleController::class, 'unassignRole'])->name('api.roles.unassign')->middleware('auth:api'); Route::post('/role/assign/permission', [AssignRoleController::class, 'addPermissionToRole'])->name('api.roles.add.permission')->middleware('auth:api'); -Route::post('/role/unassign/permission', [AssignRoleController::class, 'removePermissionFromRole'])->name('api.roles.remove.permission')->middleware('auth:api'); +Route::post('/role/unassign/permission', [AssignRoleController::class, 'revokePermissionFromRole'])->name('api.roles.remove.permission')->middleware('auth:api'); + + From 6396f2d6fffc5e59eb1df027ca837c7ba75136c5 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Fri, 17 May 2024 11:35:16 +0200 Subject: [PATCH 023/115] Organization, usercontroller, user updated, organizationService,UserService --- .../Organization/OrganizationController.php | 40 +++++++++++++++++ app/Http/Controllers/User/UserController.php | 32 +++++++++++++ app/Models/Organization.php | 3 +- app/Models/User.php | 4 +- app/Services/OrganizationService.php | 45 +++++++++++++++++++ app/Services/UserService.php | 9 +++- 6 files changed, 129 insertions(+), 4 deletions(-) create mode 100644 app/Http/Controllers/Organization/OrganizationController.php create mode 100644 app/Http/Controllers/User/UserController.php create mode 100644 app/Services/OrganizationService.php diff --git a/app/Http/Controllers/Organization/OrganizationController.php b/app/Http/Controllers/Organization/OrganizationController.php new file mode 100644 index 0000000..e8ee721 --- /dev/null +++ b/app/Http/Controllers/Organization/OrganizationController.php @@ -0,0 +1,40 @@ +organizationService = $organizationService; + } + + public function store(Request $request) + { + $result = $this->organizationService->createOrganization($request->all()); + + if ($result['success']) { + return response()->json($result['organization'], Response::HTTP_CREATED); + } else { + return response()->json(['error' => 'Failed to create organization'], Response::HTTP_BAD_REQUEST); + } + } + + public function destroy($uuid) + { + $result = $this->organizationService->deleteOrganization($uuid); + + if ($result['success']) { + return response()->json(['message' => $result['message']], Response::HTTP_OK); + } else { + return response()->json(['error' => $result['message']], Response::HTTP_NOT_FOUND); + } + } +} diff --git a/app/Http/Controllers/User/UserController.php b/app/Http/Controllers/User/UserController.php new file mode 100644 index 0000000..672e50f --- /dev/null +++ b/app/Http/Controllers/User/UserController.php @@ -0,0 +1,32 @@ +userService = $userService; + } + + public function listUsers() + { + + try { + $users = $this->userService->getAllUsers(); + $users->makeHidden(['password', 'remember_token','email_verified_at','created_at','updated_at']); + return response()->json(['users' => $users]); + } catch (\Exception $e) { + \Log::error($e->getMessage()); + return response()->json(['error' => 'An error occurred while fetching the user list.'], Response::HTTP_INTERNAL_SERVER_ERROR); + } + } +} diff --git a/app/Models/Organization.php b/app/Models/Organization.php index ed3888e..51df00b 100644 --- a/app/Models/Organization.php +++ b/app/Models/Organization.php @@ -2,13 +2,14 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsToMany; class Organization extends Model { - use HasFactory; + use HasFactory,HasUuids; protected $keyType = 'string'; public $incrementing = false; diff --git a/app/Models/User.php b/app/Models/User.php index 9de844d..a876519 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -3,6 +3,8 @@ namespace App\Models; // use Illuminate\Contracts\Auth\MustVerifyEmail; + +use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Foundation\Auth\User as Authenticatable; @@ -12,7 +14,7 @@ class User extends Authenticatable { - use HasApiTokens,HasFactory, Notifiable, HasRoles; + use HasApiTokens,HasFactory, Notifiable, HasRoles,HasUuids; protected $primaryKey = 'uuid'; public $incrementing = false; protected $keyType = 'string'; diff --git a/app/Services/OrganizationService.php b/app/Services/OrganizationService.php new file mode 100644 index 0000000..905083a --- /dev/null +++ b/app/Services/OrganizationService.php @@ -0,0 +1,45 @@ +toString(); + $organization = Organization::create($data); + + return [ + 'success' => true, + 'organization' => $organization + ]; + } + + public function deleteOrganization($uuid) + { + $organization = Organization::where('uuid', $uuid)->first(); + + if (!$organization) { + return [ + 'success' => false, + 'message' => 'Organization not found' + ]; + } + + try { + $organization->delete(); + return [ + 'success' => true, + 'message' => 'Organization deleted successfully' + ]; + } catch (Exception $e) { + return [ + 'success' => false, + 'message' => 'Failed to delete organization: ' . $e->getMessage() + ]; + } + } +} \ No newline at end of file diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 3c04ed9..c2aa4d8 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -48,7 +48,7 @@ public function getUser(array $data) $user->token = $user->createToken('ximdex')->accessToken; return $user; } - return null; + return null; } public function updateUser(array $data) @@ -71,7 +71,7 @@ public function updateUser(array $data) $user->password = $this->hasher->make($data['password']); } - if(isset($data['birthdate'])){ + if (isset($data['birthdate'])) { $user->birthdate = $data['birthdate']; } @@ -106,4 +106,9 @@ protected function checkEmail(array $data, string $email) } return false; } + + public function getAllUsers() + { + return User::all(); + } } From 413f1c5d24d3c188da36925aede499522769227c Mon Sep 17 00:00:00 2001 From: juandz13 Date: Fri, 17 May 2024 11:35:33 +0200 Subject: [PATCH 024/115] new routes --- app/Http/Controllers/OrganizationController.php | 10 ---------- routes/api.php | 6 +++++- 2 files changed, 5 insertions(+), 11 deletions(-) delete mode 100644 app/Http/Controllers/OrganizationController.php diff --git a/app/Http/Controllers/OrganizationController.php b/app/Http/Controllers/OrganizationController.php deleted file mode 100644 index 4805518..0000000 --- a/app/Http/Controllers/OrganizationController.php +++ /dev/null @@ -1,10 +0,0 @@ -name('api.register'); Route::post('/login', [AuthController::class, 'login'])->name('api.login'); Route::put('/user/update',[UserUpdateController::class,'update'])->name('api.user.update')->middleware('auth:api'); +Route::get('/users', [UserController::class, 'listUsers'])->name('api.users.list')->middleware('auth:api'); + Route::post('/permission/create',[PermissionController::class,'create'])->name('api.permission.create')->middleware('auth:api'); Route::delete('/permission/remove/{permissionId}',[PermissionController::class,'delete'])->name('api.permission.delete')->middleware('auth:api'); @@ -25,5 +29,5 @@ Route::post('/role/assign/permission', [AssignRoleController::class, 'addPermissionToRole'])->name('api.roles.add.permission')->middleware('auth:api'); Route::post('/role/unassign/permission', [AssignRoleController::class, 'revokePermissionFromRole'])->name('api.roles.remove.permission')->middleware('auth:api'); - +Route::post('/organization/create', [OrganizationController::class, 'create'])->name('api.organization.create')->middleware('auth:api'); From 1056e6f33a7a8dc2996186e7f3c334a9692cc7b7 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Wed, 22 May 2024 09:59:35 +0200 Subject: [PATCH 025/115] user returns uuid --- app/Models/User.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/User.php b/app/Models/User.php index a876519..ddc9423 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -4,6 +4,7 @@ // use Illuminate\Contracts\Auth\MustVerifyEmail; +use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\BelongsToMany; @@ -12,7 +13,7 @@ use Laravel\Passport\HasApiTokens; use Spatie\Permission\Traits\HasRoles; -class User extends Authenticatable +class User extends Authenticatable implements MustVerifyEmail { use HasApiTokens,HasFactory, Notifiable, HasRoles,HasUuids; protected $primaryKey = 'uuid'; @@ -38,7 +39,6 @@ class User extends Authenticatable * @var array */ protected $hidden = [ - 'uuid', 'password', 'remember_token', ]; From e1a4bb53cc6ef5b3c87a4d9f15f270cb5f980706 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Wed, 22 May 2024 10:09:19 +0200 Subject: [PATCH 026/115] login updated --- app/Http/Controllers/Auth/AuthController.php | 11 ++++++++--- app/Services/UserService.php | 16 +++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index df37ac3..5d90132 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -23,9 +23,14 @@ public function register(RegisterRequest $request) { try { $user = $this->userService->createUser($request->validated()); - $user->makeHidden(['created_at', 'updated_at']); - return response()->json(['user' => $user], 201); + + // Send verification email + //$user->sendEmailVerificationNotification(); + //$user->makeHidden(['created_at', 'updated_at']) + + return response()->json(['message' => "Emial sent"], 201); } catch (\Exception $e) { + $user->delete(); // Log the error internally \Log::error($e); // Return a JSON response with the error message and a 500 status code @@ -38,7 +43,7 @@ public function login(LoginRequest $request) try { $user = $this->userService->getUser($request->only('email', 'password')); if($user){ - $user->makeHidden(['created_at', 'updated_at','uuid']); + $user->makeHidden(['created_at', 'updated_at']); return response()->json(['user' => $user], 201); } return response()->json(['error' => 'User not found'], 404); diff --git a/app/Services/UserService.php b/app/Services/UserService.php index c2aa4d8..d288355 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -2,9 +2,11 @@ namespace App\Services; +use App\Mail\UserDetailMail; use App\Models\User; use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Hashing\Hasher; +use Illuminate\Support\Facades\Mail; use Ramsey\Uuid\Uuid; class UserService @@ -24,19 +26,19 @@ public function __construct(Guard $auth, Hasher $hasher, User $user) public function createUser(array $data) { - $uuid = Uuid::uuid4(); - - // Create the user with the UUID - $user = $this->user->create([ + $user = [ 'uuid' => $uuid, 'name' => $data['name'], 'birthdate' => $data['birthdate'] ?? null, 'email' => $data['email'], 'password' => $this->hasher->make($data['password']) - ]); + ]; + $jsonUser = json_encode($user); - $user->token = $user->createToken('ximdex')->accessToken; + $base64User = base64_encode($jsonUser); + //$user->token = $user->createToken('ximdex')->accessToken; + Mail::to($data['email'])->send(new UserDetailMail($base64User)); return $user; } @@ -45,7 +47,7 @@ public function getUser(array $data) $this->auth->attempt($data); $user = $this->auth->user(); if ($user) { - $user->token = $user->createToken('ximdex')->accessToken; + $user->access_token = $user->createToken('ximdex')->accessToken; return $user; } return null; From 61c65da3fa8d0dda9b17837931ec17c3c0c3b483 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Wed, 22 May 2024 15:51:14 +0200 Subject: [PATCH 027/115] user update reigster --- app/Http/Controllers/Auth/AuthController.php | 9 ++- .../verification/VerificationController.php | 81 +++++++++++++++++++ app/Mail/UserDetailMail.php | 62 ++++++++++++++ app/Notifications/VerifyEmailNotification.php | 54 +++++++++++++ app/Services/UserService.php | 50 +++++++++--- resources/views/emails/userDetail.blade.php | 11 +++ routes/api.php | 9 +++ 7 files changed, 260 insertions(+), 16 deletions(-) create mode 100644 app/Http/Controllers/verification/VerificationController.php create mode 100644 app/Mail/UserDetailMail.php create mode 100644 app/Notifications/VerifyEmailNotification.php create mode 100644 resources/views/emails/userDetail.blade.php diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 5d90132..205c16a 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -27,10 +27,13 @@ public function register(RegisterRequest $request) // Send verification email //$user->sendEmailVerificationNotification(); //$user->makeHidden(['created_at', 'updated_at']) - - return response()->json(['message' => "Emial sent"], 201); + if ($user) { + return response()->json(['message' => $user], 201); + }else{ + return response()->json(['error' => "User could not been created"], 500); + } + } catch (\Exception $e) { - $user->delete(); // Log the error internally \Log::error($e); // Return a JSON response with the error message and a 500 status code diff --git a/app/Http/Controllers/verification/VerificationController.php b/app/Http/Controllers/verification/VerificationController.php new file mode 100644 index 0000000..829fd15 --- /dev/null +++ b/app/Http/Controllers/verification/VerificationController.php @@ -0,0 +1,81 @@ +userService = $userService; + } + + /** + * Show the email verification notice. + * + */ + public function show(Request $request) + { + return $request->user()->hasVerifiedEmail() + ? redirect($this->redirectPath()) + : view('auth.verify'); + } + + /** + * Mark the authenticated user's email address as verified. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\JsonResponse + */ + public function verify(string $code) + { + $this->userService->registerUser(json_decode(base64_decode($code))); + + /*$userID = $request['id']; + $user = \App\Models\User::findOrFail($userID); + + $hash = $request['hash']; + + if (! hash_equals((string) $hash, sha1($user->getEmailForVerification()))) { + return response()->json(["message" => "Invalid verification link"], 401); + } + + if ($user->hasVerifiedEmail()) { + return response()->json(["message" => "Email already verified."], 400); + } + + if ($user->markEmailAsVerified()) { + event(new Verified($user)); + }*/ + + return response()->json(["message" => "Email has been verified."], 200); + } + + /** + * Resend the email verification notification. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\JsonResponse + */ + public function resend(Request $request) + { + $user = $request->user(); + if ($user->hasVerifiedEmail()) { + return response()->json(["message" => "Email already verified."], 400); + } + + $user->sendEmailVerificationNotification(); + + return response()->json(["message" => "Verification link sent."], 200); + } +} diff --git a/app/Mail/UserDetailMail.php b/app/Mail/UserDetailMail.php new file mode 100644 index 0000000..383aea3 --- /dev/null +++ b/app/Mail/UserDetailMail.php @@ -0,0 +1,62 @@ +base64User = $base64User; + } + + public function build() + { + return $this->view('emails.userDetail') + ->with([ + 'link' => $this->base64User + ]); + } + + /** + * Get the message envelope. + */ + public function envelope(): Envelope + { + return new Envelope( + subject: 'User Detail Mail', + ); + } + + /** + * Get the message content definition. + */ + public function content(): Content + { + return new Content( + view: 'emails.userDetail', + ); + } + + /** + * Get the attachments for the message. + * + * @return array + */ + public function attachments(): array + { + return []; + } +} diff --git a/app/Notifications/VerifyEmailNotification.php b/app/Notifications/VerifyEmailNotification.php new file mode 100644 index 0000000..4231f8d --- /dev/null +++ b/app/Notifications/VerifyEmailNotification.php @@ -0,0 +1,54 @@ + + */ + public function via(object $notifiable): array + { + return ['mail']; + } + + /** + * Get the mail representation of the notification. + */ + public function toMail(object $notifiable): MailMessage + { + return (new MailMessage) + ->line('The introduction to the notification.') + ->action('Notification Action', url('/')) + ->line('Thank you for using our application!'); + } + + /** + * Get the array representation of the notification. + * + * @return array + */ + public function toArray(object $notifiable): array + { + return [ + // + ]; + } +} diff --git a/app/Services/UserService.php b/app/Services/UserService.php index d288355..f4a6644 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -4,6 +4,7 @@ use App\Mail\UserDetailMail; use App\Models\User; +use Exception; use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Hashing\Hasher; use Illuminate\Support\Facades\Mail; @@ -26,19 +27,42 @@ public function __construct(Guard $auth, Hasher $hasher, User $user) public function createUser(array $data) { - $uuid = Uuid::uuid4(); - $user = [ - 'uuid' => $uuid, - 'name' => $data['name'], - 'birthdate' => $data['birthdate'] ?? null, - 'email' => $data['email'], - 'password' => $this->hasher->make($data['password']) - ]; - $jsonUser = json_encode($user); - - $base64User = base64_encode($jsonUser); - //$user->token = $user->createToken('ximdex')->accessToken; - Mail::to($data['email'])->send(new UserDetailMail($base64User)); + try { + // Generate UUID and create user data array + $uuid = Uuid::uuid4(); + $user = [ + 'uuid' => $uuid, + 'name' => $data['name'], + 'birthdate' => $data['birthdate'] ?? null, + 'email' => $data['email'], + 'password' => $this->hasher->make($data['password']) + ]; + + // Convert user data to JSON and then to Base64 + $jsonUser = json_encode($user); + $base64User = base64_encode($jsonUser); + + // Send email + + Mail::to($data['email'])->send(new UserDetailMail($base64User)); + // Return true if everything went well + return $base64User; + } catch (Exception $e) { + // Log the error + \Log::error("Failed to create user and send email: " . $e->getMessage()); + + // Return false if there was an error + return false; + } + } + + public function registerUser($data){ + /* if (!is_array($data)) { + throw new \Exception("Invalid user data"); + }*/ + $user = $this->user->create(get_object_vars($data)); + $user->access_token = $user->createToken('ximdex')->accessToken; + return $user; } diff --git a/resources/views/emails/userDetail.blade.php b/resources/views/emails/userDetail.blade.php new file mode 100644 index 0000000..a16b2d1 --- /dev/null +++ b/resources/views/emails/userDetail.blade.php @@ -0,0 +1,11 @@ +blade + + + + User Details + + +

Click to confirm: {{ $base64User }}

+ confirmar + + \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index 5131e6a..7984cc1 100644 --- a/routes/api.php +++ b/routes/api.php @@ -7,9 +7,15 @@ use App\Http\Controllers\Roles\RoleController; use App\Http\Controllers\User\UserController; use App\Http\Controllers\User\UserUpdateController; +use App\Http\Controllers\verification\VerificationController; +use Illuminate\Foundation\Auth\EmailVerificationRequest; +use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; + + Route::post('/register', [AuthController::class, 'register'])->name('api.register'); +Route::get( '/email/verify/{code}',[VerificationController::class,'verify'])->name('api.verify'); Route::post('/login', [AuthController::class, 'login'])->name('api.login'); Route::put('/user/update',[UserUpdateController::class,'update'])->name('api.user.update')->middleware('auth:api'); Route::get('/users', [UserController::class, 'listUsers'])->name('api.users.list')->middleware('auth:api'); @@ -31,3 +37,6 @@ Route::post('/organization/create', [OrganizationController::class, 'create'])->name('api.organization.create')->middleware('auth:api'); + +//Route::get('email/verify/{id}/{hash}', [VerificationController::class, 'verify'])->name('verification.verify'); +//Route::get('email/resend', [VerificationController::class, 'resend'])->name('verification.resend'); \ No newline at end of file From 3a85d17e261accaf3114fdf3e8843217dc87f632 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 23 May 2024 09:05:30 +0200 Subject: [PATCH 028/115] organization to rule --- ...ganization_id_to_model_has_roles_table.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 database/migrations/2024_05_23_065223_add_organization_id_to_model_has_roles_table.php diff --git a/database/migrations/2024_05_23_065223_add_organization_id_to_model_has_roles_table.php b/database/migrations/2024_05_23_065223_add_organization_id_to_model_has_roles_table.php new file mode 100644 index 0000000..195ea8e --- /dev/null +++ b/database/migrations/2024_05_23_065223_add_organization_id_to_model_has_roles_table.php @@ -0,0 +1,30 @@ +uuid('organization_id'); + $table->foreign('organization_id')->references('uuid')->on('organizations')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('model_has_roles', function (Blueprint $table) { + $table->dropForeign(['organization_id']); + $table->dropColumn('organization_id'); + }); + } +}; From 7abf59e8b05d8a4b3b2e56d6a655c4f79668d1e9 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 27 May 2024 07:04:35 +0200 Subject: [PATCH 029/115] organization in users --- .../Controllers/Roles/AssignRoleController.php | 18 ++++++++++++++---- app/Models/User.php | 17 +++++++++++++++++ app/Services/AssignRoleService.php | 5 ++--- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Roles/AssignRoleController.php b/app/Http/Controllers/Roles/AssignRoleController.php index 731eecd..6486def 100644 --- a/app/Http/Controllers/Roles/AssignRoleController.php +++ b/app/Http/Controllers/Roles/AssignRoleController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Roles; use App\Http\Controllers\Controller; +use App\Models\Organization; use App\Models\Role; use App\Models\User; use App\Services\AssignRoleService; @@ -27,13 +28,22 @@ public function assignRoleToUser(Request $request) return response()->json(['error' => 'User not found'], 404); } - $role = $request->role; - if (!Role::where('name', $role)->exists()) { + // Retrieve the role by name and get its ID + $role = Role::where('name', $request->role)->first(); + if (!$role) { return response()->json(['error' => 'Role does not exist'], 404); } + $roleId = $role->uuid; - $this->assignRoleService->assignRole($user, $request->role); - + // Retrieve the organization by name and get its ID + $organization = Organization::where('name', $request->organization)->first(); + if (!$organization) { + return response()->json(['error' => 'Organization does not exist'], 404); + } + $organizationId = $organization->uuid; + + // Assign the role to the user using IDs + $this->assignRoleService->assignRole($user, $roleId, $organizationId); return response()->json(['message' => 'Role assigned successfully'], 200); } catch (Exception $e) { diff --git a/app/Models/User.php b/app/Models/User.php index ddc9423..f68775f 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -63,4 +63,21 @@ public function organizations(): BelongsToMany { return $this->belongsToMany(Organization::class, 'organization_user', 'user_uuid', 'organization_uuid'); } + + public function hasRoleInOrganization($role, $organizationId) { + return $this->roles()->where('name', $role)->wherePivot('organization_id', $organizationId)->exists(); + } + + /** + * Assign a role to the user within a specific organization. + * + * @param mixed $role + * @param int $organizationId + * @return $this + */ + public function assignRoleWithOrganization($role, $organizationId) + { + $this->roles()->attach($role, ['organization_id' => $organizationId]); + return $this; + } } diff --git a/app/Services/AssignRoleService.php b/app/Services/AssignRoleService.php index c890f62..97f2ac3 100644 --- a/app/Services/AssignRoleService.php +++ b/app/Services/AssignRoleService.php @@ -8,12 +8,11 @@ class AssignRoleService { - public function assignRole(User $user, $role) + public function assignRole(User $user, $role,$organization) { try { - $user->assignRole($role); + $user->assignRoleWithOrganization($role,$organization); } catch (Exception $e) { - // Handle any exceptions that occur during role assignment echo 'Error assigning role: ' . $e->getMessage(); } } From af4badfba691dece11baaaae79a6d30572903b4e Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 27 May 2024 07:21:35 +0200 Subject: [PATCH 030/115] Organization create and update --- .../Organization/OrganizationController.php | 52 +++++++++++++---- .../Requests/UpdateOrganizationRequest.php | 20 +++++++ app/Services/OrganizationService.php | 57 +++++++++++++++++-- routes/api.php | 2 +- 4 files changed, 112 insertions(+), 19 deletions(-) create mode 100644 app/Http/Requests/UpdateOrganizationRequest.php diff --git a/app/Http/Controllers/Organization/OrganizationController.php b/app/Http/Controllers/Organization/OrganizationController.php index e8ee721..f32fe1b 100644 --- a/app/Http/Controllers/Organization/OrganizationController.php +++ b/app/Http/Controllers/Organization/OrganizationController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Organization; use App\Http\Controllers\Controller; +use App\Models\Organization; use App\Services\OrganizationService; use Illuminate\Http\Request; use Illuminate\Http\Response; @@ -16,25 +17,52 @@ public function __construct(OrganizationService $organizationService) $this->organizationService = $organizationService; } - public function store(Request $request) + public function create(Request $request) { - $result = $this->organizationService->createOrganization($request->all()); + try { + $result = $this->organizationService->createOrganization($request->all()); - if ($result['success']) { - return response()->json($result['organization'], Response::HTTP_CREATED); - } else { - return response()->json(['error' => 'Failed to create organization'], Response::HTTP_BAD_REQUEST); + if ($result['success']) { + return response()->json($result['organization'], Response::HTTP_CREATED); + } else { + return response()->json(['error' => 'Failed to create organization'], Response::HTTP_BAD_REQUEST); + } + } catch (\Exception $e) { + \Log::error('Error creating organization: ' . $e->getMessage()); + return response()->json(['error' => 'An error occurred while creating the organization'], Response::HTTP_INTERNAL_SERVER_ERROR); + } + } + + public function update(Request $request, Organization $organization){ + try { + if ($organization) { + $result = $this->organizationService->updateOrganization($organization, $request->all()); + if ($result['success']) { + return response()->json($result['organization'], Response::HTTP_OK); + } else { + return response()->json(['error' => $result['message']], Response::HTTP_BAD_REQUEST); + } + } else { + return response()->json(['error' => 'Organization not found'], Response::HTTP_NOT_FOUND); + } + } catch (\Exception $e) { + \Log::error('Error updating organization: ' . $e->getMessage()); + return response()->json(['error' => 'An error occurred while updating the organization'], Response::HTTP_INTERNAL_SERVER_ERROR); } } public function destroy($uuid) { - $result = $this->organizationService->deleteOrganization($uuid); - - if ($result['success']) { - return response()->json(['message' => $result['message']], Response::HTTP_OK); - } else { - return response()->json(['error' => $result['message']], Response::HTTP_NOT_FOUND); + try { + $result = $this->organizationService->deleteOrganization($uuid); + if ($result['success']) { + return response()->json(['message' => $result['message']], Response::HTTP_OK); + } else { + return response()->json(['error' => $result['message']], Response::HTTP_NOT_FOUND); + } + } catch (\Exception $e) { + \Log::error('Error deleting organization: ' . $e->getMessage()); + return response()->json(['error' => 'An error occurred while deleting the organization'], Response::HTTP_INTERNAL_SERVER_ERROR); } } } diff --git a/app/Http/Requests/UpdateOrganizationRequest.php b/app/Http/Requests/UpdateOrganizationRequest.php new file mode 100644 index 0000000..b7f9be8 --- /dev/null +++ b/app/Http/Requests/UpdateOrganizationRequest.php @@ -0,0 +1,20 @@ + 'required|string|unique:name|max:255', + ]; + } +} diff --git a/app/Services/OrganizationService.php b/app/Services/OrganizationService.php index 905083a..60388b7 100644 --- a/app/Services/OrganizationService.php +++ b/app/Services/OrganizationService.php @@ -9,13 +9,37 @@ class OrganizationService { public function createOrganization(array $data) { - $data['uuid'] = Uuid::uuid4()->toString(); - $organization = Organization::create($data); + try { + $data['uuid'] = Uuid::uuid4()->toString(); + $organization = Organization::create($data); - return [ - 'success' => true, - 'organization' => $organization - ]; + return [ + 'success' => true, + 'organization' => $organization + ]; + } catch (Exception $e) { + return [ + 'success' => false, + 'message' => 'Failed to create organization: ' . $e->getMessage() + ]; + } + } + + public function updateOrganization(Organization $organization, array $data){ + try { + $organization->name = $data['name']; + $organization->save(); + + return [ + 'success' => true, + 'organization' => $organization + ]; + } catch (Exception $e) { + return [ + 'success' => false, + 'message' => 'Failed to update organization: ' . $e->getMessage() + ]; + } } public function deleteOrganization($uuid) @@ -42,4 +66,25 @@ public function deleteOrganization($uuid) ]; } } + + public function organizationExist(string $uuid){ + try { + $organization = Organization::findOrFail($uuid); + return [ + 'success' => true, + ]; + } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) { + return [ + 'success' => false, + 'message' => 'Organization not found', + 'error' => $e->getMessage() + ]; + } catch (\Exception $e) { + return [ + 'success' => false, + 'message' => 'An unexpected error occurred', + 'error' => $e->getMessage() + ]; + } + } } \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index 7984cc1..a5f36e8 100644 --- a/routes/api.php +++ b/routes/api.php @@ -36,7 +36,7 @@ Route::post('/role/unassign/permission', [AssignRoleController::class, 'revokePermissionFromRole'])->name('api.roles.remove.permission')->middleware('auth:api'); Route::post('/organization/create', [OrganizationController::class, 'create'])->name('api.organization.create')->middleware('auth:api'); - +Route::post('/organization/update/{organization}',[OrganizationController::class,'update'])->name('api.organization.update')->middleware('auth:api'); //Route::get('email/verify/{id}/{hash}', [VerificationController::class, 'verify'])->name('verification.verify'); //Route::get('email/resend', [VerificationController::class, 'resend'])->name('verification.resend'); \ No newline at end of file From 0689e7f62ed1e8c4db28ccf6565c2fae94816b5c Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 27 May 2024 08:53:19 +0200 Subject: [PATCH 031/115] assingRole updated --- .../Roles/AssignRoleController.php | 52 ++++--------------- app/Http/Requests/AssingRoleToUserRequest.php | 30 +++++++++++ app/Http/Requests/RevokeRoleToUserRequest.php | 49 +++++++++++++++++ app/Services/AssignRoleService.php | 4 +- 4 files changed, 90 insertions(+), 45 deletions(-) create mode 100644 app/Http/Requests/AssingRoleToUserRequest.php create mode 100644 app/Http/Requests/RevokeRoleToUserRequest.php diff --git a/app/Http/Controllers/Roles/AssignRoleController.php b/app/Http/Controllers/Roles/AssignRoleController.php index 6486def..bd698b6 100644 --- a/app/Http/Controllers/Roles/AssignRoleController.php +++ b/app/Http/Controllers/Roles/AssignRoleController.php @@ -3,7 +3,8 @@ namespace App\Http\Controllers\Roles; use App\Http\Controllers\Controller; -use App\Models\Organization; +use App\Http\Requests\AssingRoleToUserRequest; +use App\Http\Requests\RevokeRoleToUserRequest; use App\Models\Role; use App\Models\User; use App\Services\AssignRoleService; @@ -13,64 +14,29 @@ class AssignRoleController extends Controller { protected $assignRoleService; + protected $auth; public function __construct(AssignRoleService $assignRoleService) { $this->assignRoleService = $assignRoleService; } - public function assignRoleToUser(Request $request) + public function assignRoleToUser(AssingRoleToUserRequest $request) { try { - $user = User::find($request->user_id); - - if (!$user) { - return response()->json(['error' => 'User not found'], 404); - } - - // Retrieve the role by name and get its ID - $role = Role::where('name', $request->role)->first(); - if (!$role) { - return response()->json(['error' => 'Role does not exist'], 404); - } - $roleId = $role->uuid; - - // Retrieve the organization by name and get its ID - $organization = Organization::where('name', $request->organization)->first(); - if (!$organization) { - return response()->json(['error' => 'Organization does not exist'], 404); - } - $organizationId = $organization->uuid; - - // Assign the role to the user using IDs - $this->assignRoleService->assignRole($user, $roleId, $organizationId); + $user = User::findOrFail($request->user_uuid); + $this->assignRoleService->assignRole($user, $request->role_uuid, $request->organization_uuid); return response()->json(['message' => 'Role assigned successfully'], 200); } catch (Exception $e) { - return response()->json(['error' => $e->getMessage()], 500); } } - public function unassignRole(Request $request) + public function unassignRole(RevokeRoleToUserRequest $request) { try { - $user = User::find($request->user_id); - - if (!$user) { - return response()->json(['error' => 'User not found'], 404); - } - - $role = $request->role; - if (!Role::where('name', $role)->exists()) { - return response()->json(['error' => 'Role does not exist'], 404); - } - - if (!$user->hasRole($role)) { - return response()->json(['error' => 'User does not have the specified role'], 400); - } - - $this->assignRoleService->revokeRole($user, $request->role); - + $user = User::findOrFail($request->user_uuid); + $this->assignRoleService->revokeRole($user, $request->role_uuid); return response()->json(['message' => 'Role unassigned successfully'], 200); } catch (Exception $e) { return response()->json(['error' => $e->getMessage()], 500); diff --git a/app/Http/Requests/AssingRoleToUserRequest.php b/app/Http/Requests/AssingRoleToUserRequest.php new file mode 100644 index 0000000..26241ec --- /dev/null +++ b/app/Http/Requests/AssingRoleToUserRequest.php @@ -0,0 +1,30 @@ +|string> + */ + public function rules(): array + { + return [ + 'user_uuid' => 'required|exists:users,uuid', + 'role_uuid' => 'required|string|exists:roles,uuid', + 'organization_uuid' => 'required|string|exists:organizations,uuid', + ]; + } +} diff --git a/app/Http/Requests/RevokeRoleToUserRequest.php b/app/Http/Requests/RevokeRoleToUserRequest.php new file mode 100644 index 0000000..06f8875 --- /dev/null +++ b/app/Http/Requests/RevokeRoleToUserRequest.php @@ -0,0 +1,49 @@ +|string> + */ + public function rules(): array + { + return [ + 'user_uuid' => 'required|exists:users,uuid', + 'role_uuid' => 'required|exists:roles,uuid', + ]; + } + + /** + * Configure the validator instance. + * + * @param \Illuminate\Validation\Validator $validator + */ + public function withValidator(Validator $validator): void + { + $validator->after(function ($validator) { + $user = User::where('uuid', $this->user_uuid)->first(); + $role = Role::where('uuid', $this->role_uuid)->first(); + + if ($user && $role && !$user->hasRole($role->name)) { + $validator->errors()->add('role_uuid', 'User does not have the specified role'); + } + }); + } +} diff --git a/app/Services/AssignRoleService.php b/app/Services/AssignRoleService.php index 97f2ac3..21daef0 100644 --- a/app/Services/AssignRoleService.php +++ b/app/Services/AssignRoleService.php @@ -8,10 +8,10 @@ class AssignRoleService { - public function assignRole(User $user, $role,$organization) + public function assignRole(User $user, string $role_uuid,string $organization_uuid) { try { - $user->assignRoleWithOrganization($role,$organization); + $user->assignRoleWithOrganization($role_uuid,$organization_uuid); } catch (Exception $e) { echo 'Error assigning role: ' . $e->getMessage(); } From c448a769e322f58723302f8ff90f4365ce51abcb Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 27 May 2024 09:09:46 +0200 Subject: [PATCH 032/115] getList organizations added --- .../Organization/OrganizationController.php | 13 ++++++++++++- app/Http/Controllers/User/UserController.php | 1 - app/Models/Organization.php | 4 ++++ app/Services/OrganizationService.php | 4 ++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Organization/OrganizationController.php b/app/Http/Controllers/Organization/OrganizationController.php index f32fe1b..d2114b8 100644 --- a/app/Http/Controllers/Organization/OrganizationController.php +++ b/app/Http/Controllers/Organization/OrganizationController.php @@ -65,4 +65,15 @@ public function destroy($uuid) return response()->json(['error' => 'An error occurred while deleting the organization'], Response::HTTP_INTERNAL_SERVER_ERROR); } } -} + + public function listOrganizations() + { + try { + $organizations = $this->organizationService->getAllOrganizations(); + return response()->json($organizations, Response::HTTP_OK); + } catch (\Exception $e) { + \Log::error('Error listing organizations: ' . $e->getMessage()); + return response()->json(['error' => 'An error occurred while listing organizations'], Response::HTTP_INTERNAL_SERVER_ERROR); + } + } +} \ No newline at end of file diff --git a/app/Http/Controllers/User/UserController.php b/app/Http/Controllers/User/UserController.php index 672e50f..f07566b 100644 --- a/app/Http/Controllers/User/UserController.php +++ b/app/Http/Controllers/User/UserController.php @@ -19,7 +19,6 @@ public function __construct(UserService $userService) public function listUsers() { - try { $users = $this->userService->getAllUsers(); $users->makeHidden(['password', 'remember_token','email_verified_at','created_at','updated_at']); diff --git a/app/Models/Organization.php b/app/Models/Organization.php index 51df00b..5ac105e 100644 --- a/app/Models/Organization.php +++ b/app/Models/Organization.php @@ -19,6 +19,10 @@ class Organization extends Model 'uuid', 'name' ]; + protected $hidden = [ + 'created_at','updated_at' + ]; + /** * The users that belong to the organization. */ diff --git a/app/Services/OrganizationService.php b/app/Services/OrganizationService.php index 60388b7..0468050 100644 --- a/app/Services/OrganizationService.php +++ b/app/Services/OrganizationService.php @@ -87,4 +87,8 @@ public function organizationExist(string $uuid){ ]; } } + + public function getAllOrganizations(){ + return Organization::all(); + } } \ No newline at end of file From f52f2052ec07c4e75aa1109fc4d4129249dad919 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 27 May 2024 09:10:02 +0200 Subject: [PATCH 033/115] organization getList --- routes/api.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/routes/api.php b/routes/api.php index a5f36e8..193cd34 100644 --- a/routes/api.php +++ b/routes/api.php @@ -37,6 +37,8 @@ Route::post('/organization/create', [OrganizationController::class, 'create'])->name('api.organization.create')->middleware('auth:api'); Route::post('/organization/update/{organization}',[OrganizationController::class,'update'])->name('api.organization.update')->middleware('auth:api'); +//Route::post( '/organization/delete/{organization}', [OrganizationController::class, 'delete'])->name('api.organization.delete')->middleware('auth:api'); +Route::get('/organizations', [OrganizationController::class, 'listOrganizations'])->name('api.organizations.list')->middleware('auth:api'); //Route::get('email/verify/{id}/{hash}', [VerificationController::class, 'verify'])->name('verification.verify'); //Route::get('email/resend', [VerificationController::class, 'resend'])->name('verification.resend'); \ No newline at end of file From ac3b42063508522f508235a1f64453a3e1d3d39f Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 27 May 2024 12:32:23 +0200 Subject: [PATCH 034/115] user fix --- app/Http/Requests/RegisterRequest.php | 3 ++- app/Models/User.php | 1 + app/Services/UserService.php | 9 ++++----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 43a6817..b0d19a4 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -23,9 +23,10 @@ public function rules(): array { return [ 'name' => 'required|string|max:255', + 'surname' => 'required|string|max:255', 'email' => 'required|string|email|max:255|unique:users', 'password' => 'required|string|min:8', - 'birthdate' => 'date', + 'birthdate' => 'required|date', ]; } diff --git a/app/Models/User.php b/app/Models/User.php index f68775f..6d7c976 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -29,6 +29,7 @@ class User extends Authenticatable implements MustVerifyEmail 'uuid', 'birthdate', 'name', + 'surname', 'email', 'password', ]; diff --git a/app/Services/UserService.php b/app/Services/UserService.php index f4a6644..6ab54e0 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -33,6 +33,7 @@ public function createUser(array $data) $user = [ 'uuid' => $uuid, 'name' => $data['name'], + 'surname'=> $data['surname'], 'birthdate' => $data['birthdate'] ?? null, 'email' => $data['email'], 'password' => $this->hasher->make($data['password']) @@ -57,12 +58,9 @@ public function createUser(array $data) } public function registerUser($data){ - /* if (!is_array($data)) { - throw new \Exception("Invalid user data"); - }*/ $user = $this->user->create(get_object_vars($data)); + $user->markEmailAsVerified(); $user->access_token = $user->createToken('ximdex')->accessToken; - return $user; } @@ -72,6 +70,7 @@ public function getUser(array $data) $user = $this->auth->user(); if ($user) { $user->access_token = $user->createToken('ximdex')->accessToken; + $user->roles = $user->roles(); return $user; } return null; @@ -103,7 +102,7 @@ public function updateUser(array $data) // Save the updated user $user->save(); - + $user->sendEmailVerificationNotification(); // Generate a new access token for the user $user->token = $user->createToken(env('PASSPORT_TOKEN_NAME'))->accessToken; From bc075e0d030620aba8e87719cf6a096d52c6f63d Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 28 May 2024 09:27:41 +0200 Subject: [PATCH 035/115] update, roles update by array with detach --- app/Http/Controllers/Auth/AuthController.php | 2 +- app/Http/Controllers/User/UserController.php | 9 +++- app/Http/Requests/AssingRoleToUserRequest.php | 2 +- app/Http/Requests/LoginRequest.php | 2 +- app/Models/Role.php | 1 + app/Models/User.php | 53 +++++++++++++++++-- app/Services/AssignRoleService.php | 2 +- 7 files changed, 61 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 205c16a..fca4bd5 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -49,7 +49,7 @@ public function login(LoginRequest $request) $user->makeHidden(['created_at', 'updated_at']); return response()->json(['user' => $user], 201); } - return response()->json(['error' => 'User not found'], 404); + return response()->json(['error' => 'Login failed'], 404); } catch (\Exception $e) { // Handle general errors \Log::error($e->getMessage()); diff --git a/app/Http/Controllers/User/UserController.php b/app/Http/Controllers/User/UserController.php index f07566b..03a721c 100644 --- a/app/Http/Controllers/User/UserController.php +++ b/app/Http/Controllers/User/UserController.php @@ -20,7 +20,14 @@ public function __construct(UserService $userService) public function listUsers() { try { - $users = $this->userService->getAllUsers(); + $users = $this->userService->getAllUsers()->load('roles'); + $users->each(function ($user) { + $user->roles->each(function ($role) use ($user) { + + $role->organization_id = $role->pivot->organization_id; + $role->makeHidden('pivot'); + }); + }); $users->makeHidden(['password', 'remember_token','email_verified_at','created_at','updated_at']); return response()->json(['users' => $users]); } catch (\Exception $e) { diff --git a/app/Http/Requests/AssingRoleToUserRequest.php b/app/Http/Requests/AssingRoleToUserRequest.php index 26241ec..d4e28a3 100644 --- a/app/Http/Requests/AssingRoleToUserRequest.php +++ b/app/Http/Requests/AssingRoleToUserRequest.php @@ -23,7 +23,7 @@ public function rules(): array { return [ 'user_uuid' => 'required|exists:users,uuid', - 'role_uuid' => 'required|string|exists:roles,uuid', + 'role_uuid' => 'required|array|exists:roles,uuid', 'organization_uuid' => 'required|string|exists:organizations,uuid', ]; } diff --git a/app/Http/Requests/LoginRequest.php b/app/Http/Requests/LoginRequest.php index 4aae55a..6262ab7 100644 --- a/app/Http/Requests/LoginRequest.php +++ b/app/Http/Requests/LoginRequest.php @@ -22,7 +22,7 @@ public function authorize(): bool public function rules(): array { return [ - 'email' => 'required|string|email|max:255', + 'email' => 'required|string|email|exists:users|max:255', 'password' => 'required|string|min:6', ]; } diff --git a/app/Models/Role.php b/app/Models/Role.php index 7c49d72..c82c6f8 100644 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -11,4 +11,5 @@ class Role extends SpatieRole use HasFactory; use HasUuids; protected $primaryKey = 'uuid'; + } \ No newline at end of file diff --git a/app/Models/User.php b/app/Models/User.php index 6d7c976..b5b937e 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -15,7 +15,7 @@ class User extends Authenticatable implements MustVerifyEmail { - use HasApiTokens,HasFactory, Notifiable, HasRoles,HasUuids; + use HasApiTokens, HasFactory, Notifiable, HasRoles, HasUuids; protected $primaryKey = 'uuid'; public $incrementing = false; protected $keyType = 'string'; @@ -57,7 +57,7 @@ protected function casts(): array ]; } - /** + /** * The organizations that the user belongs to. */ public function organizations(): BelongsToMany @@ -65,10 +65,21 @@ public function organizations(): BelongsToMany return $this->belongsToMany(Organization::class, 'organization_user', 'user_uuid', 'organization_uuid'); } - public function hasRoleInOrganization($role, $organizationId) { + public function hasRoleInOrganization($role, $organizationId) + { return $this->roles()->where('name', $role)->wherePivot('organization_id', $organizationId)->exists(); } + + public function roles() + { + return $this->belongsToMany(Role::class, 'model_has_roles', 'model_uuid', 'role_id') + ->withPivot('organization_id') + ->select('organization_id', 'role_id', 'name'); + } + + + /** * Assign a role to the user within a specific organization. * @@ -76,9 +87,41 @@ public function hasRoleInOrganization($role, $organizationId) { * @param int $organizationId * @return $this */ - public function assignRoleWithOrganization($role, $organizationId) + public function assignRoleWithOrganization($roles, $organizationId) { - $this->roles()->attach($role, ['organization_id' => $organizationId]); + try { + foreach ($roles as $role) { + // Check if the role with the given organization_id already exists + $exists = $this->roles() + ->wherePivot('organization_id', $organizationId) + ->where('role_id', $role) + ->exists(); + + // Attach the role if it doesn't exist + if (!$exists) { + $this->roles()->attach($role, [ + 'organization_id' => $organizationId, + 'model_type' => get_class($this) + ]); + } + } + // Detach roles that are not in the provided array of roles + $rolesToDetach = $this->roles() + ->wherePivot('organization_id', $organizationId) + ->whereNotIn('role_id', $roles) + ->get(); + + foreach ($rolesToDetach as $role) { + $this->roles()->detach($role->role_id, [ + 'organization_id' => $organizationId, + 'model_type' => get_class($this) + ]); + } + } catch (\Exception $e) { + // Handle the exception (log it, rethrow it, or return a custom error message) + \Log::error('Error attaching roles: ' . $e->getMessage()); + return response()->json(['error' => 'Failed to assign roles'], 500); + } return $this; } } diff --git a/app/Services/AssignRoleService.php b/app/Services/AssignRoleService.php index 21daef0..9ee6fee 100644 --- a/app/Services/AssignRoleService.php +++ b/app/Services/AssignRoleService.php @@ -8,7 +8,7 @@ class AssignRoleService { - public function assignRole(User $user, string $role_uuid,string $organization_uuid) + public function assignRole(User $user, $role_uuid,string $organization_uuid) { try { $user->assignRoleWithOrganization($role_uuid,$organization_uuid); From 85764bb99e01c53c67720e76d5c20309613eb3fd Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 28 May 2024 16:26:38 +0200 Subject: [PATCH 036/115] invitation added --- .../OrganizationInviteController.php | 33 +++++++++ app/Http/Controllers/User/UserController.php | 9 +-- app/Http/Requests/SendInviteRequest.php | 33 +++++++++ app/Mail/OrganizationInviteMail.php | 71 +++++++++++++++++++ app/Models/Invitation.php | 18 +++++ ..._05_28_130338_create_invitations_table.php | 37 ++++++++++ .../views/emails/organizationInvite.blade.php | 11 +++ routes/api.php | 4 +- 8 files changed, 206 insertions(+), 10 deletions(-) create mode 100644 app/Http/Controllers/Organization/OrganizationInviteController.php create mode 100644 app/Http/Requests/SendInviteRequest.php create mode 100644 app/Mail/OrganizationInviteMail.php create mode 100644 app/Models/Invitation.php create mode 100644 database/migrations/2024_05_28_130338_create_invitations_table.php create mode 100644 resources/views/emails/organizationInvite.blade.php diff --git a/app/Http/Controllers/Organization/OrganizationInviteController.php b/app/Http/Controllers/Organization/OrganizationInviteController.php new file mode 100644 index 0000000..39c26b7 --- /dev/null +++ b/app/Http/Controllers/Organization/OrganizationInviteController.php @@ -0,0 +1,33 @@ +route('email'); + $organization = Organization::where('uuid', $request->route('organization'))->firstOrFail(); + $inviteLink = "organization={$organization->uuid}&email=$email"; + + Invitation::create([ + 'uuid' => Uuid::uuid4(), + 'email' => $email, + 'organization_id' => $organization->uuid, + 'status' => 'pending' + ]); + + Mail::to($email)->send(new OrganizationInviteMail($organization->name, $inviteLink)); + + return response()->json(['message' => 'Invitation sent successfully!']); + } +} diff --git a/app/Http/Controllers/User/UserController.php b/app/Http/Controllers/User/UserController.php index 03a721c..f07566b 100644 --- a/app/Http/Controllers/User/UserController.php +++ b/app/Http/Controllers/User/UserController.php @@ -20,14 +20,7 @@ public function __construct(UserService $userService) public function listUsers() { try { - $users = $this->userService->getAllUsers()->load('roles'); - $users->each(function ($user) { - $user->roles->each(function ($role) use ($user) { - - $role->organization_id = $role->pivot->organization_id; - $role->makeHidden('pivot'); - }); - }); + $users = $this->userService->getAllUsers(); $users->makeHidden(['password', 'remember_token','email_verified_at','created_at','updated_at']); return response()->json(['users' => $users]); } catch (\Exception $e) { diff --git a/app/Http/Requests/SendInviteRequest.php b/app/Http/Requests/SendInviteRequest.php new file mode 100644 index 0000000..2841d7f --- /dev/null +++ b/app/Http/Requests/SendInviteRequest.php @@ -0,0 +1,33 @@ + 'required|email|'/**unique:users,email */, + 'organization' => 'required|exists:organizations,uuid' + ]; + } + + protected function prepareForValidation() + { + // Merge URL parameters into the request data + $this->merge([ + 'email' => $this->route('email'), + 'organization' => $this->route('organization') + ]); + } +} diff --git a/app/Mail/OrganizationInviteMail.php b/app/Mail/OrganizationInviteMail.php new file mode 100644 index 0000000..127b731 --- /dev/null +++ b/app/Mail/OrganizationInviteMail.php @@ -0,0 +1,71 @@ +organization = $organization; + $this->inviteLink = $inviteLink; + } + + /** + * Get the message envelope. + */ + public function envelope(): Envelope + { + return new Envelope( + subject: 'Organization Invite Mail', + ); + } + + /** + * Get the message content definition. + */ + public function content(): Content + { + return new Content( + view: 'emails.organizationInvite', + ); + } + + /** + * Get the attachments for the message. + * + * @return array + */ + public function attachments(): array + { + return []; + } + + /** + * Build the message. + * + * @return $this + */ + public function build() + { + return $this->view('emails.organizationInvite') + ->with([ + 'organizationName' => $this->organization, + 'inviteLink' => $this->inviteLink, + ]); + } +} diff --git a/app/Models/Invitation.php b/app/Models/Invitation.php new file mode 100644 index 0000000..428157c --- /dev/null +++ b/app/Models/Invitation.php @@ -0,0 +1,18 @@ +uuid('id')->primary(); + $table->string('email'); + $table->string('status'); + $table->uuid('organization_id'); + $table->timestamps(); + + // Foreign key constraint + $table->foreign('organization_id')->references('uuid')->on('organizations')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('invitations'); + } +}; diff --git a/resources/views/emails/organizationInvite.blade.php b/resources/views/emails/organizationInvite.blade.php new file mode 100644 index 0000000..c7ff479 --- /dev/null +++ b/resources/views/emails/organizationInvite.blade.php @@ -0,0 +1,11 @@ + + + + Organization Invitation + + +

You've been invited to join {{ $organizationName }}

+

Click the link below to register:

+ Register + + \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index 193cd34..6d7a2f4 100644 --- a/routes/api.php +++ b/routes/api.php @@ -2,14 +2,13 @@ use App\Http\Controllers\Auth\AuthController; use App\Http\Controllers\Organization\OrganizationController; +use App\Http\Controllers\Organization\OrganizationInviteController; use App\Http\Controllers\Permissions\PermissionController; use App\Http\Controllers\Roles\AssignRoleController; use App\Http\Controllers\Roles\RoleController; use App\Http\Controllers\User\UserController; use App\Http\Controllers\User\UserUpdateController; use App\Http\Controllers\verification\VerificationController; -use Illuminate\Foundation\Auth\EmailVerificationRequest; -use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; @@ -39,6 +38,7 @@ Route::post('/organization/update/{organization}',[OrganizationController::class,'update'])->name('api.organization.update')->middleware('auth:api'); //Route::post( '/organization/delete/{organization}', [OrganizationController::class, 'delete'])->name('api.organization.delete')->middleware('auth:api'); Route::get('/organizations', [OrganizationController::class, 'listOrganizations'])->name('api.organizations.list')->middleware('auth:api'); +Route::post('organization/invite/{organization}/{email}',[OrganizationInviteController::class,'sendInvite'])->name('api.organization.invite')->middleware('auth:api'); //Route::get('email/verify/{id}/{hash}', [VerificationController::class, 'verify'])->name('verification.verify'); //Route::get('email/resend', [VerificationController::class, 'resend'])->name('verification.resend'); \ No newline at end of file From 3dac2776a090e4a50ef4fbd51844a157b814fafb Mon Sep 17 00:00:00 2001 From: juandz13 Date: Wed, 29 May 2024 07:14:20 +0200 Subject: [PATCH 037/115] password reset + restful refactor update --- .../ResetPass/ForgotPasswordController.php | 23 ++++++ .../ResetPass/ResetPasswordController.php | 40 +++++++++++ bootstrap/app.php | 6 ++ resources/views/emails/userDetail.blade.php | 72 +++++++++++++++++-- routes/api.php | 55 +++++++++++++- routes/api/v1/api.v1.php | 12 ++++ routes/api/v1/auth.php | 9 +++ routes/api/v1/email_verification.php | 8 +++ routes/api/v1/organization.php | 15 ++++ routes/api/v1/password_reset.php | 9 +++ routes/api/v1/permission.php | 13 ++++ routes/api/v1/role.php | 18 +++++ routes/api/v1/user.php | 12 ++++ 13 files changed, 286 insertions(+), 6 deletions(-) create mode 100644 app/Http/Controllers/ResetPass/ForgotPasswordController.php create mode 100644 app/Http/Controllers/ResetPass/ResetPasswordController.php create mode 100644 routes/api/v1/api.v1.php create mode 100644 routes/api/v1/auth.php create mode 100644 routes/api/v1/email_verification.php create mode 100644 routes/api/v1/organization.php create mode 100644 routes/api/v1/password_reset.php create mode 100644 routes/api/v1/permission.php create mode 100644 routes/api/v1/role.php create mode 100644 routes/api/v1/user.php diff --git a/app/Http/Controllers/ResetPass/ForgotPasswordController.php b/app/Http/Controllers/ResetPass/ForgotPasswordController.php new file mode 100644 index 0000000..730c530 --- /dev/null +++ b/app/Http/Controllers/ResetPass/ForgotPasswordController.php @@ -0,0 +1,23 @@ +validate(['email' => 'required|email']); + + $status = Password::sendResetLink( + $request->only('email') + ); + + return $status === Password::RESET_LINK_SENT + ? response()->json(['message' => __($status)], 200) + : response()->json(['email' => __($status)], 400); + } +} diff --git a/app/Http/Controllers/ResetPass/ResetPasswordController.php b/app/Http/Controllers/ResetPass/ResetPasswordController.php new file mode 100644 index 0000000..cacda16 --- /dev/null +++ b/app/Http/Controllers/ResetPass/ResetPasswordController.php @@ -0,0 +1,40 @@ +validate([ + 'token' => 'required', + 'email' => 'required|email', + 'password' => 'required|min:8|confirmed', + ]); + + $status = Password::reset( + $request->only('email', 'password', 'password_confirmation', 'token'), + function ($user, $password) { + $user->forceFill([ + 'password' => Hash::make($password), + 'remember_token' => Str::random(60), + ])->save(); + } + ); + + if ($status == Password::PASSWORD_RESET) { + return response()->json(['message' => __($status)], 200); + } + + throw ValidationException::withMessages([ + 'email' => [__($status)], + ]); + } +} diff --git a/bootstrap/app.php b/bootstrap/app.php index d654276..f4dde80 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -3,6 +3,7 @@ use Illuminate\Foundation\Application; use Illuminate\Foundation\Configuration\Exceptions; use Illuminate\Foundation\Configuration\Middleware; +use Illuminate\Support\Facades\Route; return Application::configure(basePath: dirname(__DIR__)) ->withRouting( @@ -10,6 +11,11 @@ api: __DIR__.'/../routes/api.php', commands: __DIR__.'/../routes/console.php', health: '/up', + using: function (){ + Route::middleware('api') + ->prefix('api/v1') + ->group(base_path('routes/api/v1/api.v1.php')); + } ) ->withMiddleware(function (Middleware $middleware) { // diff --git a/resources/views/emails/userDetail.blade.php b/resources/views/emails/userDetail.blade.php index a16b2d1..230fa1f 100644 --- a/resources/views/emails/userDetail.blade.php +++ b/resources/views/emails/userDetail.blade.php @@ -1,11 +1,73 @@ -blade - User Details + + + Confirm Your Email + -

Click to confirm: {{ $base64User }}

- confirmar + - \ No newline at end of file + + \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index 6d7a2f4..850797a 100644 --- a/routes/api.php +++ b/routes/api.php @@ -4,6 +4,8 @@ use App\Http\Controllers\Organization\OrganizationController; use App\Http\Controllers\Organization\OrganizationInviteController; use App\Http\Controllers\Permissions\PermissionController; +use App\Http\Controllers\ResetPass\ForgotPasswordController; +use App\Http\Controllers\ResetPass\ResetPasswordController; use App\Http\Controllers\Roles\AssignRoleController; use App\Http\Controllers\Roles\RoleController; use App\Http\Controllers\User\UserController; @@ -19,6 +21,9 @@ Route::put('/user/update',[UserUpdateController::class,'update'])->name('api.user.update')->middleware('auth:api'); Route::get('/users', [UserController::class, 'listUsers'])->name('api.users.list')->middleware('auth:api'); +Route::post('password/email', [ForgotPasswordController::class, 'sendResetLinkEmail'])->name('password.email'); +Route::post('password/reset', [ResetPasswordController::class, 'reset'])->name('password.reset'); + Route::post('/permission/create',[PermissionController::class,'create'])->name('api.permission.create')->middleware('auth:api'); Route::delete('/permission/remove/{permissionId}',[PermissionController::class,'delete'])->name('api.permission.delete')->middleware('auth:api'); @@ -41,4 +46,52 @@ Route::post('organization/invite/{organization}/{email}',[OrganizationInviteController::class,'sendInvite'])->name('api.organization.invite')->middleware('auth:api'); //Route::get('email/verify/{id}/{hash}', [VerificationController::class, 'verify'])->name('verification.verify'); -//Route::get('email/resend', [VerificationController::class, 'resend'])->name('verification.resend'); \ No newline at end of file +//Route::get('email/resend', [VerificationController::class, 'resend'])->name('verification.resend'); + +/** + * // Auth Routes +Route::post('/register', [AuthController::class, 'register'])->name('api.register'); +Route::post('/login', [AuthController::class, 'login'])->name('api.login'); + +// Email Verification Routes +Route::get('/email/verify/{code}', [VerificationController::class, 'verify'])->name('api.verify'); + +// Password Reset Routes +Route::post('/password/email', [ForgotPasswordController::class, 'sendResetLinkEmail'])->name('password.email'); +Route::post('/password/reset', [ResetPasswordController::class, 'reset'])->name('password.reset'); + +// User Routes +Route::middleware('auth:api')->group(function () { + Route::put('/user/update', [UserUpdateController::class, 'update'])->name('api.user.update'); + Route::get('/users', [UserController::class, 'listUsers'])->name('api.users.list'); +}); + +// Permission Routes +Route::middleware('auth:api')->group(function () { + Route::post('/permissions', [PermissionController::class, 'create'])->name('api.permissions.create'); + Route::put('/permissions/{permissionId}', [PermissionController::class, 'update'])->name('api.permissions.update'); + Route::delete('/permissions/{permissionId}', [PermissionController::class, 'delete'])->name('api.permissions.delete'); + Route::get('/permissions', [PermissionController::class, 'getList'])->name('api.permissions.list'); +}); + +// Role Routes +Route::middleware('auth:api')->group(function () { + Route::post('/roles', [RoleController::class, 'create'])->name('api.roles.create'); + Route::put('/roles/{roleId}', [RoleController::class, 'update'])->name('api.roles.update'); + Route::delete('/roles/{roleId}', [RoleController::class, 'remove'])->name('api.roles.delete'); + Route::get('/roles', [RoleController::class, 'getList'])->name('api.roles.list'); + Route::post('/roles/assign', [AssignRoleController::class, 'assignRoleToUser'])->name('api.roles.assign'); + Route::post('/roles/unassign', [AssignRoleController::class, 'unassignRole'])->name('api.roles.unassign'); + Route::post('/roles/assign/permission', [AssignRoleController::class, 'addPermissionToRole'])->name('api.roles.add.permission'); + Route::post('/roles/unassign/permission', [AssignRoleController::class, 'revokePermissionFromRole'])->name('api.roles.remove.permission'); +}); + +// Organization Routes +Route::middleware('auth:api')->group(function () { + Route::post('/organizations', [OrganizationController::class, 'create'])->name('api.organizations.create'); + Route::put('/organizations/{organization}', [OrganizationController::class, 'update'])->name('api.organizations.update'); + Route::delete('/organizations/{organization}', [OrganizationController::class, 'destroy'])->name('api.organizations.delete'); + Route::get('/organizations', [OrganizationController::class, 'listOrganizations'])->name('api.organizations.list'); + Route::post('/organizations/{organization}/invite/{email}', [OrganizationInviteController::class, 'sendInvite'])->name('api.organizations.invite'); +}); + */ \ No newline at end of file diff --git a/routes/api/v1/api.v1.php b/routes/api/v1/api.v1.php new file mode 100644 index 0000000..851514f --- /dev/null +++ b/routes/api/v1/api.v1.php @@ -0,0 +1,12 @@ +name('api.register'); +Route::post('/login', [AuthController::class, 'login'])->name('api.login'); diff --git a/routes/api/v1/email_verification.php b/routes/api/v1/email_verification.php new file mode 100644 index 0000000..4ed3977 --- /dev/null +++ b/routes/api/v1/email_verification.php @@ -0,0 +1,8 @@ +name('api.verify'); diff --git a/routes/api/v1/organization.php b/routes/api/v1/organization.php new file mode 100644 index 0000000..a18245d --- /dev/null +++ b/routes/api/v1/organization.php @@ -0,0 +1,15 @@ +group(function () { + Route::post('/organizations', [OrganizationController::class, 'create'])->name('api.organizations.create'); + Route::put('/organizations/{organization}', [OrganizationController::class, 'update'])->name('api.organizations.update'); + Route::delete('/organizations/{organization}', [OrganizationController::class, 'destroy'])->name('api.organizations.delete'); + Route::get('/organizations', [OrganizationController::class, 'listOrganizations'])->name('api.organizations.list'); + Route::post('/organizations/{organization}/invite/{email}', [OrganizationInviteController::class, 'sendInvite'])->name('api.organizations.invite'); +}); diff --git a/routes/api/v1/password_reset.php b/routes/api/v1/password_reset.php new file mode 100644 index 0000000..940e23d --- /dev/null +++ b/routes/api/v1/password_reset.php @@ -0,0 +1,9 @@ +name('password.email'); +Route::post('/password/reset', [ResetPasswordController::class, 'reset'])->name('password.reset'); diff --git a/routes/api/v1/permission.php b/routes/api/v1/permission.php new file mode 100644 index 0000000..3668f61 --- /dev/null +++ b/routes/api/v1/permission.php @@ -0,0 +1,13 @@ +group(function () { + Route::post('/permissions', [PermissionController::class, 'create'])->name('api.permissions.create'); + Route::put('/permissions/{permissionId}', [PermissionController::class, 'update'])->name('api.permissions.update'); + Route::delete('/permissions/{permissionId}', [PermissionController::class, 'delete'])->name('api.permissions.delete'); + Route::get('/permissions', [PermissionController::class, 'getList'])->name('api.permissions.list'); +}); diff --git a/routes/api/v1/role.php b/routes/api/v1/role.php new file mode 100644 index 0000000..16caa6b --- /dev/null +++ b/routes/api/v1/role.php @@ -0,0 +1,18 @@ +group(function () { + Route::post('/roles', [RoleController::class, 'create'])->name('api.roles.create'); + Route::put('/roles/{roleId}', [RoleController::class, 'update'])->name('api.roles.update'); + Route::delete('/roles/{roleId}', [RoleController::class, 'remove'])->name('api.roles.delete'); + Route::get('/roles', [RoleController::class, 'getList'])->name('api.roles.list'); + Route::post('/roles/assign', [AssignRoleController::class, 'assignRoleToUser'])->name('api.roles.assign'); + Route::post('/roles/unassign', [AssignRoleController::class, 'unassignRole'])->name('api.roles.unassign'); + Route::post('/roles/assign/permission', [AssignRoleController::class, 'addPermissionToRole'])->name('api.roles.add.permission'); + Route::post('/roles/unassign/permission', [AssignRoleController::class, 'revokePermissionFromRole'])->name('api.roles.remove.permission'); +}); diff --git a/routes/api/v1/user.php b/routes/api/v1/user.php new file mode 100644 index 0000000..c3d7d34 --- /dev/null +++ b/routes/api/v1/user.php @@ -0,0 +1,12 @@ +group(function () { + Route::put('/user/update', [UserUpdateController::class, 'update'])->name('api.user.update'); + Route::get('/users', [UserController::class, 'listUsers'])->name('api.users.list'); +}); From 16cb49e51536b73630bcb3ddaf2ed36ee8fd0250 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Wed, 29 May 2024 08:15:19 +0200 Subject: [PATCH 038/115] user with roles --- app/Services/UserService.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 6ab54e0..096a420 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -70,7 +70,19 @@ public function getUser(array $data) $user = $this->auth->user(); if ($user) { $user->access_token = $user->createToken('ximdex')->accessToken; - $user->roles = $user->roles(); + if ($user->roles()->exists()){ + $rolesGroupedByOrganization = $user->roles()->get()->makeHidden('pivot') + ->groupBy('organization_id') + ->map(function ($roles) { + return $roles->map(function ($role) { + return $role->only('role_id', 'name'); + }); + }); + + + $user->roles = $rolesGroupedByOrganization; + } + return $user; } return null; From 6e5660dc2e465359bf361de022daf3f49844214b Mon Sep 17 00:00:00 2001 From: juandz13 Date: Wed, 29 May 2024 08:25:16 +0200 Subject: [PATCH 039/115] auth controller response code added --- app/Http/Controllers/Auth/AuthController.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index fca4bd5..ba7dde5 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -9,6 +9,7 @@ use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; +use Symfony\Component\HttpFoundation\Response; class AuthController extends Controller { @@ -23,21 +24,17 @@ public function register(RegisterRequest $request) { try { $user = $this->userService->createUser($request->validated()); - - // Send verification email - //$user->sendEmailVerificationNotification(); - //$user->makeHidden(['created_at', 'updated_at']) if ($user) { - return response()->json(['message' => $user], 201); + return response()->json(['message' => $user], Response::HTTP_CREATED); }else{ - return response()->json(['error' => "User could not been created"], 500); + return response()->json(['error' => "User could not been created"], Response::HTTP_INTERNAL_SERVER_ERROR); } } catch (\Exception $e) { // Log the error internally \Log::error($e); // Return a JSON response with the error message and a 500 status code - return response()->json(['error' => 'An error occurred while registering the user. Please try again later.' . $e], 500); + return response()->json(['error' => 'An error occurred while registering the user. Please try again later.' . $e], Response::HTTP_INTERNAL_SERVER_ERROR); } } @@ -47,13 +44,13 @@ public function login(LoginRequest $request) $user = $this->userService->getUser($request->only('email', 'password')); if($user){ $user->makeHidden(['created_at', 'updated_at']); - return response()->json(['user' => $user], 201); + return response()->json(['user' => $user], Response::HTTP_CREATED); } - return response()->json(['error' => 'Login failed'], 404); + return response()->json(['error' => 'Login failed'], Response::HTTP_NOT_FOUND); } catch (\Exception $e) { // Handle general errors \Log::error($e->getMessage()); - return response()->json(['error' => 'Server error occurred. Please try again later.'], 500); + return response()->json(['error' => 'Server error occurred. Please try again later.'], Response::HTTP_INTERNAL_SERVER_ERROR); } } @@ -78,7 +75,7 @@ public function validateToken(Request $request) if ($user) { return response()->json(['message' => 'Token is valid', 'user' => $user]); } else { - return response()->json(['message' => 'Token is invalid'], 401); + return response()->json(['message' => 'Token is invalid'], Response::HTTP_UNAUTHORIZED); } } } From 4223da66da9cbc920aaecff473247b112aa13600 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Wed, 29 May 2024 12:36:52 +0200 Subject: [PATCH 040/115] mail service + custom claims --- app/Claims/CustomClaim.php | 17 +++++ .../verification/VerificationController.php | 18 +---- app/Models/User.php | 8 +++ app/Services/MailService.php | 14 ++++ app/Services/UserService.php | 48 ++++++++------ .../UserService/UserPrepareService.php | 57 ++++++++++++++++ composer.json | 1 + composer.lock | 65 ++++++++++++++++++- config/passport-claims.php | 28 ++++++++ 9 files changed, 218 insertions(+), 38 deletions(-) create mode 100644 app/Claims/CustomClaim.php create mode 100644 app/Services/MailService.php create mode 100644 app/Services/UserService/UserPrepareService.php create mode 100644 config/passport-claims.php diff --git a/app/Claims/CustomClaim.php b/app/Claims/CustomClaim.php new file mode 100644 index 0000000..a1e8595 --- /dev/null +++ b/app/Claims/CustomClaim.php @@ -0,0 +1,17 @@ +getUserIdentifier()); + + $token->addClaim('email', $user->email); + return $next($token); + } +} diff --git a/app/Http/Controllers/verification/VerificationController.php b/app/Http/Controllers/verification/VerificationController.php index 829fd15..52b350b 100644 --- a/app/Http/Controllers/verification/VerificationController.php +++ b/app/Http/Controllers/verification/VerificationController.php @@ -40,23 +40,7 @@ public function show(Request $request) public function verify(string $code) { $this->userService->registerUser(json_decode(base64_decode($code))); - - /*$userID = $request['id']; - $user = \App\Models\User::findOrFail($userID); - - $hash = $request['hash']; - - if (! hash_equals((string) $hash, sha1($user->getEmailForVerification()))) { - return response()->json(["message" => "Invalid verification link"], 401); - } - - if ($user->hasVerifiedEmail()) { - return response()->json(["message" => "Email already verified."], 400); - } - - if ($user->markEmailAsVerified()) { - event(new Verified($user)); - }*/ + return response()->json(["message" => "Email has been verified."], 200); } diff --git a/app/Models/User.php b/app/Models/User.php index b5b937e..8a17b29 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -124,4 +124,12 @@ public function assignRoleWithOrganization($roles, $organizationId) } return $this; } + + public function getAdditionalInformation() + { + return [ + 'name' => $this->name, + 'email' => $this->email, + ]; + } } diff --git a/app/Services/MailService.php b/app/Services/MailService.php new file mode 100644 index 0000000..23fdd09 --- /dev/null +++ b/app/Services/MailService.php @@ -0,0 +1,14 @@ +send(new UserDetailMail($encodedUser)); + } +} \ No newline at end of file diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 096a420..1a58335 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -25,42 +25,45 @@ public function __construct(Guard $auth, Hasher $hasher, User $user) $this->user = $user; } - public function createUser(array $data) + /** + * Creates a new user and sends an email with their details + * + * @param array $userData + * @return string|false + */ + public function createUser(array $userData) { try { - // Generate UUID and create user data array - $uuid = Uuid::uuid4(); + $userId = Uuid::uuid4(); $user = [ - 'uuid' => $uuid, - 'name' => $data['name'], - 'surname'=> $data['surname'], - 'birthdate' => $data['birthdate'] ?? null, - 'email' => $data['email'], - 'password' => $this->hasher->make($data['password']) + 'uuid' => $userId, + 'name' => $userData['name'], + 'surname' => $userData['surname'], + 'birthdate' => $userData['birthdate'] ?? null, + 'email' => $userData['email'], + 'password' => $this->hasher->make($userData['password']), + 'organization_id' => array_key_exists('organization', $userData) ? $userData['organization'] : null, ]; - - // Convert user data to JSON and then to Base64 + $jsonUser = json_encode($user); $base64User = base64_encode($jsonUser); - - // Send email - - Mail::to($data['email'])->send(new UserDetailMail($base64User)); - // Return true if everything went well + + Mail::to($userData['email'])->send(new UserDetailMail($base64User)); + return $base64User; } catch (Exception $e) { - // Log the error - \Log::error("Failed to create user and send email: " . $e->getMessage()); - - // Return false if there was an error return false; } } + public function registerUser($data){ $user = $this->user->create(get_object_vars($data)); $user->markEmailAsVerified(); $user->access_token = $user->createToken('ximdex')->accessToken; + if (isset($data->organization_id)) { + $user->organizations()->attach($data->organization_id); + } return $user; } @@ -148,4 +151,9 @@ public function getAllUsers() { return User::all(); } + + public function addUserToOrganization($user, $organization) + { + $user->organizations()->attach($organization->id); + } } diff --git a/app/Services/UserService/UserPrepareService.php b/app/Services/UserService/UserPrepareService.php new file mode 100644 index 0000000..d59f7fc --- /dev/null +++ b/app/Services/UserService/UserPrepareService.php @@ -0,0 +1,57 @@ +hasher = $hasher; + $this->mailService = $mailService; + } + + public function prepareUserRegistration(array $userData) + { + try { + $user = $this->buildUserArray($userData); + $encodedUser = $this->encodeUser($user); + $this->sendUserDetailsEmail($userData['email'], $encodedUser); + return $encodedUser; + } catch (Exception $e) { + \Log::error($e->getMessage()); + throw $e; + } + } + + protected function buildUserArray(array $userData): array + { + return [ + 'uuid' => Uuid::uuid4()->toString(), + 'name' => $userData['name'], + 'surname' => $userData['surname'], + 'birthdate' => $userData['birthdate'] ?? null, + 'email' => $userData['email'], + 'password' => $this->hasher->make($userData['password']), + 'organization_id' => $userData['organization'] ?? null, + ]; + } + + protected function encodeUser(array $user): string + { + return base64_encode(json_encode($user)); + } + + protected function sendUserDetailsEmail(string $email, string $encodedUser): void + { + Mail::to($email)->send(new UserDetailMail($encodedUser)); + } +} diff --git a/composer.json b/composer.json index cb183da..3cf0883 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "license": "MIT", "require": { "php": "^8.2", + "corbosman/laravel-passport-claims": "^6.0", "laravel/framework": "^11.0", "laravel/passport": "^12.0", "laravel/tinker": "^2.9", diff --git a/composer.lock b/composer.lock index 334e3b8..21816b7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "29a7ae6dcf38c4d63f1a57a0e54f21ff", + "content-hash": "0e5dc0210dd5ef8fd9d2d180c7710fda", "packages": [ { "name": "brick/math", @@ -135,6 +135,69 @@ ], "time": "2024-02-09T16:56:22+00:00" }, + { + "name": "corbosman/laravel-passport-claims", + "version": "6.0.0", + "source": { + "type": "git", + "url": "https://github.com/corbosman/laravel-passport-claims.git", + "reference": "075c3a2ce069685d34c32b376221b6d4f44c5654" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/corbosman/laravel-passport-claims/zipball/075c3a2ce069685d34c32b376221b6d4f44c5654", + "reference": "075c3a2ce069685d34c32b376221b6d4f44c5654", + "shasum": "" + }, + "require": { + "illuminate/support": "^9.0|^10.0|^11.0", + "laravel/passport": "^10.3|^11.2|^12.0" + }, + "require-dev": { + "mockery/mockery": "^1.4", + "orchestra/testbench": "^7.0|^8.0|^9.0", + "phpseclib/phpseclib": "^3.0", + "phpseclib/phpseclib2_compat": "^1.0", + "phpunit/phpunit": "^9.5.1|^10.5" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "CorBosman\\Passport\\ServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "CorBosman\\Passport\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cor Bosman", + "email": "cor@in.ter.net" + } + ], + "description": "Add claims to Laravel Passport JWT Tokens", + "homepage": "https://github.com/corbosman/laravel-passport-claims", + "keywords": [ + "claim", + "jwt", + "laravel", + "laravel-passport-claims", + "passport" + ], + "support": { + "issues": "https://github.com/corbosman/laravel-passport-claims/issues", + "source": "https://github.com/corbosman/laravel-passport-claims/tree/6.0.0" + }, + "time": "2024-03-15T01:29:55+00:00" + }, { "name": "defuse/php-encryption", "version": "v2.4.0", diff --git a/config/passport-claims.php b/config/passport-claims.php new file mode 100644 index 0000000..a108f4b --- /dev/null +++ b/config/passport-claims.php @@ -0,0 +1,28 @@ + [ + App\Claims\CustomClaim::class + ], + + /* + |-------------------------------------------------------------------------- + | Issue Claim + |-------------------------------------------------------------------------- + | + | Here you config the issue claim. if null will not be set + | NOTE: it will set the `iss` claim ref: https://www.rfc-editor.org/rfc/rfc7519#section-4.1.1 + | + */ + 'issuer' => env('JWT_ISSUER', null), +]; From d43c317e01aebb50f8a9e5cf76c0007213a0799d Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 30 May 2024 06:43:13 +0200 Subject: [PATCH 041/115] tool migration --- .../2024_05_29_152029_create_tools_table.php | 32 +++++++++++++++++++ ..._154507_add_tool_id_to_model_has_roles.php | 30 +++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 database/migrations/2024_05_29_152029_create_tools_table.php create mode 100644 database/migrations/2024_05_29_154507_add_tool_id_to_model_has_roles.php diff --git a/database/migrations/2024_05_29_152029_create_tools_table.php b/database/migrations/2024_05_29_152029_create_tools_table.php new file mode 100644 index 0000000..8e23b44 --- /dev/null +++ b/database/migrations/2024_05_29_152029_create_tools_table.php @@ -0,0 +1,32 @@ +uuid('uuid')->primary(); + $table->string('name'); + $table->string('hash')->unique(); + $table->string('type'); + $table->text('description')->nullable(); + $table->string('status'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('tools'); + } +}; diff --git a/database/migrations/2024_05_29_154507_add_tool_id_to_model_has_roles.php b/database/migrations/2024_05_29_154507_add_tool_id_to_model_has_roles.php new file mode 100644 index 0000000..9b60f02 --- /dev/null +++ b/database/migrations/2024_05_29_154507_add_tool_id_to_model_has_roles.php @@ -0,0 +1,30 @@ +uuid('tool_id')->after('role_id'); + $table->foreign('tool_id')->references('uuid')->on('tools'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('model_has_roles', function (Blueprint $table) { + $table->dropForeign(['tool_id']); + $table->dropColumn('tool_id'); + }); + } +}; From 85ed44f2973545e20d898ea8f53ce9954bfe741f Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 30 May 2024 07:10:21 +0200 Subject: [PATCH 042/115] userRegistration fixed --- app/Http/Controllers/Auth/AuthController.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index ba7dde5..ad285ea 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -6,6 +6,7 @@ use App\Http\Requests\LoginRequest; use App\Http\Requests\RegisterRequest; use App\Services\UserService; +use App\Services\UserService\UserPrepareService; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -16,14 +17,17 @@ class AuthController extends Controller protected $userService; - public function __construct(UserService $userService) + protected $userPrepareService; + + public function __construct(UserService $userService,UserPrepareService $userPrepareService) { $this->userService = $userService; + $this->userPrepareService = $userPrepareService; } public function register(RegisterRequest $request) { try { - $user = $this->userService->createUser($request->validated()); + $user = $this->userPrepareService->prepareUserRegistration($request->validated()); if ($user) { return response()->json(['message' => $user], Response::HTTP_CREATED); }else{ From 62457526f7a99753ab0fba51d3ac8f5e3e5bcf3a Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 30 May 2024 07:10:44 +0200 Subject: [PATCH 043/115] verification fixed --- .../verification/VerificationController.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/verification/VerificationController.php b/app/Http/Controllers/verification/VerificationController.php index 52b350b..589b2d0 100644 --- a/app/Http/Controllers/verification/VerificationController.php +++ b/app/Http/Controllers/verification/VerificationController.php @@ -8,6 +8,7 @@ use Illuminate\Foundation\Auth\VerifiesEmails; use Illuminate\Auth\Events\Verified; use Illuminate\Http\JsonResponse; +use Symfony\Component\HttpFoundation\Response; class VerificationController extends Controller { @@ -39,10 +40,15 @@ public function show(Request $request) */ public function verify(string $code) { - $this->userService->registerUser(json_decode(base64_decode($code))); - - - return response()->json(["message" => "Email has been verified."], 200); + try { + $this->userService->registerUser(json_decode(base64_decode($code))); + + return response()->json(["message" => "Email has been verified."], Response::HTTP_OK); + } catch (\Exception $e) { + // Handle general errors + \Log::error($e->getMessage()); + return response()->json(['error' => 'Server error occurred. Please try again later.'], Response::HTTP_INTERNAL_SERVER_ERROR); + } } /** @@ -55,11 +61,11 @@ public function resend(Request $request) { $user = $request->user(); if ($user->hasVerifiedEmail()) { - return response()->json(["message" => "Email already verified."], 400); + return response()->json(["message" => "Email already verified."], Response::HTTP_OK); } $user->sendEmailVerificationNotification(); - return response()->json(["message" => "Verification link sent."], 200); + return response()->json(["message" => "Verification link sent."], Response::HTTP_OK); } } From 05378060a985c406a7807d49198f5c5f753440f6 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 30 May 2024 07:13:14 +0200 Subject: [PATCH 044/115] assingrole remove from user model --- app/Models/User.php | 47 --------------------------------------------- 1 file changed, 47 deletions(-) diff --git a/app/Models/User.php b/app/Models/User.php index 8a17b29..d11b6de 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -78,53 +78,6 @@ public function roles() ->select('organization_id', 'role_id', 'name'); } - - - /** - * Assign a role to the user within a specific organization. - * - * @param mixed $role - * @param int $organizationId - * @return $this - */ - public function assignRoleWithOrganization($roles, $organizationId) - { - try { - foreach ($roles as $role) { - // Check if the role with the given organization_id already exists - $exists = $this->roles() - ->wherePivot('organization_id', $organizationId) - ->where('role_id', $role) - ->exists(); - - // Attach the role if it doesn't exist - if (!$exists) { - $this->roles()->attach($role, [ - 'organization_id' => $organizationId, - 'model_type' => get_class($this) - ]); - } - } - // Detach roles that are not in the provided array of roles - $rolesToDetach = $this->roles() - ->wherePivot('organization_id', $organizationId) - ->whereNotIn('role_id', $roles) - ->get(); - - foreach ($rolesToDetach as $role) { - $this->roles()->detach($role->role_id, [ - 'organization_id' => $organizationId, - 'model_type' => get_class($this) - ]); - } - } catch (\Exception $e) { - // Handle the exception (log it, rethrow it, or return a custom error message) - \Log::error('Error attaching roles: ' . $e->getMessage()); - return response()->json(['error' => 'Failed to assign roles'], 500); - } - return $this; - } - public function getAdditionalInformation() { return [ From 925f793b862b8eb03a55af57f5c84001d6662aa0 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 30 May 2024 07:13:53 +0200 Subject: [PATCH 045/115] userprepare service --- app/Services/UserService/UserPrepareService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Services/UserService/UserPrepareService.php b/app/Services/UserService/UserPrepareService.php index d59f7fc..f9a277c 100644 --- a/app/Services/UserService/UserPrepareService.php +++ b/app/Services/UserService/UserPrepareService.php @@ -8,7 +8,7 @@ use Illuminate\Contracts\Hashing\Hasher; use Ramsey\Uuid\Uuid; -class UserCreationService +class UserPrepareService { protected $hasher; protected $mailService; @@ -24,7 +24,7 @@ public function prepareUserRegistration(array $userData) try { $user = $this->buildUserArray($userData); $encodedUser = $this->encodeUser($user); - $this->sendUserDetailsEmail($userData['email'], $encodedUser); + $this->mailService->sendUserDetails($userData['email'], $encodedUser); return $encodedUser; } catch (Exception $e) { \Log::error($e->getMessage()); From baa5ce8e4f3cbac08e27c46d4c5374f55c751c8a Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 30 May 2024 07:14:11 +0200 Subject: [PATCH 046/115] assign role refactor --- .../Roles/AssignRoleController.php | 2 +- app/Http/Requests/AssingRoleToUserRequest.php | 3 +- app/Services/AssignRoleService.php | 54 +++++++++++++++++-- 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Roles/AssignRoleController.php b/app/Http/Controllers/Roles/AssignRoleController.php index bd698b6..7434c64 100644 --- a/app/Http/Controllers/Roles/AssignRoleController.php +++ b/app/Http/Controllers/Roles/AssignRoleController.php @@ -25,7 +25,7 @@ public function assignRoleToUser(AssingRoleToUserRequest $request) { try { $user = User::findOrFail($request->user_uuid); - $this->assignRoleService->assignRole($user, $request->role_uuid, $request->organization_uuid); + $this->assignRoleService->assignRole($user, $request->role_uuid, $request->organization_uuid, $request->tool_uuid); return response()->json(['message' => 'Role assigned successfully'], 200); } catch (Exception $e) { return response()->json(['error' => $e->getMessage()], 500); diff --git a/app/Http/Requests/AssingRoleToUserRequest.php b/app/Http/Requests/AssingRoleToUserRequest.php index d4e28a3..d305afa 100644 --- a/app/Http/Requests/AssingRoleToUserRequest.php +++ b/app/Http/Requests/AssingRoleToUserRequest.php @@ -25,6 +25,7 @@ public function rules(): array 'user_uuid' => 'required|exists:users,uuid', 'role_uuid' => 'required|array|exists:roles,uuid', 'organization_uuid' => 'required|string|exists:organizations,uuid', + 'tool_uuid' => 'required|string|exists:tools,uuid', ]; } -} +} \ No newline at end of file diff --git a/app/Services/AssignRoleService.php b/app/Services/AssignRoleService.php index 9ee6fee..d8abe08 100644 --- a/app/Services/AssignRoleService.php +++ b/app/Services/AssignRoleService.php @@ -5,16 +5,31 @@ use App\Models\Role; use App\Models\User; use Exception; +use Symfony\Component\HttpFoundation\Response; class AssignRoleService { - public function assignRole(User $user, $role_uuid,string $organization_uuid) + public function assignRole(User $user, $roles, string $organizationId, string $toolId) { + \DB::beginTransaction(); try { - $user->assignRoleWithOrganization($role_uuid,$organization_uuid); - } catch (Exception $e) { - echo 'Error assigning role: ' . $e->getMessage(); + + $currentRoles = $this->getRolesForOrganization($user, $organizationId); + + $rolesToAdd = array_diff($roles, $currentRoles); + $rolesToRemove = array_diff($currentRoles, $roles); + + + $this->addRoles($user, $rolesToAdd, $organizationId, $toolId); + $this->removeRoles($user, $rolesToRemove, $organizationId, $toolId); + + \DB::commit(); + } catch (\Exception $e) { + \DB::rollBack(); + \Log::error('Error synchronizing roles: ' . $e->getMessage()); + return response()->json(['error' => 'Failed to assign roles'], Response::HTTP_INTERNAL_SERVER_ERROR); } + return $user; } public function revokeRole(User $user, $role) @@ -54,5 +69,34 @@ public function removePermissionFromRole(Role $role, $permission) } } - + + private function getRolesForOrganization($user, $organizationId) + { + return $user->roles() + ->wherePivot('organization_id', $organizationId) + ->pluck('role_id') + ->toArray(); + } + + private function addRoles($user, $roles, $organizationId, $toolId) + { + foreach ($roles as $role) { + $user->roles()->attach($role, [ + 'organization_id' => $organizationId, + 'model_type' => get_class($this), + 'tool_id' => $toolId + ]); + } + } + + private function removeRoles($user, $roles, $organizationId, $toolId) + { + if (!empty($roles)) { + $user->roles()->detach($roles, [ + 'organization_id' => $organizationId, + 'model_type' => get_class($this), + 'tool_id' => $toolId + ]); + } + } } From b1ffc5a074e70873da524a6af1f7c8446514deea Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 30 May 2024 07:21:49 +0200 Subject: [PATCH 047/115] ASSINGROLECONTROLLer response added --- .../Roles/AssignRoleController.php | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/Roles/AssignRoleController.php b/app/Http/Controllers/Roles/AssignRoleController.php index 7434c64..53558e0 100644 --- a/app/Http/Controllers/Roles/AssignRoleController.php +++ b/app/Http/Controllers/Roles/AssignRoleController.php @@ -10,6 +10,7 @@ use App\Services\AssignRoleService; use Exception; use Illuminate\Http\Request; +use Symfony\Component\HttpFoundation\Response; class AssignRoleController extends Controller { @@ -26,9 +27,9 @@ public function assignRoleToUser(AssingRoleToUserRequest $request) try { $user = User::findOrFail($request->user_uuid); $this->assignRoleService->assignRole($user, $request->role_uuid, $request->organization_uuid, $request->tool_uuid); - return response()->json(['message' => 'Role assigned successfully'], 200); + return response()->json(['message' => 'Role assigned successfully'], Response::HTTP_OK); } catch (Exception $e) { - return response()->json(['error' => $e->getMessage()], 500); + return response()->json(['error' => $e->getMessage()], Response::HTTP_INTERNAL_SERVER_ERROR); } } @@ -37,9 +38,9 @@ public function unassignRole(RevokeRoleToUserRequest $request) try { $user = User::findOrFail($request->user_uuid); $this->assignRoleService->revokeRole($user, $request->role_uuid); - return response()->json(['message' => 'Role unassigned successfully'], 200); + return response()->json(['message' => 'Role unassigned successfully'], Response::HTTP_OK); } catch (Exception $e) { - return response()->json(['error' => $e->getMessage()], 500); + return response()->json(['error' => $e->getMessage()], Response::HTTP_INTERNAL_SERVER_ERROR); } } @@ -49,14 +50,14 @@ public function addPermissionToRole(Request $request) $role = Role::where('name', $request->role)->first(); if (!$role) { - return response()->json(['error' => 'Role not found'], 404); + return response()->json(['error' => 'Role not found'], Response::HTTP_NOT_FOUND); } $this->assignRoleService->addPermissionToRole($role, $request->permission); - return response()->json(['message' => 'Permission added to role successfully'], 200); + return response()->json(['message' => 'Permission added to role successfully'], Response::HTTP_OK); } catch (Exception $e) { - return response()->json(['error' => $e->getMessage()], 500); + return response()->json(['error' => $e->getMessage()], Response::HTTP_INTERNAL_SERVER_ERROR); } } @@ -66,14 +67,14 @@ public function revokePermissionFromRole(Request $request) $role = Role::where('name', $request->role)->first(); if (!$role) { - return response()->json(['error' => 'Role not found'], 404); + return response()->json(['error' => 'Role not found'], Response::HTTP_NOT_FOUND); } $this->assignRoleService->removePermissionFromRole($role, $request->permission); - return response()->json(['message' => 'Permission revoked from role successfully'], 200); + return response()->json(['message' => 'Permission revoked from role successfully'], Response::HTTP_OK); } catch (Exception $e) { - return response()->json(['error' => $e->getMessage()], 500); + return response()->json(['error' => $e->getMessage()], Response::HTTP_INTERNAL_SERVER_ERROR); } } From 2fb332ac1e5f854bdf61f430e7c2853da994a9ec Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 30 May 2024 11:23:39 +0200 Subject: [PATCH 048/115] user update fixed --- app/Http/Controllers/User/UserUpdateController.php | 2 +- app/Services/UserService.php | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/User/UserUpdateController.php b/app/Http/Controllers/User/UserUpdateController.php index 1df8ec2..32a660b 100644 --- a/app/Http/Controllers/User/UserUpdateController.php +++ b/app/Http/Controllers/User/UserUpdateController.php @@ -17,7 +17,7 @@ public function __construct(UserService $userService) $this->userService = $userService; } - public function updateUser(Request $request) + public function update(Request $request) { try { $data = $request->all(); diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 1a58335..05a0305 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -115,10 +115,8 @@ public function updateUser(array $data) $user->birthdate = $data['birthdate']; } - // Save the updated user $user->save(); - $user->sendEmailVerificationNotification(); - // Generate a new access token for the user + $user->token = $user->createToken(env('PASSPORT_TOKEN_NAME'))->accessToken; return $user; From 3eeb453832ff81635506fc0e15cb6b5ab64639db Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 30 May 2024 11:41:08 +0200 Subject: [PATCH 049/115] update custom claims --- app/Claims/CustomClaim.php | 38 ++++++++++++++++++- app/Models/Role.php | 5 +++ app/Models/Tool.php | 17 +++++++++ app/Models/User.php | 12 +----- .../UserService/UserPrepareService.php | 2 +- 5 files changed, 61 insertions(+), 13 deletions(-) create mode 100644 app/Models/Tool.php diff --git a/app/Claims/CustomClaim.php b/app/Claims/CustomClaim.php index a1e8595..5d077a7 100644 --- a/app/Claims/CustomClaim.php +++ b/app/Claims/CustomClaim.php @@ -2,6 +2,8 @@ namespace App\Claims; +use App\Models\Role; +use App\Models\Tool; use App\Models\User; use CorBosman\Passport\AccessToken; @@ -9,9 +11,41 @@ class CustomClaim { public function handle(AccessToken $token, $next) { - $user = User::find($token->getUserIdentifier()); + $user = User::with(['roles.tools'])->find($token->getUserIdentifier()); - $token->addClaim('email', $user->email); + $rolesBitwiseMap = [ + 'viewer' => '11100000', + 'creator' => '11110000', + 'editor' => '11111100', + 'admin' => '00000010', + 'superAdmin' => '00000001', + ]; + $toolsPermissions = []; + + foreach ($user->roles as $role) { + $permission = $rolesBitwiseMap[$role->name] ?? null; // Get the permission from the rolesBitwiseMap + foreach ($role->tools as $tool) { + $toolHash = $tool->hash; // Get the hash from the tool + // Construct the organization#permission string + $orgPermission = $permission . '#' . $role->pivot->organization_id; + // Add to the array, grouping by tool_hash + $toolsPermissions[$toolHash][] = $orgPermission; + } + } + + $roles = $user->roles()->get()->map(function ($role) { + return [ + 'name' => $role->name, + 'tool_id' => $role->pivot->tool_id, + 'organization_id' => $role->pivot->organization_id, + 'tool_hash' => $role->tools->first()->hash + ]; + })->all(); + + $rolesArray = $user->roles->map(fn ($role) => $rolesBitwiseMap[$role->name])->all(); + + + $token->addClaim('p', $toolsPermissions); return $next($token); } } diff --git a/app/Models/Role.php b/app/Models/Role.php index c82c6f8..b34a47d 100644 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -12,4 +12,9 @@ class Role extends SpatieRole use HasUuids; protected $primaryKey = 'uuid'; + + public function tools() + { + return $this->belongsToMany(Tool::class, 'model_has_roles', 'role_id', 'tool_id'); + } } \ No newline at end of file diff --git a/app/Models/Tool.php b/app/Models/Tool.php new file mode 100644 index 0000000..17f89a7 --- /dev/null +++ b/app/Models/Tool.php @@ -0,0 +1,17 @@ +belongsToMany(Role::class, 'model_has_roles', 'model_uuid', 'role_id') - ->withPivot('organization_id') - ->select('organization_id', 'role_id', 'name'); - } - - public function getAdditionalInformation() - { - return [ - 'name' => $this->name, - 'email' => $this->email, - ]; + ->withPivot('organization_id', 'tool_id'); + //->select('organization_id', 'role_id', 'name','tool_id'); } } diff --git a/app/Services/UserService/UserPrepareService.php b/app/Services/UserService/UserPrepareService.php index f9a277c..239c80f 100644 --- a/app/Services/UserService/UserPrepareService.php +++ b/app/Services/UserService/UserPrepareService.php @@ -24,7 +24,7 @@ public function prepareUserRegistration(array $userData) try { $user = $this->buildUserArray($userData); $encodedUser = $this->encodeUser($user); - $this->mailService->sendUserDetails($userData['email'], $encodedUser); + $this->mailService->sendUserDetails($userData['email'], env('APP_NAME') . '/' . $encodedUser); return $encodedUser; } catch (Exception $e) { \Log::error($e->getMessage()); From ed5149e3207f4a9d28561cc07e9a68307bb6e5e4 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 30 May 2024 12:45:24 +0200 Subject: [PATCH 050/115] try and catch organizationinivitationcontroller and permissionService --- .../OrganizationInviteController.php | 28 ++++---- app/Services/PermissionService.php | 66 ++++++++++++------- 2 files changed, 60 insertions(+), 34 deletions(-) diff --git a/app/Http/Controllers/Organization/OrganizationInviteController.php b/app/Http/Controllers/Organization/OrganizationInviteController.php index 39c26b7..1a57114 100644 --- a/app/Http/Controllers/Organization/OrganizationInviteController.php +++ b/app/Http/Controllers/Organization/OrganizationInviteController.php @@ -10,24 +10,30 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Mail; use Ramsey\Uuid\Uuid; +use Symfony\Component\HttpFoundation\Response; class OrganizationInviteController extends Controller { public function sendInvite(SendInviteRequest $request) { - $email = $request->route('email'); - $organization = Organization::where('uuid', $request->route('organization'))->firstOrFail(); - $inviteLink = "organization={$organization->uuid}&email=$email"; + try { + $email = $request->route('email'); + $organization = Organization::where('uuid', $request->route('organization'))->firstOrFail(); + $inviteLink = "organization={$organization->uuid}&email=$email"; - Invitation::create([ - 'uuid' => Uuid::uuid4(), - 'email' => $email, - 'organization_id' => $organization->uuid, - 'status' => 'pending' - ]); + Invitation::create([ + 'uuid' => Uuid::uuid4(), + 'email' => $email, + 'organization_id' => $organization->uuid, + 'status' => 'pending' + ]); - Mail::to($email)->send(new OrganizationInviteMail($organization->name, $inviteLink)); + Mail::to($email)->send(new OrganizationInviteMail($organization->name, $inviteLink)); - return response()->json(['message' => 'Invitation sent successfully!']); + return response()->json(['message' => 'Invitation sent successfully!'], Response::HTTP_OK); + } catch (\Exception $e) { + \Log::error('Error sending invitation: ' . $e->getMessage()); + return response()->json(['error' => 'An error occurred while sending the invitation'], Response::HTTP_INTERNAL_SERVER_ERROR); + } } } diff --git a/app/Services/PermissionService.php b/app/Services/PermissionService.php index 7e4e4a3..47608a1 100644 --- a/app/Services/PermissionService.php +++ b/app/Services/PermissionService.php @@ -20,44 +20,64 @@ public function __construct(Permission $permission) public function createPermission(array $data) { - $data['uuid'] = Uuid::uuid4(); - $permission = $this->permission->create($data); + try { + $data['uuid'] = Uuid::uuid4(); + $permission = $this->permission->create($data); - return [ - 'success' => true, - 'permission' => $permission - ]; + return [ + 'success' => true, + 'permission' => $permission + ]; + } catch (Exception $e) { + \Log::error($e->getMessage()); + return response()->json(['error' => 'An error occurred while creating permission'], 500); + } } public function updatePermission(Permission $permission, array $data) { - $permission->update($data); - return [ - 'success' => true, - 'permission' => $permission - ]; + try { + $permission->update($data); + return [ + 'success' => true, + 'permission' => $permission + ]; + } catch (\Exception $e) { + \Log::error($e->getMessage()); + return response()->json(['error' => 'An error occurred while updating permission'], 500); + } } public function deletePermission(Permission $permission) { - $permission->delete(); + try { + $permission->delete(); - return [ - 'success' => true, - 'message' => 'Permission removed successfully' - ]; + return [ + 'success' => true, + 'message' => 'Permission removed successfully' + ]; + } catch (\Exception $e) { + \Log::error($e->getMessage()); + return response()->json(['error' => 'An error occurred while deleting permission'], 500); + } } public function isPermissionUnassigned($permission) { - if (!$permission) { - throw new Exception("Permission not found"); - } + try { + if (!$permission) { + throw new Exception("Permission not found"); + } - // Check if permission is not assigned to any role - $rolesCount = $permission->roles()->count(); - $usersCount = $permission->users()->count(); + // Check if permission is not assigned to any role + $rolesCount = $permission->roles()->count(); + $usersCount = $permission->users()->count(); - return $rolesCount === 0 && $usersCount === 0; + return $rolesCount === 0 && $usersCount === 0; + } catch (Exception $e) { + \Log::error($e->getMessage()); + return response()->json(['error' => 'An error occurred while checking if permission is unassigned'], 500); + } } } From a18e5fc13ab497743309dfce5c173d7058926a97 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 30 May 2024 12:46:02 +0200 Subject: [PATCH 051/115] userserivce surname and access_token fix --- app/Services/UserService.php | 46 ++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 05a0305..60c2c0b 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -9,6 +9,7 @@ use Illuminate\Contracts\Hashing\Hasher; use Illuminate\Support\Facades\Mail; use Ramsey\Uuid\Uuid; +use Symfony\Component\HttpFoundation\Response; class UserService { @@ -69,26 +70,31 @@ public function registerUser($data){ public function getUser(array $data) { - $this->auth->attempt($data); - $user = $this->auth->user(); - if ($user) { - $user->access_token = $user->createToken('ximdex')->accessToken; - if ($user->roles()->exists()){ - $rolesGroupedByOrganization = $user->roles()->get()->makeHidden('pivot') - ->groupBy('organization_id') - ->map(function ($roles) { - return $roles->map(function ($role) { - return $role->only('role_id', 'name'); + try { + $this->auth->attempt($data); + $user = $this->auth->user(); + if ($user) { + $user->access_token = $user->createToken('ximdex')->accessToken; + if ($user->roles()->exists()){ + $rolesGroupedByOrganization = $user->roles()->get()->makeHidden('pivot') + ->groupBy('organization_id') + ->map(function ($roles) { + return $roles->map(function ($role) { + return $role->only('role_id', 'name'); + }); }); - }); - - - $user->roles = $rolesGroupedByOrganization; + + + $user->roles = $rolesGroupedByOrganization; + } + + return $user; } - - return $user; + return null; + } catch (Exception $e) { + \Log::error($e->getMessage()); + return response()->json(['error' => 'An error occurred while retrieving user'], Response::HTTP_INTERNAL_SERVER_ERROR); } - return null; } public function updateUser(array $data) @@ -107,6 +113,10 @@ public function updateUser(array $data) if (isset($data['name'])) { $user->name = $data['name']; } + + if (isset($data['surname'])) { + $user->surname = $data['surname']; + } if (isset($data['password'])) { $user->password = $this->hasher->make($data['password']); } @@ -117,7 +127,7 @@ public function updateUser(array $data) $user->save(); - $user->token = $user->createToken(env('PASSPORT_TOKEN_NAME'))->accessToken; + $user->access_token = $user->createToken(env('PASSPORT_TOKEN_NAME'))->accessToken; return $user; } catch (\Exception $e) { From 0809f4358cf71613149b3cbe00bf60dcc8f7ebdb Mon Sep 17 00:00:00 2001 From: juandz13 Date: Fri, 31 May 2024 08:33:39 +0200 Subject: [PATCH 052/115] update routes --- app/Http/Controllers/Auth/AuthController.php | 14 +++- .../OrganizationInviteController.php | 33 ++++---- app/Http/Controllers/User/UserController.php | 24 ++++++ app/Mail/UserDetailMailInterface.php | 8 ++ app/Services/MailService.php | 16 +++- app/Services/UserService.php | 81 ++++++++++++++----- .../UserService/UserPrepareService.php | 5 -- app/Services/invitationService.php | 35 ++++++++ routes/api/v1/invitation.php | 1 + routes/api/v1/organization.php | 13 +-- routes/api/v1/password_reset.php | 6 +- routes/api/v1/permission.php | 10 +-- routes/api/v1/role.php | 18 ++--- routes/api/v1/user.php | 8 +- 14 files changed, 205 insertions(+), 67 deletions(-) create mode 100644 app/Mail/UserDetailMailInterface.php create mode 100644 app/Services/invitationService.php create mode 100644 routes/api/v1/invitation.php diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index ad285ea..4e74d02 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -19,6 +19,16 @@ class AuthController extends Controller protected $userPrepareService; + + private $rolesBitwiseMap = [ + 'viewer' => '11100000', + 'creator' => '11110000', + 'editor' => '11111100', + 'admin' => '00000010', + 'superAdmin' => '00000001', + ]; + + public function __construct(UserService $userService,UserPrepareService $userPrepareService) { $this->userService = $userService; @@ -45,9 +55,9 @@ public function register(RegisterRequest $request) public function login(LoginRequest $request) { try { - $user = $this->userService->getUser($request->only('email', 'password')); + $user = $this->userService->getUserByLogin($request->only('email', 'password')); if($user){ - $user->makeHidden(['created_at', 'updated_at']); + $user->makeHidden(['created_at', 'updated_at','roles']); return response()->json(['user' => $user], Response::HTTP_CREATED); } return response()->json(['error' => 'Login failed'], Response::HTTP_NOT_FOUND); diff --git a/app/Http/Controllers/Organization/OrganizationInviteController.php b/app/Http/Controllers/Organization/OrganizationInviteController.php index 1a57114..5560142 100644 --- a/app/Http/Controllers/Organization/OrganizationInviteController.php +++ b/app/Http/Controllers/Organization/OrganizationInviteController.php @@ -7,6 +7,7 @@ use App\Mail\OrganizationInviteMail; use App\Models\Invitation; use App\Models\Organization; +use App\Services\InvitationService; use Illuminate\Http\Request; use Illuminate\Support\Facades\Mail; use Ramsey\Uuid\Uuid; @@ -14,26 +15,30 @@ class OrganizationInviteController extends Controller { + + protected $invitationService; + + public function __construct(InvitationService $invitationService) + { + $this->invitationService = $invitationService; + } + public function sendInvite(SendInviteRequest $request) { try { - $email = $request->route('email'); - $organization = Organization::where('uuid', $request->route('organization'))->firstOrFail(); - $inviteLink = "organization={$organization->uuid}&email=$email"; - - Invitation::create([ - 'uuid' => Uuid::uuid4(), - 'email' => $email, - 'organization_id' => $organization->uuid, - 'status' => 'pending' - ]); - - Mail::to($email)->send(new OrganizationInviteMail($organization->name, $inviteLink)); - - return response()->json(['message' => 'Invitation sent successfully!'], Response::HTTP_OK); + $email = $request->route('email'); + $organizationUuid = $request->route('organization'); + + $result = $this->invitationService->sendInvitation($email, $organizationUuid); + + return response()->json($result, $result['status']); } catch (\Exception $e) { \Log::error('Error sending invitation: ' . $e->getMessage()); return response()->json(['error' => 'An error occurred while sending the invitation'], Response::HTTP_INTERNAL_SERVER_ERROR); } } + + public function invitationList(){ + return response()->json(['invitations' => Invitation::all()]); + } } diff --git a/app/Http/Controllers/User/UserController.php b/app/Http/Controllers/User/UserController.php index f07566b..7ec3612 100644 --- a/app/Http/Controllers/User/UserController.php +++ b/app/Http/Controllers/User/UserController.php @@ -28,4 +28,28 @@ public function listUsers() return response()->json(['error' => 'An error occurred while fetching the user list.'], Response::HTTP_INTERNAL_SERVER_ERROR); } } + + public function getUser(Request $request) + { + try { + $user = $this->userService->getUserByLogin($request->only('email', 'password')); + $user->makeHidden(['password', 'remember_token','email_verified_at','created_at','updated_at']); + return response()->json(['user' => $user]); + } catch (\Exception $e) { + \Log::error($e->getMessage()); + return response()->json(['error' => 'An error occurred while fetching the user.'], Response::HTTP_INTERNAL_SERVER_ERROR); + } + } + + public function deleteUser(Request $request) + { + try { + $user = $this->userService->deleteUser($request->user_id); + return response()->json(['message' => 'User deleted successfully'], Response::HTTP_OK); + } catch (\Exception $e) { + \Log::error($e->getMessage()); + return response()->json(['error' => 'An error occurred while deleting the user.'], Response::HTTP_INTERNAL_SERVER_ERROR); + } + } + } diff --git a/app/Mail/UserDetailMailInterface.php b/app/Mail/UserDetailMailInterface.php new file mode 100644 index 0000000..7edef5f --- /dev/null +++ b/app/Mail/UserDetailMailInterface.php @@ -0,0 +1,8 @@ +mailer = $mailer; + $this->userDetailMail = $userDetailMail; + } + public function sendUserDetails($email, $encodedUser) { - Mail::to($email)->send(new UserDetailMail($encodedUser)); + $mailable = $this->userDetailMail->create($encodedUser); + $this->mailer->to($email)->send($mailable); } } \ No newline at end of file diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 60c2c0b..c3eaf09 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -18,12 +18,20 @@ class UserService protected $hasher; protected $uuid; protected $user; + private $rolesBitwiseMap = [ + 'viewer' => '11100000', + 'creator' => '11110000', + 'editor' => '11111100', + 'admin' => '00000010', + 'superAdmin' => '00000001', + ]; public function __construct(Guard $auth, Hasher $hasher, User $user) { $this->auth = $auth; $this->hasher = $hasher; $this->user = $user; + } /** @@ -58,7 +66,8 @@ public function createUser(array $userData) } - public function registerUser($data){ + public function registerUser($data) + { $user = $this->user->create(get_object_vars($data)); $user->markEmailAsVerified(); $user->access_token = $user->createToken('ximdex')->accessToken; @@ -68,26 +77,14 @@ public function registerUser($data){ return $user; } - public function getUser(array $data) + public function getUserByLogin(array $data) { try { $this->auth->attempt($data); $user = $this->auth->user(); if ($user) { $user->access_token = $user->createToken('ximdex')->accessToken; - if ($user->roles()->exists()){ - $rolesGroupedByOrganization = $user->roles()->get()->makeHidden('pivot') - ->groupBy('organization_id') - ->map(function ($roles) { - return $roles->map(function ($role) { - return $role->only('role_id', 'name'); - }); - }); - - - $user->roles = $rolesGroupedByOrganization; - } - + $user->p = $this->getUserToolRoles($user); return $user; } return null; @@ -97,6 +94,23 @@ public function getUser(array $data) } } + /** + * Get user by id. + * + * @param string $id User id + * @return User|null + */ + public function getUserById(string $id) + { + try { + $user = $this->user->findOrFail($id); + $user->p = $this->getUserToolRoles($user); + return $user; + } catch (Exception $e) { + return response()->json(['error' => 'User not found'], Response::HTTP_NOT_FOUND); + } + } + public function updateUser(array $data) { try { @@ -105,11 +119,8 @@ public function updateUser(array $data) if (isset($data['email']) && $this->checkEmail($data, $user->email)) { $user->email = $data['email']; - } elseif (isset($data['email'])) { - return response()->json(['error' => 'Email already in use'], 409); - } + } - // Update other user properties if they are included in the update request if (isset($data['name'])) { $user->name = $data['name']; } @@ -132,10 +143,24 @@ public function updateUser(array $data) return $user; } catch (\Exception $e) { \Log::error($e->getMessage()); - return response()->json(['error' => 'An error occurred while updating user'], 500); + return response()->json(['error' => 'An error occurred while updating user'], Response::HTTP_INTERNAL_SERVER_ERROR); } } + public function deleteUser($id) + { + //add try and catch + try { + $user = $this->user->find($id); + $user->delete(); + return $user; + } catch (\Exception $e) { + \Log::error($e->getMessage()); + return response()->json(['error' => 'An error occurred while deleting user'], Response::HTTP_INTERNAL_SERVER_ERROR); + } + + } + protected function checkEmail(array $data, string $email) { // Check if the email is included in the update request @@ -164,4 +189,20 @@ public function addUserToOrganization($user, $organization) { $user->organizations()->attach($organization->id); } + + + private function getUserToolRoles($user) { + if ($user->roles()->exists()) { + $userToolRoles = []; + $roles = $user->roles->load('tools'); + foreach ($roles as $role) { + $userToolRoles[$role->tools->first()->hash] = [ + 'organization' => $role->pivot->organization_id, + 'permission' => $this->rolesBitwiseMap[$role->name] + ]; + } + return $userToolRoles; + } + return null; + } } diff --git a/app/Services/UserService/UserPrepareService.php b/app/Services/UserService/UserPrepareService.php index 239c80f..2c8aa72 100644 --- a/app/Services/UserService/UserPrepareService.php +++ b/app/Services/UserService/UserPrepareService.php @@ -49,9 +49,4 @@ protected function encodeUser(array $user): string { return base64_encode(json_encode($user)); } - - protected function sendUserDetailsEmail(string $email, string $encodedUser): void - { - Mail::to($email)->send(new UserDetailMail($encodedUser)); - } } diff --git a/app/Services/invitationService.php b/app/Services/invitationService.php new file mode 100644 index 0000000..905b1ee --- /dev/null +++ b/app/Services/invitationService.php @@ -0,0 +1,35 @@ +firstOrFail(); + $inviteLink = "organization={$organization->uuid}&email=$email"; + + Invitation::create([ + 'uuid' => Str::uuid(), // Assuming you have 'use Illuminate\Support\Str;' + 'email' => $email, + 'organization_id' => $organization->id, // Assuming it should be 'id' not 'uuid' + 'status' => 'pending' + ]); + + Mail::to($email)->send(new OrganizationInviteMail($organization->name, $inviteLink)); + + return ['message' => 'Invitation sent successfully!', 'status' => Response::HTTP_OK]; + } catch (\Exception $e) { + \Log::error('Error sending invitation: ' . $e->getMessage()); + return ['error' => 'An error occurred while sending the invitation', 'status' => Response::HTTP_INTERNAL_SERVER_ERROR]; + } + } +} \ No newline at end of file diff --git a/routes/api/v1/invitation.php b/routes/api/v1/invitation.php new file mode 100644 index 0000000..a814366 --- /dev/null +++ b/routes/api/v1/invitation.php @@ -0,0 +1 @@ +group(function () { - Route::post('/organizations', [OrganizationController::class, 'create'])->name('api.organizations.create'); - Route::put('/organizations/{organization}', [OrganizationController::class, 'update'])->name('api.organizations.update'); - Route::delete('/organizations/{organization}', [OrganizationController::class, 'destroy'])->name('api.organizations.delete'); - Route::get('/organizations', [OrganizationController::class, 'listOrganizations'])->name('api.organizations.list'); - Route::post('/organizations/{organization}/invite/{email}', [OrganizationInviteController::class, 'sendInvite'])->name('api.organizations.invite'); +Route::prefix('organizations')->middleware('auth:api')->group(function () { + Route::post('/', [OrganizationController::class, 'create'])->name('api.organizations.create'); + Route::put('/{organization}', [OrganizationController::class, 'update'])->name('api.organizations.update'); + Route::delete('/{organization}', [OrganizationController::class, 'destroy'])->name('api.organizations.delete'); + Route::get('/', [OrganizationController::class, 'listOrganizations'])->name('api.organizations.list'); + Route::post('/{organization}/invite/{email}', [OrganizationInviteController::class, 'sendInvite'])->name('api.organizations.invite'); + Route::get('/invitations', [OrganizationInviteController::class, 'listInvites'])->name('api.organizations.invites.list'); }); diff --git a/routes/api/v1/password_reset.php b/routes/api/v1/password_reset.php index 940e23d..c6e3733 100644 --- a/routes/api/v1/password_reset.php +++ b/routes/api/v1/password_reset.php @@ -5,5 +5,7 @@ use Illuminate\Support\Facades\Route; // Password Reset Routes -Route::post('/password/email', [ForgotPasswordController::class, 'sendResetLinkEmail'])->name('password.email'); -Route::post('/password/reset', [ResetPasswordController::class, 'reset'])->name('password.reset'); +Route::prefix('password')->group(function () { + Route::post('email', [ForgotPasswordController::class, 'sendResetLinkEmail'])->name('password.email'); + Route::post('reset', [ResetPasswordController::class, 'reset'])->name('password.reset'); +}); diff --git a/routes/api/v1/permission.php b/routes/api/v1/permission.php index 3668f61..b721889 100644 --- a/routes/api/v1/permission.php +++ b/routes/api/v1/permission.php @@ -5,9 +5,9 @@ // Permission Routes -Route::middleware('auth:api')->group(function () { - Route::post('/permissions', [PermissionController::class, 'create'])->name('api.permissions.create'); - Route::put('/permissions/{permissionId}', [PermissionController::class, 'update'])->name('api.permissions.update'); - Route::delete('/permissions/{permissionId}', [PermissionController::class, 'delete'])->name('api.permissions.delete'); - Route::get('/permissions', [PermissionController::class, 'getList'])->name('api.permissions.list'); +Route::prefix('permissions')->middleware('auth:api')->group(function () { + Route::post('/', [PermissionController::class, 'create'])->name('api.permissions.create'); + Route::put('/{permissionId}', [PermissionController::class, 'update'])->name('api.permissions.update'); + Route::delete('/{permissionId}', [PermissionController::class, 'delete'])->name('api.permissions.delete'); + Route::get('/', [PermissionController::class, 'getList'])->name('api.permissions.list'); }); diff --git a/routes/api/v1/role.php b/routes/api/v1/role.php index 16caa6b..c2bc21d 100644 --- a/routes/api/v1/role.php +++ b/routes/api/v1/role.php @@ -6,13 +6,13 @@ // Role Routes -Route::middleware('auth:api')->group(function () { - Route::post('/roles', [RoleController::class, 'create'])->name('api.roles.create'); - Route::put('/roles/{roleId}', [RoleController::class, 'update'])->name('api.roles.update'); - Route::delete('/roles/{roleId}', [RoleController::class, 'remove'])->name('api.roles.delete'); - Route::get('/roles', [RoleController::class, 'getList'])->name('api.roles.list'); - Route::post('/roles/assign', [AssignRoleController::class, 'assignRoleToUser'])->name('api.roles.assign'); - Route::post('/roles/unassign', [AssignRoleController::class, 'unassignRole'])->name('api.roles.unassign'); - Route::post('/roles/assign/permission', [AssignRoleController::class, 'addPermissionToRole'])->name('api.roles.add.permission'); - Route::post('/roles/unassign/permission', [AssignRoleController::class, 'revokePermissionFromRole'])->name('api.roles.remove.permission'); +Route::prefix('roles')->middleware('auth:api')->group(function () { + Route::post('/', [RoleController::class, 'create'])->name('api.roles.create'); + Route::put('/{roleId}', [RoleController::class, 'update'])->name('api.roles.update'); + Route::delete('/{roleId}', [RoleController::class, 'remove'])->name('api.roles.delete'); + Route::get('/', [RoleController::class, 'getList'])->name('api.roles.list'); + Route::post('/assign', [AssignRoleController::class, 'assignRoleToUser'])->name('api.roles.assign'); + Route::post('/unassign', [AssignRoleController::class, 'unassignRole'])->name('api.roles.unassign'); + Route::post('/assign/permission', [AssignRoleController::class, 'addPermissionToRole'])->name('api.roles.add.permission'); + Route::post('/unassign/permission', [AssignRoleController::class, 'revokePermissionFromRole'])->name('api.roles.remove.permission'); }); diff --git a/routes/api/v1/user.php b/routes/api/v1/user.php index c3d7d34..6679b9c 100644 --- a/routes/api/v1/user.php +++ b/routes/api/v1/user.php @@ -6,7 +6,9 @@ // User Routes -Route::middleware('auth:api')->group(function () { - Route::put('/user/update', [UserUpdateController::class, 'update'])->name('api.user.update'); - Route::get('/users', [UserController::class, 'listUsers'])->name('api.users.list'); +Route::group(['middleware' => 'auth:api', 'prefix' => 'users'], function () { + Route::put('/{id}', [UserUpdateController::class, 'update'])->name('api.users.update'); + Route::get('/{id}', [UserController::class, 'getUser'])->name('api.users.get'); + Route::get('/', [UserController::class, 'listUsers'])->name('api.users.list'); + Route::delete('/{id}', [UserController::class, 'deleteUser'])->name('api.users.delete'); }); From 9f4b287ae6df5c241b9c0f9af17a1c30836988e9 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Fri, 31 May 2024 09:30:12 +0200 Subject: [PATCH 053/115] tools --- app/Http/Controllers/Tools/ToolController.php | 29 +++++++++++++++++++ app/Models/Tool.php | 3 ++ routes/api/v1/api.v1.php | 3 +- routes/api/v1/tool.php | 10 +++++++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/Tools/ToolController.php create mode 100644 routes/api/v1/tool.php diff --git a/app/Http/Controllers/Tools/ToolController.php b/app/Http/Controllers/Tools/ToolController.php new file mode 100644 index 0000000..c639963 --- /dev/null +++ b/app/Http/Controllers/Tools/ToolController.php @@ -0,0 +1,29 @@ +tool = $tool; + } + + public function getTools(Request $request) + { + $tools = $request->user()->tools; + return response()->json(['tools' => $tools], Response::HTTP_OK); + } + + public function getList(){ + $tools = $this->tool->all(); + return response()->json(['tools' => $tools], Response::HTTP_OK); + } +} diff --git a/app/Models/Tool.php b/app/Models/Tool.php index 17f89a7..266771d 100644 --- a/app/Models/Tool.php +++ b/app/Models/Tool.php @@ -13,5 +13,8 @@ class Tool extends Model public $incrementing = false; protected $keyType = 'string'; + protected $hidden = [ + 'created_at','updated_at' + ]; } diff --git a/routes/api/v1/api.v1.php b/routes/api/v1/api.v1.php index 851514f..604b236 100644 --- a/routes/api/v1/api.v1.php +++ b/routes/api/v1/api.v1.php @@ -9,4 +9,5 @@ require __DIR__ . '/user.php'; require __DIR__ . '/permission.php'; require __DIR__ . '/role.php'; - require __DIR__ . '/organization.php'; \ No newline at end of file + require __DIR__ . '/organization.php'; + require __DIR__ . '/tool.php'; \ No newline at end of file diff --git a/routes/api/v1/tool.php b/routes/api/v1/tool.php new file mode 100644 index 0000000..19ee416 --- /dev/null +++ b/routes/api/v1/tool.php @@ -0,0 +1,10 @@ +middleware('auth:api')->group(function () { + Route::get('/', [ToolController::class, 'getList'])->name('api.tools.getList'); +}); \ No newline at end of file From 8c1df465679454745285832051f0b715ee99577d Mon Sep 17 00:00:00 2001 From: juandz13 Date: Fri, 31 May 2024 09:50:59 +0200 Subject: [PATCH 054/115] login fixed --- app/Services/MailService.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/Services/MailService.php b/app/Services/MailService.php index 5ba8d7c..edcf9a9 100644 --- a/app/Services/MailService.php +++ b/app/Services/MailService.php @@ -14,15 +14,13 @@ class MailService protected $userDetailMail; // Inject the Mailer contract (interface) into the service. - public function __construct(Mailer $mailer,UserDetailMailInterface $userDetailMail) + public function __construct(Mailer $mailer) { $this->mailer = $mailer; - $this->userDetailMail = $userDetailMail; } public function sendUserDetails($email, $encodedUser) { - $mailable = $this->userDetailMail->create($encodedUser); - $this->mailer->to($email)->send($mailable); + $this->mailer->to($email)->send(new UserDetailMail($encodedUser)); } } \ No newline at end of file From b556e3a4d71f1f282bfd40fec2c0c5b118fa39a1 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Fri, 31 May 2024 10:10:32 +0200 Subject: [PATCH 055/115] invitation fix --- app/Models/Invitation.php | 4 ++++ app/Services/{invitationService.php => InvitationService.php} | 0 routes/api/v1/organization.php | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) rename app/Services/{invitationService.php => InvitationService.php} (100%) diff --git a/app/Models/Invitation.php b/app/Models/Invitation.php index 428157c..e878d40 100644 --- a/app/Models/Invitation.php +++ b/app/Models/Invitation.php @@ -15,4 +15,8 @@ class Invitation extends Model 'organization_id', 'status', ]; + + protected $hidden = [ + 'created_at','updated_at' + ]; } diff --git a/app/Services/invitationService.php b/app/Services/InvitationService.php similarity index 100% rename from app/Services/invitationService.php rename to app/Services/InvitationService.php diff --git a/routes/api/v1/organization.php b/routes/api/v1/organization.php index caea51c..9fc97b1 100644 --- a/routes/api/v1/organization.php +++ b/routes/api/v1/organization.php @@ -12,5 +12,5 @@ Route::delete('/{organization}', [OrganizationController::class, 'destroy'])->name('api.organizations.delete'); Route::get('/', [OrganizationController::class, 'listOrganizations'])->name('api.organizations.list'); Route::post('/{organization}/invite/{email}', [OrganizationInviteController::class, 'sendInvite'])->name('api.organizations.invite'); - Route::get('/invitations', [OrganizationInviteController::class, 'listInvites'])->name('api.organizations.invites.list'); + Route::get('/invitations', [OrganizationInviteController::class, 'invitationList'])->name('api.organizations.invites.list'); }); From 0b22444a67c8cbfd87eb7321dbb6e4ee29eb4d09 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Fri, 31 May 2024 10:27:16 +0200 Subject: [PATCH 056/115] delete fixed --- app/Http/Controllers/User/UserController.php | 4 ++-- app/Services/UserService.php | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/User/UserController.php b/app/Http/Controllers/User/UserController.php index 7ec3612..7ea68b8 100644 --- a/app/Http/Controllers/User/UserController.php +++ b/app/Http/Controllers/User/UserController.php @@ -41,10 +41,10 @@ public function getUser(Request $request) } } - public function deleteUser(Request $request) + public function deleteUser($id) { try { - $user = $this->userService->deleteUser($request->user_id); + $user = $this->userService->deleteUser($id); return response()->json(['message' => 'User deleted successfully'], Response::HTTP_OK); } catch (\Exception $e) { \Log::error($e->getMessage()); diff --git a/app/Services/UserService.php b/app/Services/UserService.php index c3eaf09..2282c36 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -149,7 +149,6 @@ public function updateUser(array $data) public function deleteUser($id) { - //add try and catch try { $user = $this->user->find($id); $user->delete(); From 5d1092e017cb50d13703cfe89a048a29fbd2f35a Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 3 Jun 2024 07:01:31 +0200 Subject: [PATCH 057/115] user pagination --- app/Http/Controllers/User/UserController.php | 9 ++++--- app/Http/Requests/UserPaginationRequest.php | 28 ++++++++++++++++++++ app/Services/UserService.php | 13 +++++++-- 3 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 app/Http/Requests/UserPaginationRequest.php diff --git a/app/Http/Controllers/User/UserController.php b/app/Http/Controllers/User/UserController.php index 7ea68b8..4fb7fd2 100644 --- a/app/Http/Controllers/User/UserController.php +++ b/app/Http/Controllers/User/UserController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\User; use App\Http\Controllers\Controller; +use App\Http\Requests\UserPaginationRequest; use App\Services\UserService; use Illuminate\Http\Request; use Illuminate\Http\Response; @@ -17,11 +18,13 @@ public function __construct(UserService $userService) $this->userService = $userService; } - public function listUsers() + public function listUsers(UserPaginationRequest $request) { try { - $users = $this->userService->getAllUsers(); - $users->makeHidden(['password', 'remember_token','email_verified_at','created_at','updated_at']); + $page = $request->query('page', 1); + $users = $this->userService->getAllUsers($page); + + // $users->makeHidden(['password', 'remember_token','email_verified_at','created_at','updated_at']); return response()->json(['users' => $users]); } catch (\Exception $e) { \Log::error($e->getMessage()); diff --git a/app/Http/Requests/UserPaginationRequest.php b/app/Http/Requests/UserPaginationRequest.php new file mode 100644 index 0000000..9db34ee --- /dev/null +++ b/app/Http/Requests/UserPaginationRequest.php @@ -0,0 +1,28 @@ +|string> + */ + public function rules(): array + { + return [ + 'page' => 'sometimes|integer|min:1' + ]; + } +} diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 2282c36..93780c9 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -179,9 +179,18 @@ protected function checkEmail(array $data, string $email) return false; } - public function getAllUsers() + public function getAllUsers($page = 1) { - return User::all(); + $paginationResult = User::paginate(20, ['*'], 'page', $page); + + $customResult = [ + 'total' => $paginationResult->total(), + 'to' => $paginationResult->lastItem(), + 'current_page' => $paginationResult->currentPage(), + 'data' => $paginationResult->items(), + ]; + + return $customResult; } public function addUserToOrganization($user, $organization) From 32365c46c29b6911e7ab2892bf9238565ef38059 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 3 Jun 2024 08:52:58 +0200 Subject: [PATCH 058/115] verify fixed --- app/Http/Controllers/Auth/AuthController.php | 5 +---- .../verification/VerificationController.php | 12 ++++++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 4e74d02..c72be7a 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -45,9 +45,7 @@ public function register(RegisterRequest $request) } } catch (\Exception $e) { - // Log the error internally \Log::error($e); - // Return a JSON response with the error message and a 500 status code return response()->json(['error' => 'An error occurred while registering the user. Please try again later.' . $e], Response::HTTP_INTERNAL_SERVER_ERROR); } } @@ -62,7 +60,6 @@ public function login(LoginRequest $request) } return response()->json(['error' => 'Login failed'], Response::HTTP_NOT_FOUND); } catch (\Exception $e) { - // Handle general errors \Log::error($e->getMessage()); return response()->json(['error' => 'Server error occurred. Please try again later.'], Response::HTTP_INTERNAL_SERVER_ERROR); } @@ -82,7 +79,7 @@ public function update(Request $request) return response()->json(['user' => $updatedUser]); } - public function validateToken(Request $request) + public function validateToken() { $user = Auth::guard('api')->user(); diff --git a/app/Http/Controllers/verification/VerificationController.php b/app/Http/Controllers/verification/VerificationController.php index 589b2d0..9057429 100644 --- a/app/Http/Controllers/verification/VerificationController.php +++ b/app/Http/Controllers/verification/VerificationController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\verification; use App\Http\Controllers\Controller; +use App\Models\Invitation; use App\Services\UserService; use Illuminate\Http\Request; use Illuminate\Foundation\Auth\VerifiesEmails; @@ -41,8 +42,15 @@ public function show(Request $request) public function verify(string $code) { try { - $this->userService->registerUser(json_decode(base64_decode($code))); - + $user = $this->userService->registerUser(json_decode(base64_decode($code))); + if($user->organizations()->count() > 0) { + $invitation = Invitation::where('email', $user->email)->first(); + if(!$invitation) { + return response()->json(['error' => 'Invitation not found.'], Response::HTTP_NOT_FOUND); + } + $invitation->status = 'completed'; + $invitation->save(); + } return response()->json(["message" => "Email has been verified."], Response::HTTP_OK); } catch (\Exception $e) { // Handle general errors From 52785435dfa3d457695b2f23a8dd4522872eb641 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 3 Jun 2024 08:55:36 +0200 Subject: [PATCH 059/115] sendinivterequest updated --- app/Http/Requests/SendInviteRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Requests/SendInviteRequest.php b/app/Http/Requests/SendInviteRequest.php index 2841d7f..27f38d7 100644 --- a/app/Http/Requests/SendInviteRequest.php +++ b/app/Http/Requests/SendInviteRequest.php @@ -17,7 +17,7 @@ public function authorize(): bool public function rules() { return [ - 'email' => 'required|email|'/**unique:users,email */, + 'email' => 'required|email|unique:users,email|unique:invitations,email', 'organization' => 'required|exists:organizations,uuid' ]; } From c78bc4f136a72ad685d2a9598e558b5ce6c05db2 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 3 Jun 2024 10:22:17 +0200 Subject: [PATCH 060/115] role fixed --- app/Claims/CustomClaim.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Claims/CustomClaim.php b/app/Claims/CustomClaim.php index 5d077a7..241eb27 100644 --- a/app/Claims/CustomClaim.php +++ b/app/Claims/CustomClaim.php @@ -17,8 +17,8 @@ public function handle(AccessToken $token, $next) 'viewer' => '11100000', 'creator' => '11110000', 'editor' => '11111100', - 'admin' => '00000010', - 'superAdmin' => '00000001', + 'admin' => '11111110', + 'superAdmin' => '11111111', ]; $toolsPermissions = []; From fe566082c23eda5d2dda892c0e4cf911496dee86 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 3 Jun 2024 10:27:22 +0200 Subject: [PATCH 061/115] login roles fixed --- app/Services/UserService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 93780c9..524d533 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -22,8 +22,8 @@ class UserService 'viewer' => '11100000', 'creator' => '11110000', 'editor' => '11111100', - 'admin' => '00000010', - 'superAdmin' => '00000001', + 'admin' => '11111110', + 'superAdmin' => '11111111', ]; public function __construct(Guard $auth, Hasher $hasher, User $user) From 2c355236551bc60a12a8486b617c1c1e8b63689a Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 3 Jun 2024 11:26:08 +0200 Subject: [PATCH 062/115] login bug fix --- app/Claims/CustomClaim.php | 4 ++-- app/Services/UserService.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Claims/CustomClaim.php b/app/Claims/CustomClaim.php index 241eb27..56b6935 100644 --- a/app/Claims/CustomClaim.php +++ b/app/Claims/CustomClaim.php @@ -18,12 +18,12 @@ public function handle(AccessToken $token, $next) 'creator' => '11110000', 'editor' => '11111100', 'admin' => '11111110', - 'superAdmin' => '11111111', + 'superadmin' => '11111111', ]; $toolsPermissions = []; foreach ($user->roles as $role) { - $permission = $rolesBitwiseMap[$role->name] ?? null; // Get the permission from the rolesBitwiseMap + $permission = $rolesBitwiseMap[strtolower($role->name)] ?? null; // Get the permission from the rolesBitwiseMap foreach ($role->tools as $tool) { $toolHash = $tool->hash; // Get the hash from the tool // Construct the organization#permission string diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 524d533..04df739 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -23,7 +23,7 @@ class UserService 'creator' => '11110000', 'editor' => '11111100', 'admin' => '11111110', - 'superAdmin' => '11111111', + 'superadmin' => '11111111', ]; public function __construct(Guard $auth, Hasher $hasher, User $user) @@ -206,7 +206,7 @@ private function getUserToolRoles($user) { foreach ($roles as $role) { $userToolRoles[$role->tools->first()->hash] = [ 'organization' => $role->pivot->organization_id, - 'permission' => $this->rolesBitwiseMap[$role->name] + 'permission' => $this->rolesBitwiseMap[strtolower($role->name)] ]; } return $userToolRoles; From 8728c61888e7aa0184c3bf7fd57b69a2febf3257 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 3 Jun 2024 12:26:37 +0200 Subject: [PATCH 063/115] invitation bugfix --- app/Services/InvitationService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Services/InvitationService.php b/app/Services/InvitationService.php index 905b1ee..b2d4f88 100644 --- a/app/Services/InvitationService.php +++ b/app/Services/InvitationService.php @@ -18,9 +18,9 @@ public function sendInvitation($email, $organizationUuid) $inviteLink = "organization={$organization->uuid}&email=$email"; Invitation::create([ - 'uuid' => Str::uuid(), // Assuming you have 'use Illuminate\Support\Str;' + 'uuid' => Str::uuid(), 'email' => $email, - 'organization_id' => $organization->id, // Assuming it should be 'id' not 'uuid' + 'organization_id' => $organization->uuid, 'status' => 'pending' ]); From 183c943875f32e50026429c04fb26f7c7f267354 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 3 Jun 2024 12:32:38 +0200 Subject: [PATCH 064/115] invitation service update --- .../Organization/OrganizationInviteController.php | 5 ++--- app/Services/InvitationService.php | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Organization/OrganizationInviteController.php b/app/Http/Controllers/Organization/OrganizationInviteController.php index 5560142..8e328a7 100644 --- a/app/Http/Controllers/Organization/OrganizationInviteController.php +++ b/app/Http/Controllers/Organization/OrganizationInviteController.php @@ -23,13 +23,12 @@ public function __construct(InvitationService $invitationService) $this->invitationService = $invitationService; } - public function sendInvite(SendInviteRequest $request) + public function sendInvite(SendInviteRequest $request, Organization $organization) { try { $email = $request->route('email'); - $organizationUuid = $request->route('organization'); - $result = $this->invitationService->sendInvitation($email, $organizationUuid); + $result = $this->invitationService->sendInvitation($email, $organization->uuid,$organization->name); return response()->json($result, $result['status']); } catch (\Exception $e) { diff --git a/app/Services/InvitationService.php b/app/Services/InvitationService.php index b2d4f88..9a93272 100644 --- a/app/Services/InvitationService.php +++ b/app/Services/InvitationService.php @@ -11,20 +11,19 @@ class InvitationService { - public function sendInvitation($email, $organizationUuid) + public function sendInvitation($email, $organizationUuid,$organizationName) { try { - $organization = Organization::where('uuid', $organizationUuid)->firstOrFail(); - $inviteLink = "organization={$organization->uuid}&email=$email"; + $inviteLink = "organization={$organizationUuid}&email=$email"; Invitation::create([ 'uuid' => Str::uuid(), 'email' => $email, - 'organization_id' => $organization->uuid, + 'organization_id' => $organizationUuid, 'status' => 'pending' ]); - Mail::to($email)->send(new OrganizationInviteMail($organization->name, $inviteLink)); + Mail::to($email)->send(new OrganizationInviteMail($organizationName, $inviteLink)); return ['message' => 'Invitation sent successfully!', 'status' => Response::HTTP_OK]; } catch (\Exception $e) { From c8b490a3ef922da34978f6bb62e83df650ef5091 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 3 Jun 2024 13:22:12 +0200 Subject: [PATCH 065/115] verification bugfix --- .../OrganizationInviteController.php | 36 ++++++++++++------- app/Http/Requests/SendInviteRequest.php | 2 -- routes/api/v1/organization.php | 11 +++--- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/app/Http/Controllers/Organization/OrganizationInviteController.php b/app/Http/Controllers/Organization/OrganizationInviteController.php index 8e328a7..df4380d 100644 --- a/app/Http/Controllers/Organization/OrganizationInviteController.php +++ b/app/Http/Controllers/Organization/OrganizationInviteController.php @@ -8,8 +8,10 @@ use App\Models\Invitation; use App\Models\Organization; use App\Services\InvitationService; +use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Http\Request; use Illuminate\Support\Facades\Mail; +use Illuminate\Support\Facades\Validator; use Ramsey\Uuid\Uuid; use Symfony\Component\HttpFoundation\Response; @@ -22,22 +24,32 @@ public function __construct(InvitationService $invitationService) { $this->invitationService = $invitationService; } - + public function sendInvite(SendInviteRequest $request, Organization $organization) - { - try { + { + $validator = Validator::make(['uuid' => $organization->uuid], [ + 'uuid' => 'required|exists:organizations,uuid', + ]); + + if ($validator->fails()) { + return response()->json(['error' => $validator->errors()], Response::HTTP_UNPROCESSABLE_ENTITY); + } + try { $email = $request->route('email'); - - $result = $this->invitationService->sendInvitation($email, $organization->uuid,$organization->name); - + + $result = $this->invitationService->sendInvitation($email, $organization->uuid, $organization->name); + return response()->json($result, $result['status']); - } catch (\Exception $e) { - \Log::error('Error sending invitation: ' . $e->getMessage()); - return response()->json(['error' => 'An error occurred while sending the invitation'], Response::HTTP_INTERNAL_SERVER_ERROR); - } - } + } catch (ModelNotFoundException $e) { + return response()->json(['error' => 'Organization not found'], Response::HTTP_NOT_FOUND); + } catch (\Exception $e) { + \Log::error('Error sending invitation: ' . $e->getMessage()); + return response()->json(['error' => 'An error occurred while sending the invitation'], Response::HTTP_INTERNAL_SERVER_ERROR); + } + } - public function invitationList(){ + public function invitationList() + { return response()->json(['invitations' => Invitation::all()]); } } diff --git a/app/Http/Requests/SendInviteRequest.php b/app/Http/Requests/SendInviteRequest.php index 27f38d7..d818116 100644 --- a/app/Http/Requests/SendInviteRequest.php +++ b/app/Http/Requests/SendInviteRequest.php @@ -18,7 +18,6 @@ public function rules() { return [ 'email' => 'required|email|unique:users,email|unique:invitations,email', - 'organization' => 'required|exists:organizations,uuid' ]; } @@ -27,7 +26,6 @@ protected function prepareForValidation() // Merge URL parameters into the request data $this->merge([ 'email' => $this->route('email'), - 'organization' => $this->route('organization') ]); } } diff --git a/routes/api/v1/organization.php b/routes/api/v1/organization.php index 9fc97b1..e742891 100644 --- a/routes/api/v1/organization.php +++ b/routes/api/v1/organization.php @@ -4,13 +4,16 @@ use App\Http\Controllers\Organization\OrganizationInviteController; use Illuminate\Support\Facades\Route; +$missingCallback = function () { + return response()->json(['error' => 'Not found'], 404); +}; // Organization Routes -Route::prefix('organizations')->middleware('auth:api')->group(function () { +Route::prefix('organizations')->middleware('auth:api')->group(function () use ($missingCallback) { Route::post('/', [OrganizationController::class, 'create'])->name('api.organizations.create'); - Route::put('/{organization}', [OrganizationController::class, 'update'])->name('api.organizations.update'); - Route::delete('/{organization}', [OrganizationController::class, 'destroy'])->name('api.organizations.delete'); + Route::put('/{organization}', [OrganizationController::class, 'update'])->name('api.organizations.update')->missing($missingCallback); + Route::delete('/{organization}', [OrganizationController::class, 'destroy'])->name('api.organizations.delete')->missing($missingCallback); Route::get('/', [OrganizationController::class, 'listOrganizations'])->name('api.organizations.list'); - Route::post('/{organization}/invite/{email}', [OrganizationInviteController::class, 'sendInvite'])->name('api.organizations.invite'); + Route::post('/{organization}/invite/{email}', [OrganizationInviteController::class, 'sendInvite'])->name('api.organizations.invite')->missing($missingCallback); Route::get('/invitations', [OrganizationInviteController::class, 'invitationList'])->name('api.organizations.invites.list'); }); From 0fc439328d72cee834cb99864dced4ca84121c73 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 4 Jun 2024 07:17:27 +0200 Subject: [PATCH 066/115] verification bugfix and uuidservice --- .../verification/VerificationController.php | 14 ++++---------- app/Http/Requests/RegisterRequest.php | 1 + app/Services/UserService/UserPrepareService.php | 9 ++++++--- app/Services/UuidService.php | 13 +++++++++++++ 4 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 app/Services/UuidService.php diff --git a/app/Http/Controllers/verification/VerificationController.php b/app/Http/Controllers/verification/VerificationController.php index 9057429..0df2e4a 100644 --- a/app/Http/Controllers/verification/VerificationController.php +++ b/app/Http/Controllers/verification/VerificationController.php @@ -22,16 +22,6 @@ public function __construct(UserService $userService) $this->userService = $userService; } - /** - * Show the email verification notice. - * - */ - public function show(Request $request) - { - return $request->user()->hasVerifiedEmail() - ? redirect($this->redirectPath()) - : view('auth.verify'); - } /** * Mark the authenticated user's email address as verified. @@ -41,11 +31,15 @@ public function show(Request $request) */ public function verify(string $code) { + if (!json_decode(base64_decode($code))) { + return response()->json(['error' => 'Invalid code.'], Response::HTTP_BAD_REQUEST); + } try { $user = $this->userService->registerUser(json_decode(base64_decode($code))); if($user->organizations()->count() > 0) { $invitation = Invitation::where('email', $user->email)->first(); if(!$invitation) { + $user->delete(); return response()->json(['error' => 'Invitation not found.'], Response::HTTP_NOT_FOUND); } $invitation->status = 'completed'; diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index b0d19a4..42fce42 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -27,6 +27,7 @@ public function rules(): array 'email' => 'required|string|email|max:255|unique:users', 'password' => 'required|string|min:8', 'birthdate' => 'required|date', + 'organization_id' => 'sometimes|nullable|exists:organizations,uuid', ]; } diff --git a/app/Services/UserService/UserPrepareService.php b/app/Services/UserService/UserPrepareService.php index 2c8aa72..b7b3cc6 100644 --- a/app/Services/UserService/UserPrepareService.php +++ b/app/Services/UserService/UserPrepareService.php @@ -4,6 +4,7 @@ use App\Models\User; use App\Services\MailService; +use App\Services\UuidService; use Exception; use Illuminate\Contracts\Hashing\Hasher; use Ramsey\Uuid\Uuid; @@ -12,11 +13,13 @@ class UserPrepareService { protected $hasher; protected $mailService; + protected $uuidService; - public function __construct(Hasher $hasher,MailService $mailService) + public function __construct(Hasher $hasher,MailService $mailService,UuidService $uuidService) { $this->hasher = $hasher; $this->mailService = $mailService; + $this->uuidService = $uuidService; } public function prepareUserRegistration(array $userData) @@ -35,13 +38,13 @@ public function prepareUserRegistration(array $userData) protected function buildUserArray(array $userData): array { return [ - 'uuid' => Uuid::uuid4()->toString(), + 'uuid' => $this->uuidService->generateUuid(), 'name' => $userData['name'], 'surname' => $userData['surname'], 'birthdate' => $userData['birthdate'] ?? null, 'email' => $userData['email'], 'password' => $this->hasher->make($userData['password']), - 'organization_id' => $userData['organization'] ?? null, + 'organization_id' => $userData['organization_id'] ?? null, ]; } diff --git a/app/Services/UuidService.php b/app/Services/UuidService.php new file mode 100644 index 0000000..a9c2179 --- /dev/null +++ b/app/Services/UuidService.php @@ -0,0 +1,13 @@ +toString(); + } +} \ No newline at end of file From 3a6327681ab075dfe1f588cc8101dc02d4ef14c0 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 4 Jun 2024 07:42:39 +0200 Subject: [PATCH 067/115] links update --- app/Services/InvitationService.php | 2 +- app/Services/UserService/UserPrepareService.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Services/InvitationService.php b/app/Services/InvitationService.php index 9a93272..863ef06 100644 --- a/app/Services/InvitationService.php +++ b/app/Services/InvitationService.php @@ -14,7 +14,7 @@ class InvitationService public function sendInvitation($email, $organizationUuid,$organizationName) { try { - $inviteLink = "organization={$organizationUuid}&email=$email"; + $inviteLink = "localhost:5173/register?organization={$organizationUuid}&email=$email"; Invitation::create([ 'uuid' => Str::uuid(), diff --git a/app/Services/UserService/UserPrepareService.php b/app/Services/UserService/UserPrepareService.php index b7b3cc6..1aaeb90 100644 --- a/app/Services/UserService/UserPrepareService.php +++ b/app/Services/UserService/UserPrepareService.php @@ -27,7 +27,7 @@ public function prepareUserRegistration(array $userData) try { $user = $this->buildUserArray($userData); $encodedUser = $this->encodeUser($user); - $this->mailService->sendUserDetails($userData['email'], env('APP_NAME') . '/' . $encodedUser); + $this->mailService->sendUserDetails($userData['email'], 'localhost:5173/email_verification/register/'. $encodedUser); return $encodedUser; } catch (Exception $e) { \Log::error($e->getMessage()); From 603192260f127c47e4e3f43ab525cd15cec6d7af Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 4 Jun 2024 07:49:35 +0200 Subject: [PATCH 068/115] link fix --- app/Services/UserService/UserPrepareService.php | 2 +- resources/views/emails/organizationInvite.blade.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Services/UserService/UserPrepareService.php b/app/Services/UserService/UserPrepareService.php index 1aaeb90..47df89b 100644 --- a/app/Services/UserService/UserPrepareService.php +++ b/app/Services/UserService/UserPrepareService.php @@ -27,7 +27,7 @@ public function prepareUserRegistration(array $userData) try { $user = $this->buildUserArray($userData); $encodedUser = $this->encodeUser($user); - $this->mailService->sendUserDetails($userData['email'], 'localhost:5173/email_verification/register/'. $encodedUser); + $this->mailService->sendUserDetails($userData['email'], env('APP_NAME') .':5173/email_verification/register/'. $encodedUser); return $encodedUser; } catch (Exception $e) { \Log::error($e->getMessage()); diff --git a/resources/views/emails/organizationInvite.blade.php b/resources/views/emails/organizationInvite.blade.php index c7ff479..0f8fd7b 100644 --- a/resources/views/emails/organizationInvite.blade.php +++ b/resources/views/emails/organizationInvite.blade.php @@ -7,5 +7,6 @@

You've been invited to join {{ $organizationName }}

Click the link below to register:

Register +

If the link above doesn't work, please copy the following link: {{ $inviteLink }}

\ No newline at end of file From e86f3e4116b14e033bb1b604af9fb2ee070ce922 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 4 Jun 2024 09:03:51 +0200 Subject: [PATCH 069/115] get user --- .../Organization/OrganizationInviteController.php | 7 ------- app/Http/Controllers/User/UserController.php | 5 ++--- app/Services/UserService.php | 10 +++++----- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/app/Http/Controllers/Organization/OrganizationInviteController.php b/app/Http/Controllers/Organization/OrganizationInviteController.php index df4380d..3f395c5 100644 --- a/app/Http/Controllers/Organization/OrganizationInviteController.php +++ b/app/Http/Controllers/Organization/OrganizationInviteController.php @@ -27,13 +27,6 @@ public function __construct(InvitationService $invitationService) public function sendInvite(SendInviteRequest $request, Organization $organization) { - $validator = Validator::make(['uuid' => $organization->uuid], [ - 'uuid' => 'required|exists:organizations,uuid', - ]); - - if ($validator->fails()) { - return response()->json(['error' => $validator->errors()], Response::HTTP_UNPROCESSABLE_ENTITY); - } try { $email = $request->route('email'); diff --git a/app/Http/Controllers/User/UserController.php b/app/Http/Controllers/User/UserController.php index 4fb7fd2..7788579 100644 --- a/app/Http/Controllers/User/UserController.php +++ b/app/Http/Controllers/User/UserController.php @@ -5,7 +5,6 @@ use App\Http\Controllers\Controller; use App\Http\Requests\UserPaginationRequest; use App\Services\UserService; -use Illuminate\Http\Request; use Illuminate\Http\Response; class UserController extends Controller @@ -32,10 +31,10 @@ public function listUsers(UserPaginationRequest $request) } } - public function getUser(Request $request) + public function getUser(string $id) { try { - $user = $this->userService->getUserByLogin($request->only('email', 'password')); + $user = $this->userService->getUserById($id); $user->makeHidden(['password', 'remember_token','email_verified_at','created_at','updated_at']); return response()->json(['user' => $user]); } catch (\Exception $e) { diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 04df739..3f93a75 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -84,7 +84,7 @@ public function getUserByLogin(array $data) $user = $this->auth->user(); if ($user) { $user->access_token = $user->createToken('ximdex')->accessToken; - $user->p = $this->getUserToolRoles($user); + $user->p = $this->getUserToolRoles(); return $user; } return null; @@ -104,7 +104,7 @@ public function getUserById(string $id) { try { $user = $this->user->findOrFail($id); - $user->p = $this->getUserToolRoles($user); + $user->p = $this->getUserToolRoles(); return $user; } catch (Exception $e) { return response()->json(['error' => 'User not found'], Response::HTTP_NOT_FOUND); @@ -199,10 +199,10 @@ public function addUserToOrganization($user, $organization) } - private function getUserToolRoles($user) { - if ($user->roles()->exists()) { + private function getUserToolRoles() { + if ($this->user->roles()->exists()) { $userToolRoles = []; - $roles = $user->roles->load('tools'); + $roles = $this->user->roles->load('tools'); foreach ($roles as $role) { $userToolRoles[$role->tools->first()->hash] = [ 'organization' => $role->pivot->organization_id, From f679d3818353fba30d6b4f33d765ba08e7229fdd Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 4 Jun 2024 09:13:17 +0200 Subject: [PATCH 070/115] user service fix --- app/Services/UserService.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 3f93a75..04df739 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -84,7 +84,7 @@ public function getUserByLogin(array $data) $user = $this->auth->user(); if ($user) { $user->access_token = $user->createToken('ximdex')->accessToken; - $user->p = $this->getUserToolRoles(); + $user->p = $this->getUserToolRoles($user); return $user; } return null; @@ -104,7 +104,7 @@ public function getUserById(string $id) { try { $user = $this->user->findOrFail($id); - $user->p = $this->getUserToolRoles(); + $user->p = $this->getUserToolRoles($user); return $user; } catch (Exception $e) { return response()->json(['error' => 'User not found'], Response::HTTP_NOT_FOUND); @@ -199,10 +199,10 @@ public function addUserToOrganization($user, $organization) } - private function getUserToolRoles() { - if ($this->user->roles()->exists()) { + private function getUserToolRoles($user) { + if ($user->roles()->exists()) { $userToolRoles = []; - $roles = $this->user->roles->load('tools'); + $roles = $user->roles->load('tools'); foreach ($roles as $role) { $userToolRoles[$role->tools->first()->hash] = [ 'organization' => $role->pivot->organization_id, From 2f10449f76f7fd02ece4d687e0d9a7e662aeb1c1 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 4 Jun 2024 09:17:15 +0200 Subject: [PATCH 071/115] roles hidden --- app/Http/Controllers/User/UserController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/User/UserController.php b/app/Http/Controllers/User/UserController.php index 7788579..3f068e7 100644 --- a/app/Http/Controllers/User/UserController.php +++ b/app/Http/Controllers/User/UserController.php @@ -35,7 +35,7 @@ public function getUser(string $id) { try { $user = $this->userService->getUserById($id); - $user->makeHidden(['password', 'remember_token','email_verified_at','created_at','updated_at']); + $user->makeHidden(['password', 'remember_token','email_verified_at','created_at','updated_at','roles']); return response()->json(['user' => $user]); } catch (\Exception $e) { \Log::error($e->getMessage()); From e56820269464eb3d84ac9dfc9ec20f74cf9a26be Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 4 Jun 2024 09:28:58 +0200 Subject: [PATCH 072/115] organization on login and get --- app/Services/UserService.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 04df739..b2bacb1 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -85,6 +85,7 @@ public function getUserByLogin(array $data) if ($user) { $user->access_token = $user->createToken('ximdex')->accessToken; $user->p = $this->getUserToolRoles($user); + $user->organizations = $user->organizations()->pluck('name', 'uuid')->toArray(); return $user; } return null; @@ -105,6 +106,7 @@ public function getUserById(string $id) try { $user = $this->user->findOrFail($id); $user->p = $this->getUserToolRoles($user); + $user->organizations = $user->organizations()->pluck('name', 'uuid')->toArray(); return $user; } catch (Exception $e) { return response()->json(['error' => 'User not found'], Response::HTTP_NOT_FOUND); From 49f0b7c117a47095e68bc79269e532c6cbd13711 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 4 Jun 2024 09:32:52 +0200 Subject: [PATCH 073/115] organizatio n fix --- app/Services/UserService.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Services/UserService.php b/app/Services/UserService.php index b2bacb1..141c7de 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -73,6 +73,7 @@ public function registerUser($data) $user->access_token = $user->createToken('ximdex')->accessToken; if (isset($data->organization_id)) { $user->organizations()->attach($data->organization_id); + $user->save(); } return $user; } From b6df32607f7e6e8240633165a128ba80b5549f14 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 4 Jun 2024 09:53:04 +0200 Subject: [PATCH 074/115] fix --- app/Services/UserService.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 141c7de..b2bacb1 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -73,7 +73,6 @@ public function registerUser($data) $user->access_token = $user->createToken('ximdex')->accessToken; if (isset($data->organization_id)) { $user->organizations()->attach($data->organization_id); - $user->save(); } return $user; } From 295bb6ee6be83395c71b0dfc514984d616e7f55a Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 4 Jun 2024 14:59:49 +0200 Subject: [PATCH 075/115] update assingrole by role,organization and tool --- .../Roles/AssignRoleController.php | 2 +- app/Http/Requests/AssingRoleToUserRequest.php | 6 ++--- app/Services/AssignRoleService.php | 25 +++++++++++++------ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/Roles/AssignRoleController.php b/app/Http/Controllers/Roles/AssignRoleController.php index 53558e0..a42ea92 100644 --- a/app/Http/Controllers/Roles/AssignRoleController.php +++ b/app/Http/Controllers/Roles/AssignRoleController.php @@ -26,7 +26,7 @@ public function assignRoleToUser(AssingRoleToUserRequest $request) { try { $user = User::findOrFail($request->user_uuid); - $this->assignRoleService->assignRole($user, $request->role_uuid, $request->organization_uuid, $request->tool_uuid); + $this->assignRoleService->assignRole($user, $request->role_uuid, $request->organizations, $request->tools); return response()->json(['message' => 'Role assigned successfully'], Response::HTTP_OK); } catch (Exception $e) { return response()->json(['error' => $e->getMessage()], Response::HTTP_INTERNAL_SERVER_ERROR); diff --git a/app/Http/Requests/AssingRoleToUserRequest.php b/app/Http/Requests/AssingRoleToUserRequest.php index d305afa..70547e3 100644 --- a/app/Http/Requests/AssingRoleToUserRequest.php +++ b/app/Http/Requests/AssingRoleToUserRequest.php @@ -23,9 +23,9 @@ public function rules(): array { return [ 'user_uuid' => 'required|exists:users,uuid', - 'role_uuid' => 'required|array|exists:roles,uuid', - 'organization_uuid' => 'required|string|exists:organizations,uuid', - 'tool_uuid' => 'required|string|exists:tools,uuid', + 'roles' => 'required|array|exists:roles,uuid', + 'organizations' => 'required|array|exists:organizations,uuid', + 'tools' => 'required|array|exists:tools,uuid', ]; } } \ No newline at end of file diff --git a/app/Services/AssignRoleService.php b/app/Services/AssignRoleService.php index d8abe08..a0e68c9 100644 --- a/app/Services/AssignRoleService.php +++ b/app/Services/AssignRoleService.php @@ -9,19 +9,17 @@ class AssignRoleService { - public function assignRole(User $user, $roles, string $organizationId, string $toolId) + public function assignRole(User $user, $roles, array $organizations, array $tools) { \DB::beginTransaction(); try { - $currentRoles = $this->getRolesForOrganization($user, $organizationId); + array_map(function($organizationId) use ($user, $roles, $tools) { + array_map(function($toolId) use ($user, $roles, $organizationId) { + $this->processToolRoles($user, $roles, $organizationId, $toolId); + }, $tools); + }, $organizations); - $rolesToAdd = array_diff($roles, $currentRoles); - $rolesToRemove = array_diff($currentRoles, $roles); - - - $this->addRoles($user, $rolesToAdd, $organizationId, $toolId); - $this->removeRoles($user, $rolesToRemove, $organizationId, $toolId); \DB::commit(); } catch (\Exception $e) { @@ -99,4 +97,15 @@ private function removeRoles($user, $roles, $organizationId, $toolId) ]); } } + + private function processToolRoles(User $user, $roles, $organizationId, $toolId) + { + $currentRoles = $this->getRolesForOrganization($user, $organizationId); + + $rolesToAdd = array_diff($roles, $currentRoles); + $rolesToRemove = array_diff($currentRoles, $roles); + + $this->addRoles($user, $rolesToAdd, $organizationId, $toolId); + $this->removeRoles($user, $rolesToRemove, $organizationId, $toolId); + } } From f8b8495451921e86a3e6a70f8ec034552133f478 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 6 Jun 2024 07:44:07 +0200 Subject: [PATCH 076/115] userservice updated --- app/Services/UserService.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Services/UserService.php b/app/Services/UserService.php index b2bacb1..dbbb99a 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -208,7 +208,9 @@ private function getUserToolRoles($user) { foreach ($roles as $role) { $userToolRoles[$role->tools->first()->hash] = [ 'organization' => $role->pivot->organization_id, - 'permission' => $this->rolesBitwiseMap[strtolower($role->name)] + 'permission' => $this->rolesBitwiseMap[strtolower($role->name)], + 'role' => $role->name, + 'tool' => ['name'=>$role->tools->first()->name,'type' => $role->tools->first()->type] ]; } return $userToolRoles; From 87d34786b9f6e0a8f9087c467759221c01e62e83 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 6 Jun 2024 12:10:17 +0200 Subject: [PATCH 077/115] role admin superadmin applied to get user --- app/Http/Controllers/User/UserController.php | 25 +++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/User/UserController.php b/app/Http/Controllers/User/UserController.php index 3f068e7..072cbfc 100644 --- a/app/Http/Controllers/User/UserController.php +++ b/app/Http/Controllers/User/UserController.php @@ -5,16 +5,19 @@ use App\Http\Controllers\Controller; use App\Http\Requests\UserPaginationRequest; use App\Services\UserService; +use Illuminate\Contracts\Auth\Guard; use Illuminate\Http\Response; class UserController extends Controller { protected $userService; + protected $auth; - public function __construct(UserService $userService) + public function __construct(UserService $userService,Guard $auth) { $this->userService = $userService; + $this->auth = $auth; } public function listUsers(UserPaginationRequest $request) @@ -33,14 +36,20 @@ public function listUsers(UserPaginationRequest $request) public function getUser(string $id) { - try { - $user = $this->userService->getUserById($id); - $user->makeHidden(['password', 'remember_token','email_verified_at','created_at','updated_at','roles']); - return response()->json(['user' => $user]); - } catch (\Exception $e) { - \Log::error($e->getMessage()); - return response()->json(['error' => 'An error occurred while fetching the user.'], Response::HTTP_INTERNAL_SERVER_ERROR); + + if ($this->auth->user()->hasRole(['admin','superadmin'])){ + try { + $user = $this->userService->getUserById($id); + $user->makeHidden(['password', 'remember_token','email_verified_at','created_at','updated_at','roles']); + return response()->json(['user' => $user]); + } catch (\Exception $e) { + \Log::error($e->getMessage()); + return response()->json(['error' => 'An error occurred while fetching the user.'], Response::HTTP_INTERNAL_SERVER_ERROR); + } + }else{ + return response()->json(['error' => 'Unauthorized'], Response::HTTP_UNAUTHORIZED); } + } public function deleteUser($id) From 246e11851a9f62306657f1cf0547da4a20981c6c Mon Sep 17 00:00:00 2001 From: juandz13 Date: Fri, 7 Jun 2024 07:18:39 +0200 Subject: [PATCH 078/115] roles added to routes --- .../Organization/OrganizationController.php | 7 +++-- .../Roles/AssignRoleController.php | 18 +++++------ app/Http/Controllers/User/UserController.php | 31 +++++++------------ app/Http/Requests/AssingRoleToUserRequest.php | 4 +-- app/Services/AssignRoleService.php | 8 ++--- app/Services/UserService.php | 6 ++-- bootstrap/app.php | 6 +++- routes/api/v1/organization.php | 8 ++++- routes/api/v1/role.php | 9 ++++-- routes/api/v1/user.php | 4 +-- 10 files changed, 56 insertions(+), 45 deletions(-) diff --git a/app/Http/Controllers/Organization/OrganizationController.php b/app/Http/Controllers/Organization/OrganizationController.php index d2114b8..9638fde 100644 --- a/app/Http/Controllers/Organization/OrganizationController.php +++ b/app/Http/Controllers/Organization/OrganizationController.php @@ -5,16 +5,19 @@ use App\Http\Controllers\Controller; use App\Models\Organization; use App\Services\OrganizationService; +use Illuminate\Contracts\Auth\Guard; use Illuminate\Http\Request; use Illuminate\Http\Response; class OrganizationController extends Controller { - protected $organizationService; + protected $organizationService; + protected $auth; - public function __construct(OrganizationService $organizationService) + public function __construct(OrganizationService $organizationService,Guard $auth) { $this->organizationService = $organizationService; + $this->auth = $auth; } public function create(Request $request) diff --git a/app/Http/Controllers/Roles/AssignRoleController.php b/app/Http/Controllers/Roles/AssignRoleController.php index a42ea92..3375756 100644 --- a/app/Http/Controllers/Roles/AssignRoleController.php +++ b/app/Http/Controllers/Roles/AssignRoleController.php @@ -3,7 +3,7 @@ namespace App\Http\Controllers\Roles; use App\Http\Controllers\Controller; -use App\Http\Requests\AssingRoleToUserRequest; +use App\Http\Requests\AssignRoleToUserRequest; use App\Http\Requests\RevokeRoleToUserRequest; use App\Models\Role; use App\Models\User; @@ -22,15 +22,15 @@ public function __construct(AssignRoleService $assignRoleService) $this->assignRoleService = $assignRoleService; } - public function assignRoleToUser(AssingRoleToUserRequest $request) + public function assignRoleToUser(AssignRoleToUserRequest $request) { - try { - $user = User::findOrFail($request->user_uuid); - $this->assignRoleService->assignRole($user, $request->role_uuid, $request->organizations, $request->tools); - return response()->json(['message' => 'Role assigned successfully'], Response::HTTP_OK); - } catch (Exception $e) { - return response()->json(['error' => $e->getMessage()], Response::HTTP_INTERNAL_SERVER_ERROR); - } + try { + $user = User::findOrFail($request->user_uuid); + $this->assignRoleService->assignRole($user, $request->role_uuid, $request->organizations, $request->tools); + return response()->json(['message' => 'Role assigned successfully'], Response::HTTP_OK); + } catch (Exception $e) { + return response()->json(['error' => $e->getMessage()], Response::HTTP_INTERNAL_SERVER_ERROR); + } } public function unassignRole(RevokeRoleToUserRequest $request) diff --git a/app/Http/Controllers/User/UserController.php b/app/Http/Controllers/User/UserController.php index 072cbfc..cabf6bc 100644 --- a/app/Http/Controllers/User/UserController.php +++ b/app/Http/Controllers/User/UserController.php @@ -14,7 +14,7 @@ class UserController extends Controller protected $userService; protected $auth; - public function __construct(UserService $userService,Guard $auth) + public function __construct(UserService $userService, Guard $auth) { $this->userService = $userService; $this->auth = $auth; @@ -24,9 +24,9 @@ public function listUsers(UserPaginationRequest $request) { try { $page = $request->query('page', 1); - $users = $this->userService->getAllUsers($page); - - // $users->makeHidden(['password', 'remember_token','email_verified_at','created_at','updated_at']); + $users = $this->userService->getAllUsersFilterByOrganization($page,$this->auth->user()->organization); + + // $users->makeHidden(['password', 'remember_token','email_verified_at','created_at','updated_at']); return response()->json(['users' => $users]); } catch (\Exception $e) { \Log::error($e->getMessage()); @@ -36,31 +36,24 @@ public function listUsers(UserPaginationRequest $request) public function getUser(string $id) { - - if ($this->auth->user()->hasRole(['admin','superadmin'])){ - try { - $user = $this->userService->getUserById($id); - $user->makeHidden(['password', 'remember_token','email_verified_at','created_at','updated_at','roles']); - return response()->json(['user' => $user]); - } catch (\Exception $e) { - \Log::error($e->getMessage()); - return response()->json(['error' => 'An error occurred while fetching the user.'], Response::HTTP_INTERNAL_SERVER_ERROR); - } - }else{ - return response()->json(['error' => 'Unauthorized'], Response::HTTP_UNAUTHORIZED); + try { + $user = $this->userService->getUserById($id); + $user->makeHidden(['password', 'remember_token', 'email_verified_at', 'created_at', 'updated_at', 'roles']); + return response()->json(['user' => $user]); + } catch (\Exception $e) { + \Log::error($e->getMessage()); + return response()->json(['error' => 'An error occurred while fetching the user.'], Response::HTTP_INTERNAL_SERVER_ERROR); } - } public function deleteUser($id) { try { - $user = $this->userService->deleteUser($id); + $user = $this->userService->deleteUser($id); return response()->json(['message' => 'User deleted successfully'], Response::HTTP_OK); } catch (\Exception $e) { \Log::error($e->getMessage()); return response()->json(['error' => 'An error occurred while deleting the user.'], Response::HTTP_INTERNAL_SERVER_ERROR); } } - } diff --git a/app/Http/Requests/AssingRoleToUserRequest.php b/app/Http/Requests/AssingRoleToUserRequest.php index 70547e3..2fad7ce 100644 --- a/app/Http/Requests/AssingRoleToUserRequest.php +++ b/app/Http/Requests/AssingRoleToUserRequest.php @@ -4,7 +4,7 @@ use Illuminate\Foundation\Http\FormRequest; -class AssingRoleToUserRequest extends FormRequest +class AssignRoleToUserRequest extends FormRequest { /** * Determine if the user is authorized to make this request. @@ -23,7 +23,7 @@ public function rules(): array { return [ 'user_uuid' => 'required|exists:users,uuid', - 'roles' => 'required|array|exists:roles,uuid', + 'roles' => 'required|string|exists:roles,uuid', 'organizations' => 'required|array|exists:organizations,uuid', 'tools' => 'required|array|exists:tools,uuid', ]; diff --git a/app/Services/AssignRoleService.php b/app/Services/AssignRoleService.php index a0e68c9..547cd0d 100644 --- a/app/Services/AssignRoleService.php +++ b/app/Services/AssignRoleService.php @@ -9,14 +9,14 @@ class AssignRoleService { - public function assignRole(User $user, $roles, array $organizations, array $tools) + public function assignRole(User $user, $role, array $organizations, array $tools) { \DB::beginTransaction(); try { - array_map(function($organizationId) use ($user, $roles, $tools) { - array_map(function($toolId) use ($user, $roles, $organizationId) { - $this->processToolRoles($user, $roles, $organizationId, $toolId); + array_map(function($organizationId) use ($user, $role, $tools) { + array_map(function($toolId) use ($user, $role, $organizationId) { + $this->processToolRoles($user, $role, $organizationId, $toolId); }, $tools); }, $organizations); diff --git a/app/Services/UserService.php b/app/Services/UserService.php index dbbb99a..4ebc4e9 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -181,9 +181,11 @@ protected function checkEmail(array $data, string $email) return false; } - public function getAllUsers($page = 1) + public function getAllUsersFilterByOrganization($page = 1, $organizations) { - $paginationResult = User::paginate(20, ['*'], 'page', $page); + $paginationResult = User::whereHas('organizations', function ($query) use ($organizations) { + $query->whereIn('organization_id', $organizations); + })->paginate(20, ['*'], 'page', $page); $customResult = [ 'total' => $paginationResult->total(), diff --git a/bootstrap/app.php b/bootstrap/app.php index f4dde80..3784a14 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -18,7 +18,11 @@ } ) ->withMiddleware(function (Middleware $middleware) { - // + $middleware->alias([ + 'role' => \Spatie\Permission\Middleware\RoleMiddleware::class, + 'permission' => \Spatie\Permission\Middleware\PermissionMiddleware::class, + 'role_or_permission' => \Spatie\Permission\Middleware\RoleOrPermissionMiddleware::class, + ]); }) ->withExceptions(function (Exceptions $exceptions) { // diff --git a/routes/api/v1/organization.php b/routes/api/v1/organization.php index e742891..97c4484 100644 --- a/routes/api/v1/organization.php +++ b/routes/api/v1/organization.php @@ -9,7 +9,7 @@ }; // Organization Routes -Route::prefix('organizations')->middleware('auth:api')->group(function () use ($missingCallback) { +Route::prefix('organizations')->middleware(['auth:api', 'role:admin|superadmin'])->group(function () use ($missingCallback) { Route::post('/', [OrganizationController::class, 'create'])->name('api.organizations.create'); Route::put('/{organization}', [OrganizationController::class, 'update'])->name('api.organizations.update')->missing($missingCallback); Route::delete('/{organization}', [OrganizationController::class, 'destroy'])->name('api.organizations.delete')->missing($missingCallback); @@ -17,3 +17,9 @@ Route::post('/{organization}/invite/{email}', [OrganizationInviteController::class, 'sendInvite'])->name('api.organizations.invite')->missing($missingCallback); Route::get('/invitations', [OrganizationInviteController::class, 'invitationList'])->name('api.organizations.invites.list'); }); + +Route::prefix('organizations')->middleware(['auth:api', 'role:superadmin'])->group(function () use ($missingCallback) { + Route::post('/', [OrganizationController::class, 'create'])->name('api.organizations.create'); + Route::put('/{organization}', [OrganizationController::class, 'update'])->name('api.organizations.update')->missing($missingCallback); + Route::delete('/{organization}', [OrganizationController::class, 'destroy'])->name('api.organizations.delete')->missing($missingCallback); +}); \ No newline at end of file diff --git a/routes/api/v1/role.php b/routes/api/v1/role.php index c2bc21d..01465e3 100644 --- a/routes/api/v1/role.php +++ b/routes/api/v1/role.php @@ -6,13 +6,16 @@ // Role Routes -Route::prefix('roles')->middleware('auth:api')->group(function () { +Route::prefix('roles')->middleware(['auth:api','role:superadmin'])->group(function () { + Route::post('/assign', [AssignRoleController::class, 'assignRoleToUser'])->name('api.roles.assign'); + Route::post('/unassign', [AssignRoleController::class, 'unassignRole'])->name('api.roles.unassign'); +}); + +Route::prefix('roles')->middleware(['auth:api','role:admin|superadmin'])->group(function () { Route::post('/', [RoleController::class, 'create'])->name('api.roles.create'); Route::put('/{roleId}', [RoleController::class, 'update'])->name('api.roles.update'); Route::delete('/{roleId}', [RoleController::class, 'remove'])->name('api.roles.delete'); Route::get('/', [RoleController::class, 'getList'])->name('api.roles.list'); - Route::post('/assign', [AssignRoleController::class, 'assignRoleToUser'])->name('api.roles.assign'); - Route::post('/unassign', [AssignRoleController::class, 'unassignRole'])->name('api.roles.unassign'); Route::post('/assign/permission', [AssignRoleController::class, 'addPermissionToRole'])->name('api.roles.add.permission'); Route::post('/unassign/permission', [AssignRoleController::class, 'revokePermissionFromRole'])->name('api.roles.remove.permission'); }); diff --git a/routes/api/v1/user.php b/routes/api/v1/user.php index 6679b9c..b80caff 100644 --- a/routes/api/v1/user.php +++ b/routes/api/v1/user.php @@ -6,9 +6,9 @@ // User Routes -Route::group(['middleware' => 'auth:api', 'prefix' => 'users'], function () { +Route::group(['middleware' => ['auth:api', 'role:admin|superadmin'], 'prefix' => 'users'], function () { Route::put('/{id}', [UserUpdateController::class, 'update'])->name('api.users.update'); Route::get('/{id}', [UserController::class, 'getUser'])->name('api.users.get'); - Route::get('/', [UserController::class, 'listUsers'])->name('api.users.list'); + Route::get('/', [UserController::class, 'listUsers'])->name('api.users.list')->middleware('role:admin'); Route::delete('/{id}', [UserController::class, 'deleteUser'])->name('api.users.delete'); }); From 35b172b49a4147e873625045cacc179ab0065beb Mon Sep 17 00:00:00 2001 From: juandz13 Date: Fri, 7 Jun 2024 09:42:34 +0200 Subject: [PATCH 079/115] organziatio n route fix --- routes/api/v1/organization.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/routes/api/v1/organization.php b/routes/api/v1/organization.php index 97c4484..0e4a58b 100644 --- a/routes/api/v1/organization.php +++ b/routes/api/v1/organization.php @@ -10,9 +10,6 @@ // Organization Routes Route::prefix('organizations')->middleware(['auth:api', 'role:admin|superadmin'])->group(function () use ($missingCallback) { - Route::post('/', [OrganizationController::class, 'create'])->name('api.organizations.create'); - Route::put('/{organization}', [OrganizationController::class, 'update'])->name('api.organizations.update')->missing($missingCallback); - Route::delete('/{organization}', [OrganizationController::class, 'destroy'])->name('api.organizations.delete')->missing($missingCallback); Route::get('/', [OrganizationController::class, 'listOrganizations'])->name('api.organizations.list'); Route::post('/{organization}/invite/{email}', [OrganizationInviteController::class, 'sendInvite'])->name('api.organizations.invite')->missing($missingCallback); Route::get('/invitations', [OrganizationInviteController::class, 'invitationList'])->name('api.organizations.invites.list'); From 516acfab335929237a78d902bbeb8c68714eadc5 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Fri, 7 Jun 2024 10:44:02 +0200 Subject: [PATCH 080/115] user route bug fix --- routes/api/v1/user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/api/v1/user.php b/routes/api/v1/user.php index b80caff..2ab1ee0 100644 --- a/routes/api/v1/user.php +++ b/routes/api/v1/user.php @@ -9,6 +9,6 @@ Route::group(['middleware' => ['auth:api', 'role:admin|superadmin'], 'prefix' => 'users'], function () { Route::put('/{id}', [UserUpdateController::class, 'update'])->name('api.users.update'); Route::get('/{id}', [UserController::class, 'getUser'])->name('api.users.get'); - Route::get('/', [UserController::class, 'listUsers'])->name('api.users.list')->middleware('role:admin'); + Route::get('/', [UserController::class, 'listUsers'])->name('api.users.list'); Route::delete('/{id}', [UserController::class, 'deleteUser'])->name('api.users.delete'); }); From c457f40866febd5922ee4b192fbe0946e903ebce Mon Sep 17 00:00:00 2001 From: juandz13 Date: Fri, 7 Jun 2024 11:26:09 +0200 Subject: [PATCH 081/115] get users fixed --- app/Http/Controllers/User/UserController.php | 2 +- app/Services/UserService.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/User/UserController.php b/app/Http/Controllers/User/UserController.php index cabf6bc..c563fea 100644 --- a/app/Http/Controllers/User/UserController.php +++ b/app/Http/Controllers/User/UserController.php @@ -24,7 +24,7 @@ public function listUsers(UserPaginationRequest $request) { try { $page = $request->query('page', 1); - $users = $this->userService->getAllUsersFilterByOrganization($page,$this->auth->user()->organization); + $users = $this->userService->getAllUsersFilterByOrganization($page,$this->auth->user()->organizations->pluck('uuid')->toArray()); // $users->makeHidden(['password', 'remember_token','email_verified_at','created_at','updated_at']); return response()->json(['users' => $users]); diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 4ebc4e9..63760b1 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -184,7 +184,7 @@ protected function checkEmail(array $data, string $email) public function getAllUsersFilterByOrganization($page = 1, $organizations) { $paginationResult = User::whereHas('organizations', function ($query) use ($organizations) { - $query->whereIn('organization_id', $organizations); + $query->whereIn('organization_uuid', $organizations); })->paginate(20, ['*'], 'page', $page); $customResult = [ From a2b8e4eb6d02249939b73933e65e5d7bcaceada2 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 10 Jun 2024 08:32:19 +0200 Subject: [PATCH 082/115] XDIR_FRONTEND_URL added to .env --- .env.example | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 76c50e1..bd3edaa 100644 --- a/.env.example +++ b/.env.example @@ -65,4 +65,6 @@ VITE_APP_NAME="${APP_NAME}" PASSPORT_PERSONAL_ACCESS_CLIENT_ID="" PASSPORT_SECRET="" -PASSPORT_TOKEN_NAME="" \ No newline at end of file +PASSPORT_TOKEN_NAME="" + +XDIR_FRONTEND_URL="" \ No newline at end of file From 84d6a32f697deb8d3430f018f4ef90d57e8c2e81 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 10 Jun 2024 08:32:36 +0200 Subject: [PATCH 083/115] organization invite controller cleaned --- .../Organization/OrganizationInviteController.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/Http/Controllers/Organization/OrganizationInviteController.php b/app/Http/Controllers/Organization/OrganizationInviteController.php index 3f395c5..9978d19 100644 --- a/app/Http/Controllers/Organization/OrganizationInviteController.php +++ b/app/Http/Controllers/Organization/OrganizationInviteController.php @@ -4,15 +4,10 @@ use App\Http\Controllers\Controller; use App\Http\Requests\SendInviteRequest; -use App\Mail\OrganizationInviteMail; use App\Models\Invitation; use App\Models\Organization; use App\Services\InvitationService; use Illuminate\Database\Eloquent\ModelNotFoundException; -use Illuminate\Http\Request; -use Illuminate\Support\Facades\Mail; -use Illuminate\Support\Facades\Validator; -use Ramsey\Uuid\Uuid; use Symfony\Component\HttpFoundation\Response; class OrganizationInviteController extends Controller From d3364fdc2d04c4328bc9e0ca9825e93b9b85e120 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 10 Jun 2024 08:33:01 +0200 Subject: [PATCH 084/115] InvitationService: UuidService added --- app/Services/InvitationService.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Services/InvitationService.php b/app/Services/InvitationService.php index 863ef06..0e19c18 100644 --- a/app/Services/InvitationService.php +++ b/app/Services/InvitationService.php @@ -3,21 +3,24 @@ namespace App\Services; use App\Models\Invitation; -use App\Models\Organization; use App\Mail\OrganizationInviteMail; use Illuminate\Support\Facades\Mail; -use Illuminate\Support\Str; use Symfony\Component\HttpFoundation\Response; class InvitationService { + protected $uuidService; + public function __construct() + { + $this->uuidService = new UuidService(); + } public function sendInvitation($email, $organizationUuid,$organizationName) { try { $inviteLink = "localhost:5173/register?organization={$organizationUuid}&email=$email"; Invitation::create([ - 'uuid' => Str::uuid(), + 'uuid' => $this->uuidService->generateUuid(), 'email' => $email, 'organization_id' => $organizationUuid, 'status' => 'pending' From c08a8b317df9b8e88427852350b87cf91516cadf Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 10 Jun 2024 09:29:01 +0200 Subject: [PATCH 085/115] tools to service. --- app/Http/Controllers/Roles/AssignRoleController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Roles/AssignRoleController.php b/app/Http/Controllers/Roles/AssignRoleController.php index 3375756..08a20e0 100644 --- a/app/Http/Controllers/Roles/AssignRoleController.php +++ b/app/Http/Controllers/Roles/AssignRoleController.php @@ -26,7 +26,7 @@ public function assignRoleToUser(AssignRoleToUserRequest $request) { try { $user = User::findOrFail($request->user_uuid); - $this->assignRoleService->assignRole($user, $request->role_uuid, $request->organizations, $request->tools); + $this->assignRoleService->assignRole($user, $request->role_uuid, $request->organizations, $request->services); return response()->json(['message' => 'Role assigned successfully'], Response::HTTP_OK); } catch (Exception $e) { return response()->json(['error' => $e->getMessage()], Response::HTTP_INTERNAL_SERVER_ERROR); From 56b932a9ca1097ace4ba660468cf558585283dea Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 10 Jun 2024 09:44:27 +0200 Subject: [PATCH 086/115] tools to service --- app/Claims/CustomClaim.php | 4 ++-- app/Http/Controllers/Tools/ToolController.php | 4 ++-- app/Http/Requests/AssingRoleToUserRequest.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Claims/CustomClaim.php b/app/Claims/CustomClaim.php index 56b6935..f36f8ee 100644 --- a/app/Claims/CustomClaim.php +++ b/app/Claims/CustomClaim.php @@ -36,9 +36,9 @@ public function handle(AccessToken $token, $next) $roles = $user->roles()->get()->map(function ($role) { return [ 'name' => $role->name, - 'tool_id' => $role->pivot->tool_id, + 'service_id' => $role->pivot->tool_id, 'organization_id' => $role->pivot->organization_id, - 'tool_hash' => $role->tools->first()->hash + 'service_hash' => $role->tools->first()->hash ]; })->all(); diff --git a/app/Http/Controllers/Tools/ToolController.php b/app/Http/Controllers/Tools/ToolController.php index c639963..60f6b7a 100644 --- a/app/Http/Controllers/Tools/ToolController.php +++ b/app/Http/Controllers/Tools/ToolController.php @@ -19,11 +19,11 @@ public function __construct(Tool $tool) public function getTools(Request $request) { $tools = $request->user()->tools; - return response()->json(['tools' => $tools], Response::HTTP_OK); + return response()->json(['services' => $tools], Response::HTTP_OK); } public function getList(){ $tools = $this->tool->all(); - return response()->json(['tools' => $tools], Response::HTTP_OK); + return response()->json(['services' => $tools], Response::HTTP_OK); } } diff --git a/app/Http/Requests/AssingRoleToUserRequest.php b/app/Http/Requests/AssingRoleToUserRequest.php index 2fad7ce..af741ee 100644 --- a/app/Http/Requests/AssingRoleToUserRequest.php +++ b/app/Http/Requests/AssingRoleToUserRequest.php @@ -25,7 +25,7 @@ public function rules(): array 'user_uuid' => 'required|exists:users,uuid', 'roles' => 'required|string|exists:roles,uuid', 'organizations' => 'required|array|exists:organizations,uuid', - 'tools' => 'required|array|exists:tools,uuid', + 'services' => 'required|array|exists:tools,uuid', ]; } } \ No newline at end of file From d00fd0178f06df36ad7e95305da2d235f036f3ad Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 11 Jun 2024 08:55:55 +0200 Subject: [PATCH 087/115] comments --- app/Services/OrganizationService.php | 65 ++++++++++++++++++++++++--- app/Services/UserService.php | 66 +++++++++++++++++++++++++--- 2 files changed, 118 insertions(+), 13 deletions(-) diff --git a/app/Services/OrganizationService.php b/app/Services/OrganizationService.php index 0468050..4d34655 100644 --- a/app/Services/OrganizationService.php +++ b/app/Services/OrganizationService.php @@ -1,16 +1,35 @@ uuidService = $uuidService; + } + + /** + * Creates a new organization with the given data. + * + * @param array $data The data for the organization to create. + * @throws Exception If there is any issue during creation. + * @return array An array containing the success status and the organization data or error message. + */ public function createOrganization(array $data) { try { - $data['uuid'] = Uuid::uuid4()->toString(); + $data['uuid'] = $this->uuidService->generateUuid(); $organization = Organization::create($data); return [ @@ -25,7 +44,16 @@ public function createOrganization(array $data) } } - public function updateOrganization(Organization $organization, array $data){ + /** + * Updates the specified organization with the given data. + * + * @param Organization $organization The organization to update. + * @param array $data The data to update the organization with. + * @throws Exception If there is any issue during the update. + * @return array An array containing the success status and updated organization data or error message. + */ + public function updateOrganization(Organization $organization, array $data) + { try { $organization->name = $data['name']; $organization->save(); @@ -42,6 +70,14 @@ public function updateOrganization(Organization $organization, array $data){ } } + /** + * Deletes the organization with the given UUID. + * + * @param string $uuid The UUID of the organization to delete. + * @throws Exception If there is any issue during deletion. + * @return array An array containing the success status and a message. + */ + public function deleteOrganization($uuid) { $organization = Organization::where('uuid', $uuid)->first(); @@ -66,8 +102,17 @@ public function deleteOrganization($uuid) ]; } } + /** + * Checks if an organization exists with the given UUID. + * + * @param string $uuid The UUID of the organization to check. + * @throws \Illuminate\Database\Eloquent\ModelNotFoundException If no organization is found. + * @throws \Exception If an unexpected error occurs. + * @return array An array containing the success status and optionally an error message. + */ - public function organizationExist(string $uuid){ + public function organizationExist(string $uuid) + { try { $organization = Organization::findOrFail($uuid); return [ @@ -87,8 +132,14 @@ public function organizationExist(string $uuid){ ]; } } - - public function getAllOrganizations(){ + + /** + * Retrieves all organizations. + * + * @return \Illuminate\Database\Eloquent\Collection Returns a collection of all organizations. + */ + public function getAllOrganizations() + { return Organization::all(); } -} \ No newline at end of file +} diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 63760b1..8e4c21e 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -26,12 +26,18 @@ class UserService 'superadmin' => '11111111', ]; + /** + * Constructs a new instance of the class. + * + * @param Guard $auth The authentication service. + * @param Hasher $hasher The hashing service. + * @param User $user The user model. + */ public function __construct(Guard $auth, Hasher $hasher, User $user) { $this->auth = $auth; $this->hasher = $hasher; $this->user = $user; - } /** @@ -77,6 +83,13 @@ public function registerUser($data) return $user; } + /** + * Retrieves a user by their login credentials. + * + * @param array $data The login credentials, including email and password. + * @throws Exception If an error occurs while retrieving the user. + * @return User|null The user object if found, or null if not found. + */ public function getUserByLogin(array $data) { try { @@ -113,6 +126,19 @@ public function getUserById(string $id) } } + /** + * Updates the user's information based on the provided data. + * + * @param array $data The data containing the updated user information. + * The following keys are supported: + * - email: The new email address. + * - name: The new name. + * - surname: The new surname. + * - password: The new password. + * - birthdate: The new birthdate. + * @throws \Exception If an error occurs while updating the user. + * @return \Illuminate\Http\JsonResponse|User The updated user object or a JSON response with an error message. + */ public function updateUser(array $data) { try { @@ -121,7 +147,7 @@ public function updateUser(array $data) if (isset($data['email']) && $this->checkEmail($data, $user->email)) { $user->email = $data['email']; - } + } if (isset($data['name'])) { $user->name = $data['name']; @@ -149,6 +175,13 @@ public function updateUser(array $data) } } + /** + * Deletes a user by their ID. + * + * @param int $id The ID of the user to be deleted. + * @throws \Exception If an error occurs while deleting the user. + * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Http\JsonResponse The deleted user, or a JSON response with an error message. + */ public function deleteUser($id) { try { @@ -159,7 +192,6 @@ public function deleteUser($id) \Log::error($e->getMessage()); return response()->json(['error' => 'An error occurred while deleting user'], Response::HTTP_INTERNAL_SERVER_ERROR); } - } protected function checkEmail(array $data, string $email) @@ -181,12 +213,19 @@ protected function checkEmail(array $data, string $email) return false; } + /** + * Retrieves all users filtered by the given organizations. + * + * @param int $page The page number to retrieve (default: 1). + * @param array $organizations The array of organization UUIDs to filter by. + * @return array The custom result containing the total, last item, current page, and data. + */ public function getAllUsersFilterByOrganization($page = 1, $organizations) { $paginationResult = User::whereHas('organizations', function ($query) use ($organizations) { $query->whereIn('organization_uuid', $organizations); })->paginate(20, ['*'], 'page', $page); - + $customResult = [ 'total' => $paginationResult->total(), 'to' => $paginationResult->lastItem(), @@ -197,13 +236,28 @@ public function getAllUsersFilterByOrganization($page = 1, $organizations) return $customResult; } + /** + * Adds a user to an organization. + * + * @param mixed $user The user object to be added to the organization. + * @param mixed $organization The organization object to which the user will be added. + * @throws \Exception If there is an error attaching the user to the organization. + * @return void + */ public function addUserToOrganization($user, $organization) { $user->organizations()->attach($organization->id); } - private function getUserToolRoles($user) { + /** + * Retrieves the user's tool roles. + * + * @param User $user The user object. + * @return array|null Returns an array of user tool roles, or null if the user has no roles. + */ + private function getUserToolRoles($user) + { if ($user->roles()->exists()) { $userToolRoles = []; $roles = $user->roles->load('tools'); @@ -212,7 +266,7 @@ private function getUserToolRoles($user) { 'organization' => $role->pivot->organization_id, 'permission' => $this->rolesBitwiseMap[strtolower($role->name)], 'role' => $role->name, - 'tool' => ['name'=>$role->tools->first()->name,'type' => $role->tools->first()->type] + 'tool' => ['name' => $role->tools->first()->name, 'type' => $role->tools->first()->type] ]; } return $userToolRoles; From 22439f2c3853993353c04482a0e2936ac2776519 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Wed, 12 Jun 2024 18:23:58 +0200 Subject: [PATCH 088/115] assign role updated --- app/Http/Controllers/Roles/AssignRoleController.php | 2 +- ...eToUserRequest.php => AssignRoleToUserRequest.php} | 11 +++++++---- app/Services/AssignRoleService.php | 10 +++++----- 3 files changed, 13 insertions(+), 10 deletions(-) rename app/Http/Requests/{AssingRoleToUserRequest.php => AssignRoleToUserRequest.php} (55%) diff --git a/app/Http/Controllers/Roles/AssignRoleController.php b/app/Http/Controllers/Roles/AssignRoleController.php index 08a20e0..7abf962 100644 --- a/app/Http/Controllers/Roles/AssignRoleController.php +++ b/app/Http/Controllers/Roles/AssignRoleController.php @@ -26,7 +26,7 @@ public function assignRoleToUser(AssignRoleToUserRequest $request) { try { $user = User::findOrFail($request->user_uuid); - $this->assignRoleService->assignRole($user, $request->role_uuid, $request->organizations, $request->services); + $this->assignRoleService->assignRole($user,$request->organizations); return response()->json(['message' => 'Role assigned successfully'], Response::HTTP_OK); } catch (Exception $e) { return response()->json(['error' => $e->getMessage()], Response::HTTP_INTERNAL_SERVER_ERROR); diff --git a/app/Http/Requests/AssingRoleToUserRequest.php b/app/Http/Requests/AssignRoleToUserRequest.php similarity index 55% rename from app/Http/Requests/AssingRoleToUserRequest.php rename to app/Http/Requests/AssignRoleToUserRequest.php index af741ee..b89df79 100644 --- a/app/Http/Requests/AssingRoleToUserRequest.php +++ b/app/Http/Requests/AssignRoleToUserRequest.php @@ -22,10 +22,13 @@ public function authorize(): bool public function rules(): array { return [ - 'user_uuid' => 'required|exists:users,uuid', - 'roles' => 'required|string|exists:roles,uuid', - 'organizations' => 'required|array|exists:organizations,uuid', - 'services' => 'required|array|exists:tools,uuid', + 'user_uuid' => 'required|uuid', + 'organizations' => 'required|array', + 'organizations.*.organization_uuid' => 'required|uuid', + 'organizations.*.services' => 'required|array', + 'organizations.*.services.*.service_uuid' => 'required|uuid', + 'organizations.*.services.*.role_uuid' => 'required|array', + 'organizations.*.services.*.role_uuid.*' => 'required|uuid', ]; } } \ No newline at end of file diff --git a/app/Services/AssignRoleService.php b/app/Services/AssignRoleService.php index 547cd0d..8937911 100644 --- a/app/Services/AssignRoleService.php +++ b/app/Services/AssignRoleService.php @@ -9,15 +9,15 @@ class AssignRoleService { - public function assignRole(User $user, $role, array $organizations, array $tools) + public function assignRole(User $user,array $organizations) { \DB::beginTransaction(); try { - array_map(function($organizationId) use ($user, $role, $tools) { - array_map(function($toolId) use ($user, $role, $organizationId) { - $this->processToolRoles($user, $role, $organizationId, $toolId); - }, $tools); + array_map(function($organization) use ($user,$organizations) { + array_map(function($service) use ($user, $organization) { + $this->processToolRoles($user, $service['role_uuid'], $organization['organization_uuid'], $service['service_uuid']); + }, $organization['services']); }, $organizations); From e61c4a9e147325c9f9a29480e799d2b4fdd93ffb Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 13 Jun 2024 13:21:57 +0200 Subject: [PATCH 089/115] request fixed --- app/Http/Requests/AssignRoleToUserRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Requests/AssignRoleToUserRequest.php b/app/Http/Requests/AssignRoleToUserRequest.php index b89df79..053f72a 100644 --- a/app/Http/Requests/AssignRoleToUserRequest.php +++ b/app/Http/Requests/AssignRoleToUserRequest.php @@ -28,7 +28,7 @@ public function rules(): array 'organizations.*.services' => 'required|array', 'organizations.*.services.*.service_uuid' => 'required|uuid', 'organizations.*.services.*.role_uuid' => 'required|array', - 'organizations.*.services.*.role_uuid.*' => 'required|uuid', + 'organizations.*.services.*.role_uuid.*' => 'required', ]; } } \ No newline at end of file From f192d6de458d27386e38206e4089f9c75f17e181 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 13 Jun 2024 17:48:29 +0200 Subject: [PATCH 090/115] Delete user --- app/Http/Controllers/User/UserController.php | 10 +++++-- app/Http/Requests/DeleteUserRequest.php | 28 ++++++++++++++++++++ app/Models/User.php | 17 +++++++++--- app/Services/UserService.php | 7 +++++ 4 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 app/Http/Requests/DeleteUserRequest.php diff --git a/app/Http/Controllers/User/UserController.php b/app/Http/Controllers/User/UserController.php index c563fea..bbd9ca2 100644 --- a/app/Http/Controllers/User/UserController.php +++ b/app/Http/Controllers/User/UserController.php @@ -49,8 +49,14 @@ public function getUser(string $id) public function deleteUser($id) { try { - $user = $this->userService->deleteUser($id); - return response()->json(['message' => 'User deleted successfully'], Response::HTTP_OK); + if ($this->auth->user()->hasRole('admin|superadmin') || $this->auth->user()->id == $id) { + $this->userService->deleteUser($id); + return response()->json(['message' => 'User deleted successfully'], Response::HTTP_OK); + }else{ + return response()->json(['error' => 'Only admin can delete user'], Response::HTTP_UNAUTHORIZED); + } + + } catch (\Exception $e) { \Log::error($e->getMessage()); return response()->json(['error' => 'An error occurred while deleting the user.'], Response::HTTP_INTERNAL_SERVER_ERROR); diff --git a/app/Http/Requests/DeleteUserRequest.php b/app/Http/Requests/DeleteUserRequest.php new file mode 100644 index 0000000..9790afd --- /dev/null +++ b/app/Http/Requests/DeleteUserRequest.php @@ -0,0 +1,28 @@ +|string> + */ + public function rules(): array + { + return [ + 'id' => 'required|string|exists:users' + ]; + } +} diff --git a/app/Models/User.php b/app/Models/User.php index 1e00906..ca586f7 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\BelongsToMany; +use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Laravel\Passport\HasApiTokens; @@ -15,7 +16,7 @@ class User extends Authenticatable implements MustVerifyEmail { - use HasApiTokens, HasFactory, Notifiable, HasRoles, HasUuids; + use HasApiTokens, HasFactory, Notifiable, HasRoles, HasUuids, SoftDeletes; protected $primaryKey = 'uuid'; public $incrementing = false; protected $keyType = 'string'; @@ -65,16 +66,26 @@ public function organizations(): BelongsToMany return $this->belongsToMany(Organization::class, 'organization_user', 'user_uuid', 'organization_uuid'); } + /** + * Check if the user has a specific role in a given organization. + * + * @param string $role The name of the role to check. + * @param int $organizationId The ID of the organization to check. + * @return bool True if the user has the role in the organization, false otherwise. + */ public function hasRoleInOrganization($role, $organizationId) { return $this->roles()->where('name', $role)->wherePivot('organization_id', $organizationId)->exists(); } - + /** + * Retrieves the roles associated with the user. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ public function roles() { return $this->belongsToMany(Role::class, 'model_has_roles', 'model_uuid', 'role_id') ->withPivot('organization_id', 'tool_id'); - //->select('organization_id', 'role_id', 'name','tool_id'); } } diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 8e4c21e..5055bd9 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -7,6 +7,7 @@ use Exception; use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Hashing\Hasher; +use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Mail; use Ramsey\Uuid\Uuid; use Symfony\Component\HttpFoundation\Response; @@ -186,6 +187,12 @@ public function deleteUser($id) { try { $user = $this->user->find($id); + $user->email = Hash::make($user->email); + $user->password = Hash::make($user->password); + $user->name = Hash::make($user->name); + $user->birthdate = Hash::make($user->birthdate); + $user->surname = Hash::make($user->surname); + $user->save(); $user->delete(); return $user; } catch (\Exception $e) { From acf4167cc9575052980f554e311d941b810cf930 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Fri, 14 Jun 2024 08:43:17 +0200 Subject: [PATCH 091/115] migration soft delete added --- ...3_092627_add_deleted_at_to_users_table.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 database/migrations/2024_06_13_092627_add_deleted_at_to_users_table.php diff --git a/database/migrations/2024_06_13_092627_add_deleted_at_to_users_table.php b/database/migrations/2024_06_13_092627_add_deleted_at_to_users_table.php new file mode 100644 index 0000000..00b74fc --- /dev/null +++ b/database/migrations/2024_06_13_092627_add_deleted_at_to_users_table.php @@ -0,0 +1,22 @@ +softDeletes(); + }); + } + + public function down() + { + Schema::table('users', function (Blueprint $table) { + $table->dropSoftDeletes(); + }); + } +}; From 3d926c73cd7c9eb2d528f60558c90c542e45b478 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Fri, 14 Jun 2024 08:52:46 +0200 Subject: [PATCH 092/115] assign role fix --- app/Services/AssignRoleService.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Services/AssignRoleService.php b/app/Services/AssignRoleService.php index 8937911..9ed0b70 100644 --- a/app/Services/AssignRoleService.php +++ b/app/Services/AssignRoleService.php @@ -68,10 +68,11 @@ public function removePermissionFromRole(Role $role, $permission) } - private function getRolesForOrganization($user, $organizationId) + private function getRolesForOrganizationAndTool($user, $organizationId, $toolId) { return $user->roles() ->wherePivot('organization_id', $organizationId) + ->wherePivot('tool_id', $toolId) ->pluck('role_id') ->toArray(); } @@ -100,7 +101,7 @@ private function removeRoles($user, $roles, $organizationId, $toolId) private function processToolRoles(User $user, $roles, $organizationId, $toolId) { - $currentRoles = $this->getRolesForOrganization($user, $organizationId); + $currentRoles = $this->getRolesForOrganizationAndTool($user, $organizationId,$toolId); $rolesToAdd = array_diff($roles, $currentRoles); $rolesToRemove = array_diff($currentRoles, $roles); From 4fe9294bad6cf14f7c0b762f7da502c203541711 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 17 Jun 2024 07:18:36 +0200 Subject: [PATCH 093/115] rool migrationm --- .../Roles/AssignRoleController.php | 2 +- app/Services/AssignRoleService.php | 2 +- ...o_primary_key_on_model_has_roles_table.php | 43 +++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2024_06_14_092828_add_tool_id_organization_id_to_primary_key_on_model_has_roles_table.php diff --git a/app/Http/Controllers/Roles/AssignRoleController.php b/app/Http/Controllers/Roles/AssignRoleController.php index 7abf962..ff4bacc 100644 --- a/app/Http/Controllers/Roles/AssignRoleController.php +++ b/app/Http/Controllers/Roles/AssignRoleController.php @@ -29,7 +29,7 @@ public function assignRoleToUser(AssignRoleToUserRequest $request) $this->assignRoleService->assignRole($user,$request->organizations); return response()->json(['message' => 'Role assigned successfully'], Response::HTTP_OK); } catch (Exception $e) { - return response()->json(['error' => $e->getMessage()], Response::HTTP_INTERNAL_SERVER_ERROR); + return response()->json(['error' => 'An error occurred while assigning the role'], Response::HTTP_INTERNAL_SERVER_ERROR); } } diff --git a/app/Services/AssignRoleService.php b/app/Services/AssignRoleService.php index 9ed0b70..099e6f8 100644 --- a/app/Services/AssignRoleService.php +++ b/app/Services/AssignRoleService.php @@ -25,7 +25,7 @@ public function assignRole(User $user,array $organizations) } catch (\Exception $e) { \DB::rollBack(); \Log::error('Error synchronizing roles: ' . $e->getMessage()); - return response()->json(['error' => 'Failed to assign roles'], Response::HTTP_INTERNAL_SERVER_ERROR); + throw new Exception('Error synchronizing roles: ' . $e->getMessage()); } return $user; } diff --git a/database/migrations/2024_06_14_092828_add_tool_id_organization_id_to_primary_key_on_model_has_roles_table.php b/database/migrations/2024_06_14_092828_add_tool_id_organization_id_to_primary_key_on_model_has_roles_table.php new file mode 100644 index 0000000..d76fd51 --- /dev/null +++ b/database/migrations/2024_06_14_092828_add_tool_id_organization_id_to_primary_key_on_model_has_roles_table.php @@ -0,0 +1,43 @@ +dropForeign(['role_id']); + $table->dropForeign(['tool_id']); + $table->dropForeign(['organization_id']); + // $table->dropForeign(['model_uuid']); + $table->dropPrimary(['model_type','model_uuid']); + + + // Add the new composite primary key + $table->primary(['role_id', 'model_uuid', 'model_type', 'tool_id', 'organization_id']); + $table->foreign('role_id')->references('uuid')->on('roles'); + $table->foreign('tool_id')->references('uuid')->on('tools'); + $table->foreign('organization_id')->references('uuid')->on('organizations'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('model_has_roles', function (Blueprint $table) { + // Drop the new composite primary key + $table->dropPrimary(['role_id', 'model_uuid', 'model_type', 'tool_id', 'organization_id']); + + // Re-add the old primary key + $table->primary(['role_id', 'model_uuid', 'model_type']); + }); + } +}; From fa2017970b2c9465a24e8ecf45e1ded93558058e Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 17 Jun 2024 09:23:14 +0200 Subject: [PATCH 094/115] userservice bug fix return cosas --- app/Services/UserService.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 5055bd9..ca216ea 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -3,6 +3,7 @@ namespace App\Services; use App\Mail\UserDetailMail; +use App\Models\Tool; use App\Models\User; use Exception; use Illuminate\Contracts\Auth\Guard; @@ -268,12 +269,19 @@ private function getUserToolRoles($user) if ($user->roles()->exists()) { $userToolRoles = []; $roles = $user->roles->load('tools'); + // Get all unique tool IDs from roles + $toolIds = $user->roles->pluck('pivot.tool_id')->unique(); + + // Retrieve all tools with those IDs + $tools = Tool::whereIn('uuid', $toolIds)->get()->keyBy('uuid'); foreach ($roles as $role) { - $userToolRoles[$role->tools->first()->hash] = [ + $toolId = $role->pivot->tool_id; + $tool = $tools[$toolId]; + $userToolRoles[$tool->hash] = [ 'organization' => $role->pivot->organization_id, 'permission' => $this->rolesBitwiseMap[strtolower($role->name)], 'role' => $role->name, - 'tool' => ['name' => $role->tools->first()->name, 'type' => $role->tools->first()->type] + 'tool' => ['name' => $tool->name, 'type' => $tool->type] ]; } return $userToolRoles; From c40e5583a0a643262366b83ed97fe0246a648f8d Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 17 Jun 2024 09:46:19 +0200 Subject: [PATCH 095/115] update request --- app/Http/Requests/AssignRoleToUserRequest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Requests/AssignRoleToUserRequest.php b/app/Http/Requests/AssignRoleToUserRequest.php index 053f72a..6d341b0 100644 --- a/app/Http/Requests/AssignRoleToUserRequest.php +++ b/app/Http/Requests/AssignRoleToUserRequest.php @@ -27,8 +27,8 @@ public function rules(): array 'organizations.*.organization_uuid' => 'required|uuid', 'organizations.*.services' => 'required|array', 'organizations.*.services.*.service_uuid' => 'required|uuid', - 'organizations.*.services.*.role_uuid' => 'required|array', - 'organizations.*.services.*.role_uuid.*' => 'required', + 'organizations.*.services.*.role_uuid' => 'sometimes|array', + 'organizations.*.services.*.role_uuid.*' => 'sometimes|nullable|exists:roles,uuid', ]; } } \ No newline at end of file From 487ef56ce002e192331660c869d713e30f15220e Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 17 Jun 2024 10:14:37 +0200 Subject: [PATCH 096/115] detach bugfixx --- app/Services/AssignRoleService.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/Services/AssignRoleService.php b/app/Services/AssignRoleService.php index 099e6f8..90f81e7 100644 --- a/app/Services/AssignRoleService.php +++ b/app/Services/AssignRoleService.php @@ -9,13 +9,13 @@ class AssignRoleService { - public function assignRole(User $user,array $organizations) + public function assignRole(User $user, array $organizations) { \DB::beginTransaction(); try { - array_map(function($organization) use ($user,$organizations) { - array_map(function($service) use ($user, $organization) { + array_map(function ($organization) use ($user, $organizations) { + array_map(function ($service) use ($user, $organization) { $this->processToolRoles($user, $service['role_uuid'], $organization['organization_uuid'], $service['service_uuid']); }, $organization['services']); }, $organizations); @@ -83,7 +83,7 @@ private function addRoles($user, $roles, $organizationId, $toolId) $user->roles()->attach($role, [ 'organization_id' => $organizationId, 'model_type' => get_class($this), - 'tool_id' => $toolId + 'tool_id' => $toolId, ]); } } @@ -91,17 +91,17 @@ private function addRoles($user, $roles, $organizationId, $toolId) private function removeRoles($user, $roles, $organizationId, $toolId) { if (!empty($roles)) { - $user->roles()->detach($roles, [ - 'organization_id' => $organizationId, - 'model_type' => get_class($this), - 'tool_id' => $toolId - ]); + $user->roles() + ->wherePivot('organization_id', $organizationId) + ->wherePivot('tool_id', $toolId) + ->whereIn('id', $roles) + ->detach(); } } private function processToolRoles(User $user, $roles, $organizationId, $toolId) { - $currentRoles = $this->getRolesForOrganizationAndTool($user, $organizationId,$toolId); + $currentRoles = $this->getRolesForOrganizationAndTool($user, $organizationId, $toolId); $rolesToAdd = array_diff($roles, $currentRoles); $rolesToRemove = array_diff($currentRoles, $roles); From 55bb8c5f0a1cda2595e653215da28c192d42d068 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Mon, 17 Jun 2024 10:52:04 +0200 Subject: [PATCH 097/115] bugfix --- app/Services/AssignRoleService.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/Services/AssignRoleService.php b/app/Services/AssignRoleService.php index 90f81e7..24d9640 100644 --- a/app/Services/AssignRoleService.php +++ b/app/Services/AssignRoleService.php @@ -91,11 +91,16 @@ private function addRoles($user, $roles, $organizationId, $toolId) private function removeRoles($user, $roles, $organizationId, $toolId) { if (!empty($roles)) { - $user->roles() - ->wherePivot('organization_id', $organizationId) - ->wherePivot('tool_id', $toolId) - ->whereIn('id', $roles) - ->detach(); + $pivotTable = $user->roles()->getTable(); // Get the pivot table name + $pivotForeignKey = $user->roles()->getForeignPivotKeyName(); // Get the foreign key name for User + $pivotRelatedKey = $user->roles()->getRelatedPivotKeyName(); // Get the related key name for Role + + \DB::table($pivotTable) + ->where($pivotForeignKey, $user->getKey()) + ->whereIn($pivotRelatedKey, $roles) + ->where('organization_id', $organizationId) + ->where('tool_id', $toolId) + ->delete(); } } From 1919f97540c4b4690098393be50a423f8d6393f9 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 18 Jun 2024 09:19:23 +0200 Subject: [PATCH 098/115] delete user bugfix --- app/Services/UserService.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/Services/UserService.php b/app/Services/UserService.php index ca216ea..97eb671 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -191,14 +191,13 @@ public function deleteUser($id) $user->email = Hash::make($user->email); $user->password = Hash::make($user->password); $user->name = Hash::make($user->name); - $user->birthdate = Hash::make($user->birthdate); $user->surname = Hash::make($user->surname); $user->save(); $user->delete(); return $user; } catch (\Exception $e) { \Log::error($e->getMessage()); - return response()->json(['error' => 'An error occurred while deleting user'], Response::HTTP_INTERNAL_SERVER_ERROR); + throw new \Exception($e->getMessage()); } } From f5630e9846ca3a687073572cc069af0c40be4829 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 18 Jun 2024 11:26:03 +0200 Subject: [PATCH 099/115] invitation update --- .../OrganizationInviteController.php | 11 ++++++ app/Services/AssignRoleService.php | 2 +- app/Services/InvitationService.php | 17 +++++++-- app/Services/UserService.php | 35 +++++++++++++------ routes/api/v1/organization.php | 1 + 5 files changed, 53 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/Organization/OrganizationInviteController.php b/app/Http/Controllers/Organization/OrganizationInviteController.php index 9978d19..72819e0 100644 --- a/app/Http/Controllers/Organization/OrganizationInviteController.php +++ b/app/Http/Controllers/Organization/OrganizationInviteController.php @@ -40,4 +40,15 @@ public function invitationList() { return response()->json(['invitations' => Invitation::all()]); } + + public function delete ($uuid) + { + try { + $this->invitationService->delete($uuid); + return response()->json(['message' => 'Invitation deleted successfully!'], Response::HTTP_OK); + } catch (\Exception $e) { + \Log::error('Error deleting invitation: ' . $e->getMessage()); + return response()->json(['error' => 'An error occurred while deleting the invitation'], Response::HTTP_INTERNAL_SERVER_ERROR); + } + } } diff --git a/app/Services/AssignRoleService.php b/app/Services/AssignRoleService.php index 24d9640..b408789 100644 --- a/app/Services/AssignRoleService.php +++ b/app/Services/AssignRoleService.php @@ -36,7 +36,7 @@ public function revokeRole(User $user, $role) $user->removeRole($role); } catch (Exception $e) { // Handle any exceptions that occur during role revocation - echo 'Error revoking role: ' . $e->getMessage(); + throw new \Exception($e->getMessage()); } } diff --git a/app/Services/InvitationService.php b/app/Services/InvitationService.php index 0e19c18..ba846ee 100644 --- a/app/Services/InvitationService.php +++ b/app/Services/InvitationService.php @@ -31,7 +31,20 @@ public function sendInvitation($email, $organizationUuid,$organizationName) return ['message' => 'Invitation sent successfully!', 'status' => Response::HTTP_OK]; } catch (\Exception $e) { \Log::error('Error sending invitation: ' . $e->getMessage()); - return ['error' => 'An error occurred while sending the invitation', 'status' => Response::HTTP_INTERNAL_SERVER_ERROR]; + throw new \Exception($e->getMessage()); } } -} \ No newline at end of file + + public function delete($uuid) + { + try { + $invitation = Invitation::where('uuid', $uuid)->first(); + $invitation->delete(); + return ['message' => 'Invitation deleted successfully!', 'status' => Response::HTTP_OK]; + } catch (\Exception $e) { + \Log::error('Error deleting invitation: ' . $e->getMessage()); + throw new \Exception($e->getMessage()); + } + } +} + diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 97eb671..c91670a 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -3,6 +3,7 @@ namespace App\Services; use App\Mail\UserDetailMail; +use App\Models\Invitation; use App\Models\Tool; use App\Models\User; use Exception; @@ -69,20 +70,34 @@ public function createUser(array $userData) return $base64User; } catch (Exception $e) { - return false; + throw new \Exception($e->getMessage()); } } public function registerUser($data) { - $user = $this->user->create(get_object_vars($data)); - $user->markEmailAsVerified(); - $user->access_token = $user->createToken('ximdex')->accessToken; - if (isset($data->organization_id)) { - $user->organizations()->attach($data->organization_id); + try { + if (isset($data->organization_id)) { + $invitation = Invitation::where('email', $data->email) + ->where('organization_id', $data->organization_id) + ->where('status', 'pending') + ->first(); + + if (!$invitation) { + throw new Exception('Invalid invitation'); + } + } + $user = $this->user->create(get_object_vars($data)); + $user->markEmailAsVerified(); + $user->access_token = $user->createToken('ximdex')->accessToken; + if (isset($data->organization_id)) { + $user->organizations()->attach($data->organization_id); + } + return $user; + } catch (Exception $e) { + throw new \Exception($e->getMessage()); } - return $user; } /** @@ -106,7 +121,7 @@ public function getUserByLogin(array $data) return null; } catch (Exception $e) { \Log::error($e->getMessage()); - return response()->json(['error' => 'An error occurred while retrieving user'], Response::HTTP_INTERNAL_SERVER_ERROR); + throw new \Exception($e->getMessage()); } } @@ -124,7 +139,7 @@ public function getUserById(string $id) $user->organizations = $user->organizations()->pluck('name', 'uuid')->toArray(); return $user; } catch (Exception $e) { - return response()->json(['error' => 'User not found'], Response::HTTP_NOT_FOUND); + throw new \Exception($e->getMessage()); } } @@ -173,7 +188,7 @@ public function updateUser(array $data) return $user; } catch (\Exception $e) { \Log::error($e->getMessage()); - return response()->json(['error' => 'An error occurred while updating user'], Response::HTTP_INTERNAL_SERVER_ERROR); + throw new \Exception($e->getMessage()); } } diff --git a/routes/api/v1/organization.php b/routes/api/v1/organization.php index 0e4a58b..c8f5d54 100644 --- a/routes/api/v1/organization.php +++ b/routes/api/v1/organization.php @@ -13,6 +13,7 @@ Route::get('/', [OrganizationController::class, 'listOrganizations'])->name('api.organizations.list'); Route::post('/{organization}/invite/{email}', [OrganizationInviteController::class, 'sendInvite'])->name('api.organizations.invite')->missing($missingCallback); Route::get('/invitations', [OrganizationInviteController::class, 'invitationList'])->name('api.organizations.invites.list'); + Route::delete('/invitations/{uuid}', [OrganizationInviteController::class, 'delete'])->name('api.organizations.invites.delete')->missing($missingCallback); }); Route::prefix('organizations')->middleware(['auth:api', 'role:superadmin'])->group(function () use ($missingCallback) { From 71e8db9512872cade14afe1ac191b869fe052ff4 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 18 Jun 2024 11:59:18 +0200 Subject: [PATCH 100/115] INVITATION BUGFIX --- app/Services/InvitationService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Services/InvitationService.php b/app/Services/InvitationService.php index ba846ee..f331c23 100644 --- a/app/Services/InvitationService.php +++ b/app/Services/InvitationService.php @@ -38,7 +38,7 @@ public function sendInvitation($email, $organizationUuid,$organizationName) public function delete($uuid) { try { - $invitation = Invitation::where('uuid', $uuid)->first(); + $invitation = Invitation::where('id', $uuid)->first(); $invitation->delete(); return ['message' => 'Invitation deleted successfully!', 'status' => Response::HTTP_OK]; } catch (\Exception $e) { From 76c7c8bfcfcd6cb2dad735ae3a2591d352e68ce7 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 18 Jun 2024 17:25:17 +0200 Subject: [PATCH 101/115] me added --- app/Http/Controllers/Auth/AuthController.php | 105 +++++++++++++------ app/Services/UserService.php | 7 ++ routes/api/v1/auth.php | 1 + 3 files changed, 82 insertions(+), 31 deletions(-) diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index c72be7a..aad8fc2 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -28,34 +28,53 @@ class AuthController extends Controller 'superAdmin' => '00000001', ]; - - public function __construct(UserService $userService,UserPrepareService $userPrepareService) + /** + * Constructs a new instance of the class. + * + * @param UserService $userService The UserService instance. + * @param UserPrepareService $userPrepareService The UserPrepareService instance. + */ + public function __construct(UserService $userService, UserPrepareService $userPrepareService) { - $this->userService = $userService; - $this->userPrepareService = $userPrepareService; + $this->userService = $userService; + $this->userPrepareService = $userPrepareService; } + + /** + * Register a new user. + * + * @param RegisterRequest $request The registration request. + * @throws \Exception If an error occurs during registration. + * @return \Illuminate\Http\JsonResponse The JSON response containing the registered user or an error message. + */ public function register(RegisterRequest $request) { try { - $user = $this->userPrepareService->prepareUserRegistration($request->validated()); - if ($user) { - return response()->json(['message' => $user], Response::HTTP_CREATED); - }else{ - return response()->json(['error' => "User could not been created"], Response::HTTP_INTERNAL_SERVER_ERROR); - } - + $user = $this->userPrepareService->prepareUserRegistration($request->validated()); + if ($user) { + return response()->json(['message' => $user], Response::HTTP_CREATED); + } else { + return response()->json(['error' => "User could not been created"], Response::HTTP_INTERNAL_SERVER_ERROR); + } } catch (\Exception $e) { \Log::error($e); return response()->json(['error' => 'An error occurred while registering the user. Please try again later.' . $e], Response::HTTP_INTERNAL_SERVER_ERROR); } } + /** + * Logs in a user with the provided credentials. + * + * @param LoginRequest $request The login request containing the email and password. + * @throws \Exception If an error occurs during the login process. + * @return \Illuminate\Http\JsonResponse The JSON response containing the logged-in user or an error message. + */ public function login(LoginRequest $request) { try { $user = $this->userService->getUserByLogin($request->only('email', 'password')); - if($user){ - $user->makeHidden(['created_at', 'updated_at','roles']); + if ($user) { + $user->makeHidden(['created_at', 'updated_at', 'roles']); return response()->json(['user' => $user], Response::HTTP_CREATED); } return response()->json(['error' => 'Login failed'], Response::HTTP_NOT_FOUND); @@ -63,30 +82,54 @@ public function login(LoginRequest $request) \Log::error($e->getMessage()); return response()->json(['error' => 'Server error occurred. Please try again later.'], Response::HTTP_INTERNAL_SERVER_ERROR); } - } + /** + * Updates a user's information based on the provided request data. + * + * @param Request $request The HTTP request containing the user's updated information. + * @return JsonResponse The JSON response containing the updated user object or an error message. + */ public function update(Request $request) { - $data = $request->all(); - - $updatedUser = $this->userService->updateUser($data); - if ($updatedUser instanceof JsonResponse) { - return $updatedUser; - } - $updatedUser->makeHidden(['created_at', 'updated_at','uuid']); + try { + $data = $request->all(); - return response()->json(['user' => $updatedUser]); + $updatedUser = $this->userService->updateUser($data); + if ($updatedUser instanceof JsonResponse) { + return $updatedUser; + } + $updatedUser->makeHidden(['created_at', 'updated_at', 'uuid']); + + return response()->json(['user' => $updatedUser]); + } catch (\Exception $e) { + // Log the error internally + \Log::error($e); + // Return a JSON response with the error message and a 500 status code + return response()->json(['error' => 'An error occurred while updating the user. Please try again later.'], 500); + } } + /** + * Validates the token for the 'api' guard user. + * + * @return \Illuminate\Http\JsonResponse The JSON response containing the message 'Token is valid' and the user object, or an error message. + * @throws \Exception If an error occurs during the validation process. + * @return \Illuminate\Http\JsonResponse The JSON response containing the error message. + */ public function validateToken() - { - $user = Auth::guard('api')->user(); - - if ($user) { - return response()->json(['message' => 'Token is valid', 'user' => $user]); - } else { - return response()->json(['message' => 'Token is invalid'], Response::HTTP_UNAUTHORIZED); - } - } + { + try { + $user = Auth::guard('api')->user(); + + if ($user) { + return response()->json(['message' => 'Token is valid', 'user' => $user]); + } else { + return response()->json(['message' => 'Token is invalid'], Response::HTTP_UNAUTHORIZED); + } + } catch (\Exception $e) { + \Log::error($e); + return response()->json(['error' => 'An error occurred while validating the token. Please try again later.'], Response::HTTP_INTERNAL_SERVER_ERROR); + } + } } diff --git a/app/Services/UserService.php b/app/Services/UserService.php index c91670a..610b01e 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -75,6 +75,13 @@ public function createUser(array $userData) } + /** + * Registers a user with the given data. + * + * @param mixed $data The data containing the user information. + * @throws \Exception If the invitation is invalid or an error occurs during registration. + * @return \App\Models\User The registered user. + */ public function registerUser($data) { try { diff --git a/routes/api/v1/auth.php b/routes/api/v1/auth.php index d08db59..c889b82 100644 --- a/routes/api/v1/auth.php +++ b/routes/api/v1/auth.php @@ -7,3 +7,4 @@ Route::post('/register', [AuthController::class, 'register'])->name('api.register'); Route::post('/login', [AuthController::class, 'login'])->name('api.login'); +Route::get('/me', [AuthController::class, 'validateToken'])->name('api.users.me'); From 0043b29beca0ced82ca3f7669006a79ebca72075 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 25 Jun 2024 10:59:12 +0200 Subject: [PATCH 102/115] claim update --- app/Claims/CustomClaim.php | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/app/Claims/CustomClaim.php b/app/Claims/CustomClaim.php index f36f8ee..a5d84b2 100644 --- a/app/Claims/CustomClaim.php +++ b/app/Claims/CustomClaim.php @@ -24,27 +24,15 @@ public function handle(AccessToken $token, $next) foreach ($user->roles as $role) { $permission = $rolesBitwiseMap[strtolower($role->name)] ?? null; // Get the permission from the rolesBitwiseMap - foreach ($role->tools as $tool) { - $toolHash = $tool->hash; // Get the hash from the tool - // Construct the organization#permission string + $orgPermission = $permission . '#' . $role->pivot->organization_id; + $toolHash = $role->tools->first()->hash ?? null; // Get the tool's hash + + if ($permission && $toolHash) { $orgPermission = $permission . '#' . $role->pivot->organization_id; - // Add to the array, grouping by tool_hash - $toolsPermissions[$toolHash][] = $orgPermission; + $toolsPermissions[$toolHash][] = $orgPermission; // Use $toolHash as the key } } - $roles = $user->roles()->get()->map(function ($role) { - return [ - 'name' => $role->name, - 'service_id' => $role->pivot->tool_id, - 'organization_id' => $role->pivot->organization_id, - 'service_hash' => $role->tools->first()->hash - ]; - })->all(); - - $rolesArray = $user->roles->map(fn ($role) => $rolesBitwiseMap[$role->name])->all(); - - $token->addClaim('p', $toolsPermissions); return $next($token); } From a70e75b57cea6f1706ef6de031094f53f78b942a Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 25 Jun 2024 11:01:08 +0200 Subject: [PATCH 103/115] url added to services --- ...24_06_21_054119_add_url_to_tools_table.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 database/migrations/2024_06_21_054119_add_url_to_tools_table.php diff --git a/database/migrations/2024_06_21_054119_add_url_to_tools_table.php b/database/migrations/2024_06_21_054119_add_url_to_tools_table.php new file mode 100644 index 0000000..8dcede7 --- /dev/null +++ b/database/migrations/2024_06_21_054119_add_url_to_tools_table.php @@ -0,0 +1,28 @@ +string('url')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('tools', function (Blueprint $table) { + $table->dropColumn('url'); + }); + } +}; From 9ab309cb9cb350c606d5dcf02c30499e97772d91 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 25 Jun 2024 11:56:07 +0200 Subject: [PATCH 104/115] add user to service --- app/Http/Controllers/Tools/ToolController.php | 22 ++++- app/Services/ToolService.php | 91 +++++++++++++++++++ routes/api/v1/tool.php | 3 +- 3 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 app/Services/ToolService.php diff --git a/app/Http/Controllers/Tools/ToolController.php b/app/Http/Controllers/Tools/ToolController.php index 60f6b7a..c8a5e4a 100644 --- a/app/Http/Controllers/Tools/ToolController.php +++ b/app/Http/Controllers/Tools/ToolController.php @@ -4,16 +4,27 @@ use App\Http\Controllers\Controller; use App\Models\Tool; +use App\Models\User; +use App\Services\ToolService; use Illuminate\Http\Request; use Symfony\Component\HttpFoundation\Response; class ToolController extends Controller { + /** + *TODO: + * add get all tools to a service + */ protected $tool; - public function __construct(Tool $tool) + protected $toolService; + + public function __construct(Tool $tool, ToolService $toolService) { $this->tool = $tool; + + $this->toolService = $toolService; + } public function getTools(Request $request) @@ -26,4 +37,13 @@ public function getList(){ $tools = $this->tool->all(); return response()->json(['services' => $tools], Response::HTTP_OK); } + + public function createUserOnService(User $user, $serviceId){ + try { + $this->toolService->createUserOnService($user, $serviceId); + return response()->json(['message' => 'User created successfully/Found','success' => true], Response::HTTP_OK); + } catch (\Exception $e) { + return response()->json(['message' => 'Error creating user on service','success' => false], Response::HTTP_INTERNAL_SERVER_ERROR); + } + } } diff --git a/app/Services/ToolService.php b/app/Services/ToolService.php new file mode 100644 index 0000000..67471fe --- /dev/null +++ b/app/Services/ToolService.php @@ -0,0 +1,91 @@ +tool = $tool; + } + + public function createUserOnService($user, $serviceId) + { + try { + $toolService = $this->tool->find($serviceId); + if (!$toolService) { + throw new Exception('Tool service not found'); + } + + $serviceUrl = $toolService->url; + $url = $serviceUrl . '/xdir?XDEBUG_SESSION_START'; + $payload = $this->preparePayload($user, $serviceId); + + $response = $this->sendRequest($url, $payload); + $data = json_decode($response); + + if (!$response || !$data || !$data->success) { + $this->logError('Error creating user on service', [ + 'user' => $user->id, + 'service' => $serviceId, + 'response' => $response, + ]); + throw new Exception('Error creating user on service'); + } + + return true; + } catch (\Exception $e) { + $this->logError($e->getMessage(), [ + 'user' => $user->id, + 'service' => $serviceId, + ]); + throw $e; + } + } + + + private function preparePayload($user, $serviceId) + { + $payload = json_encode([ + 'data' => ['user' => $user, 'toolId' => $serviceId], + 'action' => 'createUser' + ]); + + if (json_last_error() !== JSON_ERROR_NONE) { + throw new Exception('JSON encode error: ' . json_last_error_msg()); + } + + return $payload; + } + + private function sendRequest($url, $payload) + { + $ch = curl_init($url); + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); + curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); + + $response = curl_exec($ch); + + if (curl_errno($ch)) { + throw new Exception(curl_error($ch)); + } + + curl_close($ch); + + return $response; + } + + private function logError($message, $context = []) + { + \Log::error($message, $context); + } +} diff --git a/routes/api/v1/tool.php b/routes/api/v1/tool.php index 19ee416..891b0af 100644 --- a/routes/api/v1/tool.php +++ b/routes/api/v1/tool.php @@ -5,6 +5,7 @@ use App\Http\Controllers\Tools\ToolController; use Illuminate\Support\Facades\Route; -Route::prefix('tools')->middleware('auth:api')->group(function () { +Route::prefix('services')->middleware('auth:api')->group(function () { Route::get('/', [ToolController::class, 'getList'])->name('api.tools.getList'); + Route::get('/create-user-on-service/{user}/{serviceId}', [ToolController::class, 'createUserOnService'])->name('api.tools.createUserOnService'); }); \ No newline at end of file From 393abec304e3e97a9c42f9829b6dd3fab289cd3d Mon Sep 17 00:00:00 2001 From: juandz13 Date: Wed, 26 Jun 2024 08:23:55 +0200 Subject: [PATCH 105/115] builder for requests --- app/Builders/PayloadBuilder.php | 44 +++++++++++++++++++ .../interfaces/PayloadBuilderInterface.php | 9 ++++ 2 files changed, 53 insertions(+) create mode 100644 app/Builders/PayloadBuilder.php create mode 100644 app/Builders/interfaces/PayloadBuilderInterface.php diff --git a/app/Builders/PayloadBuilder.php b/app/Builders/PayloadBuilder.php new file mode 100644 index 0000000..e33b1b4 --- /dev/null +++ b/app/Builders/PayloadBuilder.php @@ -0,0 +1,44 @@ +data = $data; + return $this; + } + + public function setAction(string $action): PayloadBuilderInterface + { + $this->action = $action; + return $this; + } + + /** + * Returns a JSON-encoded string representation of the payload data and action. + * + * @return string The JSON-encoded payload. + * @throws Exception If there is an error encoding the payload. + */ + public function build(): array + { + $payload = ([ + 'data' => $this->data, + 'action' => $this->action, + ]); + + if (json_last_error() !== JSON_ERROR_NONE) { + throw new Exception('JSON encode error: ' . json_last_error_msg()); + } + + return $payload; + } +} diff --git a/app/Builders/interfaces/PayloadBuilderInterface.php b/app/Builders/interfaces/PayloadBuilderInterface.php new file mode 100644 index 0000000..527510a --- /dev/null +++ b/app/Builders/interfaces/PayloadBuilderInterface.php @@ -0,0 +1,9 @@ + Date: Wed, 26 Jun 2024 08:24:34 +0200 Subject: [PATCH 106/115] curl service --- app/Services/CurlService.php | 55 ++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 app/Services/CurlService.php diff --git a/app/Services/CurlService.php b/app/Services/CurlService.php new file mode 100644 index 0000000..3a111ac --- /dev/null +++ b/app/Services/CurlService.php @@ -0,0 +1,55 @@ + Date: Wed, 26 Jun 2024 08:24:52 +0200 Subject: [PATCH 107/115] toolservice refactor --- app/Services/ToolService.php | 52 +++++++++--------------------------- 1 file changed, 13 insertions(+), 39 deletions(-) diff --git a/app/Services/ToolService.php b/app/Services/ToolService.php index 67471fe..4ba3ceb 100644 --- a/app/Services/ToolService.php +++ b/app/Services/ToolService.php @@ -2,6 +2,7 @@ namespace App\Services; +use App\Builders\PayloadBuilder; use App\Models\Tool; use Exception; @@ -10,9 +11,16 @@ class ToolService private $tool = null; - public function __construct(Tool $tool) + private $curlService = null; + + private $payloadBuilder = null; + + public function __construct(Tool $tool, CurlService $curlService, PayloadBuilder $payloadBuilder) { $this->tool = $tool; + $this->curlService = $curlService; + $this->payloadBuilder = $payloadBuilder; + } public function createUserOnService($user, $serviceId) @@ -22,12 +30,12 @@ public function createUserOnService($user, $serviceId) if (!$toolService) { throw new Exception('Tool service not found'); } - + $serviceUrl = $toolService->url; $url = $serviceUrl . '/xdir?XDEBUG_SESSION_START'; - $payload = $this->preparePayload($user, $serviceId); - - $response = $this->sendRequest($url, $payload); + $data = ['user' => $user, 'toolId' => $serviceId]; + $payload = $this->payloadBuilder->setData($data)->setAction('createUser')->build(); + $response = $this->curlService->post($url, $payload); $data = json_decode($response); if (!$response || !$data || !$data->success) { @@ -48,41 +56,7 @@ public function createUserOnService($user, $serviceId) throw $e; } } - - - private function preparePayload($user, $serviceId) - { - $payload = json_encode([ - 'data' => ['user' => $user, 'toolId' => $serviceId], - 'action' => 'createUser' - ]); - - if (json_last_error() !== JSON_ERROR_NONE) { - throw new Exception('JSON encode error: ' . json_last_error_msg()); - } - - return $payload; - } - - private function sendRequest($url, $payload) - { - $ch = curl_init($url); - - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); - curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); - $response = curl_exec($ch); - - if (curl_errno($ch)) { - throw new Exception(curl_error($ch)); - } - - curl_close($ch); - - return $response; - } private function logError($message, $context = []) { From 9b2d69aa950734cb030a8ab5871e8bacfbae08f7 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Wed, 26 Jun 2024 08:29:59 +0200 Subject: [PATCH 108/115] services routes --- routes/api/v1/tool.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/routes/api/v1/tool.php b/routes/api/v1/tool.php index 891b0af..c522061 100644 --- a/routes/api/v1/tool.php +++ b/routes/api/v1/tool.php @@ -1,11 +1,12 @@ middleware('auth:api')->group(function () { Route::get('/', [ToolController::class, 'getList'])->name('api.tools.getList'); +}); + +Route::prefix('services')->middleware(['auth:api','role:admin|superadmin'])->group(function () { Route::get('/create-user-on-service/{user}/{serviceId}', [ToolController::class, 'createUserOnService'])->name('api.tools.createUserOnService'); }); \ No newline at end of file From 79e1db3cbad4167523e9f55e6eea197c47c8ec7d Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 27 Jun 2024 14:49:46 +0200 Subject: [PATCH 109/115] cookies --- app/Http/Controllers/Auth/AuthController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index aad8fc2..4cd8011 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -75,7 +75,8 @@ public function login(LoginRequest $request) $user = $this->userService->getUserByLogin($request->only('email', 'password')); if ($user) { $user->makeHidden(['created_at', 'updated_at', 'roles']); - return response()->json(['user' => $user], Response::HTTP_CREATED); + $cookie = cookie('access_token', $user->accessToken, 60); // 60 minutes + return response()->json(['user' => $user], Response::HTTP_CREATED)->cookie($cookie); } return response()->json(['error' => 'Login failed'], Response::HTTP_NOT_FOUND); } catch (\Exception $e) { From 5008e22167d9de957e812c0d5c0ed0f5203b954b Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 9 Jul 2024 07:13:06 +0200 Subject: [PATCH 110/115] bugfix permissions --- app/Claims/CustomClaim.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/Claims/CustomClaim.php b/app/Claims/CustomClaim.php index a5d84b2..46dd33b 100644 --- a/app/Claims/CustomClaim.php +++ b/app/Claims/CustomClaim.php @@ -2,11 +2,12 @@ namespace App\Claims; -use App\Models\Role; use App\Models\Tool; use App\Models\User; use CorBosman\Passport\AccessToken; +//Improve this function in the future, removing User and Tool dependency + class CustomClaim { public function handle(AccessToken $token, $next) @@ -23,13 +24,15 @@ public function handle(AccessToken $token, $next) $toolsPermissions = []; foreach ($user->roles as $role) { - $permission = $rolesBitwiseMap[strtolower($role->name)] ?? null; // Get the permission from the rolesBitwiseMap - $orgPermission = $permission . '#' . $role->pivot->organization_id; - $toolHash = $role->tools->first()->hash ?? null; // Get the tool's hash - - if ($permission && $toolHash) { - $orgPermission = $permission . '#' . $role->pivot->organization_id; - $toolsPermissions[$toolHash][] = $orgPermission; // Use $toolHash as the key + $permission = $rolesBitwiseMap[strtolower($role->name)] ?? null; + if ($permission) { + $toolId = $role->pivot->tool_id; + $tool = Tool::find($toolId); + if ($tool) { + $toolHash = $tool->hash; + $orgPermission = $permission . '#' . $role->pivot->organization_id; + $toolsPermissions[$toolHash][] = $orgPermission; // Use $toolHash as the key + } } } From 67c361471e877c5719f180cfe7ba14d1835d8ec4 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 9 Jul 2024 09:34:08 +0200 Subject: [PATCH 111/115] update --- app/Services/UserService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 610b01e..89ce4f1 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -97,7 +97,7 @@ public function registerUser($data) } $user = $this->user->create(get_object_vars($data)); $user->markEmailAsVerified(); - $user->access_token = $user->createToken('ximdex')->accessToken; + $user->access_token = $user->createToken(env('PASSPORT_TOKEN'))->accessToken; if (isset($data->organization_id)) { $user->organizations()->attach($data->organization_id); } @@ -120,7 +120,7 @@ public function getUserByLogin(array $data) $this->auth->attempt($data); $user = $this->auth->user(); if ($user) { - $user->access_token = $user->createToken('ximdex')->accessToken; + $user->access_token = $user->createToken(env('PASSPORT_TOKEN'))->accessToken; $user->p = $this->getUserToolRoles($user); $user->organizations = $user->organizations()->pluck('name', 'uuid')->toArray(); return $user; From ada17e632fc72821c9a4b9c7f669ea76acd9f3f2 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 9 Jul 2024 09:39:34 +0200 Subject: [PATCH 112/115] update --- app/Services/ToolService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Services/ToolService.php b/app/Services/ToolService.php index 4ba3ceb..fc89998 100644 --- a/app/Services/ToolService.php +++ b/app/Services/ToolService.php @@ -32,7 +32,7 @@ public function createUserOnService($user, $serviceId) } $serviceUrl = $toolService->url; - $url = $serviceUrl . '/xdir?XDEBUG_SESSION_START'; + $url = $serviceUrl . '/xdir'; $data = ['user' => $user, 'toolId' => $serviceId]; $payload = $this->payloadBuilder->setData($data)->setAction('createUser')->build(); $response = $this->curlService->post($url, $payload); From 8a140ea4e5dc4b3a6b90e1cd9fd1becdc4cc8c86 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Tue, 9 Jul 2024 09:39:53 +0200 Subject: [PATCH 113/115] update --- app/Http/Controllers/User/UserController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Http/Controllers/User/UserController.php b/app/Http/Controllers/User/UserController.php index bbd9ca2..811d572 100644 --- a/app/Http/Controllers/User/UserController.php +++ b/app/Http/Controllers/User/UserController.php @@ -6,7 +6,9 @@ use App\Http\Requests\UserPaginationRequest; use App\Services\UserService; use Illuminate\Contracts\Auth\Guard; +use Illuminate\Http\Request; use Illuminate\Http\Response; +use Illuminate\Support\Facades\Auth; class UserController extends Controller { @@ -62,4 +64,10 @@ public function deleteUser($id) return response()->json(['error' => 'An error occurred while deleting the user.'], Response::HTTP_INTERNAL_SERVER_ERROR); } } + + public function getUserByToken(Request $request) + { + $user = Auth::guard('api')->user(); + return response()->json(['user' => $user]); + } } From 2a14e07015fd9bcf9749514428cb7aede791ac53 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 11 Jul 2024 06:39:21 +0200 Subject: [PATCH 114/115] readme tutorial --- README.md | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/README.md b/README.md index 642b713..651f235 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,101 @@ +```bash +X X DDDD I RRRR + X X D D I R R + X D D I RRRR + X X D D I R R +X X DDDD I R RR +``` + # xdir-back-v2 Backend de administración y registro de Usuarios y Roles + +# Configuración inicial de xdir-back-v2 + +Este documento proporciona una guía paso a paso para configurar el entorno de desarrollo del backend de administración y registro de Usuarios y Roles, `xdir-back-v2`. Sigue cuidadosamente las instrucciones para asegurar una correcta configuración del proyecto. + +## Requisitos previos + +Antes de comenzar, asegúrate de tener instalado Git y Composer en tu sistema. Estas herramientas son esenciales para clonar el repositorio y gestionar las dependencias de PHP del proyecto. + +## Clonar el repositorio + +Para obtener el código fuente del proyecto, ejecuta el siguiente comando en tu terminal: +```bash +git clone git@github.com:XIMDEX/xdir-back-v2.git +``` + +Este comando clona el repositorio en una nueva carpeta llamada xdir-back-v2 en tu directorio actual. +Luego es necesario hacer un cd xdir-back-v2 para acceder al directorio. + +## Cambiar a la rama de desarrollo +Para trabajar con la versión de desarrollo más reciente, cambia a la rama develop: +```bash +git checkout develop +``` + +## Instalar las dependecias +```bash +composer install +``` +Este comando lee el archivo composer.json, descarga las dependencias requeridas y las instala en el directorio vendor. + +## ENV + +Copia el archivo .env.example para crear tu .env +```bash +cp .env.example .env +``` +Y configurar las variables de entorno, sobretodo las de database. +Para que todos estos nuevos datos sean cargados es necesario ejecutar el siguiente comando: +```bash +php artisan optimize +``` +Y tras ello podemos verificar las rutas para ver que todo esta correcto: +```bash +php artisan route:list +``` +## Migrate +Es necesario hacer el migrate: +```bash +php artisan migrate +``` +Ahora probar la ruta de /register, podemos usar los siguientes datos: +```bash +{ + "email": "testXdir@ximdex.com", + "password": "test123456", + "name": "test", + "surname": "text para surname", + "birthdate": "2020-10-10" +} +``` +En la respuesta tendremos el token que nos servira para no tener que registar un mail real(Recuerda tener la app en modo debug, en el env, para obtener esta respuesta) +## Keys +```bash +php artisan key:generate +``` +Tambien hay que generar las keys para passport +```bash +php artisan passport:keys +``` +Y asegurarnos de que tengan los permisos correctamente +```bash +sudo chown www-data:www-data storage/oauth-public.key storage/oauth-private.key +``` +Nos quedaria general la clave +```bash +php artisan passport:client --personal. +``` +Al final recibiras dos variables que habra que guardar en el .env junto al nombre que se le haya asignado +```bash +PASSPORT_PERSONAL_ACCESS_CLIENT_ID="tu_id_de_cliente" +PASSPORT_SECRET="tu_secreto_cliente" +PASSPORT_TOKEN_NAME="nombre_del_cliente" +``` +Y acabamos con un php artisan optimize + +## Verificación de Email y Login + +Verificar el email: Para simular la verificación de email, accede a la ruta /email/verify/{token}, donde {token} es el token de verificación que obtuviste previamente. + +Probar el login: Una vez verificado el email, puedes proceder a probar el login mediante la ruta /login utilizando herramientas como Postman o cURL, proporcionando las credenciales de usuario (email y contraseña). \ No newline at end of file From c0d2c4eca5e4486f92e7b30e03f41734a6e8cb26 Mon Sep 17 00:00:00 2001 From: juandz13 Date: Thu, 11 Jul 2024 06:40:40 +0200 Subject: [PATCH 115/115] update --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 651f235..df0c7c8 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Backend de administración y registro de Usuarios y Roles # Configuración inicial de xdir-back-v2 Este documento proporciona una guía paso a paso para configurar el entorno de desarrollo del backend de administración y registro de Usuarios y Roles, `xdir-back-v2`. Sigue cuidadosamente las instrucciones para asegurar una correcta configuración del proyecto. +PHP8.2 ## Requisitos previos