├── .github └── workflows │ ├── duster-lint.yml │ └── main.yml ├── .gitignore ├── .husky └── pre-commit ├── .styleci.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── composer.json ├── package.json ├── phpunit.xml ├── pnpm-lock.yaml ├── socialsync ├── .gitignore └── rill.yaml ├── src ├── Console │ └── Commands │ │ └── PublishEnumsCommand.php ├── Exceptions │ └── ArgumentIsNotEnumException.php ├── Facades │ └── PublishEnums.php ├── LaravelFrontendEnumsServiceProvider.php ├── Registry.php └── config │ └── laravel-frontend-enums.php └── tests ├── Enums ├── AgeLimits.php └── Colours.php ├── Feature └── PublishesEnumsTest.php ├── Pest.php ├── Providers └── TestApplicationServiceProvider.php ├── Publish └── .gitkeep └── TestCase.php /.github/workflows/duster-lint.yml: -------------------------------------------------------------------------------- 1 | name: Duster Lint 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | 8 | jobs: 9 | duster: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v3 14 | - name: "Duster Lint" 15 | uses: tighten/duster-action@v2 16 | with: 17 | args: lint 18 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: run-tests 2 | 3 | on: [ push, pull_request ] 4 | 5 | jobs: 6 | run-tests: 7 | runs-on: ubuntu-latest 8 | strategy: 9 | fail-fast: false 10 | matrix: 11 | php: [ 8.4, 8.3, 8.2 ] 12 | laravel: [ 11.*, 12.* ] 13 | dependency-version: [ prefer-lowest, prefer-stable ] 14 | include: 15 | - laravel: 11.* 16 | testbench: 9.* 17 | - laravel: 12.* 18 | testbench: 10.* 19 | 20 | name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} 21 | 22 | steps: 23 | - name: Checkout code 24 | uses: actions/checkout@v4 25 | 26 | - name: Setup PHP 27 | uses: shivammathur/setup-php@v2 28 | with: 29 | php-version: ${{ matrix.php }} 30 | extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick 31 | coverage: none 32 | 33 | - name: Setup Problem Matches 34 | run: | 35 | echo "::add-matcher::${{ runner.tool_cache }}/php.json" 36 | echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" 37 | 38 | - name: Install dependencies 39 | run: | 40 | composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:>=2.62.1" --no-interaction --no-update 41 | composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction 42 | 43 | - name: Execute tests 44 | run: vendor/bin/pest 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .phpunit.result.cache 3 | vendor 4 | node_modules 5 | composer.lock 6 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | npx --no-install lint-staged 5 | -------------------------------------------------------------------------------- /.styleci.yml: -------------------------------------------------------------------------------- 1 | preset: laravel 2 | 3 | disabled: 4 | - single_class_element_per_statement 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `laravel-frontend-enums` will be documented in this file 4 | 5 | ## 1.0.0 - 201X-XX-XX 6 | 7 | - initial release 8 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | Please read and understand the contribution guide before creating an issue or pull request. 6 | 7 | ## Etiquette 8 | 9 | This project is open source, and as such, the maintainers give their free time to build and maintain the source code 10 | held within. They make the code freely available in the hope that it will be of use to other developers. It would be 11 | extremely unfair for them to suffer abuse or anger for their hard work. 12 | 13 | Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the 14 | world that developers are civilized and selfless people. 15 | 16 | It's the duty of the maintainer to ensure that all submissions to the project are of sufficient 17 | quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. 18 | 19 | ## Viability 20 | 21 | When requesting or submitting new features, first consider whether it might be useful to others. Open 22 | source projects are used by many developers, who may have entirely different needs to your own. Think about 23 | whether or not your feature is likely to be used by other users of the project. 24 | 25 | ## Procedure 26 | 27 | Before filing an issue: 28 | 29 | - Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. 30 | - Check to make sure your feature suggestion isn't already present within the project. 31 | - Check the pull requests tab to ensure that the bug doesn't have a fix in progress. 32 | - Check the pull requests tab to ensure that the feature isn't already in progress. 33 | 34 | Before submitting a pull request: 35 | 36 | - Check the codebase to ensure that your feature doesn't already exist. 37 | - Check the pull requests to ensure that another person hasn't already submitted the feature or fix. 38 | 39 | ## Requirements 40 | 41 | If the project maintainer has any additional requirements, you will find them listed here. 42 | 43 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). 44 | 45 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 46 | 47 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 48 | 49 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. 50 | 51 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 52 | 53 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 54 | 55 | **Happy coding**! 56 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Dan Matthews 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laravel Frontend Enums 2 | 3 | [![Latest Version on Packagist](https://img.shields.io/packagist/v/intrfce/laravel-frontend-enums.svg?style=flat-square)](https://packagist.org/packages/intrfce/laravel-frontend-enums) 4 | [![Total Downloads](https://img.shields.io/packagist/dt/intrfce/laravel-frontend-enums.svg?style=flat-square)](https://packagist.org/packages/intrfce/laravel-frontend-enums) 5 | ![GitHub Actions](https://github.com/intrfce/laravel-frontend-enums/actions/workflows/main.yml/badge.svg) 6 | 7 | Publish your PHP enums to the frontend of our application so you can refer to them in your JavaScript code. 8 | 9 | ## Installation 10 | 11 | You can install the package via composer: 12 | 13 | ```bash 14 | composer require intrfce/laravel-frontend-enums 15 | ``` 16 | 17 | ## Usage 18 | 19 | In your `AppServiceProvider.php`, tell the package which Enums you want to publish: 20 | 21 | ```php 22 | 23 | use Intrfce\LaravelFrontendEnums\Facades\PublishEnums; 24 | 25 | PublishEnums::publish([ 26 | \App\Enums\MyEnum::class, 27 | \App\Enums\MyOtherEnum::class, 28 | ])->toDirectory(resource_path('js/Enums')); 29 | ``` 30 | Then run the publish command: 31 | 32 | ```php 33 | php artisan publish:enums-to-javascript 34 | ``` 35 | 36 | Your enums will be waiting at the path you specified with the extension `.enum.js`: 37 | 38 | ``` 39 | MyEnum.enum.js 40 | MyOtherEnum.enum.js 41 | ``` 42 | 43 | You can then import and use them in your JavaScript code: 44 | 45 | ```js 46 | import {MyEnum} from './Enums/MyEnum.enum.js'; 47 | import {MyOtherEnum} from './Enums/MyOtherEnum.enum.js'; 48 | 49 | console.log(MyEnum.FOO); // 0 50 | console.log(MyOtherEnum.BAR); // 'bar' 51 | ``` 52 | 53 | ## Typescript Support 54 | 55 | Typescript support is baked in: just add `->asTypescript()` to the list of enums in your `AppServiceProvider.php`: 56 | 57 | ```php 58 | PublishEnums::publish([ 59 | \App\Enums\MyEnum::class, 60 | \App\Enums\MyOtherEnum::class, 61 | ]) 62 | ->asTypescript() 63 | ->toDirectory(resource_path('js/Enums')); 64 | ``` 65 | 66 | Files will be output as `.ts` files and Typescript native enums: 67 | 68 | ```ts 69 | export enum MyEnum { 70 | FOO = 0, 71 | BAR = 1, 72 | BAZ = 2, 73 | } 74 | ``` 75 | 76 | ## Automatically generate javascript files on change. 77 | 78 | You can use the [`vite-plugin-watch`](https://github.com/lepikhinb/vite-plugin-watch) package from [lepikhinb](https://github.com/lepikhinb) to automatically generate your javascript files when you make changes to your PHP enums: 79 | 80 | ```php 81 | npm install -D vite-plugin-watch 82 | ``` 83 | 84 | Then add the plugin to your `vite.config.js`: 85 | 86 | ```js 87 | import { defineConfig } from "vite" 88 | import { watch } from "vite-plugin-watch" 89 | 90 | export default defineConfig({ 91 | plugins: [ 92 | watch({ 93 | pattern: "app/Enums/**/*.php", 94 | command: "php artisan publish:enums-to-javascript", 95 | }), 96 | ], 97 | }) 98 | ``` 99 | 100 | ### Changelog 101 | 102 | Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. 103 | 104 | ## Contributing 105 | 106 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details. 107 | 108 | ### Security 109 | 110 | If you discover any security related issues, please email dan@danmatthews.me instead of using the issue tracker. 111 | 112 | ## Credits 113 | 114 | - [Dan Matthews](https://github.com/intrfce) 115 | - [All Contributors](../../contributors) 116 | 117 | ## License 118 | 119 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "intrfce/laravel-frontend-enums", 3 | "description": "Stop using 'magic' strings/numbers in your frontend Javascript and use your actual application enums instead.", 4 | "keywords": [ 5 | "intrfce", 6 | "laravel-frontend-enums" 7 | ], 8 | "homepage": "https://github.com/intrfce/laravel-frontend-enums", 9 | "license": "MIT", 10 | "type": "library", 11 | "authors": [ 12 | { 13 | "name": "Dan Matthews", 14 | "email": "dan@danmatthews.me", 15 | "role": "Developer" 16 | } 17 | ], 18 | "require": { 19 | "php": "^8.2.0", 20 | "laravel/framework": "^11.0 || ^12.0", 21 | "laravel/prompts": "v0.*" 22 | }, 23 | "require-dev": { 24 | "orchestra/testbench": "^8.21 || ^9.0 || ^10.0", 25 | "pestphp/pest": "^2.32 || ^3.7", 26 | "tightenco/duster": "^2.5" 27 | }, 28 | "autoload": { 29 | "psr-4": { 30 | "Intrfce\\LaravelFrontendEnums\\": "src" 31 | } 32 | }, 33 | "autoload-dev": { 34 | "psr-4": { 35 | "Intrfce\\LaravelFrontendEnums\\Tests\\": "tests" 36 | } 37 | }, 38 | "scripts": { 39 | "test": "vendor/bin/pest", 40 | "test-coverage": "vendor/bin/pest --coverage-html coverage" 41 | }, 42 | "config": { 43 | "sort-packages": true, 44 | "allow-plugins": { 45 | "pestphp/pest-plugin": true 46 | } 47 | }, 48 | "extra": { 49 | "laravel": { 50 | "providers": [ 51 | "Intrfce\\LaravelFrontendEnums\\LaravelFrontendEnumsServiceProvider" 52 | ], 53 | "aliases": { 54 | "PublishEnums": "Intrfce\\LaravelFrontendEnums\\Facades\\PublishEnums" 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel-frontend-enums", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "prepare": "husky install" 9 | }, 10 | "repositories": [ 11 | { 12 | "type": "path", 13 | "url": "/Users/danmatthews/Code/laravel-frontend-enums" 14 | } 15 | ], 16 | "keywords": [], 17 | "author": "", 18 | "license": "ISC", 19 | "devDependencies": { 20 | "husky": "^8.0.0", 21 | "lint-staged": "^15.0.2" 22 | }, 23 | "lint-staged": { 24 | "**/*.php*": [ 25 | "vendor/bin/duster fix" 26 | ] 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | ./tests/Feature 10 | 11 | 12 | 13 | 14 | ./app 15 | ./src 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /pnpm-lock.yaml: -------------------------------------------------------------------------------- 1 | lockfileVersion: '6.0' 2 | 3 | settings: 4 | autoInstallPeers: true 5 | excludeLinksFromLockfile: false 6 | 7 | devDependencies: 8 | husky: 9 | specifier: ^8.0.0 10 | version: 8.0.3 11 | lint-staged: 12 | specifier: ^15.0.2 13 | version: 15.0.2 14 | 15 | packages: 16 | 17 | /ansi-escapes@5.0.0: 18 | resolution: {integrity: sha512-5GFMVX8HqE/TB+FuBJGuO5XG0WrsA6ptUqoODaT/n9mmUaZFkqnBueB4leqGBCmrUHnCnC4PCZTCd0E7QQ83bA==} 19 | engines: {node: '>=12'} 20 | dependencies: 21 | type-fest: 1.4.0 22 | dev: true 23 | 24 | /ansi-regex@6.0.1: 25 | resolution: {integrity: sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==} 26 | engines: {node: '>=12'} 27 | dev: true 28 | 29 | /ansi-styles@6.2.1: 30 | resolution: {integrity: sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==} 31 | engines: {node: '>=12'} 32 | dev: true 33 | 34 | /braces@3.0.2: 35 | resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} 36 | engines: {node: '>=8'} 37 | dependencies: 38 | fill-range: 7.0.1 39 | dev: true 40 | 41 | /chalk@5.3.0: 42 | resolution: {integrity: sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==} 43 | engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} 44 | dev: true 45 | 46 | /cli-cursor@4.0.0: 47 | resolution: {integrity: sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg==} 48 | engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} 49 | dependencies: 50 | restore-cursor: 4.0.0 51 | dev: true 52 | 53 | /cli-truncate@3.1.0: 54 | resolution: {integrity: sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA==} 55 | engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} 56 | dependencies: 57 | slice-ansi: 5.0.0 58 | string-width: 5.1.2 59 | dev: true 60 | 61 | /colorette@2.0.20: 62 | resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==} 63 | dev: true 64 | 65 | /commander@11.1.0: 66 | resolution: {integrity: sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==} 67 | engines: {node: '>=16'} 68 | dev: true 69 | 70 | /cross-spawn@7.0.3: 71 | resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} 72 | engines: {node: '>= 8'} 73 | dependencies: 74 | path-key: 3.1.1 75 | shebang-command: 2.0.0 76 | which: 2.0.2 77 | dev: true 78 | 79 | /debug@4.3.4: 80 | resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} 81 | engines: {node: '>=6.0'} 82 | peerDependencies: 83 | supports-color: '*' 84 | peerDependenciesMeta: 85 | supports-color: 86 | optional: true 87 | dependencies: 88 | ms: 2.1.2 89 | dev: true 90 | 91 | /eastasianwidth@0.2.0: 92 | resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} 93 | dev: true 94 | 95 | /emoji-regex@9.2.2: 96 | resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} 97 | dev: true 98 | 99 | /eventemitter3@5.0.1: 100 | resolution: {integrity: sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==} 101 | dev: true 102 | 103 | /execa@8.0.1: 104 | resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==} 105 | engines: {node: '>=16.17'} 106 | dependencies: 107 | cross-spawn: 7.0.3 108 | get-stream: 8.0.1 109 | human-signals: 5.0.0 110 | is-stream: 3.0.0 111 | merge-stream: 2.0.0 112 | npm-run-path: 5.1.0 113 | onetime: 6.0.0 114 | signal-exit: 4.1.0 115 | strip-final-newline: 3.0.0 116 | dev: true 117 | 118 | /fill-range@7.0.1: 119 | resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==} 120 | engines: {node: '>=8'} 121 | dependencies: 122 | to-regex-range: 5.0.1 123 | dev: true 124 | 125 | /get-stream@8.0.1: 126 | resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==} 127 | engines: {node: '>=16'} 128 | dev: true 129 | 130 | /human-signals@5.0.0: 131 | resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} 132 | engines: {node: '>=16.17.0'} 133 | dev: true 134 | 135 | /husky@8.0.3: 136 | resolution: {integrity: sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==} 137 | engines: {node: '>=14'} 138 | hasBin: true 139 | dev: true 140 | 141 | /is-fullwidth-code-point@4.0.0: 142 | resolution: {integrity: sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==} 143 | engines: {node: '>=12'} 144 | dev: true 145 | 146 | /is-number@7.0.0: 147 | resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} 148 | engines: {node: '>=0.12.0'} 149 | dev: true 150 | 151 | /is-stream@3.0.0: 152 | resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} 153 | engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} 154 | dev: true 155 | 156 | /isexe@2.0.0: 157 | resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} 158 | dev: true 159 | 160 | /lilconfig@2.1.0: 161 | resolution: {integrity: sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==} 162 | engines: {node: '>=10'} 163 | dev: true 164 | 165 | /lint-staged@15.0.2: 166 | resolution: {integrity: sha512-vnEy7pFTHyVuDmCAIFKR5QDO8XLVlPFQQyujQ/STOxe40ICWqJ6knS2wSJ/ffX/Lw0rz83luRDh+ET7toN+rOw==} 167 | engines: {node: '>=18.12.0'} 168 | hasBin: true 169 | dependencies: 170 | chalk: 5.3.0 171 | commander: 11.1.0 172 | debug: 4.3.4 173 | execa: 8.0.1 174 | lilconfig: 2.1.0 175 | listr2: 7.0.2 176 | micromatch: 4.0.5 177 | pidtree: 0.6.0 178 | string-argv: 0.3.2 179 | yaml: 2.3.3 180 | transitivePeerDependencies: 181 | - supports-color 182 | dev: true 183 | 184 | /listr2@7.0.2: 185 | resolution: {integrity: sha512-rJysbR9GKIalhTbVL2tYbF2hVyDnrf7pFUZBwjPaMIdadYHmeT+EVi/Bu3qd7ETQPahTotg2WRCatXwRBW554g==} 186 | engines: {node: '>=16.0.0'} 187 | dependencies: 188 | cli-truncate: 3.1.0 189 | colorette: 2.0.20 190 | eventemitter3: 5.0.1 191 | log-update: 5.0.1 192 | rfdc: 1.3.0 193 | wrap-ansi: 8.1.0 194 | dev: true 195 | 196 | /log-update@5.0.1: 197 | resolution: {integrity: sha512-5UtUDQ/6edw4ofyljDNcOVJQ4c7OjDro4h3y8e1GQL5iYElYclVHJ3zeWchylvMaKnDbDilC8irOVyexnA/Slw==} 198 | engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} 199 | dependencies: 200 | ansi-escapes: 5.0.0 201 | cli-cursor: 4.0.0 202 | slice-ansi: 5.0.0 203 | strip-ansi: 7.1.0 204 | wrap-ansi: 8.1.0 205 | dev: true 206 | 207 | /merge-stream@2.0.0: 208 | resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} 209 | dev: true 210 | 211 | /micromatch@4.0.5: 212 | resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==} 213 | engines: {node: '>=8.6'} 214 | dependencies: 215 | braces: 3.0.2 216 | picomatch: 2.3.1 217 | dev: true 218 | 219 | /mimic-fn@2.1.0: 220 | resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} 221 | engines: {node: '>=6'} 222 | dev: true 223 | 224 | /mimic-fn@4.0.0: 225 | resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} 226 | engines: {node: '>=12'} 227 | dev: true 228 | 229 | /ms@2.1.2: 230 | resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} 231 | dev: true 232 | 233 | /npm-run-path@5.1.0: 234 | resolution: {integrity: sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==} 235 | engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} 236 | dependencies: 237 | path-key: 4.0.0 238 | dev: true 239 | 240 | /onetime@5.1.2: 241 | resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==} 242 | engines: {node: '>=6'} 243 | dependencies: 244 | mimic-fn: 2.1.0 245 | dev: true 246 | 247 | /onetime@6.0.0: 248 | resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==} 249 | engines: {node: '>=12'} 250 | dependencies: 251 | mimic-fn: 4.0.0 252 | dev: true 253 | 254 | /path-key@3.1.1: 255 | resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} 256 | engines: {node: '>=8'} 257 | dev: true 258 | 259 | /path-key@4.0.0: 260 | resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} 261 | engines: {node: '>=12'} 262 | dev: true 263 | 264 | /picomatch@2.3.1: 265 | resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} 266 | engines: {node: '>=8.6'} 267 | dev: true 268 | 269 | /pidtree@0.6.0: 270 | resolution: {integrity: sha512-eG2dWTVw5bzqGRztnHExczNxt5VGsE6OwTeCG3fdUf9KBsZzO3R5OIIIzWR+iZA0NtZ+RDVdaoE2dK1cn6jH4g==} 271 | engines: {node: '>=0.10'} 272 | hasBin: true 273 | dev: true 274 | 275 | /restore-cursor@4.0.0: 276 | resolution: {integrity: sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==} 277 | engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} 278 | dependencies: 279 | onetime: 5.1.2 280 | signal-exit: 3.0.7 281 | dev: true 282 | 283 | /rfdc@1.3.0: 284 | resolution: {integrity: sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==} 285 | dev: true 286 | 287 | /shebang-command@2.0.0: 288 | resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} 289 | engines: {node: '>=8'} 290 | dependencies: 291 | shebang-regex: 3.0.0 292 | dev: true 293 | 294 | /shebang-regex@3.0.0: 295 | resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} 296 | engines: {node: '>=8'} 297 | dev: true 298 | 299 | /signal-exit@3.0.7: 300 | resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} 301 | dev: true 302 | 303 | /signal-exit@4.1.0: 304 | resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} 305 | engines: {node: '>=14'} 306 | dev: true 307 | 308 | /slice-ansi@5.0.0: 309 | resolution: {integrity: sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==} 310 | engines: {node: '>=12'} 311 | dependencies: 312 | ansi-styles: 6.2.1 313 | is-fullwidth-code-point: 4.0.0 314 | dev: true 315 | 316 | /string-argv@0.3.2: 317 | resolution: {integrity: sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==} 318 | engines: {node: '>=0.6.19'} 319 | dev: true 320 | 321 | /string-width@5.1.2: 322 | resolution: {integrity: sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==} 323 | engines: {node: '>=12'} 324 | dependencies: 325 | eastasianwidth: 0.2.0 326 | emoji-regex: 9.2.2 327 | strip-ansi: 7.1.0 328 | dev: true 329 | 330 | /strip-ansi@7.1.0: 331 | resolution: {integrity: sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==} 332 | engines: {node: '>=12'} 333 | dependencies: 334 | ansi-regex: 6.0.1 335 | dev: true 336 | 337 | /strip-final-newline@3.0.0: 338 | resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} 339 | engines: {node: '>=12'} 340 | dev: true 341 | 342 | /to-regex-range@5.0.1: 343 | resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} 344 | engines: {node: '>=8.0'} 345 | dependencies: 346 | is-number: 7.0.0 347 | dev: true 348 | 349 | /type-fest@1.4.0: 350 | resolution: {integrity: sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA==} 351 | engines: {node: '>=10'} 352 | dev: true 353 | 354 | /which@2.0.2: 355 | resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} 356 | engines: {node: '>= 8'} 357 | hasBin: true 358 | dependencies: 359 | isexe: 2.0.0 360 | dev: true 361 | 362 | /wrap-ansi@8.1.0: 363 | resolution: {integrity: sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==} 364 | engines: {node: '>=12'} 365 | dependencies: 366 | ansi-styles: 6.2.1 367 | string-width: 5.1.2 368 | strip-ansi: 7.1.0 369 | dev: true 370 | 371 | /yaml@2.3.3: 372 | resolution: {integrity: sha512-zw0VAJxgeZ6+++/su5AFoqBbZbrEakwu+X0M5HmcwUiBL7AzcuPKjj5we4xfQLp78LkEMpD0cOnUhmgOVy3KdQ==} 373 | engines: {node: '>= 14'} 374 | dev: true 375 | -------------------------------------------------------------------------------- /socialsync/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | # Rill 4 | .env 5 | tmp 6 | -------------------------------------------------------------------------------- /socialsync/rill.yaml: -------------------------------------------------------------------------------- 1 | compiler: rillv1 2 | 3 | display_name: "Untitled Rill Project" 4 | 5 | # These are example mock users to test your security policies. 6 | # Learn more: https://docs.rilldata.com/manage/security 7 | mock_users: 8 | - email: john@yourcompany.com 9 | - email: jane@partnercompany.com -------------------------------------------------------------------------------- /src/Console/Commands/PublishEnumsCommand.php: -------------------------------------------------------------------------------- 1 | get() as $enumClass) { 22 | 23 | $enumClass = trim($enumClass); 24 | 25 | $caseList = []; 26 | 27 | if (class_exists($enumClass)) { 28 | 29 | foreach ($enumClass::cases() as $enum) { 30 | $caseList[] = match ($registry->asTypescript) { 31 | true => str_repeat(' ', 4) . "{$enum->name} = " . $this->printValueAsJs($enum), 32 | false => str_repeat(' ', 4) . "{$enum->name}: " . $this->printValueAsJs($enum), 33 | }; 34 | } 35 | 36 | $name = (new ReflectionClass($enumClass))->getShortName(); 37 | 38 | $jsFileContent = match ($registry->asTypescript) { 39 | true => collect([ 40 | "export enum {$name} {", 41 | collect($caseList)->implode(',' . PHP_EOL, ''), 42 | '}', 43 | ])->implode(PHP_EOL), 44 | false => collect([ 45 | "export const {$name} = {", 46 | collect($caseList)->implode(',' . PHP_EOL, ''), 47 | '};', 48 | ])->implode(PHP_EOL) 49 | }; 50 | 51 | $extension = $registry->asTypescript ? '.ts' : '.enum.js'; 52 | 53 | $jsFilePath = app('publish_enums_registry')->publishPath . "/{$name}{$extension}"; 54 | 55 | file_put_contents($jsFilePath, $jsFileContent); 56 | 57 | if (! $this->option('compact')) { 58 | info("Published: {$jsFilePath}"); 59 | } 60 | 61 | $published++; 62 | 63 | } else { 64 | $this->error("Enum class {$enumClass} not found."); 65 | } 66 | } 67 | 68 | if ($this->option('compact')) { 69 | info("Published {$published} files."); 70 | } 71 | 72 | } 73 | 74 | private function printValueAsJs(mixed $enum): string 75 | { 76 | return match (gettype($enum->value)) { 77 | 'string' => '"' . $enum->value . '"', 78 | 'integer', 'double' => $enum->value, 79 | 'boolean' => $enum->value ? 'true' : 'false', 80 | }; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/Exceptions/ArgumentIsNotEnumException.php: -------------------------------------------------------------------------------- 1 | loadTranslationsFrom(__DIR__.'/../resources/lang', 'laravel-frontend-enums'); 19 | // $this->loadViewsFrom(__DIR__.'/../resources/views', 'laravel-frontend-enums'); 20 | // $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); 21 | // $this->loadRoutesFrom(__DIR__.'/routes.php'); 22 | 23 | if ($this->app->runningInConsole()) { 24 | $this->publishes([ 25 | __DIR__ . '/../config/config.php' => config_path('laravel-frontend-enums.php'), 26 | ], 'config'); 27 | 28 | // Publishing the views. 29 | /*$this->publishes([ 30 | __DIR__.'/../resources/views' => resource_path('views/vendor/laravel-frontend-enums'), 31 | ], 'views');*/ 32 | 33 | // Publishing assets. 34 | /*$this->publishes([ 35 | __DIR__.'/../resources/assets' => public_path('vendor/laravel-frontend-enums'), 36 | ], 'assets');*/ 37 | 38 | // Publishing the translation files. 39 | /*$this->publishes([ 40 | __DIR__.'/../resources/lang' => resource_path('lang/vendor/laravel-frontend-enums'), 41 | ], 'lang');*/ 42 | 43 | // Registering package commands. 44 | $this->commands([ 45 | PublishEnumsCommand::class, 46 | ]); 47 | } 48 | } 49 | 50 | /** 51 | * Register the application services. 52 | */ 53 | public function register() 54 | { 55 | // // Automatically apply the package configuration 56 | // $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'laravel-frontend-enums'); 57 | 58 | // Register the main class to use with the facade 59 | $this->app->singleton('publish_enums_registry', function () { 60 | return new Registry; 61 | }); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Registry.php: -------------------------------------------------------------------------------- 1 | publishPath = resource_path('js/Enums'); 19 | } 20 | 21 | public function setPublishPath(string $path): self 22 | { 23 | $this->publishPath = $path; 24 | 25 | return $this; 26 | } 27 | 28 | public function publish(array $items): self 29 | { 30 | 31 | $this->validateAllEnums($items); 32 | 33 | $this->toPublish = array_merge($this->toPublish, $items); 34 | 35 | return $this; 36 | } 37 | 38 | public function get(): array 39 | { 40 | return $this->toPublish; 41 | } 42 | 43 | public function asTypescript(): self 44 | { 45 | $this->asTypescript = true; 46 | 47 | return $this; 48 | } 49 | 50 | public function toDirectory(string $path): self 51 | { 52 | $this->publishPath = $path; 53 | 54 | return $this; 55 | } 56 | 57 | /** 58 | * @throws ReflectionException 59 | * @throws ArgumentIsNotEnumException 60 | */ 61 | protected function validateAllEnums(array $items): void 62 | { 63 | foreach ($items as $enumClass) { 64 | if (! is_string($enumClass) || ! enum_exists($enumClass)) { 65 | throw new ArgumentIsNotEnumException("Class {$enumClass} is not an enum."); 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/config/laravel-frontend-enums.php: -------------------------------------------------------------------------------- 1 | resource_path('js/Enums'), 5 | ]; 6 | -------------------------------------------------------------------------------- /tests/Enums/AgeLimits.php: -------------------------------------------------------------------------------- 1 | reject(function ($file) { 9 | return str_contains('.gitkeep', $file->getFilename()); 10 | })->each(fn ($file) => File::delete($file->getPathname())); 11 | }); 12 | 13 | test('The package registry picks up on the enums you list', function () { 14 | $enumsToPublish = app('publish_enums_registry')->get(); 15 | expect($enumsToPublish)->toHaveCount(2); 16 | // \Artisan::call('publish:enums-to-javascript'); 17 | }); 18 | 19 | test('Listing anything other than an enum produces an exception', function ($test) { 20 | 21 | PublishEnums::publish([ 22 | $test, 23 | ]); 24 | 25 | }) 26 | ->with([ 27 | 'not an enum', 28 | 3.141, 29 | 23141, 30 | ]) 31 | ->throws(ArgumentIsNotEnumException::class); 32 | 33 | test('It publishes the enums to the default directory at resources/js/Enums', function () { 34 | $path = getcwd() . '/tests/Publish'; 35 | PublishEnums::setPublishPath($path); 36 | $this->artisan('publish:enums-to-javascript'); 37 | 38 | collect(PublishEnums::get())->each(function ($enum) use ($path) { 39 | $name = (new ReflectionClass($enum))->getShortName(); 40 | $this->assertFileExists("{$path}/{$name}.enum.js"); 41 | $contents = file_get_contents("{$path}/{$name}.enum.js"); 42 | collect($enum::cases())->each(fn ($case) => expect($contents)->toContain($case->name) 43 | ->and($contents)->toContain((string) $case->value) 44 | ->and($contents)->toContain("export const {$name} = {")); 45 | }); 46 | }); 47 | 48 | test('It publishes the enums to the default directory at resources/js/Enums as typescript files.', function () { 49 | $path = getcwd() . '/tests/Publish'; 50 | PublishEnums::setPublishPath($path)->asTypescript(); 51 | $this->artisan('publish:enums-to-javascript'); 52 | 53 | collect(PublishEnums::get())->each(function ($enum) use ($path) { 54 | $name = (new ReflectionClass($enum))->getShortName(); 55 | $this->assertFileExists("{$path}/{$name}.ts"); 56 | $contents = file_get_contents("{$path}/{$name}.ts"); 57 | collect($enum::cases())->each(fn ($case) => expect($contents)->toContain($case->name) 58 | ->and($contents)->toContain((string) $case->value) 59 | ->and($contents)->toContain("export enum {$name} {")); 60 | }); 61 | }); 62 | -------------------------------------------------------------------------------- /tests/Pest.php: -------------------------------------------------------------------------------- 1 | in('Feature'); 15 | 16 | /* 17 | |-------------------------------------------------------------------------- 18 | | Expectations 19 | |-------------------------------------------------------------------------- 20 | | 21 | | When you're writing tests, you often need to check that values meet certain conditions. The 22 | | "expect()" function gives you access to a set of "expectations" methods that you can use 23 | | to assert different things. Of course, you may extend the Expectation API at any time. 24 | | 25 | */ 26 | 27 | expect()->extend('toBeOne', function () { 28 | return $this->toBe(1); 29 | }); 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Functions 34 | |-------------------------------------------------------------------------- 35 | | 36 | | While Pest is very powerful out-of-the-box, you may have some testing code specific to your 37 | | project that you don't want to repeat in every file. Here you can also expose helpers as 38 | | global functions to help you to reduce the number of lines of code in your test files. 39 | | 40 | */ 41 | -------------------------------------------------------------------------------- /tests/Providers/TestApplicationServiceProvider.php: -------------------------------------------------------------------------------- 1 | toDirectory(resource_path('js/Enums')); 19 | } 20 | 21 | public function boot(): void {} 22 | } 23 | -------------------------------------------------------------------------------- /tests/Publish/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intrfce/laravel-frontend-enums/f7a1e18c5a76579c985e1bb1e1199a70e0c98644/tests/Publish/.gitkeep -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | > 16 | */ 17 | protected function getPackageProviders($app): array 18 | { 19 | return [ 20 | LaravelFrontendEnumsServiceProvider::class, 21 | TestApplicationServiceProvider::class, 22 | ]; 23 | } 24 | } 25 | --------------------------------------------------------------------------------