Skip to content

Commit

Permalink
laravel 11 upgrade, move to pinia
Browse files Browse the repository at this point in the history
  • Loading branch information
tobischulz committed May 31, 2024
1 parent bb5925e commit 841013a
Show file tree
Hide file tree
Showing 125 changed files with 5,035 additions and 8,605 deletions.
6 changes: 3 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml,vue}]
[*.{yml,yaml,vue,js}]
indent_size = 2

[docker-compose.yml]
Expand Down
60 changes: 35 additions & 25 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,38 +1,54 @@
APP_NAME="Laravel Fortify SPA"
APP_NAME="Vue Laravel SPA"
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost # set this to your local domain
APP_TIMEZONE=UTC
APP_URL=http://localhost

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US

APP_MAINTENANCE_DRIVER=file
APP_MAINTENANCE_STORE=database

BCRYPT_ROUNDS=12

LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=sanctum_spa_login
DB_USERNAME=root
DB_PASSWORD=
DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_SECURE_COOKIE=false
SESSION_DOMAIN=localhost # set this to your local domain
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null

BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database

CACHE_STORE=database
CACHE_PREFIX=

MEMCACHED_HOST=127.0.0.1

REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_MAILER=log
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
Expand All @@ -45,10 +61,4 @@ AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
VITE_APP_NAME="${APP_NAME}"
16 changes: 0 additions & 16 deletions .env.testing

This file was deleted.

3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* text=auto
* text=auto eol=lf

*.blade.php diff=html
*.css diff=css
Expand All @@ -8,3 +8,4 @@

/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore
14 changes: 0 additions & 14 deletions .github/FUNDING.yml

This file was deleted.

7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
.DS_Store
/.phpunit.cache
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.env.production
.phpunit.result.cache
docker-compose.override.yml
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.vscode
13 changes: 0 additions & 13 deletions .styleci.yml

This file was deleted.

21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
<img src="https://app.chipperci.com/projects/6fad1690-acea-4dbd-b83c-20d34e4b8737/status/master" alt="Build Status">
</p>

## Laravel Fortify Vue SPA
## Vue Laravel SPA

A simple and clean boilerplate to start a new SPA project with authentication and more features from fortify. Its like the little sister of Jetstream, but as SPA. This boilerplate uses the following tools:
A simple and clean starter-kit to start a new SPA project with authentication and more features from fortify. Its like Jetstream but without Inertia but with Vue-Router and Pinia as store. This starter-kit uses the following tools:

- [Vue 3](https://github.com/vuejs/vue)
- [Vue Router](https://router.vuejs.org/)
- [Vuex](https://vuex.vuejs.org/)
- [Pinia](https://pinia.vuejs.org/)
- [Axios](https://axios-http.com/docs/intro)
- [Tailwindcss 3.x](https://tailwindcss.com/)
- [Laravel 10.x](https://laravel.com/docs/10.x)
- [Laravel Sanctum](https://laravel.com/docs/10.x/sanctum)
- [Laravel Fortify](https://laravel.com/docs/10.x/fortify)
- [Laravel 11.x](https://laravel.com/docs/11.x)
- [Laravel Sanctum](https://laravel.com/docs/11.x/sanctum)
- [Laravel Fortify](https://laravel.com/docs/11.x/fortify)

## Features

Expand All @@ -36,8 +37,10 @@ Missing something? Feel free to tell me what would be a nice addition to this bo
- 🔘 Better error handling on UI
- 🔘 Password confirmation fixes
- 🔘 Example page with form and api controller
- 🔘 Laravel Pint
- 🔘 PWA
- 🔘 More Tests
- 🔘 CSP

## Getting started

Expand All @@ -49,12 +52,14 @@ Take this steps:
- copy .env.example to .env
- modify .env file
- migrate database `php artisan migrate`
- npm install
- npm run dev

Make sure to set those two variables to your current domain or localhost:

```
APP_URL=http://laravel-vue-spa-boilerplate.test
SESSION_DOMAIN=laravel-vue-spa-boilerplate.test
APP_URL=http://vue-laravel-spa.test
SESSION_DOMAIN=vue-laravel-spa.test
```

Consider to support my work and say thank you with a coffee. I would very much appreciate that.
Expand Down
16 changes: 4 additions & 12 deletions app/Actions/Fortify/CreateNewUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,22 @@
use App\Models\User;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
use Laravel\Fortify\Contracts\CreatesNewUsers;

class CreateNewUser implements CreatesNewUsers
{
use PasswordValidationRules;

/**
* Validate and create a newly registered user.
* Create a newly registered user.
*
* @param array $input
* @return \App\Models\User
* @param array<string, string> $input
*/
public function create(array $input)
public function create(array $input): User
{
Validator::make($input, [
'name' => ['required', 'string', 'max:255'],
'email' => [
'required',
'string',
'email',
'max:255',
Rule::unique(User::class),
],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => $this->passwordRules(),
])->validate();

Expand Down
8 changes: 4 additions & 4 deletions app/Actions/Fortify/PasswordValidationRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace App\Actions\Fortify;

use Laravel\Fortify\Rules\Password;
use Illuminate\Validation\Rules\Password;

trait PasswordValidationRules
{
/**
* Get the validation rules used to validate passwords.
*
* @return array
* @return array<int, \Illuminate\Contracts\Validation\Rule|array<mixed>|string>
*/
protected function passwordRules()
protected function passwordRules(): array
{
return ['required', 'string', new Password, 'confirmed'];
return ['required', 'string', Password::default(), 'confirmed'];
}
}
7 changes: 3 additions & 4 deletions app/Actions/Fortify/ResetUserPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Actions\Fortify;

use App\Models\User;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Laravel\Fortify\Contracts\ResetsUserPasswords;
Expand All @@ -13,11 +14,9 @@ class ResetUserPassword implements ResetsUserPasswords
/**
* Validate and reset the user's forgotten password.
*
* @param mixed $user
* @param array $input
* @return void
* @param array<string, string> $input
*/
public function reset($user, array $input)
public function reset(User $user, array $input): void
{
Validator::make($input, [
'password' => $this->passwordRules(),
Expand Down
17 changes: 7 additions & 10 deletions app/Actions/Fortify/UpdateUserPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Actions\Fortify;

use App\Models\User;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Laravel\Fortify\Contracts\UpdatesUserPasswords;
Expand All @@ -13,20 +14,16 @@ class UpdateUserPassword implements UpdatesUserPasswords
/**
* Validate and update the user's password.
*
* @param mixed $user
* @param array $input
* @return void
* @param array<string, string> $input
*/
public function update($user, array $input)
public function update(User $user, array $input): void
{
Validator::make($input, [
'current_password' => ['required', 'string'],
'current_password' => ['required', 'string', 'current_password:web'],
'password' => $this->passwordRules(),
])->after(function ($validator) use ($user, $input) {
if (! isset($input['current_password']) || ! Hash::check($input['current_password'], $user->password)) {
$validator->errors()->add('current_password', __('The provided password does not match your current password.'));
}
})->validateWithBag('updatePassword');
], [
'current_password.current_password' => __('The provided password does not match your current password.'),
])->validateWithBag('updatePassword');

$user->forceFill([
'password' => Hash::make($input['password']),
Expand Down
Loading

0 comments on commit 841013a

Please sign in to comment.