Update to laravel 5.2

This commit is contained in:
Kevin MacMartin 2016-01-03 23:55:13 -05:00
parent bc1bc55f13
commit 9bff17c34f
16 changed files with 184 additions and 180 deletions

View file

@ -1,5 +1,5 @@
SITE_NAME=Hypothetical Template SITE_NAME="Hypothetical Template"
SITE_DESC=A website template SITE_DESC="A website template"
APP_ENV=local APP_ENV=local
APP_DEBUG=true APP_DEBUG=true

View file

@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel
* @var array * @var array
*/ */
protected $commands = [ protected $commands = [
\App\Console\Commands\Inspire::class, // Commands\Inspire::class,
]; ];
/** /**
@ -24,7 +24,7 @@ class Kernel extends ConsoleKernel
*/ */
protected function schedule(Schedule $schedule) protected function schedule(Schedule $schedule)
{ {
$schedule->command('inspire') // $schedule->command('inspire')
->hourly(); // ->hourly();
} }
} }

View file

@ -3,7 +3,10 @@
namespace App\Exceptions; namespace App\Exceptions;
use Exception; use Exception;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Validation\ValidationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler class Handler extends ExceptionHandler
@ -14,7 +17,10 @@ class Handler extends ExceptionHandler
* @var array * @var array
*/ */
protected $dontReport = [ protected $dontReport = [
AuthorizationException::class,
HttpException::class, HttpException::class,
ModelNotFoundException::class,
ValidationException::class,
]; ];
/** /**
@ -27,7 +33,7 @@ class Handler extends ExceptionHandler
*/ */
public function report(Exception $e) public function report(Exception $e)
{ {
return parent::report($e); parent::report($e);
} }
/** /**

View file

@ -24,9 +24,11 @@ class AuthController extends Controller
use AuthenticatesAndRegistersUsers, ThrottlesLogins; use AuthenticatesAndRegistersUsers, ThrottlesLogins;
/** /**
* Page the user is redirected to after successfully registering * Where to redirect users after login / registration.
*
* @var string
*/ */
protected $redirectPath = '/dashboard'; protected $redirectTo = '/dashboard';
/** /**
* Create a new authentication controller instance. * Create a new authentication controller instance.
@ -35,7 +37,7 @@ class AuthController extends Controller
*/ */
public function __construct() public function __construct()
{ {
$this->middleware('guest', ['except' => 'getLogout']); $this->middleware('guest', ['except' => 'logout']);
} }
/** /**

View file

@ -5,8 +5,9 @@ namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController; use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
abstract class Controller extends BaseController class Controller extends BaseController
{ {
use DispatchesJobs, ValidatesRequests; use DispatchesJobs, ValidatesRequests;
} }

View file

@ -9,25 +9,44 @@ class Kernel extends HttpKernel
/** /**
* The application's global HTTP middleware stack. * The application's global HTTP middleware stack.
* *
* These middleware are run during every request to your application.
*
* @var array * @var array
*/ */
protected $middleware = [ protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\Middleware\EncryptCookies::class, ];
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class, /**
\Illuminate\View\Middleware\ShareErrorsFromSession::class, * The application's route middleware groups.
\App\Http\Middleware\VerifyCsrfToken::class, *
* @var array
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
],
'api' => [
'throttle:60,1',
],
]; ];
/** /**
* The application's route middleware. * The application's route middleware.
* *
* These middleware may be assigned to groups or used individually.
*
* @var array * @var array
*/ */
protected $routeMiddleware = [ protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class, 'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
]; ];
} }

View file

@ -3,38 +3,21 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use Closure; use Closure;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Support\Facades\Auth;
class Authenticate class Authenticate
{ {
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/** /**
* Handle an incoming request. * Handle an incoming request.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Closure $next * @param \Closure $next
* @param string|null $guard
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $next) public function handle($request, Closure $next, $guard = null)
{ {
if ($this->auth->guest()) { if (Auth::guard($guard)->guest()) {
if ($request->ajax()) { if ($request->ajax()) {
return response('Unauthorized.', 401); return response('Unauthorized.', 401);
} else { } else {

View file

@ -3,39 +3,22 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use Closure; use Closure;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated class RedirectIfAuthenticated
{ {
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/** /**
* Handle an incoming request. * Handle an incoming request.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Closure $next * @param \Closure $next
* @param string|null $guard
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $next) public function handle($request, Closure $next, $guard = null)
{ {
if ($this->auth->check()) { if (Auth::guard($guard)->check()) {
return redirect('/home'); return redirect('/');
} }
return $next($request); return $next($request);

View file

@ -1,32 +1,34 @@
<?php <?php
/* Route::group(['middleware' => ['web']], function () {
|-------------------------------------------------------------------------- /*
| Public Routes |--------------------------------------------------------------------------
|-------------------------------------------------------------------------- | Public Routes
*/ |--------------------------------------------------------------------------
*/
Route::get('/', function () { Route::get('/', function () {
return view('website.home'); return view('website.home');
});
Route::get('/contact', function() {
return view('website.contact');
});
Route::post('/contact-submit', 'ContactController@postContactSubmit');
/*
|--------------------------------------------------------------------------
| Content Management Routes
|--------------------------------------------------------------------------
*/
// Authentication
Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@getLogout');
// Registration
Route::get('auth/register', 'Auth\AuthController@getRegister');
Route::post('auth/register', 'Auth\AuthController@postRegister');
}); });
Route::get('/contact', function() {
return view('website.contact');
});
Route::post('/contact-submit', 'ContactController@postContactSubmit');
/*
|--------------------------------------------------------------------------
| Content Management Routes
|--------------------------------------------------------------------------
*/
// Authentication
Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@getLogout');
// Registration
Route::get('auth/register', 'Auth\AuthController@getRegister');
Route::post('auth/register', 'Auth\AuthController@postRegister');

View file

@ -2,34 +2,25 @@
namespace App; namespace App;
use Illuminate\Auth\Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract class User extends Authenticatable
{ {
use Authenticatable, CanResetPassword;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
/** /**
* The attributes that are mass assignable. * The attributes that are mass assignable.
* *
* @var array * @var array
*/ */
protected $fillable = ['name', 'email', 'password']; protected $fillable = [
'name', 'email', 'password',
];
/** /**
* The attributes excluded from the model's JSON form. * The attributes excluded from the model's JSON form.
* *
* @var array * @var array
*/ */
protected $hidden = ['password', 'remember_token']; protected $hidden = [
'password', 'remember_token',
];
} }

View file

@ -2,6 +2,19 @@
return [ return [
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services your application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Application Debug Mode | Application Debug Mode
@ -78,7 +91,7 @@ return [
| |
*/ */
'key' => env('APP_KEY', 'SomeRandomString'), 'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC', 'cipher' => 'AES-256-CBC',
@ -113,13 +126,11 @@ return [
/* /*
* Laravel Framework Service Providers... * Laravel Framework Service Providers...
*/ */
Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
Illuminate\Auth\AuthServiceProvider::class, Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class, Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class, Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class, Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Routing\ControllerServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class, Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class, Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class, Illuminate\Encryption\EncryptionServiceProvider::class,
@ -169,7 +180,6 @@ return [
'Artisan' => Illuminate\Support\Facades\Artisan::class, 'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class, 'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class, 'Blade' => Illuminate\Support\Facades\Blade::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class, 'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class, 'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class, 'Cookie' => Illuminate\Support\Facades\Cookie::class,
@ -179,8 +189,6 @@ return [
'Event' => Illuminate\Support\Facades\Event::class, 'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class, 'File' => Illuminate\Support\Facades\File::class,
'Hash' => Illuminate\Support\Facades\Hash::class, 'Hash' => Illuminate\Support\Facades\Hash::class,
'Input' => Illuminate\Support\Facades\Input::class,
'Inspiring' => Illuminate\Foundation\Inspiring::class,
'Lang' => Illuminate\Support\Facades\Lang::class, 'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class, 'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class, 'Mail' => Illuminate\Support\Facades\Mail::class,

View file

@ -4,64 +4,104 @@ return [
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Default Authentication Driver | Authentication Defaults
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| This option controls the authentication driver that will be utilized. | This option controls the default authentication "guard" and password
| This driver manages the retrieval and authentication of the users | reset options for your application. You may change these defaults
| attempting to get access to protected areas of your application. | as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session", "token"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
| |
| Supported: "database", "eloquent" | Supported: "database", "eloquent"
| |
*/ */
'driver' => 'eloquent', 'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Authentication Model | Resetting Passwords
|--------------------------------------------------------------------------
|
| When using the "Eloquent" authentication driver, we need to know which
| Eloquent model should be used to retrieve your users. Of course, it
| is often just the "User" model but you may use whatever you like.
|
*/
'model' => App\User::class,
/*
|--------------------------------------------------------------------------
| Authentication Table
|--------------------------------------------------------------------------
|
| When using the "Database" authentication driver, we need to know which
| table should be used to retrieve your users. We have chosen a basic
| default value but you may easily change it to any table you like.
|
*/
'table' => 'users',
/*
|--------------------------------------------------------------------------
| Password Reset Settings
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Here you may set the options for resetting passwords including the view | Here you may set the options for resetting passwords including the view
| that is your password reset e-mail. You can also set the name of the | that is your password reset e-mail. You may also set the name of the
| table that maintains all of the reset tokens for your application. | table that maintains all of the reset tokens for your application.
| |
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that the reset token should be | The expire time is the number of minutes that the reset token should be
| considered valid. This security feature keeps tokens short-lived so | considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed. | they have less time to be guessed. You may change this as needed.
| |
*/ */
'password' => [ 'passwords' => [
'email' => 'emails.password', 'users' => [
'table' => 'password_resets', 'provider' => 'users',
'expire' => 60, 'email' => 'auth.emails.password',
'table' => 'password_resets',
'expire' => 60,
],
], ],
]; ];

View file

@ -108,17 +108,4 @@ return [
'sendmail' => '/usr/sbin/sendmail -bs', 'sendmail' => '/usr/sbin/sendmail -bs',
/*
|--------------------------------------------------------------------------
| Mail "Pretend"
|--------------------------------------------------------------------------
|
| When this option is enabled, e-mail will not actually be sent over the
| web and will instead be written to your application's logs files so
| you may inspect the message. This is great for local development.
|
*/
'pretend' => false,
]; ];

View file

@ -12,7 +12,7 @@ return [
| syntax for each one. Here you may set the default queue driver. | syntax for each one. Here you may set the default queue driver.
| |
| Supported: "null", "sync", "database", "beanstalkd", | Supported: "null", "sync", "database", "beanstalkd",
| "sqs", "iron", "redis" | "sqs", "redis"
| |
*/ */
@ -53,19 +53,11 @@ return [
'driver' => 'sqs', 'driver' => 'sqs',
'key' => 'your-public-key', 'key' => 'your-public-key',
'secret' => 'your-secret-key', 'secret' => 'your-secret-key',
'queue' => 'your-queue-url', 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id',
'queue' => 'your-queue-name',
'region' => 'us-east-1', 'region' => 'us-east-1',
], ],
'iron' => [
'driver' => 'iron',
'host' => 'mq-aws-us-east-1.iron.io',
'token' => 'your-token',
'project' => 'your-project-id',
'queue' => 'your-queue-name',
'encrypt' => true,
],
'redis' => [ 'redis' => [
'driver' => 'redis', 'driver' => 'redis',
'connection' => 'default', 'connection' => 'default',

View file

@ -1,7 +1,6 @@
<?php <?php
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class DatabaseSeeder extends Seeder class DatabaseSeeder extends Seeder
{ {
@ -12,10 +11,6 @@ class DatabaseSeeder extends Seeder
*/ */
public function run() public function run()
{ {
Model::unguard();
// $this->call(UserTableSeeder::class); // $this->call(UserTableSeeder::class);
Model::reguard();
} }
} }

View file

@ -1,5 +0,0 @@
suites:
main:
namespace: App
psr4_prefix: App
src_path: app