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

Commit 52f226a

Browse files
committed
update code to newest Laravel
1 parent 833f1c9 commit 52f226a

40 files changed

+1024
-899
lines changed

.env

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
APP_ENV=local
22
APP_DEBUG=true
3-
APP_KEY=J6cc5Vpd1q5F76VGcCfMY3rx8dEeCOfE
3+
APP_KEY=b809vCwvtawRbsG0BmP1tWgnlXQypSKf
4+
APP_URL=http://localhost
45

5-
DB_HOST=localhost
6+
DB_HOST=127.0.0.1
67
DB_DATABASE=homestead
78
DB_USERNAME=homestead
89
DB_PASSWORD=secret
@@ -11,6 +12,10 @@ CACHE_DRIVER=file
1112
SESSION_DRIVER=file
1213
QUEUE_DRIVER=sync
1314

15+
REDIS_HOST=127.0.0.1
16+
REDIS_PASSWORD=null
17+
REDIS_PORT=6379
18+
1419
MAIL_DRIVER=smtp
1520
MAIL_HOST=mailtrap.io
1621
MAIL_PORT=2525

.env.example

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
APP_ENV=local
22
APP_DEBUG=true
33
APP_KEY=SomeRandomString
4+
APP_URL=http://localhost
45

5-
DB_HOST=localhost
6+
DB_HOST=127.0.0.1
67
DB_DATABASE=homestead
78
DB_USERNAME=homestead
89
DB_PASSWORD=secret
@@ -11,6 +12,10 @@ CACHE_DRIVER=file
1112
SESSION_DRIVER=file
1213
QUEUE_DRIVER=sync
1314

15+
REDIS_HOST=127.0.0.1
16+
REDIS_PASSWORD=null
17+
REDIS_PORT=6379
18+
1419
MAIL_DRIVER=smtp
1520
MAIL_HOST=mailtrap.io
1621
MAIL_PORT=2525

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/vendor
22
/node_modules
3+
/public/storage
34
Homestead.yaml
45
Homestead.json
6+
.env

app/Console/Kernel.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel
1313
* @var array
1414
*/
1515
protected $commands = [
16-
\App\Console\Commands\Inspire::class,
16+
// Commands\Inspire::class,
1717
];
1818

1919
/**
@@ -24,7 +24,7 @@ class Kernel extends ConsoleKernel
2424
*/
2525
protected function schedule(Schedule $schedule)
2626
{
27-
$schedule->command('inspire')
28-
->hourly();
27+
// $schedule->command('inspire')
28+
// ->hourly();
2929
}
3030
}

app/Exceptions/Handler.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
namespace App\Exceptions;
44

55
use Exception;
6+
use Illuminate\Validation\ValidationException;
7+
use Illuminate\Auth\Access\AuthorizationException;
68
use Illuminate\Database\Eloquent\ModelNotFoundException;
79
use Symfony\Component\HttpKernel\Exception\HttpException;
8-
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
910
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
1011

1112
class Handler extends ExceptionHandler
@@ -16,8 +17,10 @@ class Handler extends ExceptionHandler
1617
* @var array
1718
*/
1819
protected $dontReport = [
20+
AuthorizationException::class,
1921
HttpException::class,
2022
ModelNotFoundException::class,
23+
ValidationException::class,
2124
];
2225

2326
/**
@@ -30,7 +33,7 @@ class Handler extends ExceptionHandler
3033
*/
3134
public function report(Exception $e)
3235
{
33-
return parent::report($e);
36+
parent::report($e);
3437
}
3538

3639
/**
@@ -42,10 +45,6 @@ public function report(Exception $e)
4245
*/
4346
public function render($request, Exception $e)
4447
{
45-
if ($e instanceof ModelNotFoundException) {
46-
$e = new NotFoundHttpException($e->getMessage(), $e);
47-
}
48-
4948
return parent::render($request, $e);
5049
}
5150
}

app/Http/Controllers/Auth/AuthController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,21 @@ class AuthController extends Controller
2323

2424
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
2525

26+
/**
27+
* Where to redirect users after login / registration.
28+
*
29+
* @var string
30+
*/
31+
protected $redirectTo = '/';
32+
2633
/**
2734
* Create a new authentication controller instance.
2835
*
2936
* @return void
3037
*/
3138
public function __construct()
3239
{
33-
$this->middleware('guest', ['except' => 'getLogout']);
40+
$this->middleware('guest', ['except' => 'logout']);
3441
}
3542

3643
/**

app/Http/Controllers/Controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Illuminate\Foundation\Validation\ValidatesRequests;
88
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
99

10-
abstract class Controller extends BaseController
10+
class Controller extends BaseController
1111
{
1212
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
1313
}

app/Http/Kernel.php

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,44 @@ class Kernel extends HttpKernel
99
/**
1010
* The application's global HTTP middleware stack.
1111
*
12+
* These middleware are run during every request to your application.
13+
*
1214
* @var array
1315
*/
1416
protected $middleware = [
1517
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
16-
\App\Http\Middleware\EncryptCookies::class,
17-
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
18-
\Illuminate\Session\Middleware\StartSession::class,
19-
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
20-
\App\Http\Middleware\VerifyCsrfToken::class,
18+
];
19+
20+
/**
21+
* The application's route middleware groups.
22+
*
23+
* @var array
24+
*/
25+
protected $middlewareGroups = [
26+
'web' => [
27+
\App\Http\Middleware\EncryptCookies::class,
28+
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
29+
\Illuminate\Session\Middleware\StartSession::class,
30+
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
31+
\App\Http\Middleware\VerifyCsrfToken::class,
32+
],
33+
34+
'api' => [
35+
'throttle:60,1',
36+
],
2137
];
2238

2339
/**
2440
* The application's route middleware.
2541
*
42+
* These middleware may be assigned to groups or used individually.
43+
*
2644
* @var array
2745
*/
2846
protected $routeMiddleware = [
2947
'auth' => \App\Http\Middleware\Authenticate::class,
3048
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
3149
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
50+
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
3251
];
3352
}

app/Http/Middleware/Authenticate.php

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,25 @@
33
namespace App\Http\Middleware;
44

55
use Closure;
6-
use Illuminate\Contracts\Auth\Guard;
6+
use Illuminate\Support\Facades\Auth;
77

88
class Authenticate
99
{
10-
/**
11-
* The Guard implementation.
12-
*
13-
* @var Guard
14-
*/
15-
protected $auth;
16-
17-
/**
18-
* Create a new filter instance.
19-
*
20-
* @param Guard $auth
21-
* @return void
22-
*/
23-
public function __construct(Guard $auth)
24-
{
25-
$this->auth = $auth;
26-
}
27-
2810
/**
2911
* Handle an incoming request.
3012
*
3113
* @param \Illuminate\Http\Request $request
3214
* @param \Closure $next
15+
* @param string|null $guard
3316
* @return mixed
3417
*/
35-
public function handle($request, Closure $next)
18+
public function handle($request, Closure $next, $guard = null)
3619
{
37-
if ($this->auth->guest()) {
38-
if ($request->ajax()) {
20+
if (Auth::guard($guard)->guest()) {
21+
if ($request->ajax() || $request->wantsJson()) {
3922
return response('Unauthorized.', 401);
4023
} else {
41-
return redirect()->guest('auth/login');
24+
return redirect()->guest('login');
4225
}
4326
}
4427

app/Http/Middleware/RedirectIfAuthenticated.php

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,22 @@
33
namespace App\Http\Middleware;
44

55
use Closure;
6-
use Illuminate\Contracts\Auth\Guard;
6+
use Illuminate\Support\Facades\Auth;
77

88
class RedirectIfAuthenticated
99
{
10-
/**
11-
* The Guard implementation.
12-
*
13-
* @var Guard
14-
*/
15-
protected $auth;
16-
17-
/**
18-
* Create a new filter instance.
19-
*
20-
* @param Guard $auth
21-
* @return void
22-
*/
23-
public function __construct(Guard $auth)
24-
{
25-
$this->auth = $auth;
26-
}
27-
2810
/**
2911
* Handle an incoming request.
3012
*
3113
* @param \Illuminate\Http\Request $request
3214
* @param \Closure $next
15+
* @param string|null $guard
3316
* @return mixed
3417
*/
35-
public function handle($request, Closure $next)
18+
public function handle($request, Closure $next, $guard = null)
3619
{
37-
if ($this->auth->check()) {
38-
return redirect('/home');
20+
if (Auth::guard($guard)->check()) {
21+
return redirect('/');
3922
}
4023

4124
return $next($request);

0 commit comments

Comments
 (0)