├── .editorconfig ├── .env.example ├── .eslintrc.js ├── .gitattributes ├── .github └── workflows │ ├── laravel-unit-testing.yml │ └── php-cs-fixer.yml ├── .gitignore ├── LICENSE ├── README.md ├── app ├── Console │ ├── Commands │ │ ├── MakeBackEndModule.php │ │ ├── MakeFrontEndModule.php │ │ └── MakeModuleCommand.php │ └── Kernel.php ├── Contracts │ └── RepositoryInterface.php ├── Exceptions │ └── VerifyEmailException.php ├── Http │ └── Middleware │ │ └── EnsureEmailIsVerified.php ├── Models │ ├── PersonalAccessToken.php │ └── User.php ├── Modules │ ├── Auth │ │ ├── Controllers │ │ │ ├── AuthenticatedSessionController.php │ │ │ ├── AuthenticatedTokenController.php │ │ │ ├── CurrentUserController.php │ │ │ ├── NewPasswordController.php │ │ │ ├── PasswordResetLinkController.php │ │ │ ├── RegisteredUserController.php │ │ │ └── VerifyEmailController.php │ │ ├── Requests │ │ │ ├── LoginRequest.php │ │ │ └── LoginSessionRequest.php │ │ └── routes_api.php │ ├── Core │ │ └── Controllers │ │ │ └── Controller.php │ └── Setting │ │ ├── Controllers │ │ └── ProfileController.php │ │ ├── Requests │ │ ├── ChangePasswordRequest.php │ │ └── ProfileRequest.php │ │ └── routes_api.php ├── Notifications │ ├── ResetPassword.php │ └── VerifyEmail.php ├── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── BroadcastServiceProvider.php │ └── EventServiceProvider.php └── Repositories │ ├── AbstractRepository.php │ └── UserRepository.php ├── artisan ├── bootstrap ├── app.php ├── cache │ └── .gitignore └── providers.php ├── composer.json ├── composer.lock ├── config ├── app.php ├── auth.php ├── broadcasting.php ├── cache.php ├── cors.php ├── database.php ├── filesystems.php ├── hashing.php ├── logging.php ├── mail.php ├── queue.php ├── sanctum.php ├── services.php ├── session.php └── view.php ├── database ├── .gitignore ├── factories │ └── UserFactory.php ├── migrations │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2014_10_12_100000_create_password_resets_table.php │ ├── 2019_08_19_000000_create_failed_jobs_table.php │ └── 2019_12_14_000001_create_personal_access_tokens_table.php └── seeders │ ├── DatabaseSeeder.php │ └── UsersTableSeeder.php ├── package.json ├── phpstorm.config.js ├── phpunit.xml ├── pint.json ├── public ├── .htaccess ├── favicon.ico ├── index.php ├── preview.png └── robots.txt ├── resources ├── js │ ├── app.js │ ├── base │ │ ├── App.vue │ │ ├── baseStore.js │ │ ├── components │ │ │ ├── Base.vue │ │ │ ├── Breadcrumbs.vue │ │ │ ├── Child.vue │ │ │ ├── Index.vue │ │ │ ├── Navbar.vue │ │ │ ├── NotFound.vue │ │ │ ├── Sidebar.vue │ │ │ └── filters │ │ │ │ └── BaseFilter.vue │ │ ├── constants │ │ │ └── time.constants.js │ │ ├── layouts │ │ │ ├── Default.vue │ │ │ ├── Empty.vue │ │ │ └── Welcome.vue │ │ └── routes.js │ ├── includes │ │ ├── Event.js │ │ ├── composable │ │ │ ├── errors.js │ │ │ └── modelWrapper.js │ │ ├── filters.js │ │ └── lang │ │ │ ├── en.js │ │ │ ├── index.js │ │ │ └── ru.js │ ├── modules │ │ ├── auth │ │ │ ├── authApi.js │ │ │ ├── components │ │ │ │ ├── Login.vue │ │ │ │ ├── LoginForm.vue │ │ │ │ ├── Register.vue │ │ │ │ ├── RegisterForm.vue │ │ │ │ ├── ResendVerification.vue │ │ │ │ └── VerifyEmail.vue │ │ │ └── routes.js │ │ ├── dashboard │ │ │ ├── components │ │ │ │ └── Dashboard.vue │ │ │ └── routes.js │ │ └── profile │ │ │ ├── components │ │ │ ├── ChangePassword.vue │ │ │ ├── ChangePasswordForm.vue │ │ │ ├── Profile.vue │ │ │ └── ProfileForm.vue │ │ │ ├── profileApi.js │ │ │ └── routes.js │ └── plugins │ │ ├── auth.js │ │ ├── axios-interceptor.js │ │ ├── day.js │ │ ├── i18n.js │ │ └── router.js ├── lang │ └── en │ │ ├── auth.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ ├── validation.php │ │ └── verification.php ├── sass │ ├── _spacing-helpers.scss │ ├── _transitions.scss │ ├── _variables.scss │ ├── app.scss │ └── style.scss └── views │ ├── spa.blade.php │ └── variables.blade.php ├── routes ├── api.php ├── channels.php ├── console.php ├── modules.php └── web.php ├── storage ├── app │ ├── .gitignore │ └── public │ │ └── .gitignore ├── framework │ ├── .gitignore │ ├── cache │ │ ├── .gitignore │ │ └── data │ │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ ├── testing │ │ └── .gitignore │ └── views │ │ └── .gitignore └── logs │ └── .gitignore ├── stubs ├── backEnd │ ├── controller.api.stub │ ├── request.stub │ ├── resource.stub │ └── routes.api.stub ├── factory.stub ├── frontEnd │ ├── api.stub │ ├── routes.stub │ ├── store.stub │ ├── vue.form.stub │ ├── vue.list.stub │ └── vue.view.stub ├── migration.create.stub ├── model.stub └── test.stub ├── tests ├── CreatesApplication.php ├── Feature │ ├── ArchTest.php │ ├── Auth │ │ ├── AuthenticationTest.php │ │ ├── EmailVerificationTest.php │ │ ├── PasswordResetTest.php │ │ └── RegistrationTest.php │ └── SettingsTest.php ├── Pest.php ├── TestCase.php └── Unit │ └── ExampleTest.php ├── vite.config.js └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 4 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 16 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME="Laravel Vue SPA Skeleton" 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://127.0.0.1:8000 6 | 7 | MIX_API_ENDPOINT=http://127.0.0.1:8000/api/v1/ 8 | 9 | LOG_CHANNEL=stack 10 | 11 | DB_CONNECTION=mysql 12 | DB_HOST=127.0.0.1 13 | DB_PORT=3306 14 | DB_DATABASE=skeleton 15 | DB_USERNAME=root 16 | DB_PASSWORD=root 17 | 18 | BROADCAST_DRIVER=log 19 | CACHE_DRIVER=file 20 | QUEUE_CONNECTION=sync 21 | SESSION_DRIVER=file 22 | SESSION_LIFETIME=120 23 | 24 | SESSION_DOMAIN=localhost 25 | SANCTUM_STATEFUL_DOMAINS=localhost 26 | 27 | REDIS_HOST=127.0.0.1 28 | REDIS_PASSWORD=null 29 | REDIS_PORT=6379 30 | 31 | MAIL_DRIVER=smtp 32 | MAIL_HOST=smtp.mailtrap.io 33 | MAIL_PORT=2525 34 | MAIL_USERNAME=null 35 | MAIL_PASSWORD=null 36 | MAIL_ENCRYPTION=null 37 | MAIL_FROM_ADDRESS=null 38 | MAIL_FROM_NAME="${APP_NAME}" 39 | 40 | AWS_ACCESS_KEY_ID= 41 | AWS_SECRET_ACCESS_KEY= 42 | AWS_DEFAULT_REGION=us-east-1 43 | AWS_BUCKET= 44 | 45 | PUSHER_APP_ID= 46 | PUSHER_APP_KEY= 47 | PUSHER_APP_SECRET= 48 | PUSHER_APP_CLUSTER=mt1 49 | 50 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 51 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 52 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | parserOptions: { 3 | requireConfigFile: false, 4 | parser: '@babel/eslint-parser', 5 | sourceType: 'module', 6 | allowImportExportEverywhere: true, 7 | ecmaVersion: 2020 8 | }, 9 | extends: [ 10 | 'plugin:vue/vue3-recommended', 11 | ], 12 | rules: { 13 | 'indent': [ 14 | 'warn', 15 | 4 16 | ], 17 | 'vue/html-indent': [ 18 | 'warn', 19 | 4 20 | ], 21 | 'jsx-quotes': [ 22 | 'error', 23 | 'prefer-double' 24 | ], 25 | 'linebreak-style': [ 26 | 'error', 27 | 'unix' 28 | ], 29 | 'quotes': [ 30 | 'warn', 31 | 'single' 32 | ], 33 | 'semi': [ 34 | 'warn', 35 | 'never' 36 | ], 37 | 'vue/sort-keys': 'off', 38 | 'vue/static-class-names-order': 'off', 39 | 'vue/no-v-html': 'off', 40 | 'vue/require-valid-default-prop': 'off', 41 | 'vue/require-explicit-emits': 'off', 42 | 'vue/no-multiple-template-root': 'off' 43 | }, 44 | } 45 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | *.js linguist-vendored 5 | CHANGELOG.md export-ignore 6 | -------------------------------------------------------------------------------- /.github/workflows/laravel-unit-testing.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | changes: 10 | runs-on: ubuntu-latest 11 | name: Check changes 12 | outputs: 13 | src: ${{ steps.filter.outputs.src }} 14 | 15 | steps: 16 | - name: Git checkout 17 | uses: actions/checkout@v3 18 | 19 | - name: Add filter 20 | uses: dorny/paths-filter@v2 21 | id: filter 22 | with: 23 | filters: | 24 | src: 25 | - 'app/**' 26 | - 'routes/**' 27 | - 'tests/**' 28 | - '.github/**' 29 | 30 | testing: 31 | runs-on: ubuntu-latest 32 | needs: changes 33 | if: ${{ needs.changes.outputs.src == 'true' }} 34 | 35 | steps: 36 | - name: Checkout code 37 | uses: actions/checkout@v3 38 | 39 | - name: Setup PHP 40 | uses: shivammathur/setup-php@v2 41 | with: 42 | php-version: '8.2' 43 | extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite 44 | coverage: none 45 | 46 | - name: Install Composer dependencies 47 | run: composer install --prefer-dist --no-interaction --no-progress 48 | 49 | - name: Copy environment file 50 | run: cp .env.example .env 51 | 52 | - name: Generate app key 53 | run: php artisan key:generate 54 | 55 | - name: Create Database 56 | run: | 57 | mkdir -p database 58 | touch database/database.sqlite 59 | 60 | - name: Execute tests 61 | env: 62 | DB_CONNECTION: sqlite 63 | DB_DATABASE: database/database.sqlite 64 | run: composer test 65 | -------------------------------------------------------------------------------- /.github/workflows/php-cs-fixer.yml: -------------------------------------------------------------------------------- 1 | name: Check styles 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | laravel-tests: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - name: Checkout code 14 | uses: actions/checkout@v3 15 | 16 | - name: Setup PHP 17 | uses: shivammathur/setup-php@v2 18 | with: 19 | php-version: '8.2' 20 | extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite 21 | coverage: none 22 | 23 | - name: Install Composer dependencies 24 | run: composer install --prefer-dist --no-interaction --no-progress 25 | 26 | - name: Copy environment file 27 | run: cp .env.example .env 28 | 29 | - name: Generate app key 30 | run: php artisan key:generate 31 | 32 | - name: Check styles 33 | run: vendor/bin/pint --test 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/hot 3 | /public/storage 4 | /public/js/ 5 | /public/css/ 6 | /public/fonts/ 7 | /public/build/ 8 | /public/mix-manifest.json 9 | /storage/*.key 10 | /vendor 11 | .env 12 | .env.backup 13 | .phpunit.result.cache 14 | Homestead.json 15 | Homestead.yaml 16 | npm-debug.log 17 | yarn-error.log 18 | .idea 19 | .php-cs-fixer.cache 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Yurich 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | Vue logo 4 | 5 |

6 | 7 |
8 | 9 | [![MIT Licensed](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE) 10 | [GitHub Workflow Status (main)](https://github.com/Yurich84/laravel-vue3-spa/actions) 11 | [GitHub Workflow Status (main)](https://github.com/Yurich84/laravel-vue3-spa/actions) 12 | 13 |
14 | 15 | #### This is a groundwork for a large modular SPA, that utilises Laravel, Vue, ElementPlus. 16 | #### CRUD generator is integrated in project creates standalone modules on the frontend and backend. 17 | 18 |

19 | 20 |

21 | 22 | The main goals of the project are: 23 | - to avoid high cohesion between modules 24 | - to form the basis for writing clean code 25 | - to be easy to expand 26 | - to avoid code duplication 27 | - to reduce the start time of the project 28 | - to reduce the time of project support and code navigation 29 | - to be understandable for an inexperienced programmer 30 | 31 | ## Extensions 32 | 33 | - Back-End: [Laravel 11](https://laravel.com/) 34 | - Front-End: [Vue3 Composition Api](https://vuejs.org) + [VueRouter](https://router.vuejs.org) + [Pinia](https://pinia.vuejs.org) + [VueI18n](https://kazupon.github.io/vue-i18n/) 35 | - Login using [Vue-Auth](https://websanova.com/docs/vue-auth/home), [Axios](https://github.com/mzabriskie/axios) and [Sanctum](https://laravel.com/docs/8.x/sanctum). 36 | - The api routes, are separate for each module, in **Modules/{ModuleName}/routes_api.php** 37 | - [ElementPlus](https://element-plus.org/) UI Kit 38 | - [Lodash](https://lodash.com) js utilities 39 | - [Day.js](https://dayjs.com) time manipulations 40 | - [FontAwesome 6](http://fontawesome.io/icons/) icons 41 | 42 | ## Install 43 | - `git clone https://github.com/Yurich84/laravel-vue3-spa.git` 44 | - `cd /laravel-vue3-spa` 45 | - `composer install` 46 | - `cp .env.example .env` - copy .env file 47 | - set your DB credentials in `.env` 48 | - `php artisan key:generate` 49 | - `php artisan migrate` 50 | - `yarn install` 51 | 52 | ## Testing 53 | 54 | ### Unit Testing 55 | `php artisan test` 56 | 57 | ## Usage 58 | - `npm run dev` for hot reloading 59 | - `php artisan serve` and go [localhost:8000](http://localhost:8000) 60 | - Create new user and login. 61 | 62 | ### Creating module 63 | You can easily create module with CRUD functionality. 64 | 65 | `php artisan make:module {ModuleName}` 66 | 67 | This will create: 68 | 69 | - **migration** `database/migrations/000_00_00_000000_create_{ModuleName}_table.php` 70 | 71 | - **model** `app/Models/{ModuleName}.php` 72 | 73 | - **factory** `database/factories/{ModuleName}Factory.php` 74 | 75 | - **tests** `tests/Feature/{ModuleName}Test.php` 76 | 77 | - **backend module** `app/Modules/{ModuleName}/` 78 | ``` 79 | {ModuleName}/ 80 | │ 81 | ├── routes_api.php 82 | │ 83 | ├── Controllers/ 84 | │ └── {ModuleName}Controller.php 85 | │ 86 | ├── Requests/ 87 | │ └── {ModuleName}Request.php 88 | │ 89 | └── Resources/ 90 | └── {ModuleName}Resource.php 91 | ``` 92 | 93 | - **frontend module** `resources/js/modules/{moduleName}/` 94 | ``` 95 | {moduleName}/ 96 | │ 97 | ├── routes.js 98 | │ 99 | ├── {moduleName}Api.js 100 | │ 101 | ├── {moduleName}Store.js 102 | │ 103 | ├── components/ 104 | ├── {ModuleName}List.vue 105 | ├── {ModuleName}View.vue 106 | └── {ModuleName}Form.vue 107 | ``` 108 | 109 | 110 | > After creating module, you can edit model and migration by adding fields you need. 111 | > Also you can add this fields into view. 112 | > Don't forget run php artisan migrate. 113 | 114 | Every module loads dynamically. 115 | 116 | ## [Video](https://www.youtube.com/watch?v=0qKNlrmhgNg) 117 | -------------------------------------------------------------------------------- /app/Console/Commands/MakeBackEndModule.php: -------------------------------------------------------------------------------- 1 | output = new ConsoleOutput; 19 | $this->components = new Factory($this->output); 20 | } 21 | 22 | /** 23 | * @var string 24 | */ 25 | private $module_path; 26 | 27 | /** 28 | * @param $module 29 | * 30 | * @throws FileNotFoundException 31 | */ 32 | protected function create($module) 33 | { 34 | $this->files = new Filesystem; 35 | $this->module = $module; 36 | $this->module_path = app_path('Modules/'.$this->module); 37 | 38 | $this->createController(); 39 | $this->createRoutes(); 40 | $this->createRequest(); 41 | $this->createResource(); 42 | } 43 | 44 | /** 45 | * Create a controller for the module. 46 | * 47 | * @return void 48 | * 49 | * @throws FileNotFoundException 50 | */ 51 | private function createController() 52 | { 53 | $path = $this->module_path."/Controllers/{$this->module}Controller.php"; 54 | 55 | if ($this->alreadyExists($path)) { 56 | $this->components->error('Controller already exists!'); 57 | } else { 58 | $stub = $this->files->get(base_path('stubs/backEnd/controller.api.stub')); 59 | 60 | $this->createFileWithStub($stub, $path); 61 | 62 | $this->components->info('Controller created successfully.'); 63 | } 64 | } 65 | 66 | /** 67 | * Create a Routes for the module. 68 | * 69 | * @throws FileNotFoundException 70 | */ 71 | private function createRoutes() 72 | { 73 | $path = $this->module_path.'/routes_api.php'; 74 | 75 | if ($this->alreadyExists($path)) { 76 | $this->components->error('Routes already exists!'); 77 | } else { 78 | $stub = $this->files->get(base_path('stubs/backEnd/routes.api.stub')); 79 | 80 | $this->createFileWithStub($stub, $path); 81 | 82 | $this->components->info('Routes created successfully.'); 83 | } 84 | } 85 | 86 | /** 87 | * Create a Request for the module. 88 | * 89 | * @throws FileNotFoundException 90 | */ 91 | private function createRequest() 92 | { 93 | $path = $this->module_path."/Requests/{$this->module}Request.php"; 94 | 95 | if ($this->alreadyExists($path)) { 96 | $this->components->error('Request already exists!'); 97 | } else { 98 | $stub = $this->files->get(base_path('stubs/backEnd/request.stub')); 99 | 100 | $this->createFileWithStub($stub, $path); 101 | 102 | $this->components->info('Request created successfully.'); 103 | } 104 | } 105 | 106 | /** 107 | * Create a Resource for the module. 108 | * 109 | * @throws FileNotFoundException 110 | */ 111 | private function createResource() 112 | { 113 | $path = $this->module_path."/Resources/{$this->module}Resource.php"; 114 | 115 | if ($this->alreadyExists($path)) { 116 | $this->components->error('Resource already exists!'); 117 | } else { 118 | $stub = $this->files->get(base_path('stubs/backEnd/resource.stub')); 119 | 120 | $this->createFileWithStub($stub, $path); 121 | 122 | $this->components->info('Resource created successfully.'); 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /app/Console/Commands/MakeFrontEndModule.php: -------------------------------------------------------------------------------- 1 | output = new ConsoleOutput; 19 | $this->components = new Factory($this->output); 20 | } 21 | 22 | /** 23 | * @var string 24 | */ 25 | private $module_path; 26 | 27 | /** 28 | * @param $module 29 | * 30 | * @throws FileNotFoundException 31 | */ 32 | protected function create($module) 33 | { 34 | $this->files = new Filesystem; 35 | $this->module = $module; 36 | $this->module_path = base_path('resources/js/modules/'.lcfirst($this->module)); 37 | 38 | $this->createVueList(); 39 | $this->createVueView(); 40 | $this->createVueForm(); 41 | 42 | $this->createStore(); 43 | 44 | $this->createRoutes(); 45 | $this->createApi(); 46 | } 47 | 48 | /** 49 | * Create a Vue component file for the module. 50 | * 51 | * @return void 52 | * 53 | * @throws FileNotFoundException 54 | */ 55 | private function createVueList() 56 | { 57 | $path = $this->module_path."/components/{$this->module}List.vue"; 58 | 59 | if ($this->alreadyExists($path)) { 60 | $this->components->error('VueList Component already exists!'); 61 | } else { 62 | $stub = $this->files->get(base_path('stubs/frontEnd/vue.list.stub')); 63 | 64 | $this->createFileWithStub($stub, $path); 65 | 66 | $this->components->info('VueList Component created successfully.'); 67 | } 68 | } 69 | 70 | /** 71 | * Create a Vue component file for the module. 72 | * 73 | * @return void 74 | * 75 | * @throws FileNotFoundException 76 | */ 77 | private function createVueView() 78 | { 79 | $path = $this->module_path."/components/{$this->module}View.vue"; 80 | 81 | if ($this->alreadyExists($path)) { 82 | $this->components->error('VueView Component already exists!'); 83 | } else { 84 | $stub = $this->files->get(base_path('stubs/frontEnd/vue.view.stub')); 85 | 86 | $this->createFileWithStub($stub, $path); 87 | 88 | $this->components->info('VueView Component created successfully.'); 89 | } 90 | } 91 | 92 | /** 93 | * Create a Vue component file for the module. 94 | * 95 | * @return void 96 | * 97 | * @throws FileNotFoundException 98 | */ 99 | private function createVueForm() 100 | { 101 | $path = $this->module_path."/components/{$this->module}Form.vue"; 102 | 103 | if ($this->alreadyExists($path)) { 104 | $this->components->error('VueForm Component already exists!'); 105 | } else { 106 | $stub = $this->files->get(base_path('stubs/frontEnd/vue.form.stub')); 107 | 108 | $this->createFileWithStub($stub, $path); 109 | 110 | $this->components->info('VueForm Component created successfully.'); 111 | } 112 | } 113 | 114 | /** 115 | * Create a Vue component file for the module. 116 | * 117 | * @return void 118 | * 119 | * @throws FileNotFoundException 120 | */ 121 | private function createStore() 122 | { 123 | $moduleLC = lcfirst($this->module); 124 | $path = $this->module_path."/{$moduleLC}Store.js"; 125 | 126 | if ($this->alreadyExists($path)) { 127 | $this->components->error('Store already exists!'); 128 | } else { 129 | $stub = $this->files->get(base_path('stubs/frontEnd/store.stub')); 130 | 131 | $this->createFileWithStub($stub, $path); 132 | 133 | $this->components->info('Store created successfully.'); 134 | } 135 | } 136 | 137 | /** 138 | * Create a Vue component file for the module. 139 | * 140 | * @return void 141 | * 142 | * @throws FileNotFoundException 143 | */ 144 | private function createRoutes() 145 | { 146 | $path = $this->module_path.'/routes.js'; 147 | 148 | if ($this->alreadyExists($path)) { 149 | $this->components->error('Vue Routes already exists!'); 150 | } else { 151 | $stub = $this->files->get(base_path('stubs/frontEnd/routes.stub')); 152 | 153 | $this->createFileWithStub($stub, $path); 154 | 155 | $this->components->info('Vue Routes created successfully.'); 156 | } 157 | } 158 | 159 | /** 160 | * Create a Vue component file for the module. 161 | * 162 | * @return void 163 | * 164 | * @throws FileNotFoundException 165 | */ 166 | private function createApi() 167 | { 168 | $moduleLC = lcfirst($this->module); 169 | $path = $this->module_path."/{$moduleLC}Api.js"; 170 | 171 | if ($this->alreadyExists($path)) { 172 | $this->components->error('Api file already exists!'); 173 | } else { 174 | $stub = $this->files->get(base_path('stubs/frontEnd/api.stub')); 175 | 176 | $this->createFileWithStub($stub, $path); 177 | 178 | $this->components->info('Api file created successfully.'); 179 | } 180 | } 181 | } 182 | -------------------------------------------------------------------------------- /app/Console/Commands/MakeModuleCommand.php: -------------------------------------------------------------------------------- 1 | files = $files; 60 | 61 | $this->module = Str::of(class_basename($this->argument('name')))->studly()->singular(); 62 | 63 | $this->createModel(); 64 | 65 | $this->createMigration(); 66 | 67 | $backEndModule->create($this->module); 68 | 69 | $frontEndModule->create($this->module); 70 | 71 | $this->createFactory(); 72 | 73 | $this->createTest(); 74 | } 75 | 76 | /** 77 | * Create a model file for the module. 78 | * 79 | * @return void 80 | */ 81 | protected function createModel() 82 | { 83 | $this->call('make:model', [ 84 | 'name' => $this->module, 85 | ]); 86 | } 87 | 88 | /** 89 | * Create a migration file for the module. 90 | * 91 | * @return void 92 | */ 93 | protected function createMigration() 94 | { 95 | $table = $this->module->plural()->snake(); 96 | 97 | try { 98 | $this->call('make:migration', [ 99 | 'name' => "create_{$table}_table", 100 | '--create' => $table, 101 | ]); 102 | } catch (Exception $e) { 103 | $this->error($e->getMessage()); 104 | } 105 | } 106 | 107 | /** 108 | * Create a factory file for the module. 109 | * 110 | * @return void 111 | */ 112 | protected function createFactory() 113 | { 114 | $this->call('make:factory', [ 115 | 'name' => $this->module.'Factory', 116 | '--model' => "$this->module", 117 | ]); 118 | } 119 | 120 | /** 121 | * Create a test file for the module. 122 | * 123 | * @return void 124 | * 125 | * @throws FileNotFoundException 126 | */ 127 | protected function createTest() 128 | { 129 | $path = base_path('tests/Feature/'.$this->module.'Test.php'); 130 | 131 | if ($this->alreadyExists($path)) { 132 | $this->error('Test file already exists!'); 133 | } else { 134 | $stub = (new Filesystem)->get(base_path('stubs/test.stub')); 135 | 136 | $this->createFileWithStub($stub, $path); 137 | 138 | $this->components->info('Tests created successfully.'); 139 | } 140 | } 141 | 142 | /** 143 | * Determine if the class already exists. 144 | * 145 | * @param string $path 146 | * @return bool 147 | */ 148 | protected function alreadyExists($path) 149 | { 150 | return $this->files->exists($path); 151 | } 152 | 153 | /** 154 | * Build the directory for the class if necessary. 155 | * 156 | * @param string $path 157 | * @return string 158 | */ 159 | protected function makeDirectory($path) 160 | { 161 | if (! $this->files->isDirectory(dirname($path))) { 162 | $this->files->makeDirectory(dirname($path), 0777, true, true); 163 | } 164 | 165 | return $path; 166 | } 167 | 168 | /** 169 | * @param $stub 170 | * @param $path 171 | * @return void 172 | */ 173 | protected function createFileWithStub($stub, $path) 174 | { 175 | $this->makeDirectory($path); 176 | 177 | $content = str_replace([ 178 | 'DummyRootNamespace', 179 | 'DummySingular', 180 | 'DummyPlural', 181 | 'DUMMY_VARIABLE_SINGULAR', 182 | 'DUMMY_VARIABLE_PLURAL', 183 | 'dummyVariableSingular', 184 | 'dummyVariablePlural', 185 | 'dummy-plural', 186 | ], [ 187 | App::getNamespace(), 188 | $this->module, 189 | $this->module->pluralStudly(), 190 | $this->module->snake()->upper(), 191 | $this->module->plural()->snake()->upper(), 192 | lcfirst($this->module), 193 | lcfirst($this->module->pluralStudly()), 194 | lcfirst($this->module->plural()->snake('-')), 195 | ], 196 | $stub 197 | ); 198 | 199 | $this->files->put($path, $content); 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire') 28 | // ->hourly(); 29 | } 30 | 31 | /** 32 | * Register the commands for the application. 33 | * 34 | * @return void 35 | */ 36 | protected function commands() 37 | { 38 | $this->load(__DIR__.'/Commands'); 39 | 40 | require base_path('routes/console.php'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/Contracts/RepositoryInterface.php: -------------------------------------------------------------------------------- 1 | [__('You must :linkOpen verify :linkClose your email first.', [ 18 | 'linkOpen' => '', 19 | 'linkClose' => '', 20 | ])], 21 | ]); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/Http/Middleware/EnsureEmailIsVerified.php: -------------------------------------------------------------------------------- 1 | user() || 20 | ($request->user() instanceof MustVerifyEmail && 21 | ! $request->user()->hasVerifiedEmail())) { 22 | return response()->json(['message' => 'Your email address is not verified.'], 409); 23 | } 24 | 25 | return $next($request); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/Models/PersonalAccessToken.php: -------------------------------------------------------------------------------- 1 | 'datetime', 51 | ]; 52 | 53 | /** 54 | * The accessors to append to the model's array form. 55 | * 56 | * @var array 57 | */ 58 | protected $appends = [ 59 | 'avatar', 60 | ]; 61 | 62 | /** 63 | * Get the profile photo URL attribute. 64 | * 65 | * @return string 66 | */ 67 | public function getAvatarAttribute() 68 | { 69 | return 'https://www.gravatar.com/avatar/'.md5(strtolower($this->email)).'.jpg?s=200&d=mm'; 70 | } 71 | 72 | /** 73 | * Send the password reset notification. 74 | * 75 | * @param string $token 76 | * @return void 77 | */ 78 | public function sendPasswordResetNotification($token) 79 | { 80 | $this->notify(new ResetPassword($token)); 81 | } 82 | 83 | /** 84 | * Send the email verification notification. 85 | * 86 | * @return void 87 | */ 88 | public function sendEmailVerificationNotification() 89 | { 90 | $this->notify(new VerifyEmail); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /app/Modules/Auth/Controllers/AuthenticatedSessionController.php: -------------------------------------------------------------------------------- 1 | authenticate(); 19 | 20 | $request->session()->regenerate(); 21 | 22 | return response()->noContent(); 23 | } 24 | 25 | /** 26 | * Destroy an authenticated session. 27 | */ 28 | public function destroy(Request $request): Response 29 | { 30 | Auth::guard('web')->logout(); 31 | 32 | $request->session()->invalidate(); 33 | 34 | $request->session()->regenerateToken(); 35 | 36 | return response()->noContent(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/Modules/Auth/Controllers/AuthenticatedTokenController.php: -------------------------------------------------------------------------------- 1 | authenticate(); 20 | 21 | $token = $user->createToken($request->device_name)->plainTextToken; 22 | 23 | return response()->json([ 24 | 'token' => $token, 25 | ])->header('Authorization', $token); 26 | } 27 | 28 | /** 29 | * Destroy an authenticated session. 30 | */ 31 | public function destroy(Request $request): Response 32 | { 33 | $request->user()->currentAccessToken()->delete(); 34 | Auth::guard('api')->forgetUser(); 35 | app()->get('auth')->forgetGuards(); 36 | 37 | return response()->noContent(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Modules/Auth/Controllers/CurrentUserController.php: -------------------------------------------------------------------------------- 1 | json([ 13 | 'data' => auth()->user(), 14 | ]); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/Modules/Auth/Controllers/NewPasswordController.php: -------------------------------------------------------------------------------- 1 | validate([ 25 | 'token' => ['required'], 26 | 'email' => ['required', 'email'], 27 | 'password' => ['required', 'confirmed', Rules\Password::defaults()], 28 | ]); 29 | 30 | // Here we will attempt to reset the user's password. If it is successful we 31 | // will update the password on an actual user model and persist it to the 32 | // database. Otherwise we will parse the error and return the response. 33 | $status = Password::reset( 34 | $request->only('email', 'password', 'password_confirmation', 'token'), 35 | function ($user) use ($request) { 36 | $user->forceFill([ 37 | 'password' => Hash::make($request->password), 38 | 'remember_token' => Str::random(60), 39 | ])->save(); 40 | 41 | event(new PasswordReset($user)); 42 | } 43 | ); 44 | 45 | if ($status != Password::PASSWORD_RESET) { 46 | throw ValidationException::withMessages([ 47 | 'email' => [__($status)], 48 | ]); 49 | } 50 | 51 | return response()->json(['status' => __($status)]); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/Modules/Auth/Controllers/PasswordResetLinkController.php: -------------------------------------------------------------------------------- 1 | validate([ 21 | 'email' => ['required', 'email'], 22 | ]); 23 | 24 | // We will send the password reset link to this user. Once we have attempted 25 | // to send the link, we will examine the response then see the message we 26 | // need to show to the user. Finally, we'll send out a proper response. 27 | $status = Password::sendResetLink( 28 | $request->only('email') 29 | ); 30 | 31 | if ($status != Password::RESET_LINK_SENT) { 32 | throw ValidationException::withMessages([ 33 | 'email' => [__($status)], 34 | ]); 35 | } 36 | 37 | return response()->json(['status' => __($status)]); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Modules/Auth/Controllers/RegisteredUserController.php: -------------------------------------------------------------------------------- 1 | validate([ 23 | 'name' => ['required', 'string', 'max:255'], 24 | 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class], 25 | 'password' => ['required', 'confirmed', Rules\Password::defaults()], 26 | ]); 27 | 28 | $user = User::create([ 29 | 'name' => $request->name, 30 | 'email' => $request->email, 31 | 'password' => Hash::make($request->password), 32 | ]); 33 | 34 | event(new Registered($user)); 35 | 36 | return response()->json($user); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/Modules/Auth/Controllers/VerifyEmailController.php: -------------------------------------------------------------------------------- 1 | json([ 26 | 'status' => trans('verification.invalid'), 27 | ], 400); 28 | } 29 | 30 | if ($user->hasVerifiedEmail()) { 31 | return response()->json([ 32 | 'status' => trans('verification.already_verified'), 33 | ], 400); 34 | } 35 | 36 | $user->markEmailAsVerified(); 37 | 38 | event(new Verified($user)); 39 | 40 | return response()->json([ 41 | 'status' => trans('verification.verified'), 42 | ]); 43 | } 44 | 45 | /** 46 | * Resend the email verification notification. 47 | * 48 | * @param Request $request 49 | * @return JsonResponse 50 | * 51 | * @throws ValidationException 52 | */ 53 | public function resend(Request $request) 54 | { 55 | $request->validate(['email' => 'required|email']); 56 | 57 | /** @var User $user */ 58 | $user = User::where('email', $request->email)->first(); 59 | 60 | if (is_null($user)) { 61 | throw ValidationException::withMessages([ 62 | 'email' => [trans('verification.user')], 63 | ]); 64 | } 65 | 66 | if ($user->hasVerifiedEmail()) { 67 | throw ValidationException::withMessages([ 68 | 'email' => [trans('verification.already_verified')], 69 | ]); 70 | } 71 | 72 | $user->sendEmailVerificationNotification(); 73 | 74 | return response()->json(['status' => trans('verification.sent')]); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /app/Modules/Auth/Requests/LoginRequest.php: -------------------------------------------------------------------------------- 1 | 29 | */ 30 | public function rules(): array 31 | { 32 | return [ 33 | 'email' => ['required', 'string', 'email'], 34 | 'password' => ['required', 'string'], 35 | 'device_name' => ['required', 'string'], 36 | ]; 37 | } 38 | 39 | /** 40 | * Attempt to authenticate the request's credentials. 41 | * 42 | * @throws ValidationException 43 | */ 44 | public function authenticate(): User 45 | { 46 | $this->ensureIsNotRateLimited(); 47 | 48 | $user = User::where('email', strtolower($this->email))->first(); 49 | 50 | if (! $user || ! Hash::check($this->password, $user->password)) { 51 | throw ValidationException::withMessages([ 52 | 'email' => __('auth.failed'), 53 | ]); 54 | } 55 | 56 | if ($user instanceof MustVerifyEmail && ! $user->hasVerifiedEmail()) { 57 | throw VerifyEmailException::forUser($user); 58 | } 59 | 60 | RateLimiter::clear($this->throttleKey()); 61 | 62 | return $user; 63 | } 64 | 65 | /** 66 | * Ensure the login request is not rate limited. 67 | * 68 | * @throws ValidationException 69 | */ 70 | public function ensureIsNotRateLimited(): void 71 | { 72 | if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { 73 | return; 74 | } 75 | 76 | event(new Lockout($this)); 77 | 78 | $seconds = RateLimiter::availableIn($this->throttleKey()); 79 | 80 | throw ValidationException::withMessages([ 81 | 'email' => trans('auth.throttle', [ 82 | 'seconds' => $seconds, 83 | 'minutes' => ceil($seconds / 60), 84 | ]), 85 | ]); 86 | } 87 | 88 | /** 89 | * Get the rate limiting throttle key for the request. 90 | */ 91 | public function throttleKey(): string 92 | { 93 | return Str::transliterate(Str::lower($this->input('email')).'|'.$this->ip()); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /app/Modules/Auth/Requests/LoginSessionRequest.php: -------------------------------------------------------------------------------- 1 | 26 | */ 27 | public function rules(): array 28 | { 29 | return [ 30 | 'email' => ['required', 'string', 'email'], 31 | 'password' => ['required', 'string'], 32 | 'device_name' => ['required', 'string'], 33 | ]; 34 | } 35 | 36 | /** 37 | * Attempt to authenticate the request's credentials. 38 | * 39 | * @throws \Illuminate\Validation\ValidationException 40 | */ 41 | public function authenticate(): void 42 | { 43 | $this->ensureIsNotRateLimited(); 44 | 45 | if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) { 46 | RateLimiter::hit($this->throttleKey()); 47 | 48 | throw ValidationException::withMessages([ 49 | 'email' => __('auth.failed'), 50 | ]); 51 | } 52 | 53 | RateLimiter::clear($this->throttleKey()); 54 | } 55 | 56 | /** 57 | * Ensure the login request is not rate limited. 58 | * 59 | * @throws \Illuminate\Validation\ValidationException 60 | */ 61 | public function ensureIsNotRateLimited(): void 62 | { 63 | if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { 64 | return; 65 | } 66 | 67 | event(new Lockout($this)); 68 | 69 | $seconds = RateLimiter::availableIn($this->throttleKey()); 70 | 71 | throw ValidationException::withMessages([ 72 | 'email' => trans('auth.throttle', [ 73 | 'seconds' => $seconds, 74 | 'minutes' => ceil($seconds / 60), 75 | ]), 76 | ]); 77 | } 78 | 79 | /** 80 | * Get the rate limiting throttle key for the request. 81 | */ 82 | public function throttleKey(): string 83 | { 84 | return Str::transliterate(Str::lower($this->input('email')).'|'.$this->ip()); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /app/Modules/Auth/routes_api.php: -------------------------------------------------------------------------------- 1 | group(function () { 12 | Route::withoutMiddleware('auth:sanctum')->group(function () { 13 | 14 | Route::post('login', [AuthenticatedTokenController::class, 'store'])->name('login'); 15 | Route::post('register', [RegisteredUserController::class, 'store'])->name('register'); 16 | 17 | Route::post('forgot-password', [PasswordResetLinkController::class, 'store'])->name('forgot-password'); 18 | Route::post('reset-password', [NewPasswordController::class, 'store'])->name('reset-password'); 19 | 20 | }); 21 | 22 | Route::post('email/verify/{user}', [VerifyEmailController::class, 'verify']) 23 | ->middleware(['throttle:6,1']) 24 | ->name('verification.verify'); 25 | 26 | Route::post('email/resend', [VerifyEmailController::class, 'resend']) 27 | ->middleware(['throttle:6,1']) 28 | ->name('verification.resend'); 29 | 30 | Route::post('logout', [AuthenticatedTokenController::class, 'destroy'])->name('logout'); 31 | Route::post('me', CurrentUserController::class)->name('me'); 32 | }); 33 | -------------------------------------------------------------------------------- /app/Modules/Core/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | user(); 23 | 24 | $user->fill($profileRequest->validated())->save(); 25 | 26 | return response()->json([ 27 | 'type' => self::RESPONSE_TYPE_SUCCESS, 28 | 'message' => 'Successfully updated', 29 | ]); 30 | } 31 | 32 | /** 33 | * Update the user's profile information. 34 | * 35 | * @param ChangePasswordRequest $request 36 | * @return JsonResponse 37 | */ 38 | public function changePassword(ChangePasswordRequest $request) 39 | { 40 | /** @var User $user */ 41 | $user = auth()->user(); 42 | 43 | $user->password = bcrypt($request->password); 44 | $user->save(); 45 | 46 | return response()->json([ 47 | 'type' => self::RESPONSE_TYPE_SUCCESS, 48 | 'message' => 'Successfully updated', 49 | ]); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/Modules/Setting/Requests/ChangePasswordRequest.php: -------------------------------------------------------------------------------- 1 | [ 31 | 'string', 32 | 'required', 33 | function ($attribute, $value, $fail) { 34 | if ($value && ! Hash::check($value, auth()->user()->password)) { 35 | $fail(__('passwords.password_not_matched', ['attribute' => $attribute])); 36 | } 37 | }, 38 | ], 39 | 'password' => [ 40 | 'string', 41 | 'required', 42 | function ($attribute, $value, $fail) { 43 | if ($value && Hash::check($value, auth()->user()->password)) { 44 | $fail(__('passwords.password_matches_old', ['attribute' => $attribute])); 45 | } 46 | }, 47 | Password::min(8), 48 | // ->mixedCase() 49 | // ->letters() 50 | // ->numbers() 51 | // ->symbols() 52 | // ->uncompromised(), 53 | ], 54 | 'password_confirmation' => [ 55 | 'string', 56 | 'required', 57 | function ($attribute, $value, $fail) { 58 | if ($value != $this->password) { 59 | $fail(__('passwords.password_not_matched', ['attribute' => $attribute])); 60 | } 61 | }, 62 | ], 63 | ]; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/Modules/Setting/Requests/ProfileRequest.php: -------------------------------------------------------------------------------- 1 | 'required|string', 29 | User::COLUMN_EMAIL => 'required|email|unique:users,email,'.auth()->id(), 30 | ]; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Modules/Setting/routes_api.php: -------------------------------------------------------------------------------- 1 | group(function () { 6 | Route::patch('profile', 'ProfileController@update')->name('profile.update'); 7 | Route::patch('change-password', 'ProfileController@changePassword')->name('profile.changePassword'); 8 | }); 9 | -------------------------------------------------------------------------------- /app/Notifications/ResetPassword.php: -------------------------------------------------------------------------------- 1 | line('You are receiving this email because we received a password reset request for your account.') 20 | ->action('Reset Password', url(config('app.url').'/password/reset/'.$this->token).'?email='.urlencode($notifiable->email)) 21 | ->line('If you did not request a password reset, no further action is required.'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/Notifications/VerifyEmail.php: -------------------------------------------------------------------------------- 1 | addMinutes(60), ['user' => $notifiable->id] 21 | ); 22 | 23 | return str_replace('/api/v1/auth', '', $url); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | getEmailForPasswordReset()}"; 25 | }); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', 16 | ]; 17 | 18 | /** 19 | * Register any authentication / authorization services. 20 | * 21 | * @return void 22 | */ 23 | public function boot() 24 | { 25 | $this->registerPolicies(); 26 | 27 | // 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | ['auth:sanctum']]); 18 | 19 | require base_path('routes/channels.php'); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Providers/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 19 | SendEmailVerificationNotification::class, 20 | ], 21 | ]; 22 | 23 | /** 24 | * Register any events for your application. 25 | * 26 | * @return void 27 | */ 28 | public function boot() 29 | { 30 | parent::boot(); 31 | 32 | // 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/Repositories/AbstractRepository.php: -------------------------------------------------------------------------------- 1 | class) { 26 | $this->model = new $this->class; 27 | } 28 | } 29 | 30 | /** 31 | * @param int $id 32 | * @return Model|null 33 | */ 34 | public function get(int $id): ?Model 35 | { 36 | return $this->model::find($id); 37 | } 38 | 39 | /** 40 | * @param array $data 41 | * @return Model|null 42 | */ 43 | public function create(array $data): ?Model 44 | { 45 | return $this->model::create($data); 46 | } 47 | 48 | /** 49 | * @param array $data 50 | * @param Model $model 51 | * @return Model 52 | */ 53 | public function update(array $data, Model $model): Model 54 | { 55 | $model->fill($data)->save(); 56 | 57 | return $model; 58 | } 59 | 60 | /** 61 | * @param $id 62 | * @return bool 63 | * 64 | * @throws \Exception 65 | */ 66 | public function delete(int $id): bool 67 | { 68 | return $this->model::destroy($id); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/Repositories/UserRepository.php: -------------------------------------------------------------------------------- 1 | handleCommand(new ArgvInput); 14 | 15 | exit($status); 16 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | withRouting( 13 | web: __DIR__.'/../routes/web.php', 14 | api: __DIR__.'/../routes/api.php', 15 | commands: __DIR__.'/../routes/console.php', 16 | health: '/up', 17 | ) 18 | ->withMiddleware(function (Middleware $middleware) { 19 | $middleware->api(prepend: [ 20 | EnsureFrontendRequestsAreStateful::class, 21 | // \Illuminate\Session\Middleware\StartSession::class, 22 | ]); 23 | 24 | $middleware->alias([ 25 | 'verified' => EnsureEmailIsVerified::class, 26 | ]); 27 | }) 28 | ->withExceptions(function (Exceptions $exceptions) { 29 | $exceptions->render(function (NotFoundHttpException $e, Request $request) { 30 | if ($request->is('api/*')) { 31 | return response()->json([ 32 | 'message' => 'Record not found.', 33 | ], 404); 34 | } 35 | }); 36 | })->create(); 37 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /bootstrap/providers.php: -------------------------------------------------------------------------------- 1 | env('APP_NAME', 'Laravel Vue SPA Skeleton'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Application Environment 21 | |-------------------------------------------------------------------------- 22 | | 23 | | This value determines the "environment" your application is currently 24 | | running in. This may determine how you prefer to configure various 25 | | services the application utilizes. Set this in your ".env" file. 26 | | 27 | */ 28 | 29 | 'env' => env('APP_ENV', 'production'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Application Debug Mode 34 | |-------------------------------------------------------------------------- 35 | | 36 | | When your application is in debug mode, detailed error messages with 37 | | stack traces will be shown on every error that occurs within your 38 | | application. If disabled, a simple generic error page is shown. 39 | | 40 | */ 41 | 42 | 'debug' => env('APP_DEBUG', false), 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Application URL 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This URL is used by the console to properly generate URLs when using 50 | | the Artisan command line tool. You should set this to the root of 51 | | your application so that it is used when running Artisan tasks. 52 | | 53 | */ 54 | 55 | 'url' => env('APP_URL', 'http://localhost'), 56 | 57 | 'api_url' => env('MIX_API_ENDPOINT', 'http://localhost/api'), 58 | 59 | 'asset_url' => env('ASSET_URL', null), 60 | 61 | /* 62 | |-------------------------------------------------------------------------- 63 | | Application Timezone 64 | |-------------------------------------------------------------------------- 65 | | 66 | | Here you may specify the default timezone for your application, which 67 | | will be used by the PHP date and date-time functions. We have gone 68 | | ahead and set this to a sensible default for you out of the box. 69 | | 70 | */ 71 | 72 | 'timezone' => 'UTC', 73 | 74 | /* 75 | |-------------------------------------------------------------------------- 76 | | Application Locale Configuration 77 | |-------------------------------------------------------------------------- 78 | | 79 | | The application locale determines the default locale that will be used 80 | | by the translation service provider. You are free to set this value 81 | | to any of the locales which will be supported by the application. 82 | | 83 | */ 84 | 85 | 'locale' => 'en', 86 | 87 | /* 88 | |-------------------------------------------------------------------------- 89 | | Application Fallback Locale 90 | |-------------------------------------------------------------------------- 91 | | 92 | | The fallback locale determines the locale to use when the current one 93 | | is not available. You may change the value to correspond to any of 94 | | the language folders that are provided through your application. 95 | | 96 | */ 97 | 98 | 'fallback_locale' => 'en', 99 | 100 | /* 101 | |-------------------------------------------------------------------------- 102 | | Faker Locale 103 | |-------------------------------------------------------------------------- 104 | | 105 | | This locale will be used by the Faker PHP library when generating fake 106 | | data for your database seeds. For example, this will be used to get 107 | | localized telephone numbers, street address information and more. 108 | | 109 | */ 110 | 111 | 'faker_locale' => 'en_US', 112 | 113 | /* 114 | |-------------------------------------------------------------------------- 115 | | Encryption Key 116 | |-------------------------------------------------------------------------- 117 | | 118 | | This key is used by the Illuminate encrypter service and should be set 119 | | to a random, 32 character string, otherwise these encrypted strings 120 | | will not be safe. Please do this before deploying an application! 121 | | 122 | */ 123 | 124 | 'key' => env('APP_KEY'), 125 | 126 | 'cipher' => 'AES-256-CBC', 127 | 128 | /* 129 | |-------------------------------------------------------------------------- 130 | | Autoloaded Service Providers 131 | |-------------------------------------------------------------------------- 132 | | 133 | | The service providers listed here will be automatically loaded on the 134 | | request to your application. Feel free to add your own services to 135 | | this array to grant expanded functionality to your applications. 136 | | 137 | */ 138 | ]; 139 | -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => 'web', 18 | 'passwords' => 'users', 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | here which uses session storage and the Eloquent user provider. 29 | | 30 | | All authentication drivers have a user provider. This defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | mechanisms used by this application to persist your user's data. 33 | | 34 | | Supported: "session", "token" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | 44 | 'api' => [ 45 | 'driver' => 'sanctum', 46 | 'provider' => 'users', 47 | 'hash' => false, 48 | ], 49 | ], 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | User Providers 54 | |-------------------------------------------------------------------------- 55 | | 56 | | All authentication drivers have a user provider. This defines how the 57 | | users are actually retrieved out of your database or other storage 58 | | mechanisms used by this application to persist your user's data. 59 | | 60 | | If you have multiple user tables or models you may configure multiple 61 | | sources which represent each model / table. These sources may then 62 | | be assigned to any extra authentication guards you have defined. 63 | | 64 | | Supported: "database", "eloquent" 65 | | 66 | */ 67 | 68 | 'providers' => [ 69 | 'users' => [ 70 | 'driver' => 'eloquent', 71 | 'model' => App\Models\User::class, 72 | ], 73 | 74 | // 'users' => [ 75 | // 'driver' => 'database', 76 | // 'table' => 'users', 77 | // ], 78 | ], 79 | 80 | /* 81 | |-------------------------------------------------------------------------- 82 | | Resetting Passwords 83 | |-------------------------------------------------------------------------- 84 | | 85 | | You may specify multiple password reset configurations if you have more 86 | | than one user table or model in the application and you want to have 87 | | separate password reset settings based on the specific user types. 88 | | 89 | | The expire time is the number of minutes that the reset token should be 90 | | considered valid. This security feature keeps tokens short-lived so 91 | | they have less time to be guessed. You may change this as needed. 92 | | 93 | */ 94 | 95 | 'passwords' => [ 96 | 'users' => [ 97 | 'provider' => 'users', 98 | 'table' => 'password_resets', 99 | 'expire' => 60, 100 | 'throttle' => 60, 101 | ], 102 | ], 103 | 104 | /* 105 | |-------------------------------------------------------------------------- 106 | | Password Confirmation Timeout 107 | |-------------------------------------------------------------------------- 108 | | 109 | | Here you may define the amount of seconds before a password confirmation 110 | | times out and the user is prompted to re-enter their password via the 111 | | confirmation screen. By default, the timeout lasts for three hours. 112 | | 113 | */ 114 | 115 | 'password_timeout' => 10800, 116 | 117 | ]; 118 | -------------------------------------------------------------------------------- /config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | 'cluster' => env('PUSHER_APP_CLUSTER'), 40 | 'useTLS' => true, 41 | ], 42 | ], 43 | 44 | 'redis' => [ 45 | 'driver' => 'redis', 46 | 'connection' => 'default', 47 | ], 48 | 49 | 'log' => [ 50 | 'driver' => 'log', 51 | ], 52 | 53 | 'null' => [ 54 | 'driver' => 'null', 55 | ], 56 | 57 | ], 58 | 59 | ]; 60 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Cache Stores 26 | |-------------------------------------------------------------------------- 27 | | 28 | | Here you may define all of the cache "stores" for your application as 29 | | well as their drivers. You may even define multiple stores for the 30 | | same cache driver to group types of items stored in your caches. 31 | | 32 | */ 33 | 34 | 'stores' => [ 35 | 36 | 'apc' => [ 37 | 'driver' => 'apc', 38 | ], 39 | 40 | 'array' => [ 41 | 'driver' => 'array', 42 | ], 43 | 44 | 'database' => [ 45 | 'driver' => 'database', 46 | 'table' => 'cache', 47 | 'connection' => null, 48 | ], 49 | 50 | 'file' => [ 51 | 'driver' => 'file', 52 | 'path' => storage_path('framework/cache/data'), 53 | ], 54 | 55 | 'memcached' => [ 56 | 'driver' => 'memcached', 57 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 58 | 'sasl' => [ 59 | env('MEMCACHED_USERNAME'), 60 | env('MEMCACHED_PASSWORD'), 61 | ], 62 | 'options' => [ 63 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 64 | ], 65 | 'servers' => [ 66 | [ 67 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 68 | 'port' => env('MEMCACHED_PORT', 11211), 69 | 'weight' => 100, 70 | ], 71 | ], 72 | ], 73 | 74 | 'redis' => [ 75 | 'driver' => 'redis', 76 | 'connection' => 'cache', 77 | ], 78 | 79 | 'dynamodb' => [ 80 | 'driver' => 'dynamodb', 81 | 'key' => env('AWS_ACCESS_KEY_ID'), 82 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 83 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 84 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 85 | 'endpoint' => env('DYNAMODB_ENDPOINT'), 86 | ], 87 | 88 | ], 89 | 90 | /* 91 | |-------------------------------------------------------------------------- 92 | | Cache Key Prefix 93 | |-------------------------------------------------------------------------- 94 | | 95 | | When utilizing a RAM based store such as APC or Memcached, there might 96 | | be other applications utilizing the same cache. So, we'll specify a 97 | | value to get prefixed to all our keys so we can avoid collisions. 98 | | 99 | */ 100 | 101 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'), 102 | 103 | ]; 104 | -------------------------------------------------------------------------------- /config/cors.php: -------------------------------------------------------------------------------- 1 | ['*'], 19 | 20 | 'allowed_methods' => ['*'], 21 | 22 | 'allowed_origins' => [env('FRONTEND_URL', 'http://localhost:3000')], 23 | 24 | 'allowed_origins_patterns' => [], 25 | 26 | 'allowed_headers' => ['*'], 27 | 28 | 'exposed_headers' => [], 29 | 30 | 'max_age' => 0, 31 | 32 | 'supports_credentials' => true, 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DRIVER', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Default Cloud Filesystem Disk 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Many applications store files both locally and in the cloud. For this 24 | | reason, you may specify a default "cloud" driver here. This driver 25 | | will be bound as the Cloud disk implementation in the container. 26 | | 27 | */ 28 | 29 | 'cloud' => env('FILESYSTEM_CLOUD', 's3'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Filesystem Disks 34 | |-------------------------------------------------------------------------- 35 | | 36 | | Here you may configure as many filesystem "disks" as you wish, and you 37 | | may even configure multiple disks of the same driver. Defaults have 38 | | been setup for each driver as an example of the required options. 39 | | 40 | | Supported Drivers: "local", "ftp", "sftp", "s3" 41 | | 42 | */ 43 | 44 | 'disks' => [ 45 | 46 | 'local' => [ 47 | 'driver' => 'local', 48 | 'root' => storage_path('app'), 49 | ], 50 | 51 | 'public' => [ 52 | 'driver' => 'local', 53 | 'root' => storage_path('app/public'), 54 | 'url' => env('APP_URL').'/storage', 55 | 'visibility' => 'public', 56 | ], 57 | 58 | 's3' => [ 59 | 'driver' => 's3', 60 | 'key' => env('AWS_ACCESS_KEY_ID'), 61 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 62 | 'region' => env('AWS_DEFAULT_REGION'), 63 | 'bucket' => env('AWS_BUCKET'), 64 | 'url' => env('AWS_URL'), 65 | ], 66 | 67 | ], 68 | 69 | ]; 70 | -------------------------------------------------------------------------------- /config/hashing.php: -------------------------------------------------------------------------------- 1 | 'bcrypt', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Bcrypt Options 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may specify the configuration options that should be used when 26 | | passwords are hashed using the Bcrypt algorithm. This will allow you 27 | | to control the amount of time it takes to hash the given password. 28 | | 29 | */ 30 | 31 | 'bcrypt' => [ 32 | 'rounds' => env('BCRYPT_ROUNDS', 10), 33 | ], 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Argon Options 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here you may specify the configuration options that should be used when 41 | | passwords are hashed using the Argon algorithm. These will allow you 42 | | to control the amount of time it takes to hash the given password. 43 | | 44 | */ 45 | 46 | 'argon' => [ 47 | 'memory' => 1024, 48 | 'threads' => 2, 49 | 'time' => 2, 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 21 | 22 | /* 23 | |-------------------------------------------------------------------------- 24 | | Log Channels 25 | |-------------------------------------------------------------------------- 26 | | 27 | | Here you may configure the log channels for your application. Out of 28 | | the box, Laravel uses the Monolog PHP logging library. This gives 29 | | you a variety of powerful log handlers / formatters to utilize. 30 | | 31 | | Available Drivers: "single", "daily", "slack", "syslog", 32 | | "errorlog", "monolog", 33 | | "custom", "stack" 34 | | 35 | */ 36 | 37 | 'channels' => [ 38 | 'stack' => [ 39 | 'driver' => 'stack', 40 | 'channels' => ['single'], 41 | 'ignore_exceptions' => false, 42 | ], 43 | 44 | 'single' => [ 45 | 'driver' => 'single', 46 | 'path' => storage_path('logs/laravel.log'), 47 | 'level' => 'debug', 48 | ], 49 | 50 | 'daily' => [ 51 | 'driver' => 'daily', 52 | 'path' => storage_path('logs/laravel.log'), 53 | 'level' => 'debug', 54 | 'days' => 14, 55 | ], 56 | 57 | 'slack' => [ 58 | 'driver' => 'slack', 59 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 60 | 'username' => 'Laravel Log', 61 | 'emoji' => ':boom:', 62 | 'level' => 'critical', 63 | ], 64 | 65 | 'papertrail' => [ 66 | 'driver' => 'monolog', 67 | 'level' => 'debug', 68 | 'handler' => SyslogUdpHandler::class, 69 | 'handler_with' => [ 70 | 'host' => env('PAPERTRAIL_URL'), 71 | 'port' => env('PAPERTRAIL_PORT'), 72 | ], 73 | ], 74 | 75 | 'stderr' => [ 76 | 'driver' => 'monolog', 77 | 'handler' => StreamHandler::class, 78 | 'formatter' => env('LOG_STDERR_FORMATTER'), 79 | 'with' => [ 80 | 'stream' => 'php://stderr', 81 | ], 82 | ], 83 | 84 | 'syslog' => [ 85 | 'driver' => 'syslog', 86 | 'level' => 'debug', 87 | ], 88 | 89 | 'errorlog' => [ 90 | 'driver' => 'errorlog', 91 | 'level' => 'debug', 92 | ], 93 | 94 | 'null' => [ 95 | 'driver' => 'monolog', 96 | 'handler' => NullHandler::class, 97 | ], 98 | 99 | 'emergency' => [ 100 | 'path' => storage_path('logs/laravel.log'), 101 | ], 102 | ], 103 | 104 | ]; 105 | -------------------------------------------------------------------------------- /config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_DRIVER', 'smtp'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | SMTP Host Address 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may provide the host address of the SMTP server used by your 27 | | applications. A default option is provided that is compatible with 28 | | the Mailgun mail service which will provide reliable deliveries. 29 | | 30 | */ 31 | 32 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | SMTP Host Port 37 | |-------------------------------------------------------------------------- 38 | | 39 | | This is the SMTP port used by your application to deliver e-mails to 40 | | users of the application. Like the host we have set this value to 41 | | stay compatible with the Mailgun e-mail application by default. 42 | | 43 | */ 44 | 45 | 'port' => env('MAIL_PORT', 587), 46 | 47 | /* 48 | |-------------------------------------------------------------------------- 49 | | Global "From" Address 50 | |-------------------------------------------------------------------------- 51 | | 52 | | You may wish for all e-mails sent by your application to be sent from 53 | | the same address. Here, you may specify a name and address that is 54 | | used globally for all e-mails that are sent by your application. 55 | | 56 | */ 57 | 58 | 'from' => [ 59 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 60 | 'name' => env('MAIL_FROM_NAME', 'Example'), 61 | ], 62 | 63 | /* 64 | |-------------------------------------------------------------------------- 65 | | E-Mail Encryption Protocol 66 | |-------------------------------------------------------------------------- 67 | | 68 | | Here you may specify the encryption protocol that should be used when 69 | | the application send e-mail messages. A sensible default using the 70 | | transport layer security protocol should provide great security. 71 | | 72 | */ 73 | 74 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 75 | 76 | /* 77 | |-------------------------------------------------------------------------- 78 | | SMTP Server Username 79 | |-------------------------------------------------------------------------- 80 | | 81 | | If your SMTP server requires a username for authentication, you should 82 | | set it here. This will get used to authenticate with your server on 83 | | connection. You may also set the "password" value below this one. 84 | | 85 | */ 86 | 87 | 'username' => env('MAIL_USERNAME'), 88 | 89 | 'password' => env('MAIL_PASSWORD'), 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Sendmail System Path 94 | |-------------------------------------------------------------------------- 95 | | 96 | | When using the "sendmail" driver to send e-mails, we will need to know 97 | | the path to where Sendmail lives on this server. A default path has 98 | | been provided here, which will work well on most of your systems. 99 | | 100 | */ 101 | 102 | 'sendmail' => '/usr/sbin/sendmail -bs', 103 | 104 | /* 105 | |-------------------------------------------------------------------------- 106 | | Markdown Mail Settings 107 | |-------------------------------------------------------------------------- 108 | | 109 | | If you are using Markdown based email rendering, you may configure your 110 | | theme and component paths here, allowing you to customize the design 111 | | of the emails. Or, you may simply stick with the Laravel defaults! 112 | | 113 | */ 114 | 115 | 'markdown' => [ 116 | 'theme' => 'default', 117 | 118 | 'paths' => [ 119 | resource_path('views/vendor/mail'), 120 | ], 121 | ], 122 | 123 | /* 124 | |-------------------------------------------------------------------------- 125 | | Log Channel 126 | |-------------------------------------------------------------------------- 127 | | 128 | | If you are using the "log" driver, you may specify the logging channel 129 | | if you prefer to keep mail messages separate from other log entries 130 | | for simpler reading. Otherwise, the default channel will be used. 131 | | 132 | */ 133 | 134 | 'log_channel' => env('MAIL_LOG_CHANNEL'), 135 | 136 | ]; 137 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_CONNECTION', 'sync'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Queue Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure the connection information for each server that 24 | | is used by your application. A default configuration has been added 25 | | for each back-end shipped with Laravel. You are free to add more. 26 | | 27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'table' => 'jobs', 40 | 'queue' => 'default', 41 | 'retry_after' => 90, 42 | ], 43 | 44 | 'beanstalkd' => [ 45 | 'driver' => 'beanstalkd', 46 | 'host' => 'localhost', 47 | 'queue' => 'default', 48 | 'retry_after' => 90, 49 | 'block_for' => 0, 50 | ], 51 | 52 | 'sqs' => [ 53 | 'driver' => 'sqs', 54 | 'key' => env('AWS_ACCESS_KEY_ID'), 55 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 56 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 57 | 'queue' => env('SQS_QUEUE', 'your-queue-name'), 58 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 59 | ], 60 | 61 | 'redis' => [ 62 | 'driver' => 'redis', 63 | 'connection' => 'default', 64 | 'queue' => env('REDIS_QUEUE', 'default'), 65 | 'retry_after' => 90, 66 | 'block_for' => null, 67 | ], 68 | 69 | ], 70 | 71 | /* 72 | |-------------------------------------------------------------------------- 73 | | Failed Queue Jobs 74 | |-------------------------------------------------------------------------- 75 | | 76 | | These options configure the behavior of failed queue job logging so you 77 | | can control which database and table are used to store the jobs that 78 | | have failed. You may change them to any database / table you wish. 79 | | 80 | */ 81 | 82 | 'failed' => [ 83 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database'), 84 | 'database' => env('DB_CONNECTION', 'mysql'), 85 | 'table' => 'failed_jobs', 86 | ], 87 | 88 | ]; 89 | -------------------------------------------------------------------------------- /config/sanctum.php: -------------------------------------------------------------------------------- 1 | explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf( 19 | '%s%s%s', 20 | 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1', 21 | Sanctum::currentApplicationUrlWithPort(), 22 | env('FRONTEND_URL') ? ','.parse_url(env('FRONTEND_URL'), PHP_URL_HOST) : '' 23 | ))), 24 | 25 | /* 26 | |-------------------------------------------------------------------------- 27 | | Sanctum Guards 28 | |-------------------------------------------------------------------------- 29 | | 30 | | This array contains the authentication guards that will be checked when 31 | | Sanctum is trying to authenticate a request. If none of these guards 32 | | are able to authenticate the request, Sanctum will use the bearer 33 | | token that's present on an incoming request for authentication. 34 | | 35 | */ 36 | 37 | 'guard' => ['web'], 38 | 39 | /* 40 | |-------------------------------------------------------------------------- 41 | | Expiration Minutes 42 | |-------------------------------------------------------------------------- 43 | | 44 | | This value controls the number of minutes until an issued token will be 45 | | considered expired. This will override any values set in the token's 46 | | "expires_at" attribute, but first-party sessions are not affected. 47 | | 48 | */ 49 | 50 | 'expiration' => null, 51 | 52 | /* 53 | |-------------------------------------------------------------------------- 54 | | Token Prefix 55 | |-------------------------------------------------------------------------- 56 | | 57 | | Sanctum can prefix new tokens in order to take advantage of numerous 58 | | security scanning initiatives maintained by open source platforms 59 | | that notify developers if they commit tokens into repositories. 60 | | 61 | | See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning 62 | | 63 | */ 64 | 65 | 'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''), 66 | 67 | /* 68 | |-------------------------------------------------------------------------- 69 | | Sanctum Middleware 70 | |-------------------------------------------------------------------------- 71 | | 72 | | When authenticating your first-party SPA with Sanctum you may need to 73 | | customize some of the middleware Sanctum uses while processing the 74 | | request. You may change the middleware listed below as required. 75 | | 76 | */ 77 | 78 | 'middleware' => [ 79 | 'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class, 80 | 'encrypt_cookies' => Illuminate\Cookie\Middleware\EncryptCookies::class, 81 | 'validate_csrf_token' => Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class, 82 | ], 83 | 84 | ]; 85 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | ], 22 | 23 | 'postmark' => [ 24 | 'token' => env('POSTMARK_TOKEN'), 25 | ], 26 | 27 | 'ses' => [ 28 | 'key' => env('AWS_ACCESS_KEY_ID'), 29 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 30 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 31 | ], 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | resource_path('views'), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => env( 32 | 'VIEW_COMPILED_PATH', 33 | realpath(storage_path('framework/views')) 34 | ), 35 | 36 | ]; 37 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | *.sqlite-journal 3 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | $this->faker->firstName.' '.$this->faker->lastName, 28 | User::COLUMN_EMAIL => $this->faker->unique()->safeEmail, 29 | User::COLUMN_EMAIL_VERIFIED_AT => now(), 30 | User::COLUMN_PASSWORD => Hash::make('password'), 31 | User::COLUMN_REMEMBER_TOKEN => Str::random(10), 32 | ]; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 16 | $table->string('name'); 17 | $table->string('email')->unique(); 18 | $table->timestamp('email_verified_at')->nullable(); 19 | $table->string('password'); 20 | $table->rememberToken(); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('users'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 16 | $table->string('token'); 17 | $table->timestamp('created_at')->nullable(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | */ 24 | public function down() 25 | { 26 | Schema::dropIfExists('password_resets'); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 16 | $table->text('connection'); 17 | $table->text('queue'); 18 | $table->longText('payload'); 19 | $table->longText('exception'); 20 | $table->timestamp('failed_at')->useCurrent(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | */ 27 | public function down() 28 | { 29 | Schema::dropIfExists('failed_jobs'); 30 | } 31 | }; 32 | -------------------------------------------------------------------------------- /database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->morphs('tokenable'); 17 | $table->string('name'); 18 | $table->string('token', 64)->unique(); 19 | $table->text('abilities')->nullable(); 20 | $table->timestamp('last_used_at')->nullable(); 21 | $table->timestamp('expires_at')->nullable(); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | */ 29 | public function down(): void 30 | { 31 | Schema::dropIfExists('personal_access_tokens'); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call(UsersTableSeeder::class); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /database/seeders/UsersTableSeeder.php: -------------------------------------------------------------------------------- 1 | state([User::COLUMN_EMAIL => 'user@app.com'])->create(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "larave-vue3-spa-skeleton", 4 | "scripts": { 5 | "dev": "vite", 6 | "build": "vite build", 7 | "lint": "./node_modules/.bin/eslint -c .eslintrc.js --ignore-path .gitignore resources/js/** --ext .js,.vue --max-warnings=0", 8 | "lint-fix": "./node_modules/.bin/eslint -c .eslintrc.js --ignore-path .gitignore resources/js/** --ext .js,.vue --fix" 9 | }, 10 | "lint-staged": { 11 | "*.{js,vue}": [ 12 | "./node_modules/.bin/eslint -c .eslintrc.js --fix --max-warnings=0" 13 | ], 14 | "*.php": [ 15 | "./vendor/bin/pint --dirty" 16 | ] 17 | }, 18 | "husky": { 19 | "hooks": { 20 | "pre-commit": "lint-staged" 21 | } 22 | }, 23 | "devDependencies": { 24 | "@babel/core": "^7.20.12", 25 | "@babel/eslint-parser": "^7.19.1", 26 | "eslint": "^7.20.0", 27 | "eslint-plugin-vue": "^7.6.0", 28 | "husky": "4", 29 | "lint-staged": "11.1.2", 30 | "sass": "^1.57.1" 31 | }, 32 | "dependencies": { 33 | "@element-plus/icons-vue": "^2.0.10", 34 | "@fortawesome/fontawesome-free": "^6.2.1", 35 | "@vitejs/plugin-vue": "^4.0.0", 36 | "@vue/compiler-sfc": "^3.2.29", 37 | "@websanova/vue-auth": "^4.2.0", 38 | "axios": "^1.1.2", 39 | "dayjs": "^1.10.7", 40 | "element-plus": "^2.2.27", 41 | "laravel-vite-plugin": "^0.7.2", 42 | "lodash": "^4.17.19", 43 | "pinia": "^2.0.28", 44 | "postcss": "^8.1.14", 45 | "resolve-url-loader": "4.0.0", 46 | "vite": "^4.0.0", 47 | "vue": "3.2", 48 | "vue-axios": "^3.4.0", 49 | "vue-i18n": "^9.2.2", 50 | "vue-router": "^4.0.12" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /phpstorm.config.js: -------------------------------------------------------------------------------- 1 | System.config({ 2 | "paths": { 3 | "@/*": "./resources/js/*", 4 | } 5 | }); 6 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ./tests/Unit 6 | 7 | 8 | ./tests/Feature 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | ./app 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /pint.json: -------------------------------------------------------------------------------- 1 | { 2 | "preset": "laravel", 3 | "rules": { 4 | "class_attributes_separation": false, 5 | "no_superfluous_phpdoc_tags": false 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Handle Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yurich84/laravel-vue3-spa/53e1a7495f12ddc389fd2b9865da830faaa2997c/public/favicon.ico -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | handleRequest(Request::capture()); 18 | -------------------------------------------------------------------------------- /public/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yurich84/laravel-vue3-spa/53e1a7495f12ddc389fd2b9865da830faaa2997c/public/preview.png -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /resources/js/app.js: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import { createPinia } from 'pinia' 3 | import App from './base/App.vue' 4 | import ElementPlus from 'element-plus' 5 | import i18n from './plugins/i18n' 6 | import $dayjs from './plugins/day' 7 | import * as _ from 'lodash' 8 | import $filters from './includes/filters' 9 | import $bus from './includes/Event' 10 | import router from './plugins/router' 11 | import auth from './plugins/auth' 12 | import './plugins/day' 13 | import VueAxios from 'vue-axios' 14 | import axios from './plugins/axios-interceptor' 15 | import * as ElementPlusIconsVue from '@element-plus/icons-vue' 16 | 17 | const app = createApp(App) 18 | 19 | for (const [key, component] of Object.entries(ElementPlusIconsVue)) { 20 | app.component(key, component) 21 | } 22 | 23 | window._ = _ 24 | 25 | app.use(createPinia()) 26 | app.use(router) 27 | app.use(VueAxios, axios) 28 | app.use(auth) 29 | app.use(i18n) 30 | app.use(ElementPlus, {i18n: (key, value) => i18n.t(key, value)}) 31 | 32 | app.config.globalProperties.$config = window.config 33 | app.config.globalProperties.$filters = $filters 34 | app.config.globalProperties.$dayjs = $dayjs 35 | app.config.globalProperties.$bus = $bus 36 | 37 | app.mount('#app') 38 | 39 | export default app 40 | -------------------------------------------------------------------------------- /resources/js/base/App.vue: -------------------------------------------------------------------------------- 1 | 22 | -------------------------------------------------------------------------------- /resources/js/base/baseStore.js: -------------------------------------------------------------------------------- 1 | import { ref } from 'vue' 2 | import { defineStore } from 'pinia' 3 | 4 | const collapsed = window.innerWidth <= 768 5 | 6 | export const useBaseStore = defineStore('base', () => { 7 | const isCollapsed = ref(collapsed) 8 | function toggleCollapse() { 9 | isCollapsed.value = !isCollapsed.value 10 | } 11 | 12 | return { isCollapsed, toggleCollapse } 13 | }) 14 | -------------------------------------------------------------------------------- /resources/js/base/components/Base.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 36 | -------------------------------------------------------------------------------- /resources/js/base/components/Breadcrumbs.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 28 | -------------------------------------------------------------------------------- /resources/js/base/components/Child.vue: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /resources/js/base/components/Index.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 17 | 18 | 23 | -------------------------------------------------------------------------------- /resources/js/base/components/Navbar.vue: -------------------------------------------------------------------------------- 1 | 40 | 41 | 69 | -------------------------------------------------------------------------------- /resources/js/base/components/NotFound.vue: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /resources/js/base/components/Sidebar.vue: -------------------------------------------------------------------------------- 1 | 44 | 45 | 57 | 58 | 108 | -------------------------------------------------------------------------------- /resources/js/base/components/filters/BaseFilter.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 35 | -------------------------------------------------------------------------------- /resources/js/base/constants/time.constants.js: -------------------------------------------------------------------------------- 1 | export const DATETIME_DB_FORMAT = 'YYYY-MM-DD HH:mm:ss' 2 | export const DATE_DB_FORMAT = 'YYYY-MM-DD' 3 | 4 | export const DATETIME_FORMAT = 'DD/MM/YYYY HH:mm' 5 | export const DATE_FORMAT = 'DD/MM/YYYY' 6 | export const TIME_FORMAT = 'HH:mm' 7 | 8 | export const DATE_PIKER_FORMAT = 'dd/MM/yyyy' 9 | export const MONTH_PIKER_FORMAT = 'MMM yyyy' 10 | export const DATATIME_PIKER_FORMAT = 'dd/MM/yyyy HH:mm' 11 | -------------------------------------------------------------------------------- /resources/js/base/layouts/Default.vue: -------------------------------------------------------------------------------- 1 | 19 | 20 | 26 | 27 | 41 | -------------------------------------------------------------------------------- /resources/js/base/layouts/Empty.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /resources/js/base/layouts/Welcome.vue: -------------------------------------------------------------------------------- 1 | 26 | 27 | 30 | 31 | 72 | -------------------------------------------------------------------------------- /resources/js/base/routes.js: -------------------------------------------------------------------------------- 1 | import Index from './components/Index.vue' 2 | import NotFound from './components/NotFound.vue' 3 | import Base from './components/Base.vue' 4 | import Child from './components/Child.vue' 5 | 6 | const autoImportModules = import.meta.glob('../modules/*/routes.js', { import: 'routes' }) 7 | 8 | let moduleRoutes = [] 9 | 10 | for (const path in autoImportModules) { 11 | const routes = await autoImportModules[path]() 12 | moduleRoutes = moduleRoutes.concat(routes) 13 | } 14 | 15 | export const routes = [ 16 | { 17 | path: '/', 18 | component: Base, 19 | children: [ 20 | { 21 | path: 'admin', 22 | name: 'Home', 23 | component: Child, 24 | meta: {auth: true}, 25 | children: [ 26 | ...moduleRoutes, 27 | ] 28 | }, 29 | { 30 | path: '/', 31 | component: Index, 32 | name: 'index', 33 | meta: {layout: 'Welcome'}, 34 | hidden: true, 35 | }, 36 | { 37 | path: ':pathMatch(.*)*', 38 | component: NotFound, 39 | name: '404', 40 | meta: { 41 | layout: 'Welcome', 42 | auth: undefined 43 | }, 44 | } 45 | ] 46 | } 47 | ] 48 | 49 | -------------------------------------------------------------------------------- /resources/js/includes/Event.js: -------------------------------------------------------------------------------- 1 | class Event { 2 | constructor(){ 3 | this.events = {} 4 | } 5 | 6 | $on(eventName, fn) { 7 | this.events[eventName] = this.events[eventName] || [] 8 | this.events[eventName].push(fn) 9 | } 10 | 11 | $off(eventName, fn) { 12 | if (this.events[eventName]) { 13 | for (let i = 0; i < this.events[eventName].length; i++) { 14 | if (this.events[eventName][i] === fn) { 15 | this.events[eventName].splice(i, 1) 16 | break 17 | } 18 | } 19 | } 20 | } 21 | 22 | $emit(eventName, data) { 23 | if (this.events[eventName]) { 24 | this.events[eventName].forEach(function(fn) { 25 | if (typeof fn === 'function') fn(data) 26 | }) 27 | } 28 | } 29 | } 30 | 31 | export default new Event() 32 | -------------------------------------------------------------------------------- /resources/js/includes/composable/errors.js: -------------------------------------------------------------------------------- 1 | import {ref} from 'vue' 2 | 3 | export function useErrors() { 4 | const errors = ref({}) 5 | 6 | function clear(field = null) { 7 | if (field) { 8 | if (has(field)) { 9 | delete errors.value[field] 10 | } 11 | 12 | return 13 | } 14 | 15 | errors.value = {} 16 | } 17 | 18 | function has(field) { 19 | return errors.value.hasOwnProperty(field) 20 | } 21 | 22 | function get(field) { 23 | if (errors.value[field]) { 24 | return errors.value[field][0] 25 | } 26 | 27 | return '' 28 | } 29 | 30 | function record(errs) { 31 | errors.value = errs 32 | } 33 | 34 | return { 35 | errors, 36 | clear, 37 | has, 38 | get, 39 | record 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /resources/js/includes/composable/modelWrapper.js: -------------------------------------------------------------------------------- 1 | import { computed } from 'vue' 2 | 3 | export function useModelWrapper(props, emit, name = 'modelValue') { 4 | return computed({ 5 | get: () => props[name], 6 | set: (value) => emit(`update:${name}`, value) 7 | }) 8 | } 9 | -------------------------------------------------------------------------------- /resources/js/includes/filters.js: -------------------------------------------------------------------------------- 1 | import dayjs from '@/plugins/day' 2 | import {DATE_FORMAT, DATETIME_DB_FORMAT, DATETIME_FORMAT} from '@/base/constants/time.constants' 3 | 4 | export default { 5 | capitalize: function (value) { 6 | if (!value) return '' 7 | value = value.toString() 8 | return value.charAt(0).toUpperCase() + value.slice(1) 9 | }, 10 | price: function (number) { 11 | return Number(number).toString().replace(/\B(?=(\d{3})+(?!\d))/g, '\'') 12 | }, 13 | date: function (datetime) { 14 | return dayjs(datetime).isValid() ? dayjs(datetime, DATETIME_DB_FORMAT).format(DATE_FORMAT) : '' 15 | }, 16 | time: function (datetime) { 17 | return dayjs(datetime).isValid() ? dayjs(datetime, DATETIME_DB_FORMAT).format(DATETIME_FORMAT) : '' 18 | }, 19 | } 20 | -------------------------------------------------------------------------------- /resources/js/includes/lang/en.js: -------------------------------------------------------------------------------- 1 | import enLocale from 'element-plus/lib/locale/lang/en' 2 | 3 | export const messages = { 4 | global: { 5 | ok: 'Ok', 6 | cancel: 'Cancel', 7 | save: 'Save', 8 | add: 'Add', 9 | edit: 'Edit', 10 | delete: 'Delete', 11 | new: 'New', 12 | search: 'Search...', 13 | unknown_server_error: 'Unknown server error', 14 | form: { 15 | rules: { 16 | required: 'Field "{fieldName}" is required', 17 | email: 'Please input correct email address', 18 | min: 'Field length "{fieldName}" must be more then {attribute} characters', 19 | max: 'Field length "{fieldName}" must be less then {attribute} characters', 20 | password_repeat: { 21 | different: 'Mismatch passwords', 22 | } 23 | } 24 | }, 25 | }, 26 | auth: { 27 | token_expired_alert_title: 'Session Expired!', 28 | token_expired_alert_text: 'Please log in again to continue.', 29 | verification: { 30 | resend_link: 'Resend verification', 31 | resend_title: 'Resend verification', 32 | resend_button: 'Send', 33 | failed: 'The verification link is invalid.', 34 | }, 35 | resend_verification_link: 'Resend verification email', 36 | login: { 37 | title: 'Login', 38 | submit_button: 'Sign In', 39 | email_label: 'Email', 40 | password_label: 'Password', 41 | }, 42 | logout: { 43 | title: 'Logout', 44 | }, 45 | register: { 46 | title: 'Register', 47 | name_label: 'Name', 48 | email_label: 'Email', 49 | password_label: 'Password', 50 | password_confirmation_label: 'Repeat password', 51 | submit_button: 'Sign Up', 52 | success: 'Thanks for registration.' 53 | }, 54 | logout_confirm: { 55 | title: 'Confirm LogOut', 56 | text: 'You will be logged out', 57 | button_ok: 'Ok', 58 | button_cancel: 'Cancel', 59 | } 60 | }, 61 | profile: { 62 | name: 'Name', 63 | email: 'Email', 64 | edit: 'Edit profile', 65 | change_password: 'Change password', 66 | old_password: 'Old password', 67 | new_password: 'New password', 68 | confirm_password: 'Confirm password', 69 | }, 70 | ...enLocale 71 | } 72 | -------------------------------------------------------------------------------- /resources/js/includes/lang/index.js: -------------------------------------------------------------------------------- 1 | import {messages as en} from './en' 2 | import {messages as ru} from './ru' 3 | 4 | export default { 5 | en, 6 | ru 7 | } 8 | -------------------------------------------------------------------------------- /resources/js/includes/lang/ru.js: -------------------------------------------------------------------------------- 1 | import ruLocale from 'element-plus/lib/locale/lang/ru' 2 | 3 | export const messages = { 4 | global: { 5 | ok: 'Ok', 6 | cancel: 'Отмена', 7 | save: 'Сохранить', 8 | add: 'Добавить', 9 | edit: 'Редактировать', 10 | delete: 'Удалить', 11 | new: 'Новый', 12 | search: 'Искать...', 13 | unknown_server_error: 'Неизвестная ошибка сервера', 14 | form: { 15 | rules: { 16 | required: 'Поле "{fieldName}" обезательно', 17 | email: 'Пожалуйста введите корректный email', 18 | min: 'Длинна поля "{fieldName}" должна быть больше {attribute} символов', 19 | max: 'Длинна поля "{fieldName}" должна быть меньше {attribute} символов', 20 | password_repeat: { 21 | different: 'Пароли не совпадают', 22 | } 23 | } 24 | }, 25 | }, 26 | auth: { 27 | token_expired_alert_title: 'Сессия истекла!', 28 | token_expired_alert_text: 'Пожалуйска зайдите слова.', 29 | verification: { 30 | resend_link: 'Отправить имейл о верификации еще раз', 31 | resend_title: 'Отправка имейла о верификации', 32 | resend_button: 'Отправить', 33 | failed: 'Ссылка не действительная.', 34 | }, 35 | resend_verification_link: 'Отправить имейл о верификации еще раз', 36 | login: { 37 | title: 'Войти', 38 | submit_button: 'Войти', 39 | email_label: 'Email', 40 | password_label: 'Пароль', 41 | }, 42 | logout: { 43 | title: 'Выйти', 44 | }, 45 | register: { 46 | title: 'Зарегестрироваться', 47 | name_label: 'Имя', 48 | email_label: 'Email', 49 | password_label: 'Пароль', 50 | password_confirmation_label: 'Повторите пароль', 51 | submit_button: 'Отправить', 52 | success: 'Спасибо за регистрацию.' 53 | }, 54 | logout_confirm: { 55 | title: 'Подтвердите выход', 56 | text: 'Вы будете розлогинены', 57 | button_ok: 'Ok', 58 | button_cancel: 'Отмена', 59 | } 60 | }, 61 | setting: { 62 | profile: { 63 | name: 'Имя', 64 | email: 'Email', 65 | edit: 'Edit profile', 66 | change_password: 'Change password', 67 | } 68 | }, 69 | ...ruLocale 70 | } 71 | -------------------------------------------------------------------------------- /resources/js/modules/auth/authApi.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | 3 | const API_ENDPOINT = 'auth' 4 | 5 | export default { 6 | 7 | verify(user, query) { 8 | return axios.post(`${API_ENDPOINT}/email/verify/${user}?${query}`) 9 | }, 10 | 11 | resend() { 12 | return axios.post(`${API_ENDPOINT}/email/resend`) 13 | }, 14 | 15 | } 16 | -------------------------------------------------------------------------------- /resources/js/modules/auth/components/Login.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 38 | -------------------------------------------------------------------------------- /resources/js/modules/auth/components/LoginForm.vue: -------------------------------------------------------------------------------- 1 | 46 | 47 | 85 | -------------------------------------------------------------------------------- /resources/js/modules/auth/components/Register.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 40 | -------------------------------------------------------------------------------- /resources/js/modules/auth/components/RegisterForm.vue: -------------------------------------------------------------------------------- 1 | 67 | 68 | 139 | -------------------------------------------------------------------------------- /resources/js/modules/auth/components/ResendVerification.vue: -------------------------------------------------------------------------------- 1 | 35 | 36 | 62 | -------------------------------------------------------------------------------- /resources/js/modules/auth/components/VerifyEmail.vue: -------------------------------------------------------------------------------- 1 | 35 | 36 | 58 | -------------------------------------------------------------------------------- /resources/js/modules/auth/routes.js: -------------------------------------------------------------------------------- 1 | import Login from './components/Login.vue' 2 | import Register from './components/Register.vue' 3 | import VerifyEmail from './components/VerifyEmail.vue' 4 | import ResendVerification from './components/ResendVerification.vue' 5 | import Child from '@/base/components/Child.vue' 6 | 7 | export const routes = [ 8 | { 9 | path: '/email', 10 | name: 'Auth', 11 | component: Child, 12 | meta: { 13 | layout: 'Welcome', 14 | auth: true 15 | }, 16 | hidden: true, 17 | children: [ 18 | { 19 | path: '/login', 20 | component: Login, 21 | name: 'Login', 22 | meta: { 23 | auth: false, 24 | }, 25 | }, 26 | { 27 | path: '/register', 28 | component: Register, 29 | name: 'Register', 30 | meta: { 31 | auth: false, 32 | }, 33 | }, 34 | { 35 | path: 'verify/:user', 36 | component: VerifyEmail, 37 | name: 'Verification email' 38 | }, 39 | { 40 | path: 'resend/verification', 41 | component: ResendVerification, 42 | name: 'Verification resend' 43 | } 44 | ] 45 | } 46 | ] 47 | -------------------------------------------------------------------------------- /resources/js/modules/dashboard/components/Dashboard.vue: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /resources/js/modules/dashboard/routes.js: -------------------------------------------------------------------------------- 1 | import Dashboard from './components/Dashboard.vue' 2 | 3 | export const routes = [ 4 | { 5 | path: '', 6 | name: 'Dashboard', 7 | component: Dashboard, 8 | icon: 'fa fa-th-large' 9 | }, 10 | ] 11 | -------------------------------------------------------------------------------- /resources/js/modules/profile/components/ChangePassword.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 10 | -------------------------------------------------------------------------------- /resources/js/modules/profile/components/ChangePasswordForm.vue: -------------------------------------------------------------------------------- 1 | 59 | 60 | 123 | -------------------------------------------------------------------------------- /resources/js/modules/profile/components/Profile.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 10 | -------------------------------------------------------------------------------- /resources/js/modules/profile/components/ProfileForm.vue: -------------------------------------------------------------------------------- 1 | 46 | 47 | 100 | -------------------------------------------------------------------------------- /resources/js/modules/profile/profileApi.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | 3 | const API_ENDPOINT = 'settings' 4 | 5 | export default { 6 | 7 | update(model) { 8 | return axios.patch(API_ENDPOINT + '/profile', model) 9 | }, 10 | 11 | changePassword(data) { 12 | return axios.patch(API_ENDPOINT + '/change-password', data) 13 | }, 14 | } 15 | -------------------------------------------------------------------------------- /resources/js/modules/profile/routes.js: -------------------------------------------------------------------------------- 1 | import Profile from './components/Profile.vue' 2 | import ChangePassword from './components/ChangePassword.vue' 3 | 4 | export const routes = [ 5 | { 6 | path: 'change-password', 7 | name: 'profile.change_password', 8 | component: ChangePassword, 9 | hidden: true, 10 | }, 11 | { 12 | path: 'profile', 13 | name: 'profile.edit', 14 | component: Profile, 15 | hidden: true, 16 | }, 17 | ] 18 | -------------------------------------------------------------------------------- /resources/js/plugins/auth.js: -------------------------------------------------------------------------------- 1 | import {setI18nLanguage} from '@/plugins/i18n' 2 | 3 | import {createAuth} from '@websanova/vue-auth' 4 | import driverAuthBearer from '@websanova/vue-auth/dist/drivers/auth/bearer.esm.js' 5 | import driverHttpAxios from '@websanova/vue-auth/dist/drivers/http/axios.1.x.esm.js' 6 | import driverRouterVueRouter from '@websanova/vue-auth/dist/drivers/router/vue-router.2.x.esm.js' 7 | 8 | export default (app) => { 9 | app.use(createAuth({ 10 | plugins: { 11 | http: app.axios, 12 | router: app.router, 13 | }, 14 | drivers: { 15 | http: driverHttpAxios, 16 | auth: driverAuthBearer, 17 | router: driverRouterVueRouter, 18 | }, 19 | options: { 20 | loginData: { 21 | url: window.config.baseURL + 'auth/login', 22 | redirect: {name: 'Dashboard'} 23 | }, 24 | logoutData: { 25 | url: window.config.baseURL + 'auth/logout', 26 | redirect: {name: 'Login'}, 27 | makeRequest: true 28 | }, 29 | registerData: { 30 | url: window.config.baseURL + 'auth/register', 31 | method: 'POST', 32 | redirect: {name: 'Login'} 33 | }, 34 | fetchData: { 35 | url: window.config.baseURL + 'auth/me', 36 | method: 'POST' 37 | }, 38 | refreshData: {enabled: false}, 39 | rolesKey: 'all_permissions', 40 | parseUserData: function (data) { 41 | setI18nLanguage(data.data.locale || 'en') 42 | return data.data || {} 43 | }, 44 | } 45 | })) 46 | } 47 | -------------------------------------------------------------------------------- /resources/js/plugins/axios-interceptor.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | import {ElMessage} from 'element-plus' 3 | 4 | let token = document.head.querySelector('meta[name="csrf-token"]') 5 | axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content 6 | axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest' 7 | axios.defaults.baseURL = window.config.baseURL 8 | axios.defaults.withCredentials = true 9 | 10 | // Response interceptor 11 | axios.interceptors.response.use(response => response, error => { 12 | if (error.response.data.message) { 13 | console.error('--- ', error.response.data.message) 14 | } 15 | if (error.response?.status >= 500) { 16 | ElMessage.error('Unknown server error!') 17 | } else if (error.response?.status === 401 && error.response.data.message) { 18 | ElMessage.error(error.response.data.message) 19 | } 20 | 21 | return Promise.reject(error) 22 | }) 23 | 24 | export default axios 25 | -------------------------------------------------------------------------------- /resources/js/plugins/day.js: -------------------------------------------------------------------------------- 1 | import * as dayjs from 'dayjs' 2 | import 'dayjs/locale/en' 3 | 4 | export const changeDayjsLocale = function (locale) { 5 | dayjs.locale(locale) 6 | } 7 | 8 | export default dayjs 9 | -------------------------------------------------------------------------------- /resources/js/plugins/i18n.js: -------------------------------------------------------------------------------- 1 | import {createI18n} from 'vue-i18n' 2 | import messages from './../includes/lang' 3 | import axios from 'axios' 4 | import {changeDayjsLocale} from './day' 5 | 6 | const DEFAULT_LANGUAGE = 'en' 7 | 8 | changeDayjsLocale(DEFAULT_LANGUAGE) 9 | 10 | const i18n = createI18n({ 11 | legacy: false, 12 | locale: DEFAULT_LANGUAGE, 13 | messages, 14 | silentTranslationWarn: true 15 | }) 16 | 17 | setI18nLanguage(DEFAULT_LANGUAGE) 18 | 19 | export function setI18nLanguage (lang) { 20 | changeDayjsLocale(DEFAULT_LANGUAGE) 21 | i18n.locale = lang 22 | axios.defaults.headers.common['Accept-Language'] = lang 23 | document.querySelector('html').setAttribute('lang', lang) 24 | return lang 25 | } 26 | 27 | export default i18n 28 | -------------------------------------------------------------------------------- /resources/js/plugins/router.js: -------------------------------------------------------------------------------- 1 | import { createRouter, createWebHistory } from 'vue-router' 2 | import {routes} from '@/base/routes' 3 | 4 | const router = createRouter({ 5 | history: createWebHistory(), 6 | routes, 7 | scrollBehavior(to, from, savedPosition) { 8 | return new Promise((resolve) => { 9 | if (to.hash) { 10 | resolve({ selector: to.hash }) 11 | } else if (savedPosition) { 12 | resolve(savedPosition) 13 | } else { 14 | resolve({x: 0, y: 0}) 15 | } 16 | }) 17 | } 18 | }) 19 | 20 | export default (app) => { 21 | app.router = router 22 | 23 | app.use(router) 24 | } 25 | 26 | -------------------------------------------------------------------------------- /resources/lang/en/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Passwords must be at least eight characters and match the confirmation.', 17 | 'reset' => 'Your password has been reset!', 18 | 'sent' => 'We have emailed your password reset link!', 19 | 'token' => 'This password reset token is invalid.', 20 | 'user' => "We can't find a user with that email address.", 21 | 'password_not_matched' => 'The :attribute is not match with your current password.', 22 | 'password_matches_old' => 'The :attribute is match with old password.', 23 | 24 | ]; 25 | -------------------------------------------------------------------------------- /resources/lang/en/verification.php: -------------------------------------------------------------------------------- 1 | 'Your email has been verified!', 6 | 'invalid' => 'The verification link is invalid.', 7 | 'already_verified' => 'The email is already verified.', 8 | 'user' => 'We can\'t find a user with that e-mail address.', 9 | 'sent' => 'We have e-mailed your verification link!', 10 | 11 | ]; 12 | -------------------------------------------------------------------------------- /resources/sass/_spacing-helpers.scss: -------------------------------------------------------------------------------- 1 | /* 2 | This .scss loop will create "margin helpers" and "padding helpers" for use in your web projects. 3 | It will generate several classes such as: 4 | .m-10 which gives margin 10 pixels. 5 | .p-10 which gives padding 10 pixels. 6 | .mr-10 which gives margin-right 10 pixels. 7 | .mr-15 gives MARGIN to the RIGHT 15 pixels. 8 | .mt-15 gives MARGIN to the TOP 15 pixels and so on. 9 | .pb-5 gives PADDING to the BOTTOM of 5 pixels 10 | .pl-40 gives PADDING to the LEFT of 40 pixels 11 | The first letter is "m" or "p" for MARGIN or PADDING 12 | Second letter is "t", "b", "l", or "r" for TOP, BOTTOM, LEFT, or RIGHT 13 | Third letter is the number of spacing in pixels. Adjust the amounts generated by editing the $spaceamounts variable below. 14 | */ 15 | 16 | $spaceamounts: (0, 5, 10, 15, 20, 25, 30); 17 | $sides: (top, bottom, left, right, all); 18 | 19 | @each $space in $spaceamounts { 20 | @each $side in $sides { 21 | 22 | @if $side == 'all' { 23 | .m-#{$space} { 24 | margin: #{$space}px; 25 | } 26 | 27 | .p-#{$space} { 28 | padding: #{$space}px; 29 | } 30 | } @else { 31 | .m#{str-slice($side, 0, 1)}-#{$space} { 32 | margin-#{$side}: #{$space}px; 33 | } 34 | 35 | .p#{str-slice($side, 0, 1)}-#{$space} { 36 | padding-#{$side}: #{$space}px; 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /resources/sass/_transitions.scss: -------------------------------------------------------------------------------- 1 | .page-enter-active, 2 | .page-leave-active { 3 | transition: opacity .2s; 4 | } 5 | .page-enter, 6 | .page-leave-to { 7 | opacity: 0; 8 | } 9 | 10 | .fade-enter-active, 11 | .fade-leave-active { 12 | transition: opacity .15s 13 | } 14 | .fade-enter, 15 | .fade-leave-to { 16 | opacity: 0 17 | } 18 | -------------------------------------------------------------------------------- /resources/sass/_variables.scss: -------------------------------------------------------------------------------- 1 | @forward 'element-plus/theme-chalk/src/common/var.scss' with ( 2 | $colors: ( 3 | 'white': #ffffff, 4 | 'black': #000000, 5 | 'primary': ( 6 | 'base': #484baf, 7 | ), 8 | 'success': ( 9 | 'base': #4FBD95, 10 | ), 11 | 'warning': ( 12 | 'base': #e6a23c, 13 | ), 14 | 'danger': ( 15 | 'base': #f56c6c, 16 | ), 17 | 'error': ( 18 | 'base': #f56c6c, 19 | ), 20 | 'info': ( 21 | 'base': #d4d4d4, 22 | ) 23 | ), 24 | $pagination: ( 25 | 'hover-color': #484baf, 26 | ) 27 | ); 28 | 29 | // Body 30 | $body-bg: #f8fafc; 31 | 32 | // Typography 33 | $font-family-sans-serif: 'Nunito', sans-serif; 34 | 35 | // Screens 36 | $xs: 480px !default; 37 | $s: 768px; 38 | $m: 1024px; 39 | $l: 1200px; 40 | $xl: 1440px; 41 | $xxl: 1600px; 42 | 43 | // Colors 44 | $white: #ffffff; 45 | $blue: #00315D; 46 | $indigo: #484BAF; 47 | $green: #32CD99; 48 | $gray: #757575; 49 | $yellow: #FECD42; 50 | $black: #000000; 51 | $dark: #212121; 52 | $light-gray: #C4C4C4; 53 | $light-indigo: #ededf7; 54 | $white-second: #fafafa; 55 | $light-blue: #66839d; 56 | $maroon: #941a49; 57 | $dark-middle: #333333; 58 | $graphite: #999999; 59 | 60 | // Fonts 61 | $avant-font-family: 'ITCAvantGardeStd'; 62 | $avant-font-path: "/fonts/avant"; 63 | $avant: $avant-font-family, Helvetica, Arial, sans-serif; 64 | 65 | $avenir-next-font-family: 'AvenirNextCyr'; 66 | $avenir-next-font-path: "/fonts/avenir-next"; 67 | $avenir-next: $avenir-next-font-family, Helvetica, Arial, sans-serif; 68 | -------------------------------------------------------------------------------- /resources/sass/app.scss: -------------------------------------------------------------------------------- 1 | // Variables 2 | @use 'variables'; 3 | 4 | @use "~element-plus/theme-chalk/src/index.scss"; 5 | 6 | // Font Awesome 7 | $fa-font-path:"~@fortawesome/fontawesome-free/webfonts"; 8 | @import "~@fortawesome/fontawesome-free/scss/fontawesome.scss"; 9 | @import "~@fortawesome/fontawesome-free/scss/regular.scss"; 10 | @import "~@fortawesome/fontawesome-free/scss/solid.scss"; 11 | @import "~@fortawesome/fontawesome-free/scss/brands.scss"; 12 | @import "~@fortawesome/fontawesome-free/scss/v4-shims.scss"; 13 | 14 | // Custom Styles 15 | @import 'spacing-helpers'; 16 | @import 'transitions'; 17 | @import 'style'; 18 | -------------------------------------------------------------------------------- /resources/sass/style.scss: -------------------------------------------------------------------------------- 1 | @import "variables"; 2 | 3 | body { 4 | font-family: $font-family-sans-serif; 5 | background: #f8fafc !important; 6 | font-size: 14px !important; 7 | height: 100%; 8 | margin: 0; 9 | padding: 0; 10 | } 11 | 12 | .page-title { 13 | 14 | } 15 | 16 | .el-dialog { 17 | @media screen and (max-width: $sm - 1) { 18 | width: 100% !important; 19 | border-radius: 0; 20 | } 21 | 22 | .el-dialog__header { 23 | padding-right: 35px; 24 | } 25 | 26 | @media (max-width: $xs - 1) { 27 | .el-form-item__label { 28 | width: auto !important; 29 | } 30 | .el-form-item__content { 31 | clear: both; 32 | margin-left: 0 !important; 33 | } 34 | } 35 | } 36 | 37 | .app { 38 | > div.loading-screen { 39 | height: 100vh; 40 | 41 | > .loading-text { 42 | position: absolute; 43 | left: 50%; 44 | top: 50%; 45 | -webkit-transform: translate(-50%, -50%); 46 | -moz-transform: translate(-50%, -50%); 47 | -ms-transform: translate(-50%, -50%); 48 | -o-transform: translate(-50%, -50%); 49 | transform: translate(-50%, -50%); 50 | 51 | > p { 52 | text-shadow: 1px 1px 3px #000000; 53 | font-size: calc(3vh + 2vw); 54 | color: #ffffff; 55 | } 56 | } 57 | } 58 | } 59 | 60 | .text-center { 61 | text-align: center; 62 | margin: auto; 63 | } 64 | 65 | .float-right { 66 | float: right; 67 | } 68 | 69 | .float-left { 70 | float: left; 71 | } 72 | 73 | .w-100 { 74 | width: 100%; 75 | } 76 | 77 | .header { 78 | height: 60px; 79 | line-height: 60px; 80 | background: $color-primary; 81 | color: #fff; 82 | --el-header-padding: 0px !important; 83 | 84 | .logo { 85 | float: left; 86 | height: 60px; 87 | font-size: 22px; 88 | padding:0 20px; 89 | border-color: rgba(238, 241, 146, 0.3); 90 | border-right-width: 1px; 91 | border-right-style: solid; 92 | } 93 | 94 | .logo-width { 95 | width: 190px; 96 | } 97 | 98 | .logo-collapse-width { 99 | width: 23px; 100 | } 101 | 102 | .tools { 103 | float: left; 104 | div { 105 | padding: 0 23px; 106 | width: 14px; 107 | height: 60px; 108 | line-height: 60px; 109 | cursor: pointer; 110 | } 111 | } 112 | 113 | .userinfo { 114 | float: right; 115 | text-align: right; 116 | padding-right: 35px; 117 | .userinfo-inner { 118 | cursor: pointer; 119 | color: #fff; 120 | 121 | img { 122 | width: 40px; 123 | height: 40px; 124 | border-radius: 20px; 125 | margin: 10px 0 10px 10px; 126 | float: right; 127 | } 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /resources/views/spa.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {{ config('app.name') }} 8 | 9 | @vite(['resources/sass/app.scss', 'resources/js/app.js']) 10 | 11 | 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /resources/views/variables.blade.php: -------------------------------------------------------------------------------- 1 | {!! 2 | json_encode([ 3 | 'appName' => config('app.name'), 4 | 'baseURL' => config('app.url') . '/api/v1/', 5 | 'deviceName' => 'spa' 6 | ]) 7 | !!} 8 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 9 | return $request->user(); 10 | }); 11 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 16 | }); 17 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | is_dir($modules_folder.DIRECTORY_SEPARATOR.$item) && ! in_array($item, ['.', '..']) 14 | ) 15 | ); 16 | 17 | foreach ($modules as $module) { 18 | $routesPath = $modules_folder.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'routes_api.php'; 19 | 20 | if (file_exists($routesPath)) { 21 | Route::prefix(API_PREFIX) 22 | ->middleware(['auth:sanctum']) 23 | ->namespace("\\App\\Modules\\$module\Controllers") 24 | ->group($routesPath); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | where('any', '^(?!api).*'); 9 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | routes.php 3 | schedule-* 4 | compiled.php 5 | services.json 6 | events.scanned.php 7 | routes.scanned.php 8 | down 9 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /stubs/backEnd/controller.api.stub: -------------------------------------------------------------------------------- 1 | input('sortBy', 'id,asc')); 26 | $pageSize = (int) $request->input('pageSize', 10); 27 | 28 | $resource = DummySingular::query() 29 | ->when($request->filled('search'), function (Builder $q) use ($request) { 30 | $q->where(DummySingular::COLUMN_NAME, 'like', '%'.$request->search.'%'); 31 | }) 32 | ->orderBy($column, $order)->paginate($pageSize); 33 | 34 | return DummySingularResource::collection($resource); 35 | } 36 | 37 | /** 38 | * Store a newly created resource in storage. 39 | * 40 | * @param DummySingularRequest $request 41 | * @param DummySingular $dummyVariableSingular 42 | * @return JsonResponse 43 | */ 44 | public function store(DummySingularRequest $request, DummySingular $dummyVariableSingular) 45 | { 46 | $data = $request->validated(); 47 | $dummyVariableSingular->fill($data)->save(); 48 | 49 | return response()->json([ 50 | 'type' => self::RESPONSE_TYPE_SUCCESS, 51 | 'message' => 'Successfully created', 52 | ]); 53 | } 54 | 55 | /** 56 | * Display the specified resource. 57 | * 58 | * @param DummySingular $dummyVariableSingular 59 | * @return DummySingularResource 60 | */ 61 | public function show(DummySingular $dummyVariableSingular) 62 | { 63 | return new DummySingularResource($dummyVariableSingular); 64 | } 65 | 66 | /** 67 | * Update the specified resource in storage. 68 | * 69 | * @param DummySingularRequest $request 70 | * @param DummySingular $dummyVariableSingular 71 | * @return JsonResponse 72 | */ 73 | public function update(DummySingularRequest $request, DummySingular $dummyVariableSingular) 74 | { 75 | $data = $request->validated(); 76 | $dummyVariableSingular->fill($data)->save(); 77 | 78 | return response()->json([ 79 | 'type' => self::RESPONSE_TYPE_SUCCESS, 80 | 'message' => 'Successfully updated', 81 | ]); 82 | } 83 | 84 | /** 85 | * Delete the specified resource. 86 | * 87 | * @param DummySingular $dummyVariableSingular 88 | * @return JsonResponse 89 | * 90 | * @throws Exception 91 | */ 92 | public function destroy(DummySingular $dummyVariableSingular) 93 | { 94 | $dummyVariableSingular->delete(); 95 | 96 | return response()->json([ 97 | 'type' => self::RESPONSE_TYPE_SUCCESS, 98 | 'message' => 'Successfully deleted', 99 | ]); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /stubs/backEnd/request.stub: -------------------------------------------------------------------------------- 1 | 'required|string', 29 | ]; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /stubs/backEnd/resource.stub: -------------------------------------------------------------------------------- 1 | $this->faker->word, 26 | ]; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /stubs/frontEnd/api.stub: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | 3 | const API_ENDPOINT = 'dummyVariablePlural' 4 | 5 | export default { 6 | 7 | all(data) { 8 | return axios.get(API_ENDPOINT, {params: data}) 9 | }, 10 | 11 | find(id) { 12 | return axios.get(API_ENDPOINT + '/' + id) 13 | }, 14 | 15 | create(model) { 16 | return axios.post(API_ENDPOINT, model) 17 | }, 18 | 19 | update(model) { 20 | return axios.put(API_ENDPOINT + '/' + model.id, model) 21 | }, 22 | 23 | delete(id) { 24 | return axios.delete(API_ENDPOINT + '/' + id) 25 | }, 26 | } 27 | -------------------------------------------------------------------------------- /stubs/frontEnd/routes.stub: -------------------------------------------------------------------------------- 1 | import DummySingularList from './components/DummySingularList.vue' 2 | import DummySingularView from './components/DummySingularView.vue' 3 | 4 | export const routes = [ 5 | { 6 | path: '/dummyVariablePlural', 7 | name: 'DummyPlural', 8 | component: DummySingularList, 9 | }, 10 | { 11 | path: '/dummyVariablePlural/:id', 12 | name: 'Show DummySingular', 13 | component: DummySingularView, 14 | hidden: true 15 | }, 16 | ] 17 | -------------------------------------------------------------------------------- /stubs/frontEnd/store.stub: -------------------------------------------------------------------------------- 1 | import { ref } from 'vue' 2 | import { defineStore } from 'pinia' 3 | import dummyVariableSingularApi from './dummyVariableSingularApi' 4 | 5 | export const useDummySingularStore = defineStore('dummyVariableSingular', () => { 6 | 7 | const items = ref([]) 8 | const meta = ref([]) 9 | const loading = ref(true) 10 | 11 | async function fetchAll(params) { 12 | loading.value = true 13 | const {data} = await dummyVariableSingularApi.all(params) 14 | items.value = data.data 15 | meta.value = data.meta 16 | loading.value = false 17 | } 18 | 19 | return { 20 | items, 21 | meta, 22 | loading, 23 | fetchAll 24 | } 25 | }) 26 | -------------------------------------------------------------------------------- /stubs/frontEnd/vue.form.stub: -------------------------------------------------------------------------------- 1 | 37 | 38 | 97 | -------------------------------------------------------------------------------- /stubs/frontEnd/vue.view.stub: -------------------------------------------------------------------------------- 1 | 8 | 9 | 25 | -------------------------------------------------------------------------------- /stubs/migration.create.stub: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('name'); 19 | $table->timestamps(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('{{ table }}'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /stubs/model.stub: -------------------------------------------------------------------------------- 1 | actingAs($this->user) 8 | ->postJson(route('dummyVariablePlural.store'), [ 9 | 'name' => 'Lorem', 10 | ]) 11 | ->assertSuccessful() 12 | ->assertJson(['type' => Controller::RESPONSE_TYPE_SUCCESS]); 13 | 14 | $this->assertDatabaseHas('dummyVariablePlural', [ 15 | 'name' => 'Lorem', 16 | ]); 17 | }); 18 | 19 | test('update dummyVariableSingular', function () { 20 | $dummyVariableSingular = DummySingular::factory()->create(); 21 | 22 | $this->actingAs($this->user) 23 | ->putJson(route('dummyVariablePlural.update', $dummyVariableSingular->id), [ 24 | 'name' => 'Updated dummyVariableSingular', 25 | ]) 26 | ->assertSuccessful() 27 | ->assertJson(['type' => Controller::RESPONSE_TYPE_SUCCESS]); 28 | 29 | $this->assertDatabaseHas('dummyVariablePlural', [ 30 | 'id' => $dummyVariableSingular->id, 31 | 'name' => 'Updated dummyVariableSingular', 32 | ]); 33 | }); 34 | 35 | test('show dummyVariableSingular', function () { 36 | $dummyVariableSingular = DummySingular::factory()->create(); 37 | 38 | $this->actingAs($this->user) 39 | ->getJson(route('dummyVariablePlural.show', $dummyVariableSingular->id)) 40 | ->assertSuccessful() 41 | ->assertJson([ 42 | 'data' => [ 43 | 'name' => $dummyVariableSingular->name, 44 | ], 45 | ]); 46 | }); 47 | 48 | test('list dummyVariableSingular', function () { 49 | $dummyVariablePlural = DummySingular::factory()->count(2)->create()->map(function ($dummyVariableSingular) { 50 | return $dummyVariableSingular->only(['id', 'name']); 51 | }); 52 | 53 | $this->actingAs($this->user) 54 | ->getJson(route('dummyVariablePlural.index')) 55 | ->assertSuccessful() 56 | ->assertJson([ 57 | 'data' => $dummyVariablePlural->toArray(), 58 | ]) 59 | ->assertJsonStructure([ 60 | 'data' => [ 61 | '*' => ['id', 'name'], 62 | ], 63 | 'links', 64 | 'meta', 65 | ]); 66 | }); 67 | 68 | test('delete dummyVariableSingular', function () { 69 | $dummyVariableSingular = DummySingular::factory()->create([ 70 | 'name' => 'DummySingular for delete', 71 | ]); 72 | 73 | $this->actingAs($this->user) 74 | ->deleteJson(route('dummyVariablePlural.update', $dummyVariableSingular->id)) 75 | ->assertSuccessful() 76 | ->assertJson(['type' => Controller::RESPONSE_TYPE_SUCCESS]); 77 | 78 | $this->assertDatabaseMissing('dummyVariablePlural', [ 79 | 'id' => $dummyVariableSingular->id, 80 | 'name' => 'DummySingular for delete', 81 | ]); 82 | }); 83 | -------------------------------------------------------------------------------- /tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 20 | 21 | return $app; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/Feature/ArchTest.php: -------------------------------------------------------------------------------- 1 | expect(['dd', 'dump', 'ray']) 5 | ->not->toBeUsed(); 6 | -------------------------------------------------------------------------------- /tests/Feature/Auth/AuthenticationTest.php: -------------------------------------------------------------------------------- 1 | postJson(route('login'), [ 8 | 'email' => $this->user->email, 9 | 'password' => 'password', 10 | 'device_name' => 'spa', 11 | ]); 12 | 13 | $token = $response->json()['token']; 14 | 15 | $response 16 | ->assertSuccessful() 17 | ->assertJson(['token' => $token]) 18 | ->assertHeader('Authorization'); 19 | 20 | $this->withToken($token) 21 | ->postJson(route('me')) 22 | ->assertSuccessful(); 23 | 24 | $this->assertDatabaseHas(PersonalAccessToken::TABLE_NAME, [ 25 | PersonalAccessToken::COLUMN_NAME => 'spa', 26 | PersonalAccessToken::COLUMN_TOKENABLE_ID => $this->user->id, 27 | PersonalAccessToken::COLUMN_TOKENABLE_TYPE => User::class, 28 | ]); 29 | }); 30 | 31 | test('users can not authenticate with invalid password', function () { 32 | $user = User::factory()->create(); 33 | 34 | $this->post('/login', [ 35 | 'email' => $user->email, 36 | 'password' => 'wrong-password', 37 | ]); 38 | 39 | $this->assertGuest(); 40 | }); 41 | 42 | test('fetch the current user', function () { 43 | $this->actingAs($this->user) 44 | ->postJson(route('me')) 45 | ->assertSuccessful() 46 | ->assertJsonPath('data.email', $this->user->email); 47 | }); 48 | 49 | test('users can logout', function () { 50 | 51 | $response = $this->postJson(route('login'), [ 52 | 'email' => $this->user->email, 53 | 'password' => 'password', 54 | 'device_name' => 'spa', 55 | ]); 56 | 57 | $token = $response->json()['token']; 58 | 59 | $this->withToken($token) 60 | ->postJson(route('logout')) 61 | ->assertNoContent(); 62 | 63 | $this->assertDatabaseMissing(PersonalAccessToken::TABLE_NAME, [ 64 | PersonalAccessToken::COLUMN_NAME => 'spa', 65 | PersonalAccessToken::COLUMN_TOKENABLE_ID => $this->user->id, 66 | PersonalAccessToken::COLUMN_TOKENABLE_TYPE => User::class, 67 | ]); 68 | 69 | $this->withToken($token) 70 | ->postJson(route('me')) 71 | ->assertStatus(401); 72 | }); 73 | -------------------------------------------------------------------------------- /tests/Feature/Auth/EmailVerificationTest.php: -------------------------------------------------------------------------------- 1 | user = User::factory()->create(['email_verified_at' => null]); 12 | }); 13 | 14 | test('can verify email', function () { 15 | $user = User::factory()->create(['email_verified_at' => null]); 16 | $url = URL::temporarySignedRoute('verification.verify', now()->addMinutes(60), ['user' => $user->id]); 17 | 18 | Event::fake(); 19 | 20 | $this->actingAs($this->user) 21 | ->postJson($url) 22 | ->assertSuccessful() 23 | ->assertJsonFragment(['status' => 'Your email has been verified!']); 24 | 25 | Event::assertDispatched(Verified::class, function (Verified $e) use ($user) { 26 | return $e->user->is($user); 27 | }); 28 | }); 29 | 30 | test('can not verify if already verified', function () { 31 | $user = User::factory()->create(); 32 | $url = URL::temporarySignedRoute('verification.verify', now()->addMinutes(60), ['user' => $user->id]); 33 | 34 | $this->actingAs($this->user) 35 | ->postJson($url) 36 | ->assertStatus(400) 37 | ->assertJsonFragment(['status' => 'The email is already verified.']); 38 | }); 39 | 40 | test('can not verify if url has invalid_signature', function () { 41 | $user = User::factory()->create(['email_verified_at' => null]); 42 | 43 | $this->actingAs($this->user) 44 | ->postJson(route('verification.verify', ['user' => $user])) 45 | ->assertStatus(400) 46 | ->assertJsonFragment(['status' => 'The verification link is invalid.']); 47 | }); 48 | 49 | test('resend verification notification', function () { 50 | $user = User::factory()->create(['email_verified_at' => null]); 51 | 52 | Notification::fake(); 53 | 54 | $this->actingAs($this->user) 55 | ->postJson(route('verification.resend', ['email' => $user->email])) 56 | ->assertSuccessful(); 57 | 58 | Notification::assertSentTo($user, VerifyEmail::class); 59 | }); 60 | 61 | test('can not resend verification notification if email does not exist', function () { 62 | $this->actingAs($this->user) 63 | ->postJson(route('verification.resend', ['email' => 'not_existed_email@app.com'])) 64 | ->assertStatus(422) 65 | ->assertJsonFragment(['errors' => ['email' => ['We can\'t find a user with that e-mail address.']]]); 66 | }); 67 | 68 | test('can not resend verification notification if email already verified', function () { 69 | $user = User::factory()->create(); 70 | 71 | Notification::fake(); 72 | 73 | $this->actingAs($this->user) 74 | ->postJson(route('verification.resend', ['email' => $user->email])) 75 | ->assertStatus(422) 76 | ->assertJsonFragment(['errors' => ['email' => ['The email is already verified.']]]); 77 | 78 | Notification::assertNotSentTo($user, VerifyEmail::class); 79 | }); 80 | -------------------------------------------------------------------------------- /tests/Feature/Auth/PasswordResetTest.php: -------------------------------------------------------------------------------- 1 | create(); 11 | 12 | $this->postJson(route('forgot-password', ['email' => $user->email])); 13 | 14 | Notification::assertSentTo($user, ResetPassword::class); 15 | }); 16 | 17 | test('password can be reset with valid token', function () { 18 | Notification::fake(); 19 | 20 | $user = User::factory()->create(); 21 | 22 | $this->postJson(route('forgot-password', ['email' => $user->email])); 23 | 24 | Notification::assertSentTo($user, ResetPassword::class, function (object $notification) use ($user) { 25 | $response = $this->post(route('reset-password'), [ 26 | 'token' => $notification->token, 27 | 'email' => $user->email, 28 | 'password' => 'password', 29 | 'password_confirmation' => 'password', 30 | ]); 31 | 32 | $response 33 | ->assertSessionHasNoErrors() 34 | ->assertStatus(200); 35 | 36 | return true; 37 | }); 38 | }); 39 | -------------------------------------------------------------------------------- /tests/Feature/Auth/RegistrationTest.php: -------------------------------------------------------------------------------- 1 | postJson(route('register'), [ 8 | User::COLUMN_NAME => 'Test User', 9 | User::COLUMN_EMAIL => 'test@test.app', 10 | User::COLUMN_PASSWORD => 'Pa$$w0rd', 11 | 'password_confirmation' => 'Pa$$w0rd', 12 | ]) 13 | ->assertSuccessful(); 14 | 15 | if (new User instanceof MustVerifyEmail) { 16 | $response->assertJson(['status' => 'We have e-mailed your verification link!']); 17 | } else { 18 | $response->assertJsonStructure(['id', 'name', 'email']); 19 | } 20 | 21 | $this->assertDatabaseHas('users', [ 22 | User::COLUMN_NAME => 'Test User', 23 | User::COLUMN_EMAIL => 'test@test.app', 24 | ]); 25 | }); 26 | 27 | test('new user cannot register with existing email', function () { 28 | User::factory()->create(['email' => 'test@test.app']); 29 | 30 | $this->postJson(route('register'), [ 31 | 'name' => 'Test User', 32 | 'email' => 'test@test.app', 33 | 'password' => 'secret', 34 | 'password_confirmation' => 'secret', 35 | ]) 36 | ->assertStatus(422) 37 | ->assertJsonValidationErrors(['email']); 38 | }); 39 | -------------------------------------------------------------------------------- /tests/Feature/SettingsTest.php: -------------------------------------------------------------------------------- 1 | actingAs($this->user) 7 | ->patchJson(route('profile.update'), [ 8 | 'name' => 'Test User', 9 | 'email' => 'test@test.app', 10 | ]) 11 | ->assertSuccessful() 12 | ->assertJson(['type' => Controller::RESPONSE_TYPE_SUCCESS]); 13 | 14 | $this->assertDatabaseHas('users', [ 15 | 'id' => $this->user->id, 16 | 'name' => 'Test User', 17 | 'email' => 'test@test.app', 18 | ]); 19 | }); 20 | -------------------------------------------------------------------------------- /tests/Pest.php: -------------------------------------------------------------------------------- 1 | in('Feature'); 21 | 22 | /* 23 | |-------------------------------------------------------------------------- 24 | | Expectations 25 | |-------------------------------------------------------------------------- 26 | | 27 | | When you're writing tests, you often need to check that values meet certain conditions. The 28 | | "expect()" function gives you access to a set of "expectations" methods that you can use 29 | | to assert different things. Of course, you may extend the Expectation API at any time. 30 | | 31 | */ 32 | 33 | expect()->extend('toBeOne', function () { 34 | return $this->toBe(1); 35 | }); 36 | 37 | /* 38 | |-------------------------------------------------------------------------- 39 | | Functions 40 | |-------------------------------------------------------------------------- 41 | | 42 | | While Pest is very powerful out-of-the-box, you may have some testing code specific to your 43 | | project that you don't want to repeat in every file. Here you can also expose helpers as 44 | | global functions to help you to reduce the number of lines of code in your test files. 45 | | 46 | */ 47 | 48 | function something() 49 | { 50 | // .. 51 | } 52 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | user = User::factory()->create(); 24 | } 25 | 26 | public function actingAs(Authenticatable $user, $driver = null) 27 | { 28 | Sanctum::actingAs($user); 29 | 30 | return $this; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tests/Unit/ExampleTest.php: -------------------------------------------------------------------------------- 1 | toBeTrue(); 5 | }); 6 | -------------------------------------------------------------------------------- /vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import laravel from 'laravel-vite-plugin' 3 | import vue from '@vitejs/plugin-vue' 4 | 5 | export default defineConfig({ 6 | server: { 7 | hmr: { 8 | host: 'localhost', 9 | }, 10 | }, 11 | plugins: [ 12 | laravel({ 13 | input: [ 14 | 'resources/sass/app.scss', 15 | 'resources/js/app.js' 16 | ], 17 | refresh: [ 18 | 'resources/js/**', 19 | 'resources/sass/**', 20 | ], 21 | }), 22 | vue({ 23 | template: { 24 | transformAssetUrls: { 25 | base: null, 26 | includeAbsolute: false, 27 | }, 28 | }, 29 | }) 30 | ], 31 | resolve: { 32 | alias: [ 33 | { 34 | // this is required for the SCSS modules 35 | find: /^~(.*)$/, 36 | replacement: '$1', 37 | }, 38 | ], 39 | }, 40 | build: { 41 | target: 'esnext', 42 | chunkSizeWarningLimit: 1600, 43 | }, 44 | }) 45 | --------------------------------------------------------------------------------