├── .devcontainer ├── Dockerfile ├── README.md ├── devcontainer.json ├── docker-compose.yml └── ray.php ├── .editorconfig ├── .env.example ├── .eslintrc ├── .github └── workflows │ ├── larastan.yml │ ├── lint-js.yml │ ├── lint-php.yml │ ├── test-javascript.yml │ └── test-php.yml ├── .gitignore ├── .husky ├── .gitignore ├── check-changed.sh └── post-merge ├── .nvmrc ├── .vscode ├── extensions.json └── settings.json ├── app ├── Console │ └── Kernel.php ├── Exceptions │ └── Handler.php ├── Http │ ├── Controllers │ │ ├── AuthController.php │ │ ├── Controller.php │ │ └── SessionController.php │ ├── Kernel.php │ └── Middleware │ │ ├── Authenticate.php │ │ ├── EncryptCookies.php │ │ ├── PreventRequestsDuringMaintenance.php │ │ ├── RedirectIfAuthenticated.php │ │ ├── TrimStrings.php │ │ ├── TrustHosts.php │ │ ├── TrustProxies.php │ │ └── VerifyCsrfToken.php ├── Models │ ├── Provider.php │ └── User.php ├── Notifications │ └── LoginAttempt.php ├── Policies │ └── SessionPolicy.php └── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── BroadcastServiceProvider.php │ ├── EventServiceProvider.php │ └── RouteServiceProvider.php ├── artisan ├── bootstrap ├── app.php └── cache │ └── .gitignore ├── client ├── app.config.ts ├── app.vue ├── assets │ └── css │ │ ├── device.css │ │ └── main.css ├── components │ ├── README.md │ ├── contact │ │ ├── ContactCard.vue │ │ └── ContactCardSkeleton.vue │ ├── header │ │ ├── HeaderBar.vue │ │ ├── HeaderDarkMode.vue │ │ └── HeaderProfile.vue │ ├── layout │ │ ├── LayoutBreadCrumbs.vue │ │ ├── LayoutConfirm.vue │ │ └── LayoutLoginModal.vue │ ├── session │ │ ├── SessionDevice.vue │ │ ├── SessionDeviceSkeleton.vue │ │ └── SessionList.vue │ └── transition │ │ ├── TransitionDropdown.vue │ │ └── TransitionScaleIn.vue ├── composables │ ├── api.ts │ ├── confirm.ts │ ├── crumbs.ts │ ├── dayjs.ts │ ├── lnutils.ts │ ├── modal.ts │ └── utils.ts ├── lib │ ├── api.ts │ └── menu.ts ├── middleware │ ├── README.md │ └── auth.global.ts ├── pages │ ├── README.md │ ├── attempt │ │ └── [token].vue │ ├── gated.vue │ ├── index.vue │ └── sessions.vue ├── plugins │ └── icon.ts ├── public │ ├── README.md │ ├── devices.png │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── favicon.ico │ ├── icon.png │ ├── json │ │ └── darkMode.json │ └── laranuxt.png └── types │ ├── api.d.ts │ ├── frontend.d.ts │ ├── models.d.ts │ └── vue-shim.d.ts ├── 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 ├── services.php ├── session.php └── view.php ├── database ├── .gitignore ├── factories │ └── UserFactory.php ├── migrations │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2019_08_19_000000_create_failed_jobs_table.php │ └── 2021_10_20_233327_create_humble_tables.php └── seeders │ └── DatabaseSeeder.php ├── lang ├── en.json └── en │ ├── auth.php │ ├── pagination.php │ ├── passwords.php │ └── validation.php ├── nuxt.config.ts ├── package.json ├── phpstan.neon ├── pint.json ├── pnpm-lock.yaml ├── public ├── .htaccess ├── favicon.ico ├── index.php └── robots.txt ├── readme.md ├── resources ├── laranuxt.gif ├── laranuxt.png └── views │ ├── complete.blade.php │ └── emails │ └── user │ └── attempt.blade.php ├── routes ├── api.php ├── channels.php └── console.php ├── server.php ├── storage ├── app │ ├── .gitignore │ └── public │ │ └── .gitignore ├── framework │ ├── .gitignore │ ├── cache │ │ ├── .gitignore │ │ └── data │ │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ ├── testing │ │ └── .gitignore │ └── views │ │ └── .gitignore └── logs │ └── .gitignore ├── tests ├── js │ ├── app.spec.ts │ ├── components │ │ └── contact │ │ │ ├── ContactCard.spec.ts │ │ │ ├── ContactCardSkeleton.spec.ts │ │ │ └── __snapshots__ │ │ │ ├── ContactCard.spec.ts.snap │ │ │ └── ContactCardSkeleton.spec.ts.snap │ └── composables │ │ └── crumbs.spec.ts └── php │ ├── CreatesApplication.php │ ├── Feature │ └── ExampleTest.php │ ├── TestCase.php │ ├── Unit │ └── ExampleTest.php │ └── phpunit.xml ├── tsconfig.json └── vitest.config.ts /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 2 | 3 | ARG USERNAME=vscode 4 | ARG USER_UID=1000 5 | ARG USER_GID=$USER_UID 6 | 7 | ENV DEBIAN_FRONTEND=noninteractive 8 | 9 | ENV NODE_VERSION 16.13.0 10 | ENV NVM_DIR /usr/local/nvm 11 | ENV PATH $NVM_DIR/versions/node/$NODE_VERSION/bin:$PATH 12 | RUN mkdir -p $NVM_DIR 13 | 14 | # Install dependencies 15 | RUN apt-get -y update --no-install-recommends \ 16 | && apt-get -y install --no-install-recommends \ 17 | build-essential \ 18 | curl \ 19 | ca-certificates \ 20 | apt-utils \ 21 | dialog \ 22 | git \ 23 | openssh-server \ 24 | && apt-get autoremove -y \ 25 | && apt-get clean -y 26 | 27 | # PHP 28 | RUN apt-get -y update && apt-get -y upgrade \ 29 | && apt-get -y install software-properties-common \ 30 | && add-apt-repository ppa:ondrej/php \ 31 | && apt-get -y update \ 32 | && apt-get -y install php8.3 php8.3-gd php8.3-xml php8.3-soap php8.3-mbstring php8.3-mysql php8.3-pgsql php8.3-dev php8.3-zip php8.3-curl 33 | 34 | # XDEBUG Setup 35 | RUN echo "xdebug.mode = develop,debug" >> /etc/php/8.3/cli/conf.d/20-xdebug.ini \ 36 | && echo "xdebug.start_with_request = yes" >> /etc/php/8.3/cli/conf.d/20-xdebug.ini \ 37 | && echo "xdebug.client_host = localhost" >> /etc/php/8.3/cli/conf.d/20-xdebug.ini \ 38 | && echo "xdebug.discover_client_host=1" >> /etc/php/8.3/cli/conf.d/20-xdebug.ini \ 39 | && echo "xdebug.client_port = 9003" >> /etc/php/8.3/cli/conf.d/20-xdebug.ini \ 40 | && echo "xdebug.log = /var/log/xdebug.log" >> /etc/php/8.3/cli/conf.d/20-xdebug.ini 41 | 42 | RUN touch /var/log/xdebug.log 43 | 44 | # Yarn 45 | RUN curl https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - 46 | RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list 47 | RUN apt-get update && apt-get install -y yarn 48 | 49 | # Composer 50 | RUN cd ~ 51 | RUN curl -sS https://getcomposer.org/installer -o composer-setup.php \ 52 | && HASH=`curl -sS https://composer.github.io/installer.sig` \ 53 | && php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \ 54 | && php composer-setup.php --install-dir=/usr/local/bin --filename=composer 55 | 56 | # Nvm & Node 57 | RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash 58 | RUN /bin/bash -c "source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION" 59 | ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules 60 | ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH 61 | 62 | # Set User and Group 63 | RUN groupadd --gid $USER_GID $USERNAME \ 64 | && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME 65 | 66 | # Set Xdebug logging file 67 | RUN chown $USER_UID:$USER_GID /var/log/xdebug.log 68 | 69 | ENV DEBIAN_FRONTEND=dialog 70 | 71 | USER $USERNAME 72 | -------------------------------------------------------------------------------- /.devcontainer/README.md: -------------------------------------------------------------------------------- 1 | # Dev Container 2 | 3 | 4 | ## Running Dev Container 5 | 6 | If you need/prefer the option you can build and use this template within a Dev Container, which you can run locally or with GitHub Codespaces. 7 | 8 | To build and run locally you must first have docker and docker compose installed for your OS. 9 | 10 | Once you have those installed you can click on the prompt: 11 | 12 | ![image](https://user-images.githubusercontent.com/25044744/184038681-593065e5-f4d5-4aa2-bbe4-3da157a2c39d.png) 13 | 14 | Or by using the option in VSCode: 15 | 16 | ![image](https://user-images.githubusercontent.com/25044744/184038895-fa330419-29bb-4a01-a58e-c4ea70503910.png) 17 | ![image](https://user-images.githubusercontent.com/25044744/184038953-000377c6-627e-4c5a-b9fd-f46a49325b95.png) 18 | 19 | 20 | ## Configuring Dev Container 21 | 22 | After you click to run the app within a dev container you need to make sure your application `.env` is setup to use the proper configuration. 23 | 24 | This means updating the following: 25 | 26 | 1. Database Connection 27 | 2. Mailer 28 | 29 | > The DB connection your `.env` should match the following: 30 | 31 | ``` 32 | DB_CONNECTION=mysql 33 | DB_HOST=mysql 34 | DB_PORT=3306 35 | DB_DATABASE=laranuxt 36 | DB_USERNAME=root 37 | DB_PASSWORD=password 38 | ``` 39 | 40 | > And if you are using Mailhog as a development mail server: 41 | 42 | ``` 43 | MAIL_MAILER=smtp 44 | MAIL_HOST=mailhog 45 | MAIL_PORT=1025 46 | MAIL_USERNAME=null 47 | MAIL_PASSWORD=null 48 | MAIL_ENCRYPTION=null 49 | MAIL_FROM_ADDRESS="hello@example.com" 50 | MAIL_FROM_NAME="${APP_NAME}" 51 | ``` 52 | 53 | These `.env` entires are important to update since the HOST must match what was configured in the dockerize'd environment. Otherwise your database and mail server will not get connected. 54 | 55 | 56 | ## Dev Container Extras 57 | 58 | To use tools like Spatie Ray you need to configure the dev container to do so. 59 | 60 | First copy the `ray.php` file and add it to the root of this apps directory. 61 | 62 | ```bash 63 | cp .devcontainer/ray.php ray.php 64 | ``` 65 | 66 | Next within your `.env` add the following entires: 67 | 68 | > Keep in mind the value `RAY_LOCAL_PATH` should be set to your machines full path to the app. 69 | ``` 70 | RAY_HOST=host.docker.internal 71 | RAY_REMOTE_PATH=/workspace 72 | 73 | # Set this to your working directory 74 | RAY_LOCAL_PATH=/path/to/working/folder 75 | ``` 76 | 77 | ## Additional configuration 78 | 79 | If you need to change any of the ports the dev container needs to map to you can add the following to your `.env` 80 | 81 | ``` 82 | DOCKER_PORT_MYSQL 83 | DOCKER_PORT_MAILHOG_1 84 | DOCKER_PORT_MAILHOG_2 85 | ``` 86 | 87 | Then set the value equal to the port you want it to run at. 88 | 89 | For example if the mysql port of 3306 will not work for your locally, maybe you have another instance running. 90 | 91 | You may set it to the value you want: 92 | 93 | > To run instead at port 13306 94 | 95 | ``` 96 | DOCKER_PORT_MYSQL=13306 97 | ``` 98 | 99 | ## After Dev Container Build 100 | 101 | Once the Dev Container successfully built you can run your typically `artisan`/`composer`/`yarn` commands. 102 | 103 | We suggest after everything is built opening up 2 integrated terminals. 104 | 105 | > To migrate and seed container database & To run API server 106 | 1. One to run `yarn seed` && `yarn api` 107 | 108 | > To run Nuxt server 109 | 2. `yarn dev` 110 | 111 | 112 | But before both if this is the first time building the app you would still need to: 113 | 114 | ```bash 115 | composer install && yarn install 116 | ``` 117 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Laranuxt VSCode Container", 3 | "dockerComposeFile": "docker-compose.yml", 4 | "service": "app", 5 | "workspaceFolder": "/workspace", 6 | "remoteEnv": { 7 | "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}" 8 | }, 9 | "settings": { 10 | "terminal.integrated.shell.linux": "/bin/bash" 11 | }, 12 | "extensions": [ 13 | "editorconfig.editorconfig" 14 | ], 15 | "forwardPorts": [ 16 | 8000, 17 | 3000, 18 | 9003 19 | ], 20 | "remoteUser": "vscode" 21 | } 22 | -------------------------------------------------------------------------------- /.devcontainer/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | x-environment: &default-environment 4 | MYSQL_ROOT_PASSWORD: "password" 5 | MYSQL_DATABSE: "laranuxt" 6 | services: 7 | mysql: 8 | container_name: mysql_container_laranuxt 9 | image: mysql 10 | platform: linux/x86_64 11 | restart: unless-stopped 12 | ports: 13 | - "${DOCKER_PORT_MYSQL:-3306}:3306" 14 | environment: 15 | MYSQL_ROOT_PASSWORD: '${DB_PASSWORD:-password}' 16 | MYSQL_DATABASE: '${DB_DATABASE:-laranuxt}' 17 | volumes: 18 | - mysql-data:/var/lib/mysql 19 | mailhog: 20 | image: mailhog/mailhog:latest 21 | container_name: mailhog_container_punchlist 22 | ports: 23 | - "${DOCKER_PORT_MAILHOG_1:-1025}:1025" 24 | - "${DOCKER_PORT_MAILHOG_2:-8025}:8025" 25 | app: 26 | container_name: app_container_laranuxt 27 | build: 28 | context: .. 29 | dockerfile: .devcontainer/Dockerfile 30 | environment: 31 | <<: *default-environment 32 | PORTS: 33 | 3000 34 | 8000 35 | 9003 36 | volumes: 37 | - ..:/workspace 38 | user: vscode 39 | command: sleep infinity 40 | extra_hosts: 41 | - "host.docker.internal:host-gateway" 42 | volumes: 43 | mysql-data: 44 | -------------------------------------------------------------------------------- /.devcontainer/ray.php: -------------------------------------------------------------------------------- 1 | env('RAY_ENABLED', true), 10 | 11 | /** 12 | * When enabled, all things logged to the application log 13 | * will be sent to Ray as well. 14 | */ 15 | 'send_log_calls_to_ray' => env('SEND_LOG_CALLS_TO_RAY', true), 16 | 17 | /** 18 | * When enabled, all things passed to `dump` or `dd` 19 | * will be sent to Ray as well. 20 | */ 21 | 'send_dumps_to_ray' => env('SEND_DUMPS_TO_RAY', true), 22 | 23 | /** 24 | * The host used to communicate with the Ray app. 25 | * For usage in Docker on Mac or Windows, you can replace host with 'host.docker.internal' 26 | * For usage in Homestead on Mac or Windows, you can replace host with '10.0.2.2' 27 | */ 28 | 'host' => env('RAY_HOST', 'localhost'), 29 | 30 | /** 31 | * The port number used to communicate with the Ray app. 32 | */ 33 | 'port' => env('RAY_PORT', 23517), 34 | 35 | /** 36 | * Absolute base path for your sites or projects in Homestead, 37 | * Vagrant, Docker, or another remote development server. 38 | */ 39 | 'remote_path' => env('RAY_REMOTE_PATH', null), 40 | 41 | /** 42 | * Absolute base path for your sites or projects on your local 43 | * computer where your IDE or code editor is running on. 44 | */ 45 | 'local_path' => env('RAY_LOCAL_PATH', null), 46 | ]; 47 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.php] 15 | charset = utf-8 16 | end_of_line = lf 17 | insert_final_newline = true 18 | indent_style = space 19 | indent_size = 4 20 | trim_trailing_whitespace = true 21 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laranuxt 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | API_URL=http://localhost:8000 7 | WEB_URL=http://localhost:3000 8 | IGNITION_THEME=dark 9 | 10 | LOG_CHANNEL=stack 11 | 12 | DB_CONNECTION=mysql 13 | DB_HOST=127.0.0.1 14 | DB_PORT=3306 15 | DB_DATABASE=laranuxt 16 | DB_USERNAME=root 17 | DB_PASSWORD= 18 | 19 | BROADCAST_DRIVER=log 20 | CACHE_DRIVER=array 21 | QUEUE_CONNECTION=sync 22 | SESSION_DRIVER=file 23 | SESSION_LIFETIME=120 24 | 25 | # Example Email Using Mailhog 26 | MAIL_MAILER=smtp 27 | MAIL_HOST=0.0.0.0 28 | MAIL_PORT=1025 29 | MAIL_USERNAME=null 30 | MAIL_PASSWORD=null 31 | MAIL_ENCRYPTION=null 32 | 33 | AWS_ACCESS_KEY_ID= 34 | AWS_SECRET_ACCESS_KEY= 35 | AWS_DEFAULT_REGION=us-east-1 36 | AWS_BUCKET= 37 | 38 | PUSHER_APP_ID= 39 | PUSHER_APP_KEY= 40 | PUSHER_APP_SECRET= 41 | PUSHER_APP_CLUSTER=mt1 42 | 43 | GOOGLE_CLIENT_ID=104771318401-qthv7ou0a07bg2f4osotih40n5ituohh.apps.googleusercontent.com 44 | GOOGLE_CLIENT_SECRET=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 45 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": ["@antfu"] 4 | } 5 | -------------------------------------------------------------------------------- /.github/workflows/larastan.yml: -------------------------------------------------------------------------------- 1 | name: Larastan 2 | on: 3 | push: 4 | branches-ignore: 5 | - staging 6 | - production 7 | paths: 8 | - "**.php" 9 | - "!client/**" 10 | jobs: 11 | stan: 12 | runs-on: ubuntu-latest 13 | strategy: 14 | fail-fast: true 15 | matrix: 16 | php: [8.3] 17 | 18 | name: PHP Version:${{ matrix.php }} 19 | steps: 20 | - name: Checkout 21 | uses: actions/checkout@v3 22 | 23 | - name: Setup PHP 24 | uses: shivammathur/setup-php@v2 25 | with: 26 | php-version: ${{ matrix.php }} 27 | coverage: none 28 | tools: composer, cs2pr 29 | 30 | - name: Get Composer cache directory 31 | id: composer-cache 32 | run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT 33 | 34 | - name: Setup cache 35 | uses: pat-s/always-upload-cache@v1.1.4 36 | with: 37 | path: ${{ steps.composer-cache.outputs.dir }} 38 | key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} 39 | restore-keys: ${{ runner.os }}-composer- 40 | 41 | - name: Install dependencies 42 | run: composer install --prefer-dist --no-suggest --no-progress 43 | 44 | - name: Detect Larastan violations 45 | run: vendor/bin/phpstan analyse --error-format=checkstyle | cs2pr 46 | -------------------------------------------------------------------------------- /.github/workflows/lint-js.yml: -------------------------------------------------------------------------------- 1 | name: Lint Javascript 2 | on: 3 | push: 4 | branches-ignore: 5 | - staging 6 | - production 7 | paths: 8 | - "client/**" 9 | jobs: 10 | eslint: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout 14 | uses: actions/checkout@v3 15 | 16 | - name: Get yarn cache directory path 17 | id: yarn-cache-dir-path 18 | run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT 19 | 20 | - uses: actions/cache@v2 21 | id: yarn-cache 22 | with: 23 | path: ${{ steps.yarn-cache-dir-path.outputs.dir }} 24 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 25 | restore-keys: | 26 | ${{ runner.os }}-yarn- 27 | 28 | - name: Install Dependencies 29 | run: yarn 30 | 31 | - name: Build 32 | run: yarn build 33 | 34 | - name: Run Eslint 35 | run: yarn lint 36 | -------------------------------------------------------------------------------- /.github/workflows/lint-php.yml: -------------------------------------------------------------------------------- 1 | name: Lint PHP 2 | on: 3 | push: 4 | branches-ignore: 5 | - staging 6 | - production 7 | paths: 8 | - "**.php" 9 | - "!client/**" 10 | jobs: 11 | phpcs: 12 | runs-on: ubuntu-latest 13 | strategy: 14 | fail-fast: true 15 | matrix: 16 | php: [8.3] 17 | 18 | name: PHP Version:${{ matrix.php }} 19 | 20 | steps: 21 | - name: Checkout 22 | uses: actions/checkout@v3 23 | 24 | - name: Setup PHP 25 | uses: shivammathur/setup-php@v2 26 | with: 27 | php-version: ${{ matrix.php }} 28 | coverage: none 29 | tools: composer, cs2pr 30 | 31 | - name: Get Composer cache directory 32 | id: composer-cache 33 | run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT 34 | 35 | - name: Setup cache 36 | uses: pat-s/always-upload-cache@v1.1.4 37 | with: 38 | path: ${{ steps.composer-cache.outputs.dir }} 39 | key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} 40 | restore-keys: ${{ runner.os }}-composer- 41 | 42 | - name: Install dependencies 43 | run: composer install --prefer-dist --no-suggest --no-progress 44 | 45 | - name: Detect coding standard violations 46 | run: vendor/bin/pint --test --format=checkstyle | cs2pr 47 | -------------------------------------------------------------------------------- /.github/workflows/test-javascript.yml: -------------------------------------------------------------------------------- 1 | name: Test Javascript 2 | on: 3 | push: 4 | branches-ignore: 5 | - staging 6 | - production 7 | paths: 8 | - '**.vue' 9 | - '**.ts' 10 | - '**.tsx' 11 | jobs: 12 | test: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - 16 | uses: actions/checkout@v3 17 | - name: Get yarn cache directory path 18 | id: yarn-cache-dir-path 19 | run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT 20 | - uses: actions/cache@v1 21 | id: yarn-cache 22 | with: 23 | path: ${{ steps.yarn-cache-dir-path.outputs.dir }} 24 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 25 | restore-keys: | 26 | ${{ runner.os }}-yarn- 27 | 28 | - name: Install our dependencies 29 | run: yarn 30 | 31 | - name: Build 32 | run: yarn build 33 | 34 | - name: Run Jest 35 | run: yarn test:coverage 36 | -------------------------------------------------------------------------------- /.github/workflows/test-php.yml: -------------------------------------------------------------------------------- 1 | name: Test PHP 2 | on: 3 | push: 4 | branches-ignore: 5 | - staging 6 | - production 7 | paths: 8 | - "**.php" 9 | - "!client/**" 10 | jobs: 11 | test: 12 | runs-on: ubuntu-latest 13 | 14 | strategy: 15 | fail-fast: true 16 | matrix: 17 | php: [8.3] 18 | 19 | name: PHP Version:${{ matrix.php }} 20 | 21 | steps: 22 | - name: "MySQL - tweak mysql" 23 | run: | 24 | echo "[mysqld]" | sudo tee -a /etc/mysql/conf.d/mysql.cnf > /dev/null 25 | echo "skip-grant-tables" | sudo tee -a /etc/mysql/conf.d/mysql.cnf > /dev/null 26 | 27 | - name: MySQL - restart and add database 28 | run: | 29 | sudo service mysql restart 30 | mysql -u root -e "CREATE DATABASE IF NOT EXISTS \`test-laranuxt\`" 31 | 32 | - name: Checkout 33 | uses: actions/checkout@v3 34 | 35 | - name: Setup PHP 36 | uses: shivammathur/setup-php@v2 37 | with: 38 | php-version: ${{ matrix.php }} 39 | extensions: mbstring, intl, pdo_mysql, zip, gd, exif, pcntl, bcmath, ctype, fileinfo, json, tokenizer, xml, dom, curl, iconv, openssl, readline, sockets, zip, zlib 40 | coverage: xdebug 41 | tools: composer:v2 42 | 43 | - name: Get Composer Cache Directory 44 | id: composer-cache 45 | run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT 46 | 47 | - uses: actions/cache@v1 48 | with: 49 | path: ${{ steps.composer-cache.outputs.dir }} 50 | key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} 51 | restore-keys: | 52 | ${{ runner.os }}-composer- 53 | 54 | - name: Install Dependencies 55 | run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist 56 | 57 | - name: Run phpunit 58 | run: XDEBUG_MODE=coverage vendor/bin/phpunit --color=always --testdox --coverage-text --coverage-html coverage/ -c tests/php/phpunit.xml 59 | 60 | - uses: actions/upload-artifact@v2 61 | with: 62 | name: coverage-html 63 | path: coverage/ 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Laravel 4 | 5 | /node_modules 6 | /public/hot 7 | /public/storage 8 | /storage/*.key 9 | storage/debugbar 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 | _ide_helper.php 19 | _ide_helper_models.php 20 | .phpstorm.meta.php 21 | 22 | # Laravel Vapor 23 | .vapor/ 24 | .env.production 25 | .env.staging 26 | 27 | 28 | ## Nuxt.js 29 | # Created by .ignore support plugin (hsz.mobi) 30 | 31 | 32 | # nuxt-storm 33 | .components.gen.js 34 | 35 | ### Node template 36 | # Logs 37 | /logs 38 | *.log 39 | npm-debug.log* 40 | yarn-debug.log* 41 | yarn-error.log* 42 | 43 | # Runtime data 44 | pids 45 | *.pid 46 | *.seed 47 | *.pid.lock 48 | 49 | # Directory for instrumented libs generated by jscoverage/JSCover 50 | lib-cov 51 | 52 | # Coverage directory used by tools like istanbul 53 | coverage 54 | 55 | # nyc test coverage 56 | .nyc_output 57 | 58 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 59 | .grunt 60 | 61 | # Bower dependency directory (https://bower.io/) 62 | bower_components 63 | 64 | # node-waf configuration 65 | .lock-wscript 66 | 67 | # Compiled binary addons (https://nodejs.org/api/addons.html) 68 | build/Release 69 | 70 | # Dependency directories 71 | node_modules/ 72 | jspm_packages/ 73 | 74 | # TypeScript v1 declaration files 75 | typings/ 76 | 77 | # Optional npm cache directory 78 | .npm 79 | 80 | # Optional eslint cache 81 | .eslintcache 82 | 83 | # Optional REPL history 84 | .node_repl_history 85 | 86 | # Output of 'npm pack' 87 | *.tgz 88 | 89 | # Yarn Integrity file 90 | .yarn-integrity 91 | 92 | # dotenv environment variables file 93 | .env 94 | 95 | # nuxt.js build output 96 | .output 97 | .nuxt 98 | 99 | # Nuxt generate 100 | dist 101 | # IDE / Editor 102 | .idea 103 | .fleet 104 | 105 | # Service worker 106 | sw.* 107 | 108 | # macOS 109 | .DS_Store 110 | 111 | # Vim swap files 112 | *.swp 113 | -------------------------------------------------------------------------------- /.husky/.gitignore: -------------------------------------------------------------------------------- 1 | _ 2 | -------------------------------------------------------------------------------- /.husky/check-changed.sh: -------------------------------------------------------------------------------- 1 | function changed { 2 | git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD | grep "^$1" > /dev/null 2>&1 3 | } 4 | 5 | if changed 'yarn.lock'; then 6 | echo -ne '\u000a\u001b[31mNOTICE:\u001b[m \u001b[33mDetected a change in \u001b[37myarn.lock\u001b[33m. Update dependencies by running \u001b[36myarn\u001b[m\u000a' 7 | fi 8 | 9 | if changed 'composer.lock'; then 10 | echo -ne '\u000a\u001b[31mNOTICE:\u001b[m \u001b[33mDetected a change in \u001b[37mcomposer.lock\u001b[33m. Update dependencies by running \u001b[36mcomposer install\u001b[m\u000a' 11 | fi 12 | 13 | if changed 'database/factories/'; then 14 | echo -ne '\u000a\u001b[31mNOTICE:\u001b[m \u001b[33mDetected a change in \u001b[37mdatabase/factories\u001b[33m. Update database by running \u001b[36myarn seed\u001b[m\u000a' 15 | fi 16 | 17 | if changed 'database/migrations/'; then 18 | echo -ne '\u000a\u001b[31mNOTICE:\u001b[m \u001b[33mDetected a change in \u001b[37mdatabase/migrations\u001b[33m. Update database by running \u001b[36myarn seed\u001b[m\u000a' 19 | fi 20 | 21 | if changed 'database/seeders/'; then 22 | echo -ne '\u000a\u001b[31mNOTICE:\u001b[m \u001b[33mDetected a change in \u001b[37mdatabase/seeders\u001b[33m. Update database by running \u001b[36myarn seed\u001b[m\u000a' 23 | fi 24 | 25 | exit 0 26 | -------------------------------------------------------------------------------- /.husky/post-merge: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PARENT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) 4 | 5 | if [[ "$OSTYPE" == "darwin"* ]]; then 6 | zsh $PARENT_PATH/check-changed.sh 7 | else 8 | bash $PARENT_PATH/check-changed.sh 9 | fi 10 | 11 | exit 0 12 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 16 2 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "editorconfig.editorconfig", 4 | "dbaeumer.vscode-eslint", 5 | "henrynguyen5-vsc.vsc-nvm", 6 | "ms-vscode.vscode-typescript-next", 7 | "open-southeners.laravel-pint", 8 | "Vue.volar", 9 | "Vue.vscode-typescript-vue-plugin", 10 | "emeraldwalk.RunOnSave", 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "*.css": "tailwindcss" 4 | }, 5 | "editor.quickSuggestions": { 6 | "strings": true 7 | }, 8 | "prettier.enable": false, 9 | "editor.formatOnSave": false, 10 | "editor.codeActionsOnSave": { 11 | "source.fixAll.eslint": "explicit" 12 | }, 13 | "emeraldwalk.runonsave": { 14 | "commands": [ 15 | { 16 | "match": "\\.php$", 17 | "isAsync": true, 18 | "cmd": "./vendor/bin/pint ${file}" 19 | }, 20 | ] 21 | }, 22 | } 23 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | protected $commands = [ 16 | // 17 | ]; 18 | 19 | /** 20 | * Define the application's command schedule. 21 | * 22 | * @return void 23 | */ 24 | protected function schedule(Schedule $schedule) 25 | { 26 | // $schedule->command('inspire')->hourly(); 27 | } 28 | 29 | /** 30 | * Register the commands for the application. 31 | */ 32 | protected function commands(): void 33 | { 34 | $this->load(__DIR__ . '/Commands'); 35 | 36 | require base_path('routes/console.php'); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | > 14 | */ 15 | protected $dontReport = [ 16 | // 17 | ]; 18 | 19 | /** 20 | * A list of the inputs that are never flashed for validation exceptions. 21 | * 22 | * @var array 23 | */ 24 | protected $dontFlash = [ 25 | 'password', 26 | 'password_confirmation', 27 | ]; 28 | 29 | /** 30 | * Register the exception handling callbacks for the application. 31 | * 32 | * @return void 33 | */ 34 | public function register() 35 | { 36 | // 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/Http/Controllers/AuthController.php: -------------------------------------------------------------------------------- 1 | error('auth.provider-invalid'); 23 | } 24 | 25 | return Socialite::driver($provider)->stateless()->redirect(); 26 | } 27 | 28 | /* 29 | public function onetap(string $credential) 30 | { 31 | $client = new Client(['client_id' => config('services.google.client_id')]); 32 | $oaUser = (object) $client->verifyIdToken($credential); 33 | if (!isset($oaUser->sub)) { 34 | return $this->error('auth.provider-invalid'); 35 | } 36 | $user = $this->oaHandle($oaUser, 'google'); 37 | 38 | // @var User $user 39 | auth()->login($user, 'google'); 40 | 41 | return $this->render([ 42 | 'token' => auth()->token(), 43 | 'user' => auth()->user(), 44 | ])->cookie('token', auth()->token(), 0, ''); 45 | } 46 | */ 47 | 48 | /** 49 | * Callback hit by the provider to verify user 50 | */ 51 | public function callback(string $provider, Request $request): Response 52 | { 53 | if (! in_array($provider, Provider::$allowed)) { 54 | return $this->error('auth.generic'); 55 | } 56 | 57 | $oaUser = Socialite::driver($provider)->stateless()->user(); 58 | 59 | $user = $this->oaHandle($oaUser, $provider); 60 | 61 | /** @var Authenticatable $user */ 62 | auth()->login($user, $provider); 63 | 64 | return $this->response($provider); 65 | } 66 | 67 | /** 68 | * Handle the login/creation process of a user 69 | * 70 | * @param mixed $oaUser 71 | */ 72 | private function oaHandle($oaUser, string $provider): User 73 | { 74 | if (! $user = User::where('email', $oaUser->email)->first()) { 75 | $user = $this->createUser( 76 | $provider, 77 | $oaUser->name, 78 | $oaUser->email, 79 | $oaUser->picture ?? $oaUser->avatar_original ?? $oaUser->avatar, 80 | (array) $oaUser 81 | ); 82 | } 83 | 84 | if ($user->avatar === null) { 85 | $user->avatar = $oaUser->picture ?? $oaUser->avatar_original ?? $oaUser->avatar; 86 | $user->save(); 87 | } 88 | 89 | if (! $user->providers->where('name', $provider)->first()) { 90 | Provider::create( 91 | [ 92 | 'user_id' => $user->id, 93 | 'name' => $provider, 94 | 'avatar' => $oaUser->picture ?? $oaUser->avatar_original ?? $oaUser->avatar, 95 | 'payload' => (array) $oaUser, 96 | ] 97 | ); 98 | } 99 | 100 | return $user; 101 | } 102 | 103 | private function response(string $provider): Response 104 | { 105 | return response( 106 | view('complete', [ 107 | 'json' => json_encode([ 108 | 'token' => auth()->token(), 109 | 'user' => auth()->user(), 110 | 'provider' => $provider, 111 | ]), 112 | ]) 113 | )->cookie('token', auth()->token(), 60 * 24 * 30, '/', '', true, false); 114 | } 115 | 116 | /** 117 | * Create new users with their initial team 118 | * 119 | * @param array $payload 120 | */ 121 | private function createUser(string $provider, string $name, string $email, string $avatar, array $payload): User 122 | { 123 | $user = User::create([ 124 | 'name' => $name, 125 | 'email' => $email, 126 | 'avatar' => $avatar, 127 | ]); 128 | Provider::create([ 129 | 'user_id' => $user->id, 130 | 'name' => $provider, 131 | 'avatar' => $avatar, 132 | 'payload' => $payload, 133 | ]); 134 | 135 | return $user; 136 | } 137 | 138 | /** 139 | * Login attempt via e-mail 140 | */ 141 | public function attempt(Request $request): Response|JsonResponse 142 | { 143 | $this 144 | ->option('email', 'required|email') 145 | ->option('action', 'nullable|string') 146 | ->verify(); 147 | 148 | if (! $user = User::where('email', $request->email)->first()) { 149 | $user = $this->createUser( 150 | 'email', 151 | explode('@', $request->email)[0], 152 | $request->email, 153 | 'https://www.gravatar.com/avatar/' . md5($request->email), 154 | [] 155 | ); 156 | } 157 | 158 | $attempt = auth()->attempt($user, json_decode($request->action)); 159 | $user->notify(new LoginAttempt($attempt)); 160 | 161 | return $this->success('auth.attempt'); 162 | } 163 | 164 | /** 165 | * Verify the link clicked in the e-mail 166 | */ 167 | public function login(string $token): Response|JsonResponse 168 | { 169 | if (! $login = auth()->verify($token)) { 170 | return $this->error('auth.failed'); 171 | } 172 | 173 | return $this->render([ 174 | 'token' => auth()->token(), 175 | 'user' => auth()->user(), 176 | 'action' => $login->action, // @phpstan-ignore-line 177 | ])->cookie('token', auth()->token(), 60 * 24 * 30, '/', '', true, false); 178 | } 179 | 180 | /** 181 | * Standard user info auth check 182 | */ 183 | public function me(Request $request): Response|JsonResponse 184 | { 185 | $this 186 | ->option('providers', 'boolean') 187 | ->verify(); 188 | 189 | if ($request->providers) { 190 | return $this->render(User::whereId(auth()->user()?->id)->with(['providers'])->first()); 191 | } 192 | auth()->user()?->session->touch(); 193 | 194 | return $this->render(auth()->user()); 195 | } 196 | 197 | /** 198 | * Update user info 199 | * 200 | * @return Response|JsonResponse 201 | */ 202 | public function update(Request $request) 203 | { 204 | $this 205 | ->option('name', 'required|string') 206 | ->option('avatar', 'required|url') 207 | ->verify(); 208 | 209 | /** @var User $user */ 210 | $user = auth()->user(); 211 | 212 | $user->name ??= $request->name; 213 | $user->avatar ??= $request->avatar; 214 | $user->save(); 215 | 216 | return $this->success('user.updated'); 217 | } 218 | 219 | /** 220 | * Log a user out 221 | */ 222 | public function logout(): Response|JsonResponse 223 | { 224 | auth()->logout(); 225 | 226 | return $this->success('auth.logout')->cookie('token', false, 0, '/', '', true, false); 227 | } 228 | } 229 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | metApiInit($request); 29 | } 30 | 31 | /** 32 | * Display our routes 33 | */ 34 | public function routes(): string 35 | { 36 | Artisan::call('route:list --json'); 37 | $routes = json_decode(Artisan::output()); 38 | $html = <<<'TABLE' 39 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | TABLE; 67 | 68 | foreach ($routes as $route) { 69 | $html .= << 71 | 72 | 73 | 74 | 75 | 76 | BODY; 77 | } 78 | $html .= '
MethodURINameAction
$route->method $route->uri $route->name $route->action
'; 79 | 80 | return $html; 81 | } 82 | 83 | /** 84 | * Example endpoint returning random users 85 | */ 86 | public function example(Request $request): Response|JsonResponse 87 | { 88 | if (! app()->environment('testing')) { 89 | sleep(1); 90 | } 91 | 92 | $this 93 | ->option('count', 'required|integer') 94 | ->verify(); 95 | 96 | $faker = Factory::create(); 97 | $users = []; 98 | 99 | for ($i = 0; $i !== (int) $request->get('count'); $i++) { 100 | $email = $faker->unique()->safeEmail; 101 | $users[] = [ 102 | 'name' => $faker->name(), 103 | 'job' => $faker->jobTitle, 104 | 'email' => $email, 105 | 'avatar' => 'https://api.multiavatar.com/' . $email . '.svg', 106 | ]; 107 | } 108 | 109 | return $this->render($users); 110 | } 111 | 112 | public function exampleError(): Response|JsonResponse 113 | { 114 | // @phpstan-ignore-next-line 115 | return $this->render(['forced_error' => $forced_error]); 116 | } 117 | 118 | public function auth(): Redirector|Application|RedirectResponse 119 | { 120 | return redirect(config('app.web')); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /app/Http/Controllers/SessionController.php: -------------------------------------------------------------------------------- 1 | render(Session::whereUserId(auth()->user()?->id)->get()); 20 | } 21 | 22 | /** 23 | * Remove the specified resource from storage. 24 | * 25 | * 26 | * @throws AuthorizationException 27 | */ 28 | public function destroy(Session $session): JsonResponse|Response 29 | { 30 | $this->authorize('delete', $session); 31 | $session->delete(); 32 | 33 | return $this->success('auth.session-removed'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/Http/Kernel.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | protected $middleware = [ 17 | // \App\Http\Middleware\TrustHosts::class, 18 | \App\Http\Middleware\TrustProxies::class, 19 | \Illuminate\Http\Middleware\HandleCors::class, 20 | \App\Http\Middleware\PreventRequestsDuringMaintenance::class, 21 | \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, 22 | \App\Http\Middleware\TrimStrings::class, 23 | \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, 24 | ]; 25 | 26 | /** 27 | * The application's route middleware groups. 28 | * 29 | * @var array> 30 | */ 31 | protected $middlewareGroups = [ 32 | 'web' => [ 33 | \App\Http\Middleware\EncryptCookies::class, 34 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 35 | \Illuminate\Session\Middleware\StartSession::class, 36 | // \Illuminate\Session\Middleware\AuthenticateSession::class, 37 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 38 | \App\Http\Middleware\VerifyCsrfToken::class, 39 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 40 | ], 41 | 42 | 'api' => [ 43 | 'throttle:api', 44 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 45 | ], 46 | ]; 47 | 48 | /** 49 | * The application's route middleware. 50 | * 51 | * These middleware may be assigned to groups or used individually. 52 | * 53 | * @var array 54 | */ 55 | protected $middlewareAliases = [ 56 | 'auth' => \App\Http\Middleware\Authenticate::class, 57 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 58 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 59 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 60 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 61 | 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 62 | 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 63 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 64 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 65 | ]; 66 | } 67 | -------------------------------------------------------------------------------- /app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | expectsJson()) { 18 | return route('login'); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/PreventRequestsDuringMaintenance.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 24 | return redirect(RouteServiceProvider::HOME); 25 | } 26 | } 27 | 28 | return $next($request); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | 'password', 16 | 'password_confirmation', 17 | ]; 18 | } 19 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustHosts.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | public function hosts() 15 | { 16 | return [ 17 | $this->allSubdomainsOfApplicationUrl(), 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustProxies.php: -------------------------------------------------------------------------------- 1 | |string|null 14 | */ 15 | protected $proxies; 16 | 17 | /** 18 | * The headers that should be used to detect proxies. 19 | * 20 | * @var int 21 | */ 22 | protected $headers = 23 | Request::HEADER_X_FORWARDED_FOR | 24 | Request::HEADER_X_FORWARDED_HOST | 25 | Request::HEADER_X_FORWARDED_PORT | 26 | Request::HEADER_X_FORWARDED_PROTO | 27 | Request::HEADER_X_FORWARDED_AWS_ELB; 28 | } 29 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Models/Provider.php: -------------------------------------------------------------------------------- 1 | 40 | */ 41 | public static array $allowed = ['email', 'google', 'facebook']; 42 | 43 | protected $guarded = []; 44 | 45 | protected $casts = ['payload' => 'array']; 46 | 47 | protected $hidden = ['payload.token']; 48 | } 49 | -------------------------------------------------------------------------------- /app/Models/User.php: -------------------------------------------------------------------------------- 1 | |bool 68 | */ 69 | protected $guarded = []; 70 | 71 | protected $appends = ['first_name', 'is_trial']; 72 | 73 | protected $casts = ['is_sub' => 'boolean']; 74 | 75 | /** 76 | * Providers allowed. 77 | * 78 | * @var array> 79 | */ 80 | public array $interfaces = [ 81 | 'location' => [ 82 | 'name' => 'api.SessionLocation', 83 | ], 84 | 'session' => [ 85 | 'name' => 'api.Session', 86 | ], 87 | 'sessions' => [ 88 | 'name' => 'api.Sessions', 89 | ], 90 | ]; 91 | 92 | public function getIsTrialAttribute(): bool 93 | { 94 | return Carbon::now()->diffInDays($this->created_at) < 8; 95 | } 96 | 97 | public function getFirstNameAttribute(): string 98 | { 99 | return explode(' ', $this->name ?? '')[0]; 100 | } 101 | 102 | /** 103 | * Get the providers for the user model. 104 | * 105 | * @return HasMany 106 | */ 107 | public function providers(): HasMany 108 | { 109 | return $this->hasMany(Provider::class); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /app/Notifications/LoginAttempt.php: -------------------------------------------------------------------------------- 1 | attempt = $attempt; 24 | } 25 | 26 | /** 27 | * Get the notification's delivery channels. 28 | * 29 | * @param mixed $notifiable 30 | * @return array 31 | */ 32 | public function via($notifiable) 33 | { 34 | return ['mail']; 35 | } 36 | 37 | /** 38 | * Get the mail representation of the notification. 39 | * 40 | * @param mixed $notifiable 41 | * @return \Illuminate\Notifications\Messages\MailMessage 42 | */ 43 | public function toMail($notifiable) 44 | { 45 | return (new MailMessage()) 46 | ->subject('Login Request') 47 | ->markdown('emails.user.attempt', $this->toArray($notifiable)); 48 | } 49 | 50 | /** 51 | * Get the array representation of the notification. 52 | * 53 | * @param mixed $notifiable 54 | * @return array 55 | */ 56 | public function toArray($notifiable) 57 | { 58 | return [ 59 | 'token' => $this->attempt->token, 60 | 'created_at' => $this->attempt->created_at, 61 | ]; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/Policies/SessionPolicy.php: -------------------------------------------------------------------------------- 1 | id === $session->user_id; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | protected $policies = [ 16 | Session::class => 'App\Policies\SessionPolicy', 17 | // 'App\Model' => 'App\Policies\ModelPolicy', 18 | ]; 19 | 20 | /** 21 | * Register any authentication / authorization services. 22 | * 23 | * @return void 24 | */ 25 | public function boot() 26 | { 27 | $this->registerPolicies(); 28 | 29 | // 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | ['auth:api']]); 18 | require base_path('routes/channels.php'); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/Providers/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | > 16 | */ 17 | protected $listen = [ 18 | Registered::class => [ 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 | // 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | configureRateLimiting(); 39 | Route::middleware('api') 40 | ->group(base_path('routes/api.php')); 41 | } 42 | 43 | /** 44 | * Configure the rate limiters for the application. 45 | * 46 | * @return void 47 | */ 48 | protected function configureRateLimiting() 49 | { 50 | RateLimiter::for('api', function (Request $request) { 51 | return Limit::perMinute(60); 52 | }); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | make(Illuminate\Contracts\Console\Kernel::class); 34 | 35 | $status = $kernel->handle( 36 | $input = new Symfony\Component\Console\Input\ArgvInput, 37 | new Symfony\Component\Console\Output\ConsoleOutput 38 | ); 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Shutdown The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once Artisan has finished running, we will fire off the shutdown events 46 | | so that any final work may be done by the application before we shut 47 | | down the process. This is the last thing to happen to the request. 48 | | 49 | */ 50 | 51 | $kernel->terminate($input, $status); 52 | 53 | exit($status); 54 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /client/app.config.ts: -------------------------------------------------------------------------------- 1 | export default defineAppConfig({ 2 | ui: { 3 | primary: 'emerald', 4 | strategy: 'override', 5 | gray: 'slate', 6 | notifications: { 7 | // Show toasts at the top right of the screen for desktop 8 | position: 'lg:top-0 lg:right-0 lg:justify-start', 9 | 10 | }, 11 | button: { 12 | default: { 13 | loadingIcon: 'i-mdi-loading', 14 | }, 15 | }, 16 | input: { 17 | default: { 18 | loadingIcon: 'i-mdi-loading', 19 | }, 20 | }, 21 | selectMenu: { 22 | default: { 23 | selectedIcon: 'i-mdi-check-bold', 24 | }, 25 | }, 26 | } 27 | }) 28 | -------------------------------------------------------------------------------- /client/app.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 29 | -------------------------------------------------------------------------------- /client/assets/css/device.css: -------------------------------------------------------------------------------- 1 | .device { 2 | width: 72px; 3 | height: 72px; 4 | } 5 | .device-mac { 6 | background: no-repeat url("/devices.png") 0 -511px; 7 | background-size: 72px 1167px; 8 | } 9 | .device-windows { 10 | background: no-repeat url("/devices.png") 0 -219px; 11 | background-size: 72px 1167px; 12 | } 13 | .device-linux { 14 | background: no-repeat url("/devices.png") 0 -801px; 15 | background-size: 72px 1167px; 16 | } 17 | .device-iphone { 18 | background: no-repeat url("/devices.png") 0 -1095px; 19 | background-size: 72px 1167px; 20 | } 21 | .device-ipad { 22 | background: no-repeat url("/devices.png") 0 -365px; 23 | background-size: 72px 1167px; 24 | } 25 | .device-android { 26 | background: no-repeat url("/devices.png") 0 -658px; 27 | background-size: 72px 1167px; 28 | } 29 | .device-postman { 30 | background: no-repeat url("https://calliditasblog.files.wordpress.com/2017/12/linuxpostman.png?w=72"); 31 | background-size: 72px 72px; 32 | } 33 | 34 | .device-other { 35 | display: none; 36 | } 37 | -------------------------------------------------------------------------------- /client/assets/css/main.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | @apply bg-gray-100 dark:bg-gray-900 text-gray-600 dark:text-gray-300; 3 | } 4 | 5 | html.dark { 6 | @apply bg-gray-900; 7 | } 8 | 9 | p, h1, h2, h3 { 10 | @apply m-0; 11 | } 12 | 13 | button { 14 | @apply bg-transparent; 15 | } 16 | -------------------------------------------------------------------------------- /client/components/README.md: -------------------------------------------------------------------------------- 1 | # COMPONENTS 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | The components directory contains your Vue.js Components. 6 | 7 | _Nuxt.js doesn't supercharge these components._ 8 | -------------------------------------------------------------------------------- /client/components/contact/ContactCard.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 64 | -------------------------------------------------------------------------------- /client/components/contact/ContactCardSkeleton.vue: -------------------------------------------------------------------------------- 1 | 34 | -------------------------------------------------------------------------------- /client/components/header/HeaderBar.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 50 | -------------------------------------------------------------------------------- /client/components/header/HeaderDarkMode.vue: -------------------------------------------------------------------------------- 1 | 44 | 45 | 53 | -------------------------------------------------------------------------------- /client/components/header/HeaderProfile.vue: -------------------------------------------------------------------------------- 1 | 38 | 39 | 57 | -------------------------------------------------------------------------------- /client/components/layout/LayoutBreadCrumbs.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 63 | -------------------------------------------------------------------------------- /client/components/layout/LayoutConfirm.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 25 | -------------------------------------------------------------------------------- /client/components/layout/LayoutLoginModal.vue: -------------------------------------------------------------------------------- 1 | 74 | 75 | 147 | -------------------------------------------------------------------------------- /client/components/session/SessionDevice.vue: -------------------------------------------------------------------------------- 1 | 75 | 76 | 155 | -------------------------------------------------------------------------------- /client/components/session/SessionDeviceSkeleton.vue: -------------------------------------------------------------------------------- 1 | 45 | -------------------------------------------------------------------------------- /client/components/session/SessionList.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 26 | -------------------------------------------------------------------------------- /client/components/transition/TransitionDropdown.vue: -------------------------------------------------------------------------------- 1 | 13 | -------------------------------------------------------------------------------- /client/components/transition/TransitionScaleIn.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 22 | -------------------------------------------------------------------------------- /client/composables/api.ts: -------------------------------------------------------------------------------- 1 | import Api from '@/lib/api' 2 | 3 | let api: Api 4 | 5 | export const useApi = () => { 6 | if (!api) { 7 | const config = useRuntimeConfig() 8 | api = new Api({ 9 | fetchOptions: { 10 | baseURL: config.public.apiURL, 11 | }, 12 | apiURL: config.public.apiURL, 13 | webURL: config.public.webURL, 14 | redirect: { 15 | logout: '/', 16 | login: '/gated', 17 | }, 18 | /* 19 | echoConfig: { 20 | pusherAppKey: config.public.pusherAppKey, 21 | pusheAppCluster: config.public.pusherAppCluster, 22 | }, 23 | */ 24 | }) 25 | } 26 | return api 27 | } 28 | -------------------------------------------------------------------------------- /client/composables/confirm.ts: -------------------------------------------------------------------------------- 1 | interface ConfirmParams { 2 | title: string 3 | message: string 4 | label: string 5 | action: Function 6 | } 7 | 8 | const confirming = ref(false) 9 | 10 | const params = ref({ 11 | title: 'Title', 12 | message: 'Description', 13 | label: 'Confirm', 14 | action: () => {}, 15 | }) 16 | 17 | export const useConfirm = () => { 18 | function confirm (title: string, message: string, label: string, action: Function) { 19 | params.value = { title, message, label, action } 20 | confirming.value = true 21 | } 22 | 23 | return { confirm, confirming, params } 24 | } 25 | -------------------------------------------------------------------------------- /client/composables/crumbs.ts: -------------------------------------------------------------------------------- 1 | import { ref } from 'vue' 2 | import type { BreadCrumb } from '@/types/frontend' 3 | 4 | const list = ref([]) 5 | const actions = ref([]) 6 | 7 | export const useCrumbs = () => { 8 | const setCrumbs = (crumbs: BreadCrumb[]): void => { 9 | list.value = crumbs 10 | actions.value = [] 11 | } 12 | 13 | const setActions = (crumbs: BreadCrumb[]): void => { 14 | actions.value = crumbs 15 | } 16 | 17 | return { list, actions, setCrumbs, setActions } 18 | } 19 | -------------------------------------------------------------------------------- /client/composables/dayjs.ts: -------------------------------------------------------------------------------- 1 | import dayjs from 'dayjs' 2 | import relativeTime from 'dayjs/plugin/relativeTime.js' 3 | 4 | export const useDayjs = () => { 5 | dayjs.extend(relativeTime) 6 | return dayjs 7 | } 8 | -------------------------------------------------------------------------------- /client/composables/lnutils.ts: -------------------------------------------------------------------------------- 1 | export const useLnUtils = () => { 2 | /** 3 | * Perform a sleep as a Promise 4 | * ex: await this.$sleep(200) 5 | * @param milliseconds 6 | */ 7 | const sleep = (milliseconds: number) => { 8 | return new Promise(resolve => setTimeout(resolve, milliseconds)) 9 | } 10 | 11 | /** 12 | * Generate a random integer similar to php's rand() 13 | * @see https://www.php.net/rand 14 | * @param min - The lowest value to return 15 | * @param max - The highest value to return 16 | */ 17 | const rand = (min: number, max: number): number => { 18 | return Math.floor(Math.random() * (max - min + 1)) + min 19 | } 20 | 21 | /** 22 | * Capitalize the first letter of a string 23 | * @param string 24 | */ 25 | const ucFirst = (string: string) => { 26 | return string.charAt(0).toUpperCase() + string.slice(1) 27 | } 28 | 29 | /** 30 | * Scroll to an element on the page 31 | * @param id 32 | * @param offset 33 | */ 34 | const properScroll = (id: string, offset: number) => { 35 | const el = document.getElementById(id) 36 | if (!el) return true 37 | const y = el.getBoundingClientRect().top + window.pageYOffset + offset 38 | window.scrollTo(0, y) 39 | } 40 | 41 | /** 42 | * Get the name from a URL 43 | * 44 | * @param url 45 | */ 46 | const nameFromURL = (url: string): string => { 47 | const domain = url.replace('http://', '').replace('https://', '').split(/[/?#]/)[0] 48 | return domain 49 | } 50 | 51 | /** 52 | * Get the query string from a URL 53 | * @param url 54 | */ 55 | 56 | const queryFromURL = (urlString: string): string => { 57 | const url = new URL(urlString) 58 | return url.search 59 | } 60 | 61 | return { sleep, rand, ucFirst, properScroll, nameFromURL, queryFromURL } 62 | } 63 | -------------------------------------------------------------------------------- /client/composables/modal.ts: -------------------------------------------------------------------------------- 1 | 2 | const loginModal = ref(false) 3 | 4 | export const useModal = () => { 5 | 6 | const loginModalOn = () => loginModal.value = true 7 | const loginModalOff = () => loginModal.value = false 8 | const loginModalToggle = () => loginModal.value = !loginModal.value 9 | 10 | return { 11 | loginModal, 12 | loginModalOn, 13 | loginModalOff, 14 | loginModalToggle, 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /client/composables/utils.ts: -------------------------------------------------------------------------------- 1 | export const useUtils = () => { 2 | /** 3 | * Perform a sleep as a Promise 4 | * ex: await this.$sleep(200) 5 | * @param milliseconds 6 | */ 7 | const sleep = (milliseconds: number) => { 8 | return new Promise(resolve => setTimeout(resolve, milliseconds)) 9 | } 10 | 11 | /** 12 | * Generate a random integer similar to php's rand() 13 | * @see https://www.php.net/rand 14 | * @param min - The lowest value to return 15 | * @param max - The highest value to return 16 | */ 17 | const rand = (min: number, max: number): number => { 18 | return Math.floor(Math.random() * (max - min + 1)) + min 19 | } 20 | 21 | /** 22 | * Capitalize the first letter of a string 23 | * @param string 24 | */ 25 | const ucFirst = (string: string) => { 26 | return string.charAt(0).toUpperCase() + string.slice(1) 27 | } 28 | 29 | /** 30 | * Scroll to an element on the page 31 | * @param id 32 | * @param offset 33 | */ 34 | const properScroll = (id: string, offset: number) => { 35 | const el = document.getElementById(id) 36 | if (!el) 37 | return true 38 | const y = el.getBoundingClientRect().top + window.pageYOffset + offset 39 | window.scrollTo(0, y) 40 | } 41 | 42 | return { sleep, rand, ucFirst, properScroll } 43 | } 44 | -------------------------------------------------------------------------------- /client/lib/api.ts: -------------------------------------------------------------------------------- 1 | import type { Notification } from '@nuxt/ui/dist/runtime/types' 2 | import { reactive, ref } from 'vue' 3 | 4 | import { NitroFetchRequest, $Fetch } from "nitropack"; 5 | 6 | 7 | import Echo from 'laravel-echo' 8 | import Pusher from 'pusher-js' 9 | import { NuxtApp } from '#app' 10 | 11 | export interface SearchParameters { 12 | [key: string]: any; 13 | } 14 | 15 | export interface UserLogin { 16 | token: string 17 | user: models.User 18 | provider: string 19 | error?: string 20 | action?: LoginAction 21 | } 22 | 23 | export interface AuthConfig { 24 | fetchOptions: any 25 | webURL: string 26 | apiURL: string 27 | redirect: { 28 | logout: string 29 | login: undefined | string 30 | } 31 | paymentToast?: Partial 32 | echoConfig?: EchoConfig 33 | } 34 | 35 | export interface EchoConfig { 36 | pusherAppKey: string 37 | pusherAppCluster: string 38 | 39 | } 40 | 41 | export interface LoginAction { 42 | action: string 43 | url: string 44 | } 45 | 46 | const authConfigDefaults: AuthConfig = { 47 | fetchOptions: {}, 48 | webURL: 'https://localhost:3000', 49 | apiURL: 'https://localhost:8000', 50 | redirect: { 51 | logout: '/', 52 | login: undefined, 53 | }, 54 | } 55 | 56 | export default class Api { 57 | public token = useCookie('token', { path: '/', maxAge: 60 * 60 * 24 * 30 }) 58 | public config: AuthConfig 59 | public $user = reactive({} as models.User) 60 | public $echo: undefined | Echo = undefined 61 | public loggedIn = ref(undefined) 62 | public modal = ref(false) 63 | public redirect = ref(false) 64 | public action = ref(undefined) 65 | 66 | public nuxtApp:NuxtApp|undefined = undefined 67 | 68 | constructor(config: AuthConfig) { 69 | this.config = { ...authConfigDefaults, ...config } 70 | } 71 | 72 | setNuxtApp(nuxtApp:NuxtApp) { 73 | this.nuxtApp = nuxtApp 74 | } 75 | 76 | on(redirect: boolean, action?: LoginAction | undefined) { 77 | this.redirect.value = redirect 78 | this.modal.value = true 79 | this.action.value = action 80 | } 81 | 82 | off() { 83 | this.modal.value = false 84 | } 85 | 86 | async checkUser() { 87 | if (this.token.value !== undefined) 88 | this.loggedIn.value = await this.setUser() 89 | else this.loggedIn.value = false 90 | } 91 | 92 | setEcho() { 93 | if (this.config.echoConfig === undefined) return 94 | window.Pusher = Pusher 95 | this.$echo = new Echo({ 96 | broadcaster: 'pusher', 97 | key: this.config.echoConfig.pusherAppKey, 98 | cluster: this.config.echoConfig.pusherAppCluster, 99 | authEndpoint: `${this.config.apiURL}/broadcasting/auth`, 100 | forceTls: true, 101 | encrypted: true, 102 | auth: { 103 | headers: { 104 | Accept: 'application/json', 105 | Authorization: `Bearer ${this.token.value || ''}`, 106 | }, 107 | }, 108 | }) 109 | } 110 | 111 | login(result: UserLogin, discreet = false): undefined | string { 112 | this.loggedIn.value = true 113 | this.token.value = result.token 114 | Object.assign(this.$user, result.user) 115 | this.setEcho() 116 | if (!discreet) 117 | useToast().add({ icon: 'i-mdi-check-bold', color: 'green', title: 'Login Successful', timeout: 1 }) 118 | if (result.action && result.action.action === 'redirect') 119 | return result.action.url 120 | return this.config.redirect.login 121 | } 122 | 123 | public fetch (params?: SearchParameters, method = 'GET'): $Fetch { 124 | const nuxtApp = this.nuxtApp 125 | return $fetch.create({ 126 | baseURL: this.config.apiURL, 127 | method, 128 | params: method === 'GET' ? params : undefined, 129 | body: ['POST','PUT'].includes(method) ? params : undefined, 130 | headers: {Accept: 'application/json', Authorization: `Bearer ${this.token.value}`}, 131 | onRequest() { nuxtApp?.callHook('page:start') }, 132 | onResponse() { nuxtApp?.callHook('page:finish') }, 133 | }) 134 | } 135 | 136 | 137 | public async setUser(): Promise { 138 | try { 139 | const result = await this.index('/me') 140 | if (!result || !result.status || result.status !== 'success') return false 141 | Object.assign(this.$user, result.data) 142 | } catch (e) { console.log(this.token.value, e.response._data) } 143 | this.setEcho() 144 | return true 145 | } 146 | 147 | public async index(endpoint: string, params?: SearchParameters): Promise { 148 | return await this.fetch(params)(endpoint) 149 | } 150 | 151 | public async update(endpoint: string, params?: SearchParameters): Promise { 152 | return await this.fetch(params, 'PUT')(endpoint) 153 | } 154 | 155 | public async store(endpoint: string, params?: SearchParameters): Promise { 156 | return await this.fetch(params, 'POST')(endpoint) 157 | } 158 | 159 | public async delete(endpoint: string, params?: SearchParameters): Promise { 160 | return await this.fetch(params, 'DELETE')(endpoint) 161 | } 162 | 163 | public async attempt(token: string | string[]): Promise { 164 | if (Array.isArray(token)) 165 | token = token.join('') 166 | 167 | return (await this.fetch([])(`/login/${token}`)).data 168 | } 169 | 170 | public upload(endpoint: string, params?: SearchParameters) { 171 | return this.fetch(params, 'PUT')(endpoint) 172 | } 173 | 174 | public async toastError(error: any): Promise { 175 | if (error.response?.status === 401) { 176 | } 177 | 178 | if (error.response?.status === 402 && this.config.paymentToast) 179 | return useToast().add(this.config.paymentToast) 180 | 181 | if (error.response?._data && error.response._data.errors?.error?.reason) { 182 | for (const err of error.response._data.errors) { 183 | useToast().add({ icon: 'i-mdi-alert', title: err.detail ?? err.message ?? '', color: 'red' }) 184 | } 185 | } 186 | 187 | if (error.response?.status === 403) { 188 | useToast().add({ 189 | icon: 'i-mdi-account-cancel', 190 | title: error.response._data.message, 191 | color: 'red', 192 | }) 193 | } 194 | 195 | if (error.response?._data.exception) { 196 | useToast().add({ 197 | icon: 'i-mdi-document', 198 | color: 'red', 199 | title: ` 200 | [${error.response._data.exception}]
201 | ${error.response._data.message}
202 | 203 | ${error.response._data.file}:${error.response._data.line} 204 | `, 205 | timeout: 0, 206 | }) 207 | } 208 | } 209 | 210 | public async invalidate(): Promise { 211 | this.token.value = undefined 212 | this.loggedIn.value = false 213 | Object.assign(this.$user, {}) 214 | navigateTo(this.config.redirect.logout) 215 | } 216 | 217 | public async logout(): Promise { 218 | if (this.$echo) 219 | this.$echo.disconnect() 220 | const response = (await this.fetch([])('/logout')) 221 | useToast().add({ icon: 'i-mdi-check-bold', color: 'green', title: response.data.message, timeout: 1 }) 222 | await this.invalidate() 223 | } 224 | 225 | } 226 | -------------------------------------------------------------------------------- /client/lib/menu.ts: -------------------------------------------------------------------------------- 1 | import type { DropdownGroup } from '@/components/dropdown/DropdownGroup.vue' 2 | import type Api from '@/lib/api' 3 | 4 | interface MenuItem { 5 | name: string 6 | icon: string 7 | to: string 8 | names: string[] 9 | gated: boolean 10 | } 11 | 12 | export default class { 13 | constructor( 14 | private api: Api, 15 | ) { } 16 | 17 | public main(): MenuItem[] { 18 | if (this.api.loggedIn.value) 19 | return this.items() 20 | return this.items().filter(item => !item.gated) 21 | } 22 | 23 | public items(): MenuItem[] { 24 | return [ 25 | { 26 | name: 'Home', 27 | icon: 'mdi-view-dashboard', 28 | to: '/', 29 | names: ['index'], 30 | gated: false, 31 | }, 32 | { 33 | name: 'Gated', 34 | icon: 'fluent:people-team-24-regular', 35 | to: '/gated', 36 | names: ['gated'], 37 | gated: true, 38 | }, 39 | { 40 | name: 'User Sessions', 41 | icon: 'mdi-devices', 42 | to: '/sessions', 43 | gated: true, 44 | names: ['sessions'], 45 | }, 46 | ] 47 | } 48 | private async logout() { 49 | await this.api.logout() 50 | } 51 | 52 | public isCurrent = (item: MenuItem) => 53 | typeof useRoute().name === 'string' && item.names.includes(useRoute().name as string) 54 | } 55 | -------------------------------------------------------------------------------- /client/middleware/README.md: -------------------------------------------------------------------------------- 1 | # MIDDLEWARE 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | This directory contains your application middleware. 6 | Middleware let you define custom functions that can be run before rendering either a page or a group of pages. 7 | 8 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/routing#middleware). 9 | -------------------------------------------------------------------------------- /client/middleware/auth.global.ts: -------------------------------------------------------------------------------- 1 | import Menu from '@/lib/menu' 2 | 3 | export default defineNuxtRouteMiddleware(async (to, from) => { 4 | const api = useApi() 5 | await api.checkUser() 6 | const menu = new Menu(api) 7 | const item = menu.items().find(item => item.to === to.path) 8 | // console.log(`loggedIn: ${ api.loggedIn.value } - ${ api.$user.name }`) 9 | if (item && item.gated === true && api.loggedIn.value === false) { 10 | useToast().add({ icon: 'i-mdi-lock', color: 'red', title: 'Access Denied', }) 11 | return navigateTo('/') 12 | } 13 | 14 | }) 15 | -------------------------------------------------------------------------------- /client/pages/README.md: -------------------------------------------------------------------------------- 1 | # PAGES 2 | 3 | This directory contains your Application Views and Routes. 4 | The framework reads all the `*.vue` files inside this directory and creates the router of your application. 5 | 6 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/routing). 7 | -------------------------------------------------------------------------------- /client/pages/attempt/[token].vue: -------------------------------------------------------------------------------- 1 | 40 | 41 | 44 | 45 | 50 | -------------------------------------------------------------------------------- /client/pages/gated.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 16 | -------------------------------------------------------------------------------- /client/pages/index.vue: -------------------------------------------------------------------------------- 1 | 27 | 28 | 50 | -------------------------------------------------------------------------------- /client/pages/sessions.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 21 | -------------------------------------------------------------------------------- /client/plugins/icon.ts: -------------------------------------------------------------------------------- 1 | import { Icon } from '@iconify/vue' 2 | 3 | export default defineNuxtPlugin((nuxtApp) => { 4 | nuxtApp.vueApp.component('Icon', Icon) 5 | }) 6 | -------------------------------------------------------------------------------- /client/public/README.md: -------------------------------------------------------------------------------- 1 | # STATIC 2 | 3 | **This directory is not required, you can delete it if you don't want to use it.** 4 | 5 | This directory contains your static files. 6 | Each file inside this directory is mapped to `/`. 7 | Thus you'd want to delete this README.md before deploying to production. 8 | 9 | Example: `/static/robots.txt` is mapped as `/robots.txt`. 10 | 11 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/assets#static). 12 | -------------------------------------------------------------------------------- /client/public/devices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fumeapp/laranuxt/e15336bf2b8c99bef5e529edd2eaf9ad37c0cb8c/client/public/devices.png -------------------------------------------------------------------------------- /client/public/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fumeapp/laranuxt/e15336bf2b8c99bef5e529edd2eaf9ad37c0cb8c/client/public/favicon-16x16.png -------------------------------------------------------------------------------- /client/public/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fumeapp/laranuxt/e15336bf2b8c99bef5e529edd2eaf9ad37c0cb8c/client/public/favicon-32x32.png -------------------------------------------------------------------------------- /client/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fumeapp/laranuxt/e15336bf2b8c99bef5e529edd2eaf9ad37c0cb8c/client/public/favicon.ico -------------------------------------------------------------------------------- /client/public/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fumeapp/laranuxt/e15336bf2b8c99bef5e529edd2eaf9ad37c0cb8c/client/public/icon.png -------------------------------------------------------------------------------- /client/public/laranuxt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fumeapp/laranuxt/e15336bf2b8c99bef5e529edd2eaf9ad37c0cb8c/client/public/laranuxt.png -------------------------------------------------------------------------------- /client/types/api.d.ts: -------------------------------------------------------------------------------- 1 | export { } 2 | declare global { 3 | export namespace api { 4 | interface MetApiQuery { 5 | options: Record 6 | params: Record 7 | } 8 | 9 | interface MetApiData { 10 | success: boolean 11 | type: 'success' | 'failure' 12 | message: string 13 | data: unknown 14 | } 15 | 16 | export interface MetApiResponse { 17 | status: 'success' | 'failure' 18 | benchmark: number 19 | success: boolean 20 | query: MetApiQuery 21 | data: MetApiData 22 | } 23 | 24 | export type Me = Modify 25 | 26 | export interface MetApiResults { 27 | benchmark: number 28 | status: 'success' | 'failure' 29 | query: MetApiQuery 30 | paginate?: MetApiPaginate 31 | data: unknown 32 | } 33 | 34 | export interface MetApiPaginate { 35 | current_page: number 36 | first_item: number 37 | last_item: number 38 | last_page: number 39 | pages: Array 40 | per_page: number 41 | total: number 42 | } 43 | 44 | export interface Session { 45 | token: string 46 | user_id: number 47 | source: string 48 | ip: string 49 | agent: string 50 | location: SessionLocation 51 | device: SessionDevice 52 | current: boolean 53 | created_at: Date 54 | updated_at: Date 55 | } 56 | 57 | export interface SessionLocation { 58 | ip: string 59 | country: string 60 | city: string 61 | state: string 62 | postal_code: number 63 | lat: string 64 | lon: string 65 | timezone: string 66 | currency: string 67 | } 68 | 69 | export interface SessionDevice { 70 | string: string 71 | platform: string 72 | browser: string 73 | name: string 74 | desktop: boolean 75 | mobile: boolean 76 | } 77 | 78 | export type Sessions = Array 79 | export type SessionResults = Modify 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /client/types/frontend.d.ts: -------------------------------------------------------------------------------- 1 | 2 | export interface BreadCrumb { 3 | name: string 4 | to?: RouteLocationRaw 5 | icon?: string 6 | } 7 | 8 | export interface UserLogin { 9 | token: string 10 | user: models.User 11 | provider: string 12 | error?: string 13 | action?: LoginAction 14 | } 15 | 16 | export interface AuthConfig { 17 | fetchOptions: FetchOptions<'json'> 18 | webURL: string 19 | apiURL: string 20 | redirect: { 21 | logout: string 22 | login: undefined | string 23 | } 24 | paymentToast?: ToastProps, 25 | echoConfig?: EchoConfig, 26 | } 27 | 28 | export interface EchoConfig { 29 | pusherAppKey: string 30 | pusherAppCluster: string 31 | 32 | } 33 | 34 | export interface LoginAction { 35 | action: string 36 | url: string 37 | } 38 | 39 | 40 | -------------------------------------------------------------------------------- /client/types/models.d.ts: -------------------------------------------------------------------------------- 1 | export {} 2 | declare global { 3 | export namespace models { 4 | 5 | export interface Provider { 6 | // columns 7 | id: number 8 | user_id: number 9 | avatar: string|null 10 | name: string 11 | payload: string[] 12 | created_at: Date|null 13 | updated_at: Date|null 14 | } 15 | export type Providers = Provider[] 16 | export type ProviderResults = Modify 17 | 18 | export interface User { 19 | // columns 20 | id: number 21 | email: string 22 | name: string|null 23 | avatar: string|null 24 | job: string 25 | stripe: string|null 26 | is_sub: boolean 27 | created_at: Date|null 28 | updated_at: Date|null 29 | // mutators 30 | is_trial: boolean 31 | first_name: string 32 | has_active_session: boolean 33 | session: Session 34 | location: Array 35 | // relations 36 | providers: Providers 37 | sessions: Sessions 38 | notifications: DatabaseNotifications 39 | } 40 | export type Users = User[] 41 | export type UserResult = Modify 42 | export type UserResults = Modify 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /client/types/vue-shim.d.ts: -------------------------------------------------------------------------------- 1 | import { Numeral } from 'numeral' 2 | import { LottiePlayer } from 'lottie-web' 3 | 4 | declare module '*.vue' { 5 | import Vue from 'vue' 6 | export default Vue 7 | } 8 | 9 | declare global { 10 | interface Window { 11 | Pusher: typeof Pusher 12 | numeral: Numeral 13 | lottie: LottiePlayer 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "type": "project", 4 | "description": "The Laravel Framework.", 5 | "keywords": [ 6 | "framework", 7 | "laravel" 8 | ], 9 | "license": "MIT", 10 | "require": { 11 | "php": "^8.1", 12 | "acidjazz/humble": "^3.0", 13 | "acidjazz/metapi": "^2.1", 14 | "composer/composer": "^2.2.1", 15 | "google/apiclient": "^2.11", 16 | "guzzlehttp/guzzle": "^7.0.1", 17 | "laravel/framework": "^11.0", 18 | "laravel/socialite": "^5.6", 19 | "laravel/tinker": "^2.5" 20 | }, 21 | "require-dev": { 22 | "barryvdh/laravel-debugbar": "^3.5", 23 | "barryvdh/laravel-ide-helper": "^3.0", 24 | "fakerphp/faker": "^1.9.1", 25 | "fumeapp/modeltyper": "^2.2", 26 | "larastan/larastan": "^2.1", 27 | "laravel/pint": "^1.0.0", 28 | "mockery/mockery": "^1.4.4", 29 | "nunomaduro/collision": "^8.1", 30 | "phpunit/phpunit": "^10.0", 31 | "spatie/laravel-ignition": "^2.0", 32 | "spatie/laravel-ray": "^1.29", 33 | "squizlabs/php_codesniffer": "^3.6" 34 | }, 35 | "config": { 36 | "optimize-autoloader": true, 37 | "preferred-install": "dist", 38 | "sort-packages": true 39 | }, 40 | "extra": { 41 | "laravel": { 42 | "dont-discover": [] 43 | } 44 | }, 45 | "autoload": { 46 | "psr-4": { 47 | "App\\": "app/", 48 | "Database\\Factories\\": "database/factories/", 49 | "Database\\Seeders\\": "database/seeders/" 50 | } 51 | }, 52 | "autoload-dev": { 53 | "psr-4": { 54 | "Tests\\": "tests/php/" 55 | } 56 | }, 57 | "minimum-stability": "stable", 58 | "prefer-stable": true, 59 | "scripts": { 60 | "test": [ 61 | "vendor/bin/phpunit -c tests/php/phpunit.xml --colors=always --testdox" 62 | ], 63 | "test:coverage": [ 64 | "XDEBUG_MODE=coverage vendor/bin/phpunit -c tests/php/phpunit.xml --colors=always --testdox --coverage-text" 65 | ], 66 | "post-autoload-dump": [ 67 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 68 | "@php artisan package:discover --ansi" 69 | ], 70 | "post-root-package-install": [ 71 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 72 | ], 73 | "post-create-project-cmd": [ 74 | "@php artisan key:generate --ansi" 75 | ], 76 | "stan": [ 77 | "vendor/bin/phpstan analyse" 78 | ], 79 | "pint": [ 80 | "vendor/bin/pint" 81 | ] 82 | }, 83 | "scripts-descriptions": { 84 | "test:coverage": "Run the PHPUnit tests with coverage.", 85 | "post-autoload-dump": "Run after autoloading has been dumped.", 86 | "post-root-package-install": "Run after the root package has been installed.", 87 | "post-create-project-cmd": "Run after the project has been created.", 88 | "stan": "Run the PHPStan analyser.", 89 | "pint": "Run the Pint analyser." 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => 'api', 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' => 'humble', 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 | 'serialize' => false, 43 | ], 44 | 45 | 'database' => [ 46 | 'driver' => 'database', 47 | 'table' => 'cache', 48 | 'connection' => null, 49 | ], 50 | 51 | 'file' => [ 52 | 'driver' => 'file', 53 | 'path' => storage_path('framework/cache/data'), 54 | ], 55 | 56 | 'memcached' => [ 57 | 'driver' => 'memcached', 58 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 59 | 'sasl' => [ 60 | env('MEMCACHED_USERNAME'), 61 | env('MEMCACHED_PASSWORD'), 62 | ], 63 | 'options' => [ 64 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 65 | ], 66 | 'servers' => [ 67 | [ 68 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 69 | 'port' => env('MEMCACHED_PORT', 11211), 70 | 'weight' => 100, 71 | ], 72 | ], 73 | ], 74 | 75 | 'redis' => [ 76 | 'driver' => 'redis', 77 | 'connection' => 'cache', 78 | ], 79 | 80 | 'dynamodb' => [ 81 | 'driver' => 'dynamodb', 82 | 'key' => env('AWS_ACCESS_KEY_ID'), 83 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 84 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 85 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 86 | 'endpoint' => env('DYNAMODB_ENDPOINT'), 87 | ], 88 | 89 | ], 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Cache Key Prefix 94 | |-------------------------------------------------------------------------- 95 | | 96 | | When utilizing a RAM based store such as APC or Memcached, there might 97 | | be other applications utilizing the same cache. So, we'll specify a 98 | | value to get prefixed to all our keys so we can avoid collisions. 99 | | 100 | */ 101 | 102 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache'), 103 | 104 | ]; 105 | -------------------------------------------------------------------------------- /config/cors.php: -------------------------------------------------------------------------------- 1 | ['*'], 19 | 20 | 'allowed_methods' => ['*'], 21 | 22 | 'allowed_origins' => [env('WEB_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/database.php: -------------------------------------------------------------------------------- 1 | env('DB_CONNECTION', 'mysql'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Database Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here are each of the database connections setup for your application. 26 | | Of course, examples of configuring each database platform that is 27 | | supported by Laravel is shown below to make development simple. 28 | | 29 | | 30 | | All database work in Laravel is done through the PHP PDO facilities 31 | | so make sure you have the driver for your particular database of 32 | | choice installed on your machine before you begin development. 33 | | 34 | */ 35 | 36 | 'connections' => [ 37 | 38 | 'sqlite' => [ 39 | 'driver' => 'sqlite', 40 | 'url' => env('DATABASE_URL'), 41 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 42 | 'prefix' => '', 43 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 44 | ], 45 | 46 | 'mysql' => [ 47 | 'driver' => 'mysql', 48 | 'url' => env('DATABASE_URL'), 49 | 'host' => env('DB_HOST', '127.0.0.1'), 50 | 'port' => env('DB_PORT', '3306'), 51 | 'database' => env('DB_DATABASE', 'forge'), 52 | 'username' => env('DB_USERNAME', 'forge'), 53 | 'password' => env('DB_PASSWORD', ''), 54 | 'unix_socket' => env('DB_SOCKET', ''), 55 | 'charset' => 'utf8mb4', 56 | 'collation' => 'utf8mb4_unicode_ci', 57 | 'prefix' => '', 58 | 'prefix_indexes' => true, 59 | 'strict' => true, 60 | 'engine' => null, 61 | 'options' => extension_loaded('pdo_mysql') ? array_filter([ 62 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), 63 | ]) : [], 64 | ], 65 | 66 | 'pgsql' => [ 67 | 'driver' => 'pgsql', 68 | 'url' => env('DATABASE_URL'), 69 | 'host' => env('DB_HOST', '127.0.0.1'), 70 | 'port' => env('DB_PORT', '5432'), 71 | 'database' => env('DB_DATABASE', 'forge'), 72 | 'username' => env('DB_USERNAME', 'forge'), 73 | 'password' => env('DB_PASSWORD', ''), 74 | 'charset' => 'utf8', 75 | 'prefix' => '', 76 | 'prefix_indexes' => true, 77 | 'schema' => 'public', 78 | 'sslmode' => 'prefer', 79 | ], 80 | 81 | 'sqlsrv' => [ 82 | 'driver' => 'sqlsrv', 83 | 'url' => env('DATABASE_URL'), 84 | 'host' => env('DB_HOST', 'localhost'), 85 | 'port' => env('DB_PORT', '1433'), 86 | 'database' => env('DB_DATABASE', 'forge'), 87 | 'username' => env('DB_USERNAME', 'forge'), 88 | 'password' => env('DB_PASSWORD', ''), 89 | 'charset' => 'utf8', 90 | 'prefix' => '', 91 | 'prefix_indexes' => true, 92 | ], 93 | 94 | ], 95 | 96 | /* 97 | |-------------------------------------------------------------------------- 98 | | Migration Repository Table 99 | |-------------------------------------------------------------------------- 100 | | 101 | | This table keeps track of all the migrations that have already run for 102 | | your application. Using this information, we can determine which of 103 | | the migrations on disk haven't actually been run in the database. 104 | | 105 | */ 106 | 107 | 'migrations' => 'migrations', 108 | 109 | /* 110 | |-------------------------------------------------------------------------- 111 | | Redis Databases 112 | |-------------------------------------------------------------------------- 113 | | 114 | | Redis is an open source, fast, and advanced key-value store that also 115 | | provides a richer body of commands than a typical key-value system 116 | | such as APC or Memcached. Laravel makes it easy to dig right in. 117 | | 118 | */ 119 | 120 | 'redis' => [ 121 | 122 | 'client' => env('REDIS_CLIENT', 'phpredis'), 123 | 124 | 'options' => [ 125 | 'cluster' => env('REDIS_CLUSTER', 'redis'), 126 | 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'), 127 | ], 128 | 129 | 'default' => [ 130 | 'url' => env('REDIS_URL'), 131 | 'host' => env('REDIS_HOST', '127.0.0.1'), 132 | 'password' => env('REDIS_PASSWORD', null), 133 | 'port' => env('REDIS_PORT', '6379'), 134 | 'database' => env('REDIS_DB', '0'), 135 | ], 136 | 137 | 'cache' => [ 138 | 'url' => env('REDIS_URL'), 139 | 'host' => env('REDIS_HOST', '127.0.0.1'), 140 | 'password' => env('REDIS_PASSWORD', null), 141 | 'port' => env('REDIS_PORT', '6379'), 142 | 'database' => env('REDIS_CACHE_DB', '1'), 143 | ], 144 | 145 | ], 146 | 147 | ]; 148 | -------------------------------------------------------------------------------- /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 | 'endpoint' => env('AWS_ENDPOINT'), 66 | ], 67 | 68 | ], 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Symbolic Links 73 | |-------------------------------------------------------------------------- 74 | | 75 | | Here you may configure the symbolic links that will be created when the 76 | | `storage:link` Artisan command is executed. The array keys should be 77 | | the locations of the links and the values should be their targets. 78 | | 79 | */ 80 | 81 | 'links' => [ 82 | public_path('storage') => storage_path('app/public'), 83 | ], 84 | 85 | ]; 86 | -------------------------------------------------------------------------------- /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_MAILER', 'smtp'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Mailer Configurations 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure all of the mailers used by your application plus 24 | | their respective settings. Several examples have been configured for 25 | | you and you are free to add your own as your application requires. 26 | | 27 | | Laravel supports a variety of mail "transport" drivers to be used while 28 | | sending an e-mail. You will specify which one you are using for your 29 | | mailers below. You are free to add additional mailers as required. 30 | | 31 | | Supported: "smtp", "sendmail", "mailgun", "ses", 32 | | "postmark", "log", "array" 33 | | 34 | */ 35 | 36 | 'mailers' => [ 37 | 'smtp' => [ 38 | 'transport' => 'smtp', 39 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 40 | 'port' => env('MAIL_PORT', 587), 41 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 42 | 'username' => env('MAIL_USERNAME'), 43 | 'password' => env('MAIL_PASSWORD'), 44 | 'timeout' => null, 45 | 'auth_mode' => null, 46 | ], 47 | 48 | 'ses' => [ 49 | 'transport' => 'ses', 50 | ], 51 | 52 | 'mailgun' => [ 53 | 'transport' => 'mailgun', 54 | ], 55 | 56 | 'postmark' => [ 57 | 'transport' => 'postmark', 58 | ], 59 | 60 | 'sendmail' => [ 61 | 'transport' => 'sendmail', 62 | 'path' => '/usr/sbin/sendmail -bs', 63 | ], 64 | 65 | 'log' => [ 66 | 'transport' => 'log', 67 | 'channel' => env('MAIL_LOG_CHANNEL'), 68 | ], 69 | 70 | 'array' => [ 71 | 'transport' => 'array', 72 | ], 73 | ], 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Global "From" Address 78 | |-------------------------------------------------------------------------- 79 | | 80 | | You may wish for all e-mails sent by your application to be sent from 81 | | the same address. Here, you may specify a name and address that is 82 | | used globally for all e-mails that are sent by your application. 83 | | 84 | */ 85 | 86 | 'from' => [ 87 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 88 | 'name' => env('MAIL_FROM_NAME', 'Example'), 89 | ], 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Markdown Mail Settings 94 | |-------------------------------------------------------------------------- 95 | | 96 | | If you are using Markdown based email rendering, you may configure your 97 | | theme and component paths here, allowing you to customize the design 98 | | of the emails. Or, you may simply stick with the Laravel defaults! 99 | | 100 | */ 101 | 102 | 'markdown' => [ 103 | 'theme' => 'default', 104 | 105 | 'paths' => [ 106 | resource_path('views/vendor/mail'), 107 | ], 108 | ], 109 | 110 | ]; 111 | -------------------------------------------------------------------------------- /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 | 'suffix' => env('SQS_SUFFIX'), 59 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 60 | ], 61 | 62 | 'redis' => [ 63 | 'driver' => 'redis', 64 | 'connection' => 'default', 65 | 'queue' => env('REDIS_QUEUE', 'default'), 66 | 'retry_after' => 90, 67 | 'block_for' => null, 68 | ], 69 | 70 | ], 71 | 72 | /* 73 | |-------------------------------------------------------------------------- 74 | | Failed Queue Jobs 75 | |-------------------------------------------------------------------------- 76 | | 77 | | These options configure the behavior of failed queue job logging so you 78 | | can control which database and table are used to store the jobs that 79 | | have failed. You may change them to any database / table you wish. 80 | | 81 | */ 82 | 83 | 'failed' => [ 84 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), 85 | 'database' => env('DB_CONNECTION', 'mysql'), 86 | 'table' => 'failed_jobs', 87 | ], 88 | 89 | ]; 90 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'client_id' => env('GOOGLE_CLIENT_ID'), 18 | 'client_secret' => env('GOOGLE_CLIENT_SECRET'), 19 | 'redirect' => '/callback/google', 20 | ], 21 | 22 | 'mailgun' => [ 23 | 'domain' => env('MAILGUN_DOMAIN'), 24 | 'secret' => env('MAILGUN_SECRET'), 25 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 26 | ], 27 | 28 | 'postmark' => [ 29 | 'token' => env('POSTMARK_TOKEN'), 30 | ], 31 | 32 | 'ses' => [ 33 | 'key' => env('AMAZON_KEY'), 34 | 'secret' => env('AMAZON_SECRET'), 35 | 'region' => env('AMAZON_DEFAULT_REGION', 'us-east-1'), 36 | ], 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /config/session.php: -------------------------------------------------------------------------------- 1 | env('SESSION_DRIVER', 'file'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Session Lifetime 26 | |-------------------------------------------------------------------------- 27 | | 28 | | Here you may specify the number of minutes that you wish the session 29 | | to be allowed to remain idle before it expires. If you want them 30 | | to immediately expire on the browser closing, set that option. 31 | | 32 | */ 33 | 34 | 'lifetime' => env('SESSION_LIFETIME', 120), 35 | 36 | 'expire_on_close' => false, 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Session Encryption 41 | |-------------------------------------------------------------------------- 42 | | 43 | | This option allows you to easily specify that all of your session data 44 | | should be encrypted before it is stored. All encryption will be run 45 | | automatically by Laravel and you can use the Session like normal. 46 | | 47 | */ 48 | 49 | 'encrypt' => false, 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | Session File Location 54 | |-------------------------------------------------------------------------- 55 | | 56 | | When using the native session driver, we need a location where session 57 | | files may be stored. A default has been set for you but a different 58 | | location may be specified. This is only needed for file sessions. 59 | | 60 | */ 61 | 62 | 'files' => storage_path('framework/sessions'), 63 | 64 | /* 65 | |-------------------------------------------------------------------------- 66 | | Session Database Connection 67 | |-------------------------------------------------------------------------- 68 | | 69 | | When using the "database" or "redis" session drivers, you may specify a 70 | | connection that should be used to manage these sessions. This should 71 | | correspond to a connection in your database configuration options. 72 | | 73 | */ 74 | 75 | 'connection' => env('SESSION_CONNECTION', null), 76 | 77 | /* 78 | |-------------------------------------------------------------------------- 79 | | Session Database Table 80 | |-------------------------------------------------------------------------- 81 | | 82 | | When using the "database" session driver, you may specify the table we 83 | | should use to manage the sessions. Of course, a sensible default is 84 | | provided for you; however, you are free to change this as needed. 85 | | 86 | */ 87 | 88 | 'table' => 'sessions', 89 | 90 | /* 91 | |-------------------------------------------------------------------------- 92 | | Session Cache Store 93 | |-------------------------------------------------------------------------- 94 | | 95 | | While using one of the framework's cache driven session backends you may 96 | | list a cache store that should be used for these sessions. This value 97 | | must match with one of the application's configured cache "stores". 98 | | 99 | | Affects: "apc", "dynamodb", "memcached", "redis" 100 | | 101 | */ 102 | 103 | 'store' => env('SESSION_STORE', null), 104 | 105 | /* 106 | |-------------------------------------------------------------------------- 107 | | Session Sweeping Lottery 108 | |-------------------------------------------------------------------------- 109 | | 110 | | Some session drivers must manually sweep their storage location to get 111 | | rid of old sessions from storage. Here are the chances that it will 112 | | happen on a given request. By default, the odds are 2 out of 100. 113 | | 114 | */ 115 | 116 | 'lottery' => [2, 100], 117 | 118 | /* 119 | |-------------------------------------------------------------------------- 120 | | Session Cookie Name 121 | |-------------------------------------------------------------------------- 122 | | 123 | | Here you may change the name of the cookie used to identify a session 124 | | instance by ID. The name specified here will get used every time a 125 | | new session cookie is created by the framework for every driver. 126 | | 127 | */ 128 | 129 | 'cookie' => env( 130 | 'SESSION_COOKIE', 131 | Str::slug(env('APP_NAME', 'laravel'), '_') . '_session' 132 | ), 133 | 134 | /* 135 | |-------------------------------------------------------------------------- 136 | | Session Cookie Path 137 | |-------------------------------------------------------------------------- 138 | | 139 | | The session cookie path determines the path for which the cookie will 140 | | be regarded as available. Typically, this will be the root path of 141 | | your application but you are free to change this when necessary. 142 | | 143 | */ 144 | 145 | 'path' => '/', 146 | 147 | /* 148 | |-------------------------------------------------------------------------- 149 | | Session Cookie Domain 150 | |-------------------------------------------------------------------------- 151 | | 152 | | Here you may change the domain of the cookie used to identify a session 153 | | in your application. This will determine which domains the cookie is 154 | | available to in your application. A sensible default has been set. 155 | | 156 | */ 157 | 158 | 'domain' => env('SESSION_DOMAIN', null), 159 | 160 | /* 161 | |-------------------------------------------------------------------------- 162 | | HTTPS Only Cookies 163 | |-------------------------------------------------------------------------- 164 | | 165 | | By setting this option to true, session cookies will only be sent back 166 | | to the server if the browser has a HTTPS connection. This will keep 167 | | the cookie from being sent to you if it can not be done securely. 168 | | 169 | */ 170 | 171 | 'secure' => env('SESSION_SECURE_COOKIE'), 172 | 173 | /* 174 | |-------------------------------------------------------------------------- 175 | | HTTP Access Only 176 | |-------------------------------------------------------------------------- 177 | | 178 | | Setting this value to true will prevent JavaScript from accessing the 179 | | value of the cookie and the cookie will only be accessible through 180 | | the HTTP protocol. You are free to modify this option if needed. 181 | | 182 | */ 183 | 184 | 'http_only' => true, 185 | 186 | /* 187 | |-------------------------------------------------------------------------- 188 | | Same-Site Cookies 189 | |-------------------------------------------------------------------------- 190 | | 191 | | This option determines how your cookies behave when cross-site requests 192 | | take place, and can be used to mitigate CSRF attacks. By default, we 193 | | will set this value to "lax" since this is a secure default value. 194 | | 195 | | Supported: "lax", "strict", "none", null 196 | | 197 | */ 198 | 199 | 'same_site' => 'lax', 200 | 201 | ]; 202 | -------------------------------------------------------------------------------- /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->name, 27 | 'email' => $this->faker->unique()->safeEmail, 28 | 'email_verified_at' => now(), 29 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 30 | 'remember_token' => Str::random(10), 31 | ]; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 19 | $table->string('email')->unique(); 20 | $table->string('name')->nullable(); 21 | $table->string('avatar', 1000)->nullable(); 22 | $table->string('stripe')->nullable(); 23 | $table->boolean('is_sub')->default(false); 24 | $table->timestamps(); 25 | }); 26 | 27 | Schema::create('providers', function (Blueprint $table) { 28 | $table->bigIncrements('id'); 29 | $table->foreignIdFor(User::class)->constrained(); 30 | $table->string('avatar')->nullable(); 31 | $table->string('name'); 32 | $table->text('payload'); 33 | $table->timestamps(); 34 | }); 35 | } 36 | 37 | /** 38 | * Reverse the migrations. 39 | * 40 | * @return void 41 | */ 42 | public function down() 43 | { 44 | Schema::dropIfExists('users'); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('uuid')->unique(); 19 | $table->text('connection'); 20 | $table->text('queue'); 21 | $table->longText('payload'); 22 | $table->longText('exception'); 23 | $table->timestamp('failed_at')->useCurrent(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('failed_jobs'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /database/migrations/2021_10_20_233327_create_humble_tables.php: -------------------------------------------------------------------------------- 1 | string('token', 64)->unique(); 18 | $table->bigInteger('user_id')->unsigned(); 19 | $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); 20 | $table->string('source')->nullable(); 21 | $table->json('abilities')->nullable(); 22 | 23 | // user metadata 24 | $table->string('ip', 300)->nullable(); 25 | $table->string('agent')->nullable(); 26 | $table->string('location')->nullable(); 27 | 28 | $table->timestamps(); 29 | $table->primary('token'); 30 | }); 31 | 32 | Schema::create('attempts', function (Blueprint $table) { 33 | $table->string('token', 64)->unique(); 34 | 35 | // action functionality store data involving what the user was doing 36 | $table->json('action')->nullable(); 37 | 38 | $table->bigInteger('user_id')->unsigned(); 39 | $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); 40 | 41 | $table->string('ip', 300)->nullable(); 42 | $table->string('agent')->nullable(); 43 | 44 | $table->timestamps(); 45 | $table->primary('token'); 46 | }); 47 | } 48 | 49 | /** 50 | * Reverse the migrations. 51 | * 52 | * @return void 53 | */ 54 | public function down() 55 | { 56 | Schema::dropIfExists('sessions'); 57 | Schema::dropIfExists('attempts'); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lang/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "The :attribute must contain at least one letter.": "The :attribute must contain at least one letter.", 3 | "The :attribute must contain at least one number.": "The :attribute must contain at least one number.", 4 | "The :attribute must contain at least one symbol.": "The :attribute must contain at least one symbol.", 5 | "The :attribute must contain at least one uppercase and one lowercase letter.": "The :attribute must contain at least one uppercase and one lowercase letter.", 6 | "The given :attribute has appeared in a data leak. Please choose a different :attribute.": "The given :attribute has appeared in a data leak. Please choose a different :attribute." 7 | } 8 | -------------------------------------------------------------------------------- /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 | 'logout' => 'Logout successful', 19 | 'session-removed' => 'Session removed', 20 | ]; 21 | -------------------------------------------------------------------------------- /lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Your password has been reset!', 17 | 'sent' => 'We have emailed your password reset link!', 18 | 'throttled' => 'Please wait before retrying.', 19 | 'token' => 'This password reset token is invalid.', 20 | 'user' => "We can't find a user with that email address.", 21 | 22 | ]; 23 | -------------------------------------------------------------------------------- /lang/en/validation.php: -------------------------------------------------------------------------------- 1 | 'The :attribute must be accepted.', 17 | 'active_url' => 'The :attribute is not a valid URL.', 18 | 'after' => 'The :attribute must be a date after :date.', 19 | 'after_or_equal' => 'The :attribute must be a date after or equal to :date.', 20 | 'alpha' => 'The :attribute may only contain letters.', 21 | 'alpha_dash' => 'The :attribute may only contain letters, numbers, dashes and underscores.', 22 | 'alpha_num' => 'The :attribute may only contain letters and numbers.', 23 | 'array' => 'The :attribute must be an array.', 24 | 'before' => 'The :attribute must be a date before :date.', 25 | 'before_or_equal' => 'The :attribute must be a date before or equal to :date.', 26 | 'between' => [ 27 | 'numeric' => 'The :attribute must be between :min and :max.', 28 | 'file' => 'The :attribute must be between :min and :max kilobytes.', 29 | 'string' => 'The :attribute must be between :min and :max characters.', 30 | 'array' => 'The :attribute must have between :min and :max items.', 31 | ], 32 | 'boolean' => 'The :attribute field must be true or false.', 33 | 'confirmed' => 'The :attribute confirmation does not match.', 34 | 'date' => 'The :attribute is not a valid date.', 35 | 'date_equals' => 'The :attribute must be a date equal to :date.', 36 | 'date_format' => 'The :attribute does not match the format :format.', 37 | 'different' => 'The :attribute and :other must be different.', 38 | 'digits' => 'The :attribute must be :digits digits.', 39 | 'digits_between' => 'The :attribute must be between :min and :max digits.', 40 | 'dimensions' => 'The :attribute has invalid image dimensions.', 41 | 'distinct' => 'The :attribute field has a duplicate value.', 42 | 'email' => 'The :attribute must be a valid email address.', 43 | 'ends_with' => 'The :attribute must end with one of the following: :values.', 44 | 'exists' => 'The selected :attribute is invalid.', 45 | 'file' => 'The :attribute must be a file.', 46 | 'filled' => 'The :attribute field must have a value.', 47 | 'gt' => [ 48 | 'numeric' => 'The :attribute must be greater than :value.', 49 | 'file' => 'The :attribute must be greater than :value kilobytes.', 50 | 'string' => 'The :attribute must be greater than :value characters.', 51 | 'array' => 'The :attribute must have more than :value items.', 52 | ], 53 | 'gte' => [ 54 | 'numeric' => 'The :attribute must be greater than or equal :value.', 55 | 'file' => 'The :attribute must be greater than or equal :value kilobytes.', 56 | 'string' => 'The :attribute must be greater than or equal :value characters.', 57 | 'array' => 'The :attribute must have :value items or more.', 58 | ], 59 | 'image' => 'The :attribute must be an image.', 60 | 'in' => 'The selected :attribute is invalid.', 61 | 'in_array' => 'The :attribute field does not exist in :other.', 62 | 'integer' => 'The :attribute must be an integer.', 63 | 'ip' => 'The :attribute must be a valid IP address.', 64 | 'ipv4' => 'The :attribute must be a valid IPv4 address.', 65 | 'ipv6' => 'The :attribute must be a valid IPv6 address.', 66 | 'json' => 'The :attribute must be a valid JSON string.', 67 | 'lt' => [ 68 | 'numeric' => 'The :attribute must be less than :value.', 69 | 'file' => 'The :attribute must be less than :value kilobytes.', 70 | 'string' => 'The :attribute must be less than :value characters.', 71 | 'array' => 'The :attribute must have less than :value items.', 72 | ], 73 | 'lte' => [ 74 | 'numeric' => 'The :attribute must be less than or equal :value.', 75 | 'file' => 'The :attribute must be less than or equal :value kilobytes.', 76 | 'string' => 'The :attribute must be less than or equal :value characters.', 77 | 'array' => 'The :attribute must not have more than :value items.', 78 | ], 79 | 'max' => [ 80 | 'numeric' => 'The :attribute may not be greater than :max.', 81 | 'file' => 'The :attribute may not be greater than :max kilobytes.', 82 | 'string' => 'The :attribute may not be greater than :max characters.', 83 | 'array' => 'The :attribute may not have more than :max items.', 84 | ], 85 | 'mimes' => 'The :attribute must be a file of type: :values.', 86 | 'mimetypes' => 'The :attribute must be a file of type: :values.', 87 | 'min' => [ 88 | 'numeric' => 'The :attribute must be at least :min.', 89 | 'file' => 'The :attribute must be at least :min kilobytes.', 90 | 'string' => 'The :attribute must be at least :min characters.', 91 | 'array' => 'The :attribute must have at least :min items.', 92 | ], 93 | 'not_in' => 'The selected :attribute is invalid.', 94 | 'not_regex' => 'The :attribute format is invalid.', 95 | 'numeric' => 'The :attribute must be a number.', 96 | 'password' => 'The password is incorrect.', 97 | 'present' => 'The :attribute field must be present.', 98 | 'regex' => 'The :attribute format is invalid.', 99 | 'required' => 'The :attribute field is required.', 100 | 'required_if' => 'The :attribute field is required when :other is :value.', 101 | 'required_unless' => 'The :attribute field is required unless :other is in :values.', 102 | 'required_with' => 'The :attribute field is required when :values is present.', 103 | 'required_with_all' => 'The :attribute field is required when :values are present.', 104 | 'required_without' => 'The :attribute field is required when :values is not present.', 105 | 'required_without_all' => 'The :attribute field is required when none of :values are present.', 106 | 'same' => 'The :attribute and :other must match.', 107 | 'size' => [ 108 | 'numeric' => 'The :attribute must be :size.', 109 | 'file' => 'The :attribute must be :size kilobytes.', 110 | 'string' => 'The :attribute must be :size characters.', 111 | 'array' => 'The :attribute must contain :size items.', 112 | ], 113 | 'starts_with' => 'The :attribute must start with one of the following: :values.', 114 | 'string' => 'The :attribute must be a string.', 115 | 'timezone' => 'The :attribute must be a valid zone.', 116 | 'unique' => 'The :attribute has already been taken.', 117 | 'uploaded' => 'The :attribute failed to upload.', 118 | 'url' => 'The :attribute format is invalid.', 119 | 'uuid' => 'The :attribute must be a valid UUID.', 120 | 121 | /* 122 | |-------------------------------------------------------------------------- 123 | | Custom Validation Language Lines 124 | |-------------------------------------------------------------------------- 125 | | 126 | | Here you may specify custom validation messages for attributes using the 127 | | convention "attribute.rule" to name the lines. This makes it quick to 128 | | specify a specific custom language line for a given attribute rule. 129 | | 130 | */ 131 | 132 | 'custom' => [ 133 | 'attribute-name' => [ 134 | 'rule-name' => 'custom-message', 135 | ], 136 | ], 137 | 138 | /* 139 | |-------------------------------------------------------------------------- 140 | | Custom Validation Attributes 141 | |-------------------------------------------------------------------------- 142 | | 143 | | The following language lines are used to swap our attribute placeholder 144 | | with something more reader friendly such as "E-Mail Address" instead 145 | | of "email". This simply helps us make our message more expressive. 146 | | 147 | */ 148 | 149 | 'attributes' => [], 150 | 151 | ]; 152 | -------------------------------------------------------------------------------- /nuxt.config.ts: -------------------------------------------------------------------------------- 1 | export default defineNuxtConfig({ 2 | srcDir: 'client/', 3 | app: { 4 | head: { 5 | title: process.env.npm_package_name || '', 6 | meta: [ 7 | { charset: 'utf-8' }, 8 | { name: 'viewport', content: 'width=device-width, initial-scale=1' }, 9 | { hid: 'description', name: 'description', content: process.env.npm_package_description || '' }, 10 | ], 11 | link: [ 12 | { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }, 13 | ], 14 | script: [ 15 | { src: 'https://cdnjs.cloudflare.com/ajax/libs/lottie-web/5.8.1/lottie.min.js' }, 16 | ], 17 | }, 18 | }, 19 | tailwindcss: { 20 | }, 21 | css: [ 22 | '@/assets/css/main.css', 23 | '@/assets/css/device.css', 24 | ], 25 | 26 | /** 27 | * @see https://v3.nuxtjs.org/api/configuration/nuxt.config#modules 28 | */ 29 | modules: [ 30 | '@vueuse/nuxt', 31 | '@nuxt/ui', 32 | ], 33 | ui: { 34 | icons: ['mdi'], 35 | }, 36 | 37 | /** 38 | * @see https://v3.nuxtjs.org/guide/features/runtime-config#exposing-runtime-config 39 | */ 40 | runtimeConfig: { 41 | public: { 42 | webURL: process.env.WEB_URL || 'http://localhost:3000', 43 | apiURL: process.env.API_URL || 'http://localhost:8000', 44 | }, 45 | }, 46 | 47 | }) 48 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laranuxt", 3 | "version": "1.0.0", 4 | "private": true, 5 | "scripts": { 6 | "prepare": "husky install", 7 | "dev": "nuxi dev", 8 | "build": "nuxi build", 9 | "start": "node .output/server/index.mjs", 10 | "lint": "yarn lint:js", 11 | "lint:js": "eslint --ext .ts,.js,.vue --ignore-path .gitignore .", 12 | "lint:action": "yarn lint:js -f @jamesacarr/github-actions", 13 | "style": "composer cs; yarn lint", 14 | "test": "vitest", 15 | "t": "yarn test", 16 | "test:coverage": "vitest run --coverage", 17 | "tc": "yarn test:coverage", 18 | "api": "./artisan serve", 19 | "seed": "./artisan migrate:fresh --seed", 20 | "caches": "./artisan config:cache; ./artisan route:cache; ./artisan cache:clear; ./artisan event:clear;", 21 | "stan": "composer stan" 22 | }, 23 | "dependencies": { 24 | "@nuxt/ui": "^2.9.0" 25 | }, 26 | "devDependencies": { 27 | "@antfu/eslint-config": "1.0.0-beta.21", 28 | "@iconify-json/mdi": "^1.1.54", 29 | "@iconify/vue": "^4.1.1", 30 | "@jamesacarr/eslint-formatter-github-actions": "^0.2.0", 31 | "@typescript-eslint/eslint-plugin": "^6.7.4", 32 | "@vitest/coverage-v8": "^0.34.6", 33 | "@vueuse/nuxt": "^10.5.0", 34 | "dayjs": "^1.11.10", 35 | "eslint": "^8.51.0", 36 | "husky": "^8.0.3", 37 | "jsdom": "^22.1.0", 38 | "laravel-echo": "^1.15.3", 39 | "lottie-web": "^5.12.2", 40 | "nuxt": "^3.7.4", 41 | "ofetch": "^1.3.3", 42 | "pusher-js": "^8.3.0", 43 | "tailwindcss": "^3.3.3", 44 | "typescript": "^5.2.2", 45 | "vitest": "^0.34.6", 46 | "vue": "^3.3.4", 47 | "vue-router": "^4.2.5" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /phpstan.neon: -------------------------------------------------------------------------------- 1 | includes: 2 | - ./vendor/larastan/larastan/extension.neon 3 | 4 | parameters: 5 | paths: 6 | - app 7 | 8 | # Determines the level of checking. 5 is a good starter point 8 is max 9 | level: 8 10 | 11 | ignoreErrors: 12 | - '#Call to an undefined method Laravel\\Socialite\\Contracts\\Provider::stateless\(\)\.#' 13 | 14 | excludePaths: 15 | 16 | -------------------------------------------------------------------------------- /pint.json: -------------------------------------------------------------------------------- 1 | { 2 | "preset": "laravel", 3 | "exclude": [ 4 | "node_modules", 5 | "vendor", 6 | "client" 7 | ], 8 | "rules": { 9 | "no_useless_else": true, 10 | "concat_space": { 11 | "spacing": "one" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /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 | # Send Requests To 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/fumeapp/laranuxt/e15336bf2b8c99bef5e529edd2eaf9ad37c0cb8c/public/favicon.ico -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class); 50 | 51 | $response = tap($kernel->handle( 52 | $request = Request::capture() 53 | ))->send(); 54 | 55 | $kernel->terminate($request, $response); 56 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | ## Laravel + Nuxt.js Boilerplate 6 | 7 | > Now supporting [Nuxt v3](https://nuxt.com) 8 | 9 | 10 | **Are you using Laravel with vapor? want your Nuxt setup on lambda as well? [TRY FUME!](https://fume.app)** 11 | 12 | 13 | [![](https://img.shields.io/badge/nuxt.js-v3.7-04C690.svg)](https://nuxt.com) 14 | [![](https://img.shields.io/badge/Laravel-v11.0.0-ff2e21.svg)](https://laravel.com) 15 | [![MadeWithLaravel shield](https://madewithlaravel.com/storage/repo-shields/3372-shield.svg)](https://madewithlaravel.com/p/laranuxt/shield-link) 16 | 17 | ![Test PHP](https://github.com/fumeapp/laranuxt/workflows/Test%20PHP/badge.svg) 18 | [![Lint Javascript](https://github.com/fumeapp/laranuxt/actions/workflows/lint-js.yml/badge.svg)](https://github.com/fumeapp/laranuxt/actions/workflows/lint-js.yml) 19 | [![Lint PHP](https://github.com/fumeapp/laranuxt/actions/workflows/lint-php.yml/badge.svg)](https://github.com/fumeapp/laranuxt/actions/workflows/lint-php.yml) 20 | 21 | ![](resources/laranuxt.gif) 22 | 23 | > Examples on using Dark Mode, authentication, and listing data 24 | 25 | ### What is included 26 | 27 | * [NUXT v3](https://nuxt.com) front end, a progressive Vue.js framework - For Nuxt v2 visit [this branch](https://github.com/fumeapp/laranuxt/tree/nuxt2) 28 | * [nuxt UI](https://ui.nuxt.com) a collection of components built by the NuxtJS team, powered by TailwindCSS 29 | * [Authentication library](https://github.com/fumeapp/laranuxt#api-and-authentication) to assist with user sessions and logging in/out 30 | * Example Authentication Middleware 31 | 32 | * [Laravel](https://laravel.com) - for our API - `v11.0.0` 33 | * [Model Typer](https://github.com/fumeapp/modeltyper) - Generates Typescript interfaces from Laravel Models 34 | * [MetAPI](https://github.com/fumeapp/metapi) - API helpers and utilities 35 | * [humble](https://github.com/fumeapp/humble) - Passwordless sessioning with detailed device and location 36 | * [debugbar](https://github.com/barryvdh/laravel-debugbar) - awesome debugbar for our API 37 | * [ide-helper](https://github.com/barryvdh/laravel-ide-helper) - Helper files to enable help with IDE autocompletion 38 | 39 | ### Installation 40 | 41 | * clone from GitHub 42 | * run `pnpm i` and `composer install` to install all of your deps 43 | * copy `.env.example` to `.env` and configure it to your likings 44 | * TL;DR 45 | ```bash 46 | git clone git@github.com:fumeapp/laranuxt.git; cd laranuxt; pnpm i; composer install; cp .env.example .env; 47 | ``` 48 | * Feel free to delete excess media in `/resources/` 49 | 50 | 51 | ### Local Environment 52 | * run `pnpm run dev` in one terminal for our nuxt dev setup 53 | * run `pnpm run api` (alias for `./artisan serve`) in another terminal for our laravel API 54 | 55 | ### Api and Authentication 56 | 57 | * Api and auth can be accessed via the provided `Api` library 58 | 59 | ```ts 60 | const api = useApi() 61 | console.log(api.$user.name); 62 | ``` 63 | 64 | #### Authentication 65 | 66 | * Take a look at [HeaderLoginModal.vue](https://github.com/fumeapp/laranuxt/blob/main/client/components/header/HeaderLoginModal.vue#L143) to see how we pass the credentials to our library 67 | ```ts 68 | const redirect = await api.login(result) 69 | if (redirect) await router.push({path: redirect}) 70 | ``` 71 | * Once logged on, you have the ref `api.loggedIn` and the object `api.$user` 72 | ```html 73 | User Avatar 74 | ``` 75 | 76 | #### API 77 | The API class provides helper functions to easily retrieve, update, and remove data from your Laravel endpoints. If you use and update [modeltyper](https://github.com/fumeapp/modeltyper) regularly you will always have completely typed results 78 | 79 | * To get a listing/index of data, use `api.index` 80 | ```ts 81 | const users = api.index('/user', { page: 1 }) 82 | ``` 83 | 84 | * To get an individual by id, use `api.get` 85 | ```ts 86 | const users = api.get('/user/1') 87 | ``` 88 | 89 | * To update with an id, use `api.put` 90 | ```ts 91 | const result = api.put('/user/1', user) 92 | ``` 93 | 94 | * To store a new record, use `api.store` 95 | ```ts 96 | const result = api.store('/user', { name: 'Bob', email: 'bob@mail.com' }) 97 | ``` 98 | 99 | * To delete with an id, use `api.delete` 100 | ```ts 101 | const result = api.delete('/user/1') 102 | ``` 103 | -------------------------------------------------------------------------------- /resources/laranuxt.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fumeapp/laranuxt/e15336bf2b8c99bef5e529edd2eaf9ad37c0cb8c/resources/laranuxt.gif -------------------------------------------------------------------------------- /resources/laranuxt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fumeapp/laranuxt/e15336bf2b8c99bef5e529edd2eaf9ad37c0cb8c/resources/laranuxt.png -------------------------------------------------------------------------------- /resources/views/complete.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{ config('app.name') }} 5 | 9 | 10 | Processing Login 11 | 12 | -------------------------------------------------------------------------------- /resources/views/emails/user/attempt.blade.php: -------------------------------------------------------------------------------- 1 | @component('mail::message') 2 | 3 | # Hello! 4 | ## You have requested to login via e-mail 5 | 6 | @component('mail::button', ['url' => config('app.web').'/attempt/'.$token]) 7 | Sign In / Register 8 | @endcomponent 9 | 10 | @component('mail::subcopy') 11 | Note: Please contact support if you did not request this e-mail 12 | @endcomponent 13 | 14 | @endcomponent 15 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | name('entry-point') 21 | ->withoutMiddleware('api'); 22 | Route::get('example', [Controller::class, 'example'])->name('example'); 23 | Route::get('error', [Controller::class, 'exampleError'])->name('error'); 24 | 25 | // Authentication 26 | Route::get('login/{token}', [AuthController::class, 'login'])->name('login'); 27 | 28 | Route::controller(AuthController::class)->group(function () { 29 | Route::get('redirect/{provider}', 'redirect')->name('provider.redirect'); 30 | Route::get('callback/{provider}', 'callback')->name('provider.callback'); 31 | Route::get('onetap/{credential}', 'onetap')->name('onetap.support'); 32 | Route::post('attempt', 'attempt')->name('auth.attempt'); 33 | Route::post('login', 'login')->name('auth.login'); 34 | Route::get('logout', 'logout')->middleware('auth:api')->name('auth.logout'); 35 | Route::get('me', 'me')->middleware('auth:api')->name('auth.session'); 36 | }); 37 | 38 | Route::apiResource('session', SessionController::class)->middleware('auth:api'); 39 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 18 | }); 19 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 19 | })->purpose('Display an inspiring quote'); 20 | -------------------------------------------------------------------------------- /server.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | $uri = urldecode( 9 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 10 | ); 11 | 12 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the 13 | // built-in PHP web server. This provides a convenient way to test a Laravel 14 | // application without having installed a "real" web server software here. 15 | if ($uri !== '/' && file_exists(__DIR__ . '/public' . $uri)) { 16 | return false; 17 | } 18 | 19 | require_once __DIR__ . '/public/index.php'; 20 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | compiled.php 2 | config.php 3 | down 4 | events.scanned.php 5 | maintenance.php 6 | routes.php 7 | routes.scanned.php 8 | schedule-* 9 | services.json 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/js/app.spec.ts: -------------------------------------------------------------------------------- 1 | import { 2 | describe, 3 | expect, 4 | test, 5 | } from 'vitest' 6 | 7 | describe('Test App', () => { 8 | test('works', () => { 9 | expect(true).toBe(true) 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /tests/js/components/contact/ContactCard.spec.ts: -------------------------------------------------------------------------------- 1 | import { mount } from '@vue/test-utils' 2 | import { 3 | describe, 4 | expect, 5 | test, 6 | } from 'vitest' 7 | import ContactCard from '~/components/contact/ContactCard.vue' 8 | 9 | describe('ContactCard', () => { 10 | test('renders contact card for non admin', () => { 11 | const wrapper = mount(ContactCard, { 12 | props: { 13 | user: {} as models.User, 14 | }, 15 | 16 | computed: { 17 | is_admin: () => false, 18 | }, 19 | }) 20 | expect(wrapper.html()).toMatchSnapshot() 21 | }) 22 | 23 | test('renders contact card for admin', () => { 24 | const wrapper = mount(ContactCard, { 25 | props: { 26 | user: {} as models.User, 27 | }, 28 | 29 | computed: { 30 | is_admin: () => true, 31 | }, 32 | }) 33 | 34 | expect(wrapper.html()).toMatchSnapshot() 35 | }) 36 | }) 37 | -------------------------------------------------------------------------------- /tests/js/components/contact/ContactCardSkeleton.spec.ts: -------------------------------------------------------------------------------- 1 | import { mount } from '@vue/test-utils' 2 | import { 3 | describe, 4 | expect, 5 | test, 6 | } from 'vitest' 7 | import ContactCardSkeleton from '~/components/contact/ContactCardSkeleton.vue' 8 | 9 | describe('ContactCardSkeleton', () => { 10 | test('renders contact card skelton', () => { 11 | const wrapper = mount(ContactCardSkeleton) 12 | expect(wrapper.html()).toMatchSnapshot() 13 | }) 14 | }) 15 | -------------------------------------------------------------------------------- /tests/js/components/contact/__snapshots__/ContactCard.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 | 3 | exports[`ContactCard > renders contact card for admin 1`] = ` 4 | "
  • 5 |
    6 |
    7 |
    8 |

    Admin 9 |
    10 |

    11 |
    12 | 13 |
    14 |
    15 |
    16 | 17 | 18 |
    19 |
    20 |
  • " 21 | `; 22 | 23 | exports[`ContactCard > renders contact card for non admin 1`] = ` 24 | "
  • 25 |
    26 |
    27 |
    28 |

    29 | 30 |
    31 |

    32 |
    33 | 34 |
    35 |
    36 |
    37 | 38 | 39 |
    40 |
    41 |
  • " 42 | `; 43 | -------------------------------------------------------------------------------- /tests/js/components/contact/__snapshots__/ContactCardSkeleton.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 | 3 | exports[`ContactCardSkeleton > renders contact card skelton 1`] = ` 4 | "
  • 5 |
    6 |
    7 |
    8 |

     

    9 |
    10 |

     

    11 |
    12 |
    13 |
    14 |
    15 | 23 |
    24 |
  • " 25 | `; 26 | -------------------------------------------------------------------------------- /tests/js/composables/crumbs.spec.ts: -------------------------------------------------------------------------------- 1 | import { 2 | describe, 3 | expect, 4 | test, 5 | } from 'vitest' 6 | import type { BreadCrumb } from '@/types/frontend' 7 | import { useCrumbs } from '~/composables/crumbs' 8 | 9 | describe('useCrumbs', () => { 10 | test('sets crumbs', () => { 11 | const { setCrumbs, list } = useCrumbs() 12 | const crumbs = [{ name: 'foo', to: '/foo' }] as BreadCrumb[] 13 | setCrumbs(crumbs) 14 | expect(list.value).toEqual(crumbs) 15 | }) 16 | 17 | test('sets actions', () => { 18 | const { setActions, actions } = useCrumbs() 19 | const crumbs = [{ name: 'foo', to: '/foo' }] as BreadCrumb[] 20 | setActions(crumbs) 21 | expect(actions.value).toEqual(crumbs) 22 | }) 23 | }) 24 | -------------------------------------------------------------------------------- /tests/php/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 19 | 20 | return $app; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/php/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 19 | 20 | $response->assertStatus(200); 21 | } 22 | 23 | /** 24 | * Test Our Example Endpoint required parameters are present 25 | * 26 | * @return void 27 | */ 28 | public function testFail() 29 | { 30 | $this->json('get', '/example') 31 | ->assertStatus(Response::HTTP_BAD_REQUEST) 32 | ->assertJsonStructure([ 33 | 'status', 34 | 'errors' => [ 35 | '*' => [ 36 | 'status', 37 | 'message', 38 | 'detail', 39 | ], 40 | ], 41 | ]); 42 | } 43 | 44 | /** 45 | * Test our our example endpoint returns random users 46 | * 47 | * @return void 48 | */ 49 | public function testExample() 50 | { 51 | $count = 1; 52 | 53 | $this->json('get', "/example?count={$count}") 54 | ->assertOk() 55 | ->assertJson(fn (AssertableJson $json) => $json->where('status', 'success') 56 | ->has('benchmark') 57 | ->has('query') 58 | ->has('data') 59 | ->has('data.0', fn ($json) => $json->has('name') 60 | ->has('job') 61 | ->has('email') 62 | ->has('avatar'))); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /tests/php/TestCase.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/php/phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | ./Unit 10 | 11 | 12 | ./Feature 13 | 14 | 15 | 16 | 17 | ../../app 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | // https://nuxt.com/docs/guide/concepts/typescript 3 | "extends": "./.nuxt/tsconfig.json" 4 | } 5 | -------------------------------------------------------------------------------- /vitest.config.ts: -------------------------------------------------------------------------------- 1 | import path from 'path' 2 | import Vue from '@vitejs/plugin-vue' 3 | import { defineConfig } from 'vite' 4 | 5 | export default defineConfig({ 6 | resolve: { 7 | alias: { 8 | '~/': `${path.resolve(__dirname, 'client')}/`, 9 | }, 10 | }, 11 | plugins: [ 12 | Vue({ 13 | include: [/\.vue$/], 14 | reactivityTransform: true, 15 | }), 16 | ], 17 | test: { 18 | globals: true, 19 | environment: 'jsdom', 20 | include: [ 21 | './tests/js/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}', 22 | ], 23 | }, 24 | }) 25 | --------------------------------------------------------------------------------