Skip to content

Commit

Permalink
Upgrade to Laravel 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed Aug 27, 2016
1 parent 1e2b02e commit 0eb2e1a
Show file tree
Hide file tree
Showing 45 changed files with 582 additions and 338 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
APP_ENV=local
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://lio.dev

DB_HOST=localhost
DB_DATABASE=laravelio
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.DS_Store
.idea
/.idea
/vendor
/node_modules
Homestead.yaml
Homestead.json
.env
/public/build
/public/css
/public/js
/public/js
18 changes: 16 additions & 2 deletions app/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace App;

use App\Forum\EloquentThread;
use Auth;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\ServiceProvider;
use Hash;
use Validator;
Expand All @@ -16,9 +18,14 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot()
{
require __DIR__ . '/helpers.php';

$this->bootHelpers();
$this->bootPasscheckValidationRule();
$this->bootEloquentMorphs();
}

private function bootHelpers()
{
require __DIR__ . '/helpers.php';
}

private function bootPasscheckValidationRule()
Expand All @@ -29,6 +36,13 @@ private function bootPasscheckValidationRule()
});
}

private function bootEloquentMorphs()
{
Relation::morphMap([
EloquentThread::TYPE => EloquentThread::class,
]);
}

/**
* Register any application services.
*
Expand Down
8 changes: 0 additions & 8 deletions app/Events/Event.php

This file was deleted.

26 changes: 0 additions & 26 deletions app/Events/EventServiceProvider.php

This file was deleted.

44 changes: 26 additions & 18 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

namespace App\Exceptions;

use Auth;
use Bugsnag;
use Bugsnag\BugsnagLaravel\BugsnagExceptionHandler as ExceptionHandler;
use Exception;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Session\TokenMismatchException;
use Illuminate\Validation\ValidationException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class Handler extends ExceptionHandler
{
Expand All @@ -20,41 +19,50 @@ class Handler extends ExceptionHandler
* @var array
*/
protected $dontReport = [
AuthenticationException::class,
AuthorizationException::class,
HttpException::class,
ModelNotFoundException::class,
TokenMismatchException::class,
ValidationException::class,
];

/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $exception
* @return void
*/
public function report(Exception $e)
public function report(Exception $exception)
{
// If a user is logged in, we'll set him as the target user for which the errors will occur.
if (Auth::check()) {
Bugsnag::setUser([
'name' => Auth::user()->name(),
'email' => Auth::user()->emailAddress(),
]);
}

return parent::report($e);
parent::report($exception);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
return parent::render($request, $exception);
}

/**
* Convert an authentication exception into an unauthenticated response.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($e instanceof ModelNotFoundException) {
$e = new NotFoundHttpException($e->getMessage(), $e);
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthenticated.'], 401);
}

return parent::render($request, $e);
return redirect()->guest('login');
}
}
5 changes: 0 additions & 5 deletions app/Forum/EloquentThread.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ final class EloquentThread extends Model implements Thread, ReplyAble
*/
protected $table = self::TYPE;

/**
* @var string
*/
protected $morphClass = self::TYPE;

/**
* @var array
*/
Expand Down
27 changes: 27 additions & 0 deletions app/Http/Controllers/Auth/ForgotPasswordController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;

class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/

use SendsPasswordResetEmails;

public function __construct()
{
$this->middleware('guest');
}
}
42 changes: 42 additions & 0 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/

use AuthenticatesUsers;

/**
* @var string
*/
protected $redirectTo = '/dashboard';

public function __construct()
{
$this->middleware('guest', ['except' => 'logout']);
}

/**
* Get the login username to be used by the controller.
*
* @return string
*/
public function username()
{
return 'username';
}
}
34 changes: 14 additions & 20 deletions app/Http/Controllers/Auth/AuthController.php → ...p/Controllers/Auth/RegisterController.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,28 @@

namespace App\Http\Controllers\Auth;

use Illuminate\Contracts\Validation\Validator as ValidatorContract;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
use App\Users\User;
use App\Users\UserRepository;
use Illuminate\Foundation\Auth\RegistersUsers;
use Validator;

class AuthController extends Controller
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/

use AuthenticatesAndRegistersUsers, ThrottlesLogins;
use RegistersUsers;

/**
* Override for the default email field
*
* @var string
*/
protected $username = 'username';

/**
* Override the default redirect path
*
* @var string
*/
protected $redirectTo = '/dashboard';
Expand All @@ -48,13 +37,18 @@ public function __construct(UserRepository $users)
{
$this->users = $users;

$this->middleware($this->guestMiddleware(), ['except' => 'getLogout']);
$this->middleware('guest');
}

public function redirectToRegistrationForm()
{
return redirect()->route('register', [], 301);
}

/**
* Get a validator for an incoming registration request.
*/
protected function validator(array $data): ValidatorContract
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace App\Http\Controllers\Auth;

use Illuminate\Foundation\Auth\ResetsPasswords;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;

class PasswordController extends Controller
class ResetPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
Expand All @@ -21,15 +21,10 @@ class PasswordController extends Controller
use ResetsPasswords;

/**
* Override the default redirect path
*
* @var string
*/
protected $redirectTo = '/dashboard';

/**
* Create a new password controller instance.
*/
public function __construct()
{
$this->middleware('guest');
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 @@ -2,7 +2,6 @@

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesResources;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
Expand All @@ -11,5 +10,5 @@

class Controller extends BaseController
{
use AuthorizesRequests, AuthorizesResources, DispatchesJobs, SendsAlerts, ValidatesRequests;
use AuthorizesRequests, DispatchesJobs, SendsAlerts, ValidatesRequests;
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public function rss()

public function redirectToMainWebsite()
{
return redirect('http://laravel.io/');
return redirect('http://laravel.io/', 301);
}
}
Loading

0 comments on commit 0eb2e1a

Please sign in to comment.