Go to file
Flycro cae791ae27
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is passing Details
style: Added Logo to Login
2024-03-24 19:06:42 +01:00
.github/workflows Initial commit 2024-03-17 14:07:38 +01:00
.vscode Initial commit 2024-03-17 14:07:38 +01:00
app feat: Realtime for Votes + Deadlines 2024-03-24 01:36:16 +01:00
art Initial commit 2024-03-17 14:07:38 +01:00
bootstrap feat: Realtime Functionality 2024-03-23 17:40:59 +01:00
config feat: Realtime Functionality 2024-03-23 17:40:59 +01:00
data Initial commit 2024-03-17 14:07:38 +01:00
database fix: Wrong ISBN 2024-03-22 23:42:49 +01:00
lang/en Initial commit 2024-03-17 14:07:38 +01:00
nuxt style: Added Logo to Login 2024-03-24 19:06:42 +01:00
public Initial commit 2024-03-17 14:07:38 +01:00
resources feat: Realtime Functionality 2024-03-23 17:40:59 +01:00
routes feat: Realtime for Votes + Deadlines 2024-03-24 01:36:16 +01:00
storage Initial commit 2024-03-17 14:07:38 +01:00
tests Initial commit 2024-03-17 14:07:38 +01:00
.dockerignore wip: Reordered Build Steps and added Dockerignore 2024-03-21 01:13:53 +01:00
.drone.yml fix: Git Hash #3 2024-03-24 14:36:50 +01:00
.editorconfig Initial commit 2024-03-17 14:07:38 +01:00
.env.example chore: Updated .env.example 2024-03-23 18:07:15 +01:00
.gitattributes Initial commit 2024-03-17 14:07:38 +01:00
.gitignore Initial commit 2024-03-17 14:07:38 +01:00
.npmrc Initial commit 2024-03-17 14:07:38 +01:00
Dockerfile fix: Fixed Problems in Docker Files + deploy script 2024-03-21 00:57:04 +01:00
LICENSE Initial commit 2024-03-17 14:07:38 +01:00
README.md Initial commit 2024-03-17 14:07:38 +01:00
artisan Initial commit 2024-03-17 14:07:38 +01:00
composer.json feat: Realtime Functionality 2024-03-23 17:40:59 +01:00
composer.lock feat: Realtime Functionality 2024-03-23 17:40:59 +01:00
docker-compose-production.yml fix: Fixed Problems in Docker Files + deploy script 2024-03-21 00:57:04 +01:00
docker-compose.yml feat: Multiple Systems 2024-03-18 01:26:54 +01:00
ecosystem.config.cjs fix: Hash in Build #4 2024-03-24 00:17:56 +01:00
eslint.config.js feat: Multiple Systems 2024-03-18 01:26:54 +01:00
nuxt.config.ts feat: Added Footer 2024-03-23 22:26:05 +01:00
package.json fix: Hash in Build #4 2024-03-24 00:17:56 +01:00
phpunit.xml Initial commit 2024-03-17 14:07:38 +01:00
pint.json Initial commit 2024-03-17 14:07:38 +01:00
pnpm-lock.yaml feat: Confetti on Deadline Confirm 2024-03-23 19:01:47 +01:00
tailwind.config.ts feat: Add Config + Set Default Font to DM Sans 2024-03-20 18:12:02 +01:00
tsconfig.json Initial commit 2024-03-17 14:07:38 +01:00

README.md

Laravel Nuxt Boilerplate

FOSSA Status GitHub Workflow Status CodeQL

The goal of the project is to create a template for development on Laravel and Nuxt with maximum API performance, ready-made authorization methods, image uploading with optimization and ready-made user roles.

Features

  • Laravel 11 and Nuxt 3
  • Laravel Octane supercharges your application's performance by serving your application using high-powered application servers.
  • Laravel Telescope provides insight into the requests coming into your application, exceptions, log entries, database queries, queued jobs, mail, notifications, cache operations, scheduled tasks, variable dumps, and more.
  • Laravel Sanctum Token-based authorization is compatible with SSR and CSR
  • Laravel Socialite OAuth providers
  • Spatie Laravel Permissions This package allows you to manage user permissions and roles in a database.
  • UI library Nuxt UI based on TailwindCSS and HeadlessUI.
  • Pinia The intuitive store for Vue.js
  • Integrated pages: login, registration, password recovery, email confirmation, account information update, password change.
  • Temporary uploads with cropping and optimization of images.
  • Device management
  • ofetch preset for working with Laravel API, which makes it possible use **fetch** without having to resort to custom fetch wrappers.

Requirements

Installation

  1. clone repository
  2. composer install
  3. cp .env.example .env && php artisan key:generate && php artisan storage:link
  4. php artisan migrate
  5. php artisan db:seed
  6. php artisan octane:install
  7. php artisan octane:start --watch --port=8000 --host=127.0.0.1
  8. yarn install
  9. yarn dev

Upgrade

  1. npx nuxi upgrade
  2. composer update

Nuxt port is set in package.json scripts via cross-env

Usage

Nuxt $fetch

To work with the api, the default path is "/api/v1". All requests from Nuxt to the Laravel API can be executed without wrappers, as described in the Nuxt.js documentation. For example, the code for authorizing a user by email and password:

<script lang="ts" setup>
const router = useRouter();
const auth = useAuthStore();
const form = ref();
const state = reactive({
  email: "",
  password: "",
  remember: false,
});

const { refresh: onSubmit, status } = useFetch("login", {
  method: "POST",
  body: state,
  immediate: false,
  watch: false,
  async onResponse({ response }) {
    if (response?.status === 422) {
      form.value.setErrors(response._data?.errors);
    } else if (response._data?.ok) {
      auth.token = response._data.token;

      await auth.fetchUser();
      await router.push("/");
    }
  }
});

const loading = computed(() => status.value === "pending");
</script>
<template>
  <UForm ref="form" :state="state" @submit="onSubmit" class="space-y-4">
    <UFormGroup label="Email" name="email" required>
      <UInput
        v-model="state.email"
        placeholder="you@example.com"
        icon="i-heroicons-envelope"
        trailing
        type="email"
        autofocus
      />
    </UFormGroup>

    <UFormGroup label="Password" name="password" required>
      <UInput v-model="state.password" type="password" />
    </UFormGroup>

    <UTooltip text="for 1 month" :popper="{ placement: 'right' }">
      <UCheckbox v-model="state.remember" label="Remember me" />
    </UTooltip>

    <div class="flex items-center justify-end space-x-4">
      <NuxtLink class="text-sm" to="/auth/forgot">Forgot your password?</NuxtLink>
      <UButton type="submit" label="Login" :loading="loading" />
    </div>
  </UForm>
</template>

In this example, a POST request will be made to the url "/api/v1/login"

Authentication

useAuthStore() has everything you need to work with authorization.

Data returned by useAuthStore:

  • isLoggedIn: Boolean, whether the user is authorized
  • token: Cookie, sanctum token
  • user: User object, user stored in pinia store
  • logout: Function, remove local data and call API to remove token
  • fetchUser: Function, fetch user data

Nuxt Middleware

The following middleware is supported:

  • guest: unauthorized users
  • auth: authorized users
  • verified: users who have confirmed their email
  • role-user: users with the 'user' role
  • role-admin: users with the 'admin' role

Laravel Middleware

All built-in middleware from Laravel + middleware based on roles Spatie Laravel Permissions Middleware