Skip to content

Commit

Permalink
Update to Laravel 11
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Jun 26, 2024
1 parent e9121ff commit 348a286
Show file tree
Hide file tree
Showing 40 changed files with 3,268 additions and 5,151 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ 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]
Expand Down
60 changes: 39 additions & 21 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,63 @@ APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
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=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=

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

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_DRIVER=database
SESSION_LIFETIME=120
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=smtp.mailtrap.io
MAIL_MAILER=log
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
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}"
5 changes: 4 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
* text=auto
* text=auto eol=lf

*.md diff=markdown
*.php diff=php
14 changes: 6 additions & 8 deletions .github/workflows/autoformat.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
name: Autoformat

on:
push:
branches:
Expand All @@ -9,32 +7,32 @@ jobs:
composer-normalize:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- uses: shivammathur/setup-php@v2
with:
coverage: none
extensions: mbstring
php-version: 8.0
php-version: 8.3

- run: composer install --no-interaction --no-progress --no-suggest
- uses: ramsey/composer-install@v3

- run: composer normalize

- uses: stefanzweifel/git-auto-commit-action@v4
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Normalize composer.json

prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- uses: creyD/prettier_action@v4.2
- uses: creyD/prettier_action@v4.4
with:
prettier_options: --write --tab-width=2 *.md **/*.md
branch: ${{ github.head_ref }}
Expand Down
64 changes: 0 additions & 64 deletions .github/workflows/continuous-integration.yml

This file was deleted.

49 changes: 49 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
on:
pull_request:
push:
branches:
- master

env:
PHP_EXTENSIONS: mbstring, mysqli, pdo_mysql
PHP_VERSION: 8.3
DB_DATABASE: laravel
DB_USERNAME: root
DB_PASSWORD: root

jobs:
static-code-analysis:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: shivammathur/setup-php@v2
with:
coverage: none
extensions: ${{ env.PHP_EXTENSIONS }}
php-version: ${{ env.PHP_VERSION }}

- uses: ramsey/composer-install@v3

- run: vendor/bin/phpstan

tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: shivammathur/setup-php@v2
with:
coverage: none
extensions: ${{ env.PHP_EXTENSIONS }}
php-version: ${{ env.PHP_VERSION }}

- uses: ramsey/composer-install@v3

- run: |
sudo systemctl start mysql.service
mysql --user=root --password=root --execute='CREATE DATABASE laravel;'
- run: vendor/bin/phpunit
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
/.phpunit.result.cache
/_ide_helper.php
/_lighthouse_ide_helper.php
/schema-directives.graphql
/programmatic-types.graphql
/schema-directives.graphql
13 changes: 0 additions & 13 deletions app/Console/Kernel.php

This file was deleted.

9 changes: 0 additions & 9 deletions app/Exceptions/Handler.php

This file was deleted.

51 changes: 0 additions & 51 deletions app/Http/Kernel.php

This file was deleted.

1 change: 1 addition & 0 deletions app/Models/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/
final class Comment extends Model
{
/** @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\Post, self> */
public function post(): BelongsTo
{
return $this->belongsTo(Post::class);
Expand Down
18 changes: 7 additions & 11 deletions app/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,24 @@
*/
final class Post extends Model
{
protected static function boot()
protected static function booted(): void
{
parent::boot();

self::creating(function (Post $post): void {
if ($post->author_id === null) {
$user = auth()->user();
if ($user === null) {
throw new AuthenticationException();
}
assert($user instanceof User);

$post->author_id = $user->id;
if ($post->author()->doesntExist()) {
$user = auth()->user()
?? throw new AuthenticationException();
$post->author()->associate($user);
}
});
}

/** @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\User, self> */
public function author(): BelongsTo
{
return $this->belongsTo(User::class);
}

/** @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\Comment> */
public function comments(): HasMany
{
return $this->hasMany(Comment::class);
Expand Down
Loading

0 comments on commit 348a286

Please sign in to comment.