Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.

Commit 38ff07b

Browse files
committed
Upgrade to Laravel 8.x
1 parent c931ebf commit 38ff07b

38 files changed

+2305
-996
lines changed

.env.example

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ APP_DEBUG=true
55
APP_URL=http://localhost
66

77
LOG_CHANNEL=stack
8+
LOG_DEPRECATIONS_CHANNEL=null
9+
LOG_LEVEL=debug
810

911
DB_CONNECTION=mysql
1012
DB_HOST=127.0.0.1
@@ -15,15 +17,18 @@ DB_PASSWORD=secret
1517

1618
BROADCAST_DRIVER=pusher
1719
CACHE_DRIVER=file
20+
FILESYSTEM_DRIVER=local
1821
QUEUE_CONNECTION=sync
1922
SESSION_DRIVER=file
2023
SESSION_LIFETIME=120
2124

25+
MEMCACHED_HOST=127.0.0.1
26+
2227
REDIS_HOST=127.0.0.1
2328
REDIS_PASSWORD=null
2429
REDIS_PORT=6379
2530

26-
MAIL_DRIVER=smtp
31+
MAIL_MAILER=smtp
2732
MAIL_HOST=smtp.mailtrap.io
2833
MAIL_PORT=2525
2934
MAIL_USERNAME=null
@@ -34,5 +39,8 @@ PUSHER_APP_ID=testapp
3439
PUSHER_APP_KEY=websocketkey
3540
PUSHER_APP_SECRET=somethingsecret
3641

42+
LARAVEL_WEBSOCKETS_PORT=6001
43+
3744
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
3845
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
46+
MIX_LARAVEL_WEBSOCKETS_PORT="${LARAVEL_WEBSOCKETS_PORT}"

app/Events/MessageSent.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22

33
namespace App\Events;
44

5-
use App\User;
6-
use App\Message;
7-
use Illuminate\Broadcasting\Channel;
5+
use App\Models\{User,Message};
86
use Illuminate\Queue\SerializesModels;
9-
use Illuminate\Broadcasting\PrivateChannel;
10-
use Illuminate\Broadcasting\PresenceChannel;
7+
use Illuminate\Broadcasting\{Channel,PrivateChannel,PresenceChannel,InteractsWithSockets};
118
use Illuminate\Foundation\Events\Dispatchable;
12-
use Illuminate\Broadcasting\InteractsWithSockets;
139
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
1410

1511
class MessageSent implements ShouldBroadcast
@@ -19,14 +15,14 @@ class MessageSent implements ShouldBroadcast
1915
/**
2016
* User that sent the message
2117
*
22-
* @var \App\User
18+
* @var \App\Models\User
2319
*/
2420
public $user;
2521

2622
/**
2723
* Message details
2824
*
29-
* @var \App\Message
25+
* @var \App\Models\Message
3026
*/
3127
public $message;
3228

app/Exceptions/Handler.php

+10-18
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
use Exception;
66
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
7+
use Throwable;
78

89
class Handler extends ExceptionHandler
910
{
1011
/**
1112
* A list of the exception types that are not reported.
1213
*
13-
* @var array
14+
* @var string[]
1415
*/
1516
protected $dontReport = [
1617
//
@@ -19,33 +20,24 @@ class Handler extends ExceptionHandler
1920
/**
2021
* A list of the inputs that are never flashed for validation exceptions.
2122
*
22-
* @var array
23+
* @var string[]
2324
*/
2425
protected $dontFlash = [
26+
'current_password',
2527
'password',
2628
'password_confirmation',
2729
];
2830

2931
/**
30-
* Report or log an exception.
32+
* Register the exception handling callbacks for the application.
3133
*
32-
* @param \Exception $exception
34+
* @param \Throwable $exception
3335
* @return void
3436
*/
35-
public function report(Exception $exception)
37+
public function register()
3638
{
37-
parent::report($exception);
38-
}
39-
40-
/**
41-
* Render an exception into an HTTP response.
42-
*
43-
* @param \Illuminate\Http\Request $request
44-
* @param \Exception $exception
45-
* @return \Illuminate\Http\Response
46-
*/
47-
public function render($request, Exception $exception)
48-
{
49-
return parent::render($request, $exception);
39+
$this->reportable(function (Throwable $e) {
40+
//
41+
});
5042
}
5143
}

app/Http/Controllers/Auth/RegisterController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace App\Http\Controllers\Auth;
44

5-
use App\User;
5+
use App\Models\User;
66
use App\Http\Controllers\Controller;
77
use Illuminate\Support\Facades\Hash;
88
use Illuminate\Support\Facades\Validator;
@@ -59,7 +59,7 @@ protected function validator(array $data)
5959
* Create a new user instance after a valid registration.
6060
*
6161
* @param array $data
62-
* @return \App\User
62+
* @return \App\Models\User
6363
*/
6464
protected function create(array $data)
6565
{

app/Http/Controllers/ChatsController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace App\Http\Controllers;
44

55
use App\Events\MessageSent;
6-
use App\Message;
6+
use App\Models\Message;
77
use Illuminate\Http\Request;
88

99
class ChatsController extends Controller

app/Http/Kernel.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ class Kernel extends HttpKernel
1414
* @var array
1515
*/
1616
protected $middleware = [
17-
\App\Http\Middleware\CheckForMaintenanceMode::class,
17+
\App\Http\Middleware\TrustProxies::class,
18+
\Fruitcake\Cors\HandleCors::class,
19+
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
1820
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
1921
\App\Http\Middleware\TrimStrings::class,
2022
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
21-
\App\Http\Middleware\TrustProxies::class,
2223
];
2324

2425
/**
@@ -38,7 +39,8 @@ class Kernel extends HttpKernel
3839
],
3940

4041
'api' => [
41-
'throttle:60,1',
42+
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
43+
'throttle:api',
4244
'bindings',
4345
],
4446
];
@@ -53,7 +55,6 @@ class Kernel extends HttpKernel
5355
protected $routeMiddleware = [
5456
'auth' => \App\Http\Middleware\Authenticate::class,
5557
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
56-
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
5758
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
5859
'can' => \Illuminate\Auth\Middleware\Authorize::class,
5960
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,

app/Http/Middleware/CheckForMaintenanceMode.php renamed to app/Http/Middleware/PreventRequestsDuringMaintenance.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace App\Http\Middleware;
44

5-
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
5+
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
66

7-
class CheckForMaintenanceMode extends Middleware
7+
class PreventRequestsDuringMaintenance extends Middleware
88
{
99
/**
1010
* The URIs that should be reachable while maintenance mode is enabled.

app/Http/Middleware/RedirectIfAuthenticated.php

+10-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace App\Http\Middleware;
44

5+
use App\Providers\RouteServiceProvider;
56
use Closure;
7+
use Illuminate\Http\Request;
68
use Illuminate\Support\Facades\Auth;
79

810
class RedirectIfAuthenticated
@@ -12,13 +14,17 @@ class RedirectIfAuthenticated
1214
*
1315
* @param \Illuminate\Http\Request $request
1416
* @param \Closure $next
15-
* @param string|null $guard
17+
* @param string|null ...$guards
1618
* @return mixed
1719
*/
18-
public function handle($request, Closure $next, $guard = null)
20+
public function handle(Request $request, Closure $next, ...$guards)
1921
{
20-
if (Auth::guard($guard)->check()) {
21-
return redirect('/home');
22+
$guards = empty($guards) ? [null] : $guards;
23+
24+
foreach ($guards as $guard) {
25+
if (Auth::guard($guard)->check()) {
26+
return redirect(RouteServiceProvider::HOME);
27+
}
2228
}
2329

2430
return $next($request);

app/Http/Middleware/TrimStrings.php

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class TrimStrings extends Middleware
1212
* @var array
1313
*/
1414
protected $except = [
15+
'current_password',
1516
'password',
1617
'password_confirmation',
1718
];

app/Http/Middleware/TrustHosts.php

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace App\Http\Middleware;
4+
5+
use Illuminate\Http\Middleware\TrustHosts as Middleware;
6+
7+
class TrustHosts extends Middleware
8+
{
9+
/**
10+
* Get the host patterns that should be trusted.
11+
*
12+
* @return array
13+
*/
14+
public function hosts()
15+
{
16+
return [
17+
$this->allSubdomainsOfApplicationUrl(),
18+
];
19+
}
20+
}

app/Http/Middleware/TrustProxies.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
namespace App\Http\Middleware;
44

55
use Illuminate\Http\Request;
6-
use Fideloper\Proxy\TrustProxies as Middleware;
6+
use Illuminate\Http\Middleware\TrustProxies as Middleware;
77

88
class TrustProxies extends Middleware
99
{
1010
/**
1111
* The trusted proxies for this application.
1212
*
13-
* @var array
13+
* @var array|string|null
1414
*/
1515
protected $proxies;
1616

app/Http/Middleware/VerifyCsrfToken.php

-7
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66

77
class VerifyCsrfToken extends Middleware
88
{
9-
/**
10-
* Indicates whether the XSRF-TOKEN cookie should be set on the response.
11-
*
12-
* @var bool
13-
*/
14-
protected $addHttpCookie = true;
15-
169
/**
1710
* The URIs that should be excluded from CSRF verification.
1811
*

app/Message.php renamed to app/Models/Message.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace App;
3+
namespace App\Models;
44

55
use Illuminate\Database\Eloquent\Model;
66

app/User.php renamed to app/Models/User.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace App;
3+
namespace App\Models;
44

55
use Illuminate\Notifications\Notifiable;
66
use Illuminate\Contracts\Auth\MustVerifyEmail;

app/Providers/EventServiceProvider.php

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class EventServiceProvider extends ServiceProvider
2727
*/
2828
public function boot()
2929
{
30-
parent::boot();
3130

3231
//
3332
}

composer.json

+11-8
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,22 @@
88
],
99
"license": "MIT",
1010
"require": {
11-
"php": "^7.1.3|^8.0",
11+
"php": "^7.3|^8.0",
1212
"beyondcode/laravel-websockets": "dev-master",
1313
"fideloper/proxy": "^4.4",
14-
"laravel/framework": "^6.20.26",
15-
"laravel/tinker": "^2.5"
14+
"fruitcake/laravel-cors": "^2.0",
15+
"guzzlehttp/guzzle": "^7.0.1",
16+
"laravel/framework": "^8.0",
17+
"laravel/tinker": "^2.5",
18+
"laravel/ui": "^3.0"
1619
},
1720
"require-dev": {
18-
"beyondcode/laravel-dump-server": "^1.3",
19-
"facade/ignition": "^1.16.15",
21+
"beyondcode/laravel-dump-server": "^1.7",
22+
"facade/ignition": "^2.5",
2023
"fakerphp/faker": "^1.9.1",
21-
"mockery/mockery": "^1.0",
22-
"nunomaduro/collision": "^3.0",
23-
"phpunit/phpunit": "^8.5.8|^9.3.3"
24+
"mockery/mockery": "^1.4.4",
25+
"nunomaduro/collision": "^5.10",
26+
"phpunit/phpunit": "^9.3.3"
2427
},
2528
"config": {
2629
"optimize-autoloader": true,

0 commit comments

Comments
 (0)