Skip to content

Commit

Permalink
Upgrading to Laravel 10.x
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumebriday committed Dec 25, 2023
1 parent 037dbfa commit 8fecf6f
Show file tree
Hide file tree
Showing 74 changed files with 1,329 additions and 1,928 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* text=auto
* text=auto eol=lf
*.css linguist-vendored
*.scss linguist-vendored
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.phpunit.cache
/node_modules
/public/storage
/public/hot
Expand All @@ -18,3 +19,4 @@ public/build/
/log
.phpunit.result.cache
pint.json
storage/media-library/temp
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# Laravel 9.0 blog
# Laravel 10.x blog

[![Build Status](https://travis-ci.org/guillaumebriday/laravel-blog.svg?branch=master)](https://travis-ci.org/guillaumebriday/laravel-blog)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/guillaumebriday)

The purpose of this repository is to show good development practices on [Laravel](http://laravel.com/) as well as to present cases of use of the framework's features like:

- [Authentication](https://laravel.com/docs/9.x/authentication)
- [Authentication](https://laravel.com/docs/10.x/authentication)
- API
- [Sanctum](https://laravel.com/docs/9.x/sanctum)
- [API Resources](https://laravel.com/docs/9.x/eloquent-resources)
- [Sanctum](https://laravel.com/docs/10.x/sanctum)
- [API Resources](https://laravel.com/docs/10.x/eloquent-resources)
- Versioning
- [Blade](https://laravel.com/docs/9.x/blade)
- [Broadcasting](https://laravel.com/docs/9.x/broadcasting)
- [Cache](https://laravel.com/docs/9.x/cache)
- [Email Verification](https://laravel.com/docs/9.x/verification)
- [Filesystem](https://laravel.com/docs/9.x/filesystem)
- [Helpers](https://laravel.com/docs/9.x/helpers)
- [Horizon](https://laravel.com/docs/9.x/horizon)
- [Localization](https://laravel.com/docs/9.x/localization)
- [Mail](https://laravel.com/docs/9.x/mail)
- [Migrations](https://laravel.com/docs/9.x/migrations)
- [Policies](https://laravel.com/docs/9.x/authorization)
- [Providers](https://laravel.com/docs/9.x/providers)
- [Requests](https://laravel.com/docs/9.x/validation#form-request-validation)
- [Seeding & Factories](https://laravel.com/docs/9.x/seeding)
- [Testing](https://laravel.com/docs/9.x/testing)
- [Homestead](https://laravel.com/docs/9.x/homestead)
- [Blade](https://laravel.com/docs/10.x/blade)
- [Broadcasting](https://laravel.com/docs/10.x/broadcasting)
- [Cache](https://laravel.com/docs/10.x/cache)
- [Email Verification](https://laravel.com/docs/10.x/verification)
- [Filesystem](https://laravel.com/docs/10.x/filesystem)
- [Helpers](https://laravel.com/docs/10.x/helpers)
- [Horizon](https://laravel.com/docs/10.x/horizon)
- [Localization](https://laravel.com/docs/10.x/localization)
- [Mail](https://laravel.com/docs/10.x/mail)
- [Migrations](https://laravel.com/docs/10.x/migrations)
- [Policies](https://laravel.com/docs/10.x/authorization)
- [Providers](https://laravel.com/docs/10.x/providers)
- [Requests](https://laravel.com/docs/10.x/validation#form-request-validation)
- [Seeding & Factories](https://laravel.com/docs/10.x/seeding)
- [Testing](https://laravel.com/docs/10.x/testing)
- [Homestead](https://laravel.com/docs/10.x/homestead)

Beside Laravel, this project uses other tools like:

Expand Down
17 changes: 2 additions & 15 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,10 @@

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];

/**
* Define the application's command schedule.
*
* @return void
*/
protected function schedule(Schedule $schedule)
protected function schedule(Schedule $schedule): void
{
$schedule->command('backup:clean')->daily()->at('01:00');
$schedule->command('backup:run')->daily()->at('02:00');
Expand All @@ -30,10 +19,8 @@ protected function schedule(Schedule $schedule)

/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
protected function commands(): void
{
$this->load(__DIR__ . '/Commands');

Expand Down
24 changes: 2 additions & 22 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,7 @@
class Handler extends ExceptionHandler
{
/**
* A list of exception types with their corresponding custom log levels.
*
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
*/
protected $levels = [
//
];

/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<\Throwable>>
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed for validation exceptions.
* The list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array<int, string>
*/
Expand All @@ -38,10 +20,8 @@ class Handler extends ExceptionHandler

/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
public function register(): void
{
$this->reportable(function (Throwable $e) {
//
Expand Down
2 changes: 1 addition & 1 deletion app/Helpers/date.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Return a Carbon instance.
*/
function carbon(string $parseString = '', string $tz = null): Carbon
function carbon(string $parseString = '', ?string $tz = null): Carbon
{
return new Carbon($parseString, $tz);
}
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
use AuthorizesRequests, ValidatesRequests;
}
9 changes: 5 additions & 4 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,22 @@ class Kernel extends HttpKernel
];

/**
* The application's route middleware.
* The application's middleware aliases.
*
* These middleware may be assigned to groups or used individually.
* Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
*
* @var array<string, class-string|string>
*/
protected $routeMiddleware = [
protected $middlewareAliases = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
'signed' => \App\Http\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'role' => \App\Http\Middleware\RoleMiddleware::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
Expand Down
8 changes: 3 additions & 5 deletions app/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
namespace App\Http\Middleware;

use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Illuminate\Http\Request;

class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string
*/
protected function redirectTo($request)
protected function redirectTo(Request $request): ?string
{
return route('login');
return $request->expectsJson() ? null : route('login');
}
}
8 changes: 4 additions & 4 deletions app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpFoundation\Response;

class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param null|string ...$guards
* @return mixed
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle($request, Closure $next, ...$guards)
public function handle(Request $request, Closure $next, string ...$guards): Response
{
$guards = empty($guards) ? [null] : $guards;

Expand Down
3 changes: 2 additions & 1 deletion app/Http/Middleware/TrimStrings.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ class TrimStrings extends Middleware
/**
* The names of the attributes that should not be trimmed.
*
* @var array
* @var array<int, string>
*/
protected $except = [
'current_password',
'password',
'password_confirmation',
];
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TrustProxies extends Middleware
/**
* The trusted proxies for this application.
*
* @var array
* @var array<int, string>|string|null
*/
protected $proxies;

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/VerifyCsrfToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class VerifyCsrfToken extends Middleware
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
* @var array<int, string>
*/
protected $except = [
//
Expand Down
4 changes: 1 addition & 3 deletions app/Http/Requests/Admin/CommentsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ class CommentsRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
public function authorize(): bool
{
return true;
}
Expand Down
4 changes: 1 addition & 3 deletions app/Http/Requests/Admin/MediaLibraryRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ class MediaLibraryRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
public function authorize(): bool
{
return true;
}
Expand Down
4 changes: 1 addition & 3 deletions app/Http/Requests/Admin/PostsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ class PostsRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
public function authorize(): bool
{
return true;
}
Expand Down
4 changes: 1 addition & 3 deletions app/Http/Requests/Admin/UsersRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ class UsersRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
public function authorize(): bool
{
return true;
}
Expand Down
4 changes: 1 addition & 3 deletions app/Http/Requests/Api/CommentsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ class CommentsRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
public function authorize(): bool
{
return true;
}
Expand Down
4 changes: 1 addition & 3 deletions app/Http/Requests/CommentsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ class CommentsRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
public function authorize(): bool
{
return true;
}
Expand Down
4 changes: 1 addition & 3 deletions app/Http/Requests/NewsletterSubscriptionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ class NewsletterSubscriptionRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
public function authorize(): bool
{
return true;
}
Expand Down
4 changes: 1 addition & 3 deletions app/Http/Requests/UserPasswordsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ class UserPasswordsRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
public function authorize(): bool
{
return true;
}
Expand Down
4 changes: 1 addition & 3 deletions app/Http/Requests/UsersRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ class UsersRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
public function authorize(): bool
{
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions app/Models/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class Comment extends Model
*
* @var array
*/
protected $dates = [
'posted_at'
protected $casts = [
'posted_at' => 'datetime'
];

/**
Expand Down
8 changes: 6 additions & 2 deletions app/Models/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ class Media extends BaseMedia
*
* @var array
*/
protected $dates = [
'posted_at'
protected $casts = [
'posted_at' => 'datetime',
'manipulations' => 'array',
'custom_properties' => 'array',
'generated_conversions' => 'array',
'responsive_images' => 'array',
];
}
Loading

0 comments on commit 8fecf6f

Please sign in to comment.