From e40fa43d8345bcd4f9bc7b8c8998d47cd04f5174 Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Wed, 5 Apr 2017 15:15:55 +0000 Subject: [PATCH 01/21] Adopt PSR-2 coding style The Laravel framework adopts the PSR-2 coding style in version 5.1. Laravel apps *should* adopt this coding style as well. Read the [PSR-2 coding style guide][1] for more details and check out [PHPCS][2] to use as a code formatting tool. [1]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md [2]: https://github.com/squizlabs/PHP_CodeSniffer --- example/app/Article.php | 9 +- .../app/Http/Controllers/Admin/Articles.php | 51 ++++---- example/app/Http/Controllers/Admin/Slides.php | 7 +- example/app/Http/Controllers/Admin/Tags.php | 7 +- example/app/Http/routes.php | 2 +- example/app/Recipe.php | 5 +- example/app/Slide.php | 35 +++--- example/app/Tag.php | 5 +- example/config/decoy/core.php | 44 +++---- example/config/decoy/encode.php | 116 +++++++++--------- example/config/decoy/site.php | 32 ++--- .../2014_08_25_144559_encodables_table.php | 66 +++++----- .../2014_11_04_090719_elements_table.php | 63 +++++----- .../2015_04_15_161242_create_admins.php | 79 ++++++------ .../2015_06_08_133737_create_changes.php | 85 ++++++------- ...015_07_07_160435_create_redirect_rules.php | 54 ++++---- .../2016_01_14_220627_create_images.php | 82 ++++++------- .../2017_03_22_202910_create_tags.php | 1 - .../2017_03_24_224708_create_recipes.php | 2 +- 19 files changed, 379 insertions(+), 366 deletions(-) diff --git a/example/app/Article.php b/example/app/Article.php index d884499b..161dcec9 100644 --- a/example/app/Article.php +++ b/example/app/Article.php @@ -1,8 +1,10 @@ position)) return; + if (isset($this->position)) { + return; + } $this->position = self::max('position') + 1; } @@ -82,5 +86,4 @@ public function getAdminFeaturedAttribute() { return $this->featured ? 'Featured' : ''; } - } diff --git a/example/app/Http/Controllers/Admin/Articles.php b/example/app/Http/Controllers/Admin/Articles.php index a6435272..41bca8bf 100644 --- a/example/app/Http/Controllers/Admin/Articles.php +++ b/example/app/Http/Controllers/Admin/Articles.php @@ -1,30 +1,31 @@ 'getAdminTitleHtmlAttribute', - 'Status' => 'getAdminFeaturedAttribute', - 'Date' => 'created_at', - ]; - protected $search = [ - 'title', - 'featured' => [ - 'type' => 'select', - 'label' => 'featured status', - 'options' => [ - 1 => 'featured', - 0 => 'not featured', - ] - ], - 'category' => [ - 'type' => 'select', - 'options' => 'App\Article::$categories', - ], - 'date' => 'date', - ]; +class Articles extends Base +{ + protected $title = 'News & Events'; + protected $description = 'News and events yo!'; + protected $columns = [ + 'Title' => 'getAdminTitleHtmlAttribute', + 'Status' => 'getAdminFeaturedAttribute', + 'Date' => 'created_at', + ]; + protected $search = [ + 'title', + 'featured' => [ + 'type' => 'select', + 'label' => 'featured status', + 'options' => [ + 1 => 'featured', + 0 => 'not featured', + ] + ], + 'category' => [ + 'type' => 'select', + 'options' => 'App\Article::$categories', + ], + 'date' => 'date', + ]; } diff --git a/example/app/Http/Controllers/Admin/Slides.php b/example/app/Http/Controllers/Admin/Slides.php index 87caee5a..a41dd07c 100644 --- a/example/app/Http/Controllers/Admin/Slides.php +++ b/example/app/Http/Controllers/Admin/Slides.php @@ -1,9 +1,11 @@ 'article', function($slug) { +Route::get('article/{slug}', ['as' => 'article', function ($slug) { return 'hello'; }]); diff --git a/example/app/Recipe.php b/example/app/Recipe.php index 8a8912e4..e66a89a3 100644 --- a/example/app/Recipe.php +++ b/example/app/Recipe.php @@ -15,8 +15,8 @@ class Recipe extends Base * @var array */ public static $rules = [ - 'title' => 'required', - 'images.default' => 'image', + 'title' => 'required', + 'images.default' => 'image', 'file' => 'file', ]; @@ -33,5 +33,4 @@ class Recipe extends Base * @var boolean */ static public $localizable = true; - } diff --git a/example/app/Slide.php b/example/app/Slide.php index a47250d5..5cf8b2a1 100644 --- a/example/app/Slide.php +++ b/example/app/Slide.php @@ -1,25 +1,26 @@ 'required', - ]; + /** + * Validation rules + * + * @var array + */ + public static $rules = [ + 'title' => 'required', + ]; - /** - * List of all relationships - * - * @return Illuminate\Database\Eloquent\Relations\Relation - */ - public function article() + /** + * List of all relationships + * + * @return Illuminate\Database\Eloquent\Relations\Relation + */ + public function article() { - return $this->belongsTo('App\Article'); + return $this->belongsTo('App\Article'); } - } diff --git a/example/app/Tag.php b/example/app/Tag.php index 1b5043b8..f6eeeeb2 100644 --- a/example/app/Tag.php +++ b/example/app/Tag.php @@ -1,8 +1,10 @@ orderBy('name'); } - } diff --git a/example/config/decoy/core.php b/example/config/decoy/core.php index 59a05edd..ad2ea6a4 100644 --- a/example/config/decoy/core.php +++ b/example/config/decoy/core.php @@ -1,33 +1,33 @@ 'admin', + // The directory for the admin + 'dir' => 'admin', - // The layout to use - 'layout' => 'decoy::layouts.default', + // The layout to use + 'layout' => 'decoy::layouts.default', - // Auth guard and policy to use - 'guard' => 'decoy', - 'policy' => 'Bkwld\Decoy\Auth\Policy@check', + // Auth guard and policy to use + 'guard' => 'decoy', + 'policy' => 'Bkwld\Decoy\Auth\Policy@check', - // Use a password input field for admins - 'obscure_admin_password' => false, + // Use a password input field for admins + 'obscure_admin_password' => false, - // Mail FROM info - 'mail_from_name' => 'Site Admin', - 'mail_from_address' => 'postmaster@'.(app()->runningInConsole() ? - 'locahost' : parse_url(url()->current(), PHP_URL_HOST)), + // Mail FROM info + 'mail_from_name' => 'Site Admin', + 'mail_from_address' => 'postmaster@'.(app()->runningInConsole() ? + 'locahost' : parse_url(url()->current(), PHP_URL_HOST)), - // Allow regex in redirect rules - 'allow_regex_in_redirects' => false, + // Allow regex in redirect rules + 'allow_regex_in_redirects' => false, - // Register routes automatically in ServiceProvider->boot(). You might set - // this to false if the App needed to register some /admin routes and didn't - // want them to get trampled by the Decoy wildcard capture. - 'register_routes' => true, + // Register routes automatically in ServiceProvider->boot(). You might set + // this to false if the App needed to register some /admin routes and didn't + // want them to get trampled by the Decoy wildcard capture. + 'register_routes' => true, - // Set up the default stylesheet and script tags - 'stylesheet' => '/assets/decoy/index.min.css', - 'script' => '/assets/decoy/index.min.js', + // Set up the default stylesheet and script tags + 'stylesheet' => '/assets/decoy/index.min.css', + 'script' => '/assets/decoy/index.min.js', ); diff --git a/example/config/decoy/encode.php b/example/config/decoy/encode.php index 8abca45d..ef40e88b 100644 --- a/example/config/decoy/encode.php +++ b/example/config/decoy/encode.php @@ -1,62 +1,62 @@ 'REQUIRED', - - /** - * The destination directory. In other words, where the encoded video files - * should be pushed to. - * Ex: s3://bucket-name/directory - * Ex: sftp://xx.xx.xx.xx:xx/home/gopagoda/data/public/uploads/encodes - */ - 'destination' => 'REQUIRED', - - /** - * If not empty, subsitute the destiation path that is returned from the - * encoder with this. If this is an absolute path (like the example), then - * Decoy will try and remove the encodes if the encode is deleted. - * Ex: /uploads/encodes - */ - 'destination_root' => '', - - /** - * Settings that can be applied uniquely to each video instance. - */ - 'presets' => [ - - '1080p' => [ - 'title' => '1080p (quality: 2)', - 'settings' => [ - 'quality' => 2, - 'height' => '1080', - ], - ], - - '1080pq3' => [ - 'title' => '1080p (quality: 3)', - 'settings' => [ - 'quality' => 3, - 'height' => '1080', - ], - ], - - '720p' => [ - 'title' => '1080p (quality: 2)', - 'settings' => [ - 'quality' => 2, - 'height' => '720', - ], - ], - - ], - - /** - * A class that implements the Bkwld\Decoy\Input\EncodingProviders\EncoderInterface - * interface and contains the logic to push a video encode request to service - * provider and handle the responses - */ - 'provider' => '\Bkwld\Decoy\Input\EncodingProviders\Zencoder', + /** + * The API key used to access the specified provider + */ + 'api_key' => 'REQUIRED', + + /** + * The destination directory. In other words, where the encoded video files + * should be pushed to. + * Ex: s3://bucket-name/directory + * Ex: sftp://xx.xx.xx.xx:xx/home/gopagoda/data/public/uploads/encodes + */ + 'destination' => 'REQUIRED', + + /** + * If not empty, subsitute the destiation path that is returned from the + * encoder with this. If this is an absolute path (like the example), then + * Decoy will try and remove the encodes if the encode is deleted. + * Ex: /uploads/encodes + */ + 'destination_root' => '', + + /** + * Settings that can be applied uniquely to each video instance. + */ + 'presets' => [ + + '1080p' => [ + 'title' => '1080p (quality: 2)', + 'settings' => [ + 'quality' => 2, + 'height' => '1080', + ], + ], + + '1080pq3' => [ + 'title' => '1080p (quality: 3)', + 'settings' => [ + 'quality' => 3, + 'height' => '1080', + ], + ], + + '720p' => [ + 'title' => '1080p (quality: 2)', + 'settings' => [ + 'quality' => 2, + 'height' => '720', + ], + ], + + ], + + /** + * A class that implements the Bkwld\Decoy\Input\EncodingProviders\EncoderInterface + * interface and contains the logic to push a video encode request to service + * provider and handle the responses + */ + 'provider' => '\Bkwld\Decoy\Input\EncodingProviders\Zencoder', ); diff --git a/example/config/decoy/site.php b/example/config/decoy/site.php index 3d23d597..8d681c47 100644 --- a/example/config/decoy/site.php +++ b/example/config/decoy/site.php @@ -48,21 +48,21 @@ 'viewer' => 'Viewer - Can only read.', ], - /** - * Permissions rules. These are described in more detail in the README. - * - * @var array - */ - 'permissions' => [ - 'viewer' => [ - 'can' => [ - 'manage.articles', - ], - 'cant' => [ - 'destroy.articles', - ] - ], - ], + /** + * Permissions rules. These are described in more detail in the README. + * + * @var array + */ + 'permissions' => [ + 'viewer' => [ + 'can' => [ + 'manage.articles', + ], + 'cant' => [ + 'destroy.articles', + ] + ], + ], /** * A hash of localization slugs and readable labels for all the locales for this @@ -99,7 +99,7 @@ * @return boolean */ // 'log_changes' => true, - 'log_changes' => function($model, $action, $admin_id) { + 'log_changes' => function ($model, $action, $admin_id) { return true; }, diff --git a/example/database/migrations/2014_08_25_144559_encodables_table.php b/example/database/migrations/2014_08_25_144559_encodables_table.php index 63e8ea74..e2a87331 100644 --- a/example/database/migrations/2014_08_25_144559_encodables_table.php +++ b/example/database/migrations/2014_08_25_144559_encodables_table.php @@ -3,39 +3,41 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class EncodablesTable extends Migration { +class EncodablesTable extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() { - Schema::create('encodings', function(Blueprint $table) { - $table->engine = 'InnoDB'; - $table->increments('id'); - $table->string('encodable_type'); - $table->string('encodable_id'); // String for Elements - $table->string('encodable_attribute'); - $table->string('status')->index(); - $table->string('job_id')->nullable()->index(); - $table->text('outputs')->nullable(); - $table->text('message')->nullable(); - $table->timestamps(); + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('encodings', function (Blueprint $table) { + $table->engine = 'InnoDB'; + $table->increments('id'); + $table->string('encodable_type'); + $table->string('encodable_id'); // String for Elements + $table->string('encodable_attribute'); + $table->string('status')->index(); + $table->string('job_id')->nullable()->index(); + $table->text('outputs')->nullable(); + $table->text('message')->nullable(); + $table->timestamps(); - $table->index(['encodable_id', 'encodable_type', 'encodable_attribute']); - $table->index(['encodable_type', 'encodable_id', 'encodable_attribute']); - $table->index(['encodable_attribute', 'encodable_id', 'encodable_type']); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() { - Schema::drop('encodings'); - } + $table->index(['encodable_id', 'encodable_type', 'encodable_attribute']); + $table->index(['encodable_type', 'encodable_id', 'encodable_attribute']); + $table->index(['encodable_attribute', 'encodable_id', 'encodable_type']); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('encodings'); + } } diff --git a/example/database/migrations/2014_11_04_090719_elements_table.php b/example/database/migrations/2014_11_04_090719_elements_table.php index daf796d3..db9989ee 100644 --- a/example/database/migrations/2014_11_04_090719_elements_table.php +++ b/example/database/migrations/2014_11_04_090719_elements_table.php @@ -3,35 +3,36 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class ElementsTable extends Migration { - - /** - * Run the migrations. - * - * @return void - */ - public function up() { - Schema::create('elements', function($table){ - $table->engine = 'InnoDB'; - - $table->string('key'); - $table->string('type'); - $table->mediumtext('value')->nullable(); - $table->string('locale'); - - $table->primary(['key', 'locale']); - $table->index(['locale', 'key']); - - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() { - Schema::drop('elements'); - } - +class ElementsTable extends Migration +{ + + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('elements', function ($table) { + $table->engine = 'InnoDB'; + + $table->string('key'); + $table->string('type'); + $table->mediumtext('value')->nullable(); + $table->string('locale'); + + $table->primary(['key', 'locale']); + $table->index(['locale', 'key']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('elements'); + } } diff --git a/example/database/migrations/2015_04_15_161242_create_admins.php b/example/database/migrations/2015_04_15_161242_create_admins.php index c6dcab71..d2570fc7 100644 --- a/example/database/migrations/2015_04_15_161242_create_admins.php +++ b/example/database/migrations/2015_04_15_161242_create_admins.php @@ -3,43 +3,44 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class CreateAdmins extends Migration { - - /** - * Run the migrations. - * - * @return void - */ - public function up() { - - // Adapted from: - // https://scotch.io/tutorials/simple-and-easy-laravel-login-authentication - Schema::create('admins', function(Blueprint $table) { - $table->engine = 'InnoDB'; - $table->increments('id'); - - $table->string('first_name'); - $table->string('last_name'); - $table->string('email')->index(); - $table->string('password'); - $table->string('image')->nullable(); - $table->string('role'); - $table->text('permissions')->nullable(); - $table->rememberToken(); - $table->boolean('active'); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('admins'); - } - +class CreateAdmins extends Migration +{ + + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + + // Adapted from: + // https://scotch.io/tutorials/simple-and-easy-laravel-login-authentication + Schema::create('admins', function (Blueprint $table) { + $table->engine = 'InnoDB'; + $table->increments('id'); + + $table->string('first_name'); + $table->string('last_name'); + $table->string('email')->index(); + $table->string('password'); + $table->string('image')->nullable(); + $table->string('role'); + $table->text('permissions')->nullable(); + $table->rememberToken(); + $table->boolean('active'); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('admins'); + } } diff --git a/example/database/migrations/2015_06_08_133737_create_changes.php b/example/database/migrations/2015_06_08_133737_create_changes.php index 82322171..77ba54b2 100644 --- a/example/database/migrations/2015_06_08_133737_create_changes.php +++ b/example/database/migrations/2015_06_08_133737_create_changes.php @@ -3,46 +3,47 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class CreateChanges extends Migration { - - /** - * Run the migrations. - * - * @return void - */ - public function up() { - Schema::create('changes', function($table) { - $table->engine = 'InnoDB'; - $table->increments('id'); - - $table->string('model'); - $table->string('key'); - $table->string('action'); - $table->string('title')->nullable(); - $table->longText('changed')->nullable(); - - $table->integer('admin_id')->unsigned(); - $table->longText('meta')->nullable(); - $table->boolean('deleted')->nullable(); - $table->timestamps(); - - $table->index(['model', 'key']); - $table->index(['key', 'model']); - $table->index(['action', 'created_at']); - $table->index(['created_at', 'action']); - $table->index(['deleted', 'created_at']); - $table->foreign('admin_id')->references('id')->on('admins')->onUpdate('cascade')->onDelete('cascade'); - - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() { - Schema::drop('changes'); - } - +class CreateChanges extends Migration +{ + + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('changes', function ($table) { + $table->engine = 'InnoDB'; + $table->increments('id'); + + $table->string('model'); + $table->string('key'); + $table->string('action'); + $table->string('title')->nullable(); + $table->longText('changed')->nullable(); + + $table->integer('admin_id')->unsigned(); + $table->longText('meta')->nullable(); + $table->boolean('deleted')->nullable(); + $table->timestamps(); + + $table->index(['model', 'key']); + $table->index(['key', 'model']); + $table->index(['action', 'created_at']); + $table->index(['created_at', 'action']); + $table->index(['deleted', 'created_at']); + $table->foreign('admin_id')->references('id')->on('admins')->onUpdate('cascade')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('changes'); + } } diff --git a/example/database/migrations/2015_07_07_160435_create_redirect_rules.php b/example/database/migrations/2015_07_07_160435_create_redirect_rules.php index e67b6ac0..20a535e3 100644 --- a/example/database/migrations/2015_07_07_160435_create_redirect_rules.php +++ b/example/database/migrations/2015_07_07_160435_create_redirect_rules.php @@ -3,34 +3,36 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class CreateRedirectRules extends Migration { +class CreateRedirectRules extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() { - Schema::create('redirect_rules', function(Blueprint $table) { - $table->engine = 'InnoDB'; - $table->increments('id'); + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('redirect_rules', function (Blueprint $table) { + $table->engine = 'InnoDB'; + $table->increments('id'); - $table->string('from')->index(); - $table->string('to'); - $table->string('code'); - $table->string('label')->nullable(); + $table->string('from')->index(); + $table->string('to'); + $table->string('code'); + $table->string('label')->nullable(); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() { - Schema::drop('redirect_rules'); - } + $table->timestamps(); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('redirect_rules'); + } } diff --git a/example/database/migrations/2016_01_14_220627_create_images.php b/example/database/migrations/2016_01_14_220627_create_images.php index d71a3430..68a80cf1 100644 --- a/example/database/migrations/2016_01_14_220627_create_images.php +++ b/example/database/migrations/2016_01_14_220627_create_images.php @@ -5,45 +5,45 @@ class CreateImages extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('images', function (Blueprint $table) { - $table->engine = 'InnoDB'; - $table->increments('id'); - - $table->string('imageable_type'); - $table->string('imageable_id'); - - $table->string('file'); - $table->string('file_type'); - $table->string('file_size'); - - $table->string('name')->nullable(); // Key used to refer to it in code - $table->string('title')->nullable(); // Alt title - $table->text('crop_box')->nullable(); - $table->string('focal_point')->nullable(); - - $table->integer('width')->unsigned(); - $table->integer('height')->unsigned(); - $table->timestamps(); - - $table->index(['imageable_type', 'imageable_id']); - $table->index(['imageable_id', 'imageable_type']); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('images'); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('images', function (Blueprint $table) { + $table->engine = 'InnoDB'; + $table->increments('id'); + + $table->string('imageable_type'); + $table->string('imageable_id'); + + $table->string('file'); + $table->string('file_type'); + $table->string('file_size'); + + $table->string('name')->nullable(); // Key used to refer to it in code + $table->string('title')->nullable(); // Alt title + $table->text('crop_box')->nullable(); + $table->string('focal_point')->nullable(); + + $table->integer('width')->unsigned(); + $table->integer('height')->unsigned(); + $table->timestamps(); + + $table->index(['imageable_type', 'imageable_id']); + $table->index(['imageable_id', 'imageable_type']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('images'); + } } diff --git a/example/database/migrations/2017_03_22_202910_create_tags.php b/example/database/migrations/2017_03_22_202910_create_tags.php index b0eafc4e..4faca82e 100644 --- a/example/database/migrations/2017_03_22_202910_create_tags.php +++ b/example/database/migrations/2017_03_22_202910_create_tags.php @@ -25,7 +25,6 @@ public function up() ->onUpdate('cascade') ->onDelete('cascade'); }); - } /** diff --git a/example/database/migrations/2017_03_24_224708_create_recipes.php b/example/database/migrations/2017_03_24_224708_create_recipes.php index 67c4bf86..20f147a5 100644 --- a/example/database/migrations/2017_03_24_224708_create_recipes.php +++ b/example/database/migrations/2017_03_24_224708_create_recipes.php @@ -20,7 +20,7 @@ public function up() $table->string('file')->nullable(); $table->string('locale'); - $table->string('locale_group')->index(); + $table->string('locale_group')->index(); $table->boolean('public')->index(); $table->timestamps(); }); From a3abcfab8732b3f6d9a5186fed63e9b4ec477a3e Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Wed, 5 Apr 2017 15:15:55 +0000 Subject: [PATCH 02/21] Adopt PHP short array syntax Laravel 5 adopted the short array syntax which became available in PHP 5.4. --- example/config/decoy/core.php | 4 ++-- example/config/decoy/encode.php | 4 ++-- example/config/decoy/site.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/example/config/decoy/core.php b/example/config/decoy/core.php index ad2ea6a4..232ffca8 100644 --- a/example/config/decoy/core.php +++ b/example/config/decoy/core.php @@ -1,4 +1,4 @@ - 'admin', @@ -30,4 +30,4 @@ 'stylesheet' => '/assets/decoy/index.min.css', 'script' => '/assets/decoy/index.min.js', -); +]; diff --git a/example/config/decoy/encode.php b/example/config/decoy/encode.php index ef40e88b..660df8d1 100644 --- a/example/config/decoy/encode.php +++ b/example/config/decoy/encode.php @@ -1,4 +1,4 @@ - '\Bkwld\Decoy\Input\EncodingProviders\Zencoder', -); +]; diff --git a/example/config/decoy/site.php b/example/config/decoy/site.php index 8d681c47..476cac3f 100644 --- a/example/config/decoy/site.php +++ b/example/config/decoy/site.php @@ -1,4 +1,4 @@ - Date: Wed, 5 Apr 2017 15:15:55 +0000 Subject: [PATCH 03/21] Shift core files --- example/app/Console/Kernel.php | 12 +++++- example/app/Exceptions/Handler.php | 43 +++++++++++++------ example/app/Http/Controllers/Controller.php | 3 +- example/app/User.php | 3 ++ .../2014_10_12_000000_create_users_table.php | 1 + ...12_100000_create_password_resets_table.php | 3 +- example/resources/lang/en/validation.php | 4 ++ 7 files changed, 51 insertions(+), 18 deletions(-) diff --git a/example/app/Console/Kernel.php b/example/app/Console/Kernel.php index 71c519d3..622e774b 100644 --- a/example/app/Console/Kernel.php +++ b/example/app/Console/Kernel.php @@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel * @var array */ protected $commands = [ - // Commands\Inspire::class, + // ]; /** @@ -27,4 +27,14 @@ protected function schedule(Schedule $schedule) // $schedule->command('inspire') // ->hourly(); } + + /** + * Register the Closure based commands for the application. + * + * @return void + */ + protected function commands() + { + require base_path('routes/console.php'); + } } diff --git a/example/app/Exceptions/Handler.php b/example/app/Exceptions/Handler.php index 53617ef4..21c9784c 100644 --- a/example/app/Exceptions/Handler.php +++ b/example/app/Exceptions/Handler.php @@ -3,10 +3,7 @@ namespace App\Exceptions; use Exception; -use Illuminate\Validation\ValidationException; -use Illuminate\Auth\Access\AuthorizationException; -use Illuminate\Database\Eloquent\ModelNotFoundException; -use Symfony\Component\HttpKernel\Exception\HttpException; +use Illuminate\Auth\AuthenticationException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; class Handler extends ExceptionHandler @@ -17,10 +14,12 @@ class Handler extends ExceptionHandler * @var array */ protected $dontReport = [ - AuthorizationException::class, - HttpException::class, - ModelNotFoundException::class, - ValidationException::class, + \Illuminate\Auth\AuthenticationException::class, + \Illuminate\Auth\Access\AuthorizationException::class, + \Symfony\Component\HttpKernel\Exception\HttpException::class, + \Illuminate\Database\Eloquent\ModelNotFoundException::class, + \Illuminate\Session\TokenMismatchException::class, + \Illuminate\Validation\ValidationException::class, ]; /** @@ -28,23 +27,39 @@ class Handler extends ExceptionHandler * * This is a great spot to send exceptions to Sentry, Bugsnag, etc. * - * @param \Exception $e + * @param \Exception $exception * @return void */ - public function report(Exception $e) + public function report(Exception $exception) { - parent::report($e); + parent::report($exception); } /** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request - * @param \Exception $e + * @param \Exception $exception * @return \Illuminate\Http\Response */ - public function render($request, Exception $e) + public function render($request, Exception $exception) { - return parent::render($request, $e); + return parent::render($request, $exception); + } + + /** + * Convert an authentication exception into an unauthenticated response. + * + * @param \Illuminate\Http\Request $request + * @param \Illuminate\Auth\AuthenticationException $exception + * @return \Illuminate\Http\Response + */ + protected function unauthenticated($request, AuthenticationException $exception) + { + if ($request->expectsJson()) { + return response()->json(['error' => 'Unauthenticated.'], 401); + } + + return redirect()->guest('login'); } } diff --git a/example/app/Http/Controllers/Controller.php b/example/app/Http/Controllers/Controller.php index d492e0b3..03e02a23 100644 --- a/example/app/Http/Controllers/Controller.php +++ b/example/app/Http/Controllers/Controller.php @@ -6,9 +6,8 @@ use Illuminate\Routing\Controller as BaseController; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; -use Illuminate\Foundation\Auth\Access\AuthorizesResources; class Controller extends BaseController { - use AuthorizesRequests, AuthorizesResources, DispatchesJobs, ValidatesRequests; + use AuthorizesRequests, DispatchesJobs, ValidatesRequests; } diff --git a/example/app/User.php b/example/app/User.php index 75741ae4..bfd96a6a 100644 --- a/example/app/User.php +++ b/example/app/User.php @@ -2,10 +2,13 @@ namespace App; +use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { + use Notifiable; + /** * The attributes that are mass assignable. * diff --git a/example/database/migrations/2014_10_12_000000_create_users_table.php b/example/database/migrations/2014_10_12_000000_create_users_table.php index 59aa01a5..55574ee4 100644 --- a/example/database/migrations/2014_10_12_000000_create_users_table.php +++ b/example/database/migrations/2014_10_12_000000_create_users_table.php @@ -1,5 +1,6 @@ string('email')->index(); $table->string('token')->index(); - $table->timestamp('created_at'); + $table->timestamp('created_at')->nullable(); }); } diff --git a/example/resources/lang/en/validation.php b/example/resources/lang/en/validation.php index b1e61204..73b49d08 100644 --- a/example/resources/lang/en/validation.php +++ b/example/resources/lang/en/validation.php @@ -34,9 +34,11 @@ 'different' => 'The :attribute and :other must be different.', 'digits' => 'The :attribute must be :digits digits.', 'digits_between' => 'The :attribute must be between :min and :max digits.', + 'dimensions' => 'The :attribute has invalid image dimensions.', 'distinct' => 'The :attribute field has a duplicate value.', 'email' => 'The :attribute must be a valid email address.', 'exists' => 'The selected :attribute is invalid.', + 'file' => 'The :attribute must be a file.', 'filled' => 'The :attribute field is required.', 'image' => 'The :attribute must be an image.', 'in' => 'The selected :attribute is invalid.', @@ -51,6 +53,7 @@ 'array' => 'The :attribute may not have more than :max items.', ], 'mimes' => 'The :attribute must be a file of type: :values.', + 'mimetypes' => 'The :attribute must be a file of type: :values.', 'min' => [ 'numeric' => 'The :attribute must be at least :min.', 'file' => 'The :attribute must be at least :min kilobytes.', @@ -78,6 +81,7 @@ 'string' => 'The :attribute must be a string.', 'timezone' => 'The :attribute must be a valid zone.', 'unique' => 'The :attribute has already been taken.', + 'uploaded' => 'The :attribute failed to upload.', 'url' => 'The :attribute format is invalid.', /* From 635708da7d59d27e80d5363e04bc90b71b46381d Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Wed, 5 Apr 2017 15:15:55 +0000 Subject: [PATCH 04/21] Shift app folder structure Laravel 5.3 no longer includes the `Events`, `Jobs`, `Listeners`, and `Policies` folders by default. Instead, they are created when you make them using `artisan`. --- example/app/Events/Event.php | 8 -------- example/app/Jobs/Job.php | 21 --------------------- example/app/Listeners/.gitkeep | 1 - example/app/Policies/.gitkeep | 1 - 4 files changed, 31 deletions(-) delete mode 100644 example/app/Events/Event.php delete mode 100644 example/app/Jobs/Job.php delete mode 100644 example/app/Listeners/.gitkeep delete mode 100644 example/app/Policies/.gitkeep diff --git a/example/app/Events/Event.php b/example/app/Events/Event.php deleted file mode 100644 index ba2f8883..00000000 --- a/example/app/Events/Event.php +++ /dev/null @@ -1,8 +0,0 @@ - Date: Wed, 5 Apr 2017 15:15:56 +0000 Subject: [PATCH 05/21] Shift auth components --- .../Auth/ForgotPasswordController.php | 32 +++++++++++++++ .../Http/Controllers/Auth/LoginController.php | 39 +++++++++++++++++++ ...hController.php => RegisterController.php} | 21 +++++----- ...roller.php => ResetPasswordController.php} | 4 +- 4 files changed, 83 insertions(+), 13 deletions(-) create mode 100644 example/app/Http/Controllers/Auth/ForgotPasswordController.php create mode 100644 example/app/Http/Controllers/Auth/LoginController.php rename example/app/Http/Controllers/Auth/{AuthController.php => RegisterController.php} (67%) rename example/app/Http/Controllers/Auth/{PasswordController.php => ResetPasswordController.php} (88%) diff --git a/example/app/Http/Controllers/Auth/ForgotPasswordController.php b/example/app/Http/Controllers/Auth/ForgotPasswordController.php new file mode 100644 index 00000000..6a247fef --- /dev/null +++ b/example/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -0,0 +1,32 @@ +middleware('guest'); + } +} diff --git a/example/app/Http/Controllers/Auth/LoginController.php b/example/app/Http/Controllers/Auth/LoginController.php new file mode 100644 index 00000000..75949531 --- /dev/null +++ b/example/app/Http/Controllers/Auth/LoginController.php @@ -0,0 +1,39 @@ +middleware('guest', ['except' => 'logout']); + } +} diff --git a/example/app/Http/Controllers/Auth/AuthController.php b/example/app/Http/Controllers/Auth/RegisterController.php similarity index 67% rename from example/app/Http/Controllers/Auth/AuthController.php rename to example/app/Http/Controllers/Auth/RegisterController.php index a100dd6e..34c376cf 100644 --- a/example/app/Http/Controllers/Auth/AuthController.php +++ b/example/app/Http/Controllers/Auth/RegisterController.php @@ -5,39 +5,38 @@ use App\User; use Validator; use App\Http\Controllers\Controller; -use Illuminate\Foundation\Auth\ThrottlesLogins; -use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers; +use Illuminate\Foundation\Auth\RegistersUsers; -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; /** * Where to redirect users after login / registration. * * @var string */ - protected $redirectTo = '/'; + protected $redirectTo = '/home'; /** - * Create a new authentication controller instance. + * Create a new controller instance. * * @return void */ public function __construct() { - $this->middleware($this->guestMiddleware(), ['except' => 'logout']); + $this->middleware('guest'); } /** diff --git a/example/app/Http/Controllers/Auth/PasswordController.php b/example/app/Http/Controllers/Auth/ResetPasswordController.php similarity index 88% rename from example/app/Http/Controllers/Auth/PasswordController.php rename to example/app/Http/Controllers/Auth/ResetPasswordController.php index 1ceed97b..c73bf99f 100644 --- a/example/app/Http/Controllers/Auth/PasswordController.php +++ b/example/app/Http/Controllers/Auth/ResetPasswordController.php @@ -5,7 +5,7 @@ use App\Http\Controllers\Controller; use Illuminate\Foundation\Auth\ResetsPasswords; -class PasswordController extends Controller +class ResetPasswordController extends Controller { /* |-------------------------------------------------------------------------- @@ -21,7 +21,7 @@ class PasswordController extends Controller use ResetsPasswords; /** - * Create a new password controller instance. + * Create a new controller instance. * * @return void */ From 3eba07de5eb6fcfcfe9a5835064c7d100f0384dc Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Wed, 5 Apr 2017 15:15:56 +0000 Subject: [PATCH 06/21] Shift Providers --- example/app/Providers/AuthServiceProvider.php | 9 ++-- .../Providers/BroadcastServiceProvider.php | 26 ++++++++++++ .../app/Providers/EventServiceProvider.php | 9 ++-- .../app/Providers/RouteServiceProvider.php | 42 +++++++++++++------ 4 files changed, 64 insertions(+), 22 deletions(-) create mode 100644 example/app/Providers/BroadcastServiceProvider.php diff --git a/example/app/Providers/AuthServiceProvider.php b/example/app/Providers/AuthServiceProvider.php index 57d88ea3..9784b1a3 100644 --- a/example/app/Providers/AuthServiceProvider.php +++ b/example/app/Providers/AuthServiceProvider.php @@ -2,7 +2,7 @@ namespace App\Providers; -use Illuminate\Contracts\Auth\Access\Gate as GateContract; +use Illuminate\Support\Facades\Gate; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; class AuthServiceProvider extends ServiceProvider @@ -17,14 +17,13 @@ class AuthServiceProvider extends ServiceProvider ]; /** - * Register any application authentication / authorization services. + * Register any authentication / authorization services. * - * @param \Illuminate\Contracts\Auth\Access\Gate $gate * @return void */ - public function boot(GateContract $gate) + public function boot() { - $this->registerPolicies($gate); + $this->registerPolicies(); // } diff --git a/example/app/Providers/BroadcastServiceProvider.php b/example/app/Providers/BroadcastServiceProvider.php new file mode 100644 index 00000000..1dcf8d28 --- /dev/null +++ b/example/app/Providers/BroadcastServiceProvider.php @@ -0,0 +1,26 @@ +id === (int) $userId; + }); + } +} diff --git a/example/app/Providers/EventServiceProvider.php b/example/app/Providers/EventServiceProvider.php index 58ce9624..a182657e 100644 --- a/example/app/Providers/EventServiceProvider.php +++ b/example/app/Providers/EventServiceProvider.php @@ -2,7 +2,7 @@ namespace App\Providers; -use Illuminate\Contracts\Events\Dispatcher as DispatcherContract; +use Illuminate\Support\Facades\Event; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; class EventServiceProvider extends ServiceProvider @@ -19,14 +19,13 @@ class EventServiceProvider extends ServiceProvider ]; /** - * Register any other events for your application. + * Register any events for your application. * - * @param \Illuminate\Contracts\Events\Dispatcher $events * @return void */ - public function boot(DispatcherContract $events) + public function boot() { - parent::boot($events); + parent::boot(); // } diff --git a/example/app/Providers/RouteServiceProvider.php b/example/app/Providers/RouteServiceProvider.php index bde08819..87ffb05a 100644 --- a/example/app/Providers/RouteServiceProvider.php +++ b/example/app/Providers/RouteServiceProvider.php @@ -2,7 +2,7 @@ namespace App\Providers; -use Illuminate\Routing\Router; +use Illuminate\Support\Facades\Route; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; class RouteServiceProvider extends ServiceProvider @@ -19,25 +19,25 @@ class RouteServiceProvider extends ServiceProvider /** * Define your route model bindings, pattern filters, etc. * - * @param \Illuminate\Routing\Router $router * @return void */ - public function boot(Router $router) + public function boot() { // - parent::boot($router); + parent::boot(); } /** * Define the routes for the application. * - * @param \Illuminate\Routing\Router $router * @return void */ - public function map(Router $router) + public function map() { - $this->mapWebRoutes($router); + $this->mapApiRoutes(); + + $this->mapWebRoutes(); // } @@ -47,15 +47,33 @@ public function map(Router $router) * * These routes all receive session state, CSRF protection, etc. * - * @param \Illuminate\Routing\Router $router * @return void */ - protected function mapWebRoutes(Router $router) + protected function mapWebRoutes() + { + Route::group([ + 'middleware' => 'web', + 'namespace' => $this->namespace, + ], function ($router) { + require base_path('routes/web.php'); + }); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + * + * @return void + */ + protected function mapApiRoutes() { - $router->group([ - 'namespace' => $this->namespace, 'middleware' => 'web', + Route::group([ + 'middleware' => 'api', + 'namespace' => $this->namespace, + 'prefix' => 'api', ], function ($router) { - require app_path('Http/routes.php'); + require base_path('routes/api.php'); }); } } From 9ff1a8665cd8d916c4a2a263d42fed522ee0042c Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Wed, 5 Apr 2017 15:15:56 +0000 Subject: [PATCH 07/21] Shift Middleware --- example/app/Http/Kernel.php | 7 +++-- example/app/Http/Middleware/Authenticate.php | 30 ------------------- .../Middleware/RedirectIfAuthenticated.php | 2 +- example/app/Http/Requests/Request.php | 10 ------- 4 files changed, 6 insertions(+), 43 deletions(-) delete mode 100644 example/app/Http/Middleware/Authenticate.php delete mode 100644 example/app/Http/Requests/Request.php diff --git a/example/app/Http/Kernel.php b/example/app/Http/Kernel.php index bffcfd9f..bcabec41 100644 --- a/example/app/Http/Kernel.php +++ b/example/app/Http/Kernel.php @@ -29,10 +29,12 @@ class Kernel extends HttpKernel \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, + \Illuminate\Routing\Middleware\SubstituteBindings::class, ], 'api' => [ 'throttle:60,1', + 'bindings', ], ]; @@ -44,9 +46,10 @@ class Kernel extends HttpKernel * @var array */ protected $routeMiddleware = [ - 'auth' => \App\Http\Middleware\Authenticate::class, + 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, - 'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class, + 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, + 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, ]; diff --git a/example/app/Http/Middleware/Authenticate.php b/example/app/Http/Middleware/Authenticate.php deleted file mode 100644 index 67abcaea..00000000 --- a/example/app/Http/Middleware/Authenticate.php +++ /dev/null @@ -1,30 +0,0 @@ -guest()) { - if ($request->ajax() || $request->wantsJson()) { - return response('Unauthorized.', 401); - } else { - return redirect()->guest('login'); - } - } - - return $next($request); - } -} diff --git a/example/app/Http/Middleware/RedirectIfAuthenticated.php b/example/app/Http/Middleware/RedirectIfAuthenticated.php index e27860e2..e4cec9c8 100644 --- a/example/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/example/app/Http/Middleware/RedirectIfAuthenticated.php @@ -18,7 +18,7 @@ class RedirectIfAuthenticated public function handle($request, Closure $next, $guard = null) { if (Auth::guard($guard)->check()) { - return redirect('/'); + return redirect('/home'); } return $next($request); diff --git a/example/app/Http/Requests/Request.php b/example/app/Http/Requests/Request.php deleted file mode 100644 index 76b2ffd4..00000000 --- a/example/app/Http/Requests/Request.php +++ /dev/null @@ -1,10 +0,0 @@ - Date: Wed, 5 Apr 2017 15:15:56 +0000 Subject: [PATCH 08/21] Shift Routes Laravel 5.3 now stores Routes in a top-level `routes` folder and separates them into API, console, and web files. --- example/routes/api.php | 18 ++++++++++++++++++ example/routes/console.php | 18 ++++++++++++++++++ .../{app/Http/routes.php => routes/web.php} | 0 3 files changed, 36 insertions(+) create mode 100644 example/routes/api.php create mode 100644 example/routes/console.php rename example/{app/Http/routes.php => routes/web.php} (100%) diff --git a/example/routes/api.php b/example/routes/api.php new file mode 100644 index 00000000..6b907f39 --- /dev/null +++ b/example/routes/api.php @@ -0,0 +1,18 @@ +user(); +})->middleware('auth:api'); diff --git a/example/routes/console.php b/example/routes/console.php new file mode 100644 index 00000000..75dd0cde --- /dev/null +++ b/example/routes/console.php @@ -0,0 +1,18 @@ +comment(Inspiring::quote()); +})->describe('Display an inspiring quote'); diff --git a/example/app/Http/routes.php b/example/routes/web.php similarity index 100% rename from example/app/Http/routes.php rename to example/routes/web.php From 58f84a17c145ca301ea4efc890e959f139d93139 Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Wed, 5 Apr 2017 15:15:56 +0000 Subject: [PATCH 09/21] Shift configuration --- example/config/app.php | 16 ++++++++++++++++ example/config/auth.php | 5 ----- example/config/cache.php | 10 ++++++++++ example/config/queue.php | 8 ++++---- example/config/services.php | 2 +- example/config/session.php | 17 +++++++++++++++-- 6 files changed, 46 insertions(+), 12 deletions(-) diff --git a/example/config/app.php b/example/config/app.php index 71e86659..1aaa7c7a 100644 --- a/example/config/app.php +++ b/example/config/app.php @@ -2,6 +2,18 @@ return [ + /* + |-------------------------------------------------------------------------- + | Application Name + |-------------------------------------------------------------------------- + | + | This value is the name of your application. This value is used when the + | framework needs to place the application's name in a notification or + | any other location as required by the application or its packages. + */ + + 'name' => 'My Application', + /* |-------------------------------------------------------------------------- | Application Environment @@ -138,6 +150,7 @@ Illuminate\Foundation\Providers\FoundationServiceProvider::class, Illuminate\Hashing\HashServiceProvider::class, Illuminate\Mail\MailServiceProvider::class, + Illuminate\Notifications\NotificationServiceProvider::class, Illuminate\Pagination\PaginationServiceProvider::class, Illuminate\Pipeline\PipelineServiceProvider::class, Illuminate\Queue\QueueServiceProvider::class, @@ -152,6 +165,7 @@ * Application Service Providers... */ App\Providers\AppServiceProvider::class, + // App\Providers\BroadcastServiceProvider::class, App\Providers\AuthServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, @@ -177,6 +191,7 @@ 'Artisan' => Illuminate\Support\Facades\Artisan::class, 'Auth' => Illuminate\Support\Facades\Auth::class, 'Blade' => Illuminate\Support\Facades\Blade::class, + 'Bus' => Illuminate\Support\Facades\Bus::class, 'Cache' => Illuminate\Support\Facades\Cache::class, 'Config' => Illuminate\Support\Facades\Config::class, 'Cookie' => Illuminate\Support\Facades\Cookie::class, @@ -190,6 +205,7 @@ 'Lang' => Illuminate\Support\Facades\Lang::class, 'Log' => Illuminate\Support\Facades\Log::class, 'Mail' => Illuminate\Support\Facades\Mail::class, + 'Notification' => Illuminate\Support\Facades\Notification::class, 'Password' => Illuminate\Support\Facades\Password::class, 'Queue' => Illuminate\Support\Facades\Queue::class, 'Redirect' => Illuminate\Support\Facades\Redirect::class, diff --git a/example/config/auth.php b/example/config/auth.php index 3fa7f491..78175010 100644 --- a/example/config/auth.php +++ b/example/config/auth.php @@ -81,10 +81,6 @@ | Resetting Passwords |-------------------------------------------------------------------------- | - | Here you may set the options for resetting passwords including the view - | 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. - | | 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. @@ -98,7 +94,6 @@ 'passwords' => [ 'users' => [ 'provider' => 'users', - 'email' => 'auth.emails.password', 'table' => 'password_resets', 'expire' => 60, ], diff --git a/example/config/cache.php b/example/config/cache.php index 3ffa840b..1d3de874 100644 --- a/example/config/cache.php +++ b/example/config/cache.php @@ -11,6 +11,8 @@ | using this caching library. This connection is used when another is | not explicitly specified when executing a given caching function. | + | Supported: "apc", "array", "database", "file", "memcached", "redis" + | */ 'default' => env('CACHE_DRIVER', 'file'), @@ -49,6 +51,14 @@ 'memcached' => [ 'driver' => 'memcached', + 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), + 'sasl' => [ + env('MEMCACHED_USERNAME'), + env('MEMCACHED_PASSWORD'), + ], + 'options' => [ + // Memcached::OPT_CONNECT_TIMEOUT => 2000, + ], 'servers' => [ [ 'host' => env('MEMCACHED_HOST', '127.0.0.1'), diff --git a/example/config/queue.php b/example/config/queue.php index d0f732a6..549322ed 100644 --- a/example/config/queue.php +++ b/example/config/queue.php @@ -11,7 +11,7 @@ | API, giving you convenient access to each back-end using the same | syntax for each one. Here you may set the default queue driver. | - | Supported: "null", "sync", "database", "beanstalkd", "sqs", "redis" + | Supported: "sync", "database", "beanstalkd", "sqs", "redis", "null" | */ @@ -38,14 +38,14 @@ 'driver' => 'database', 'table' => 'jobs', 'queue' => 'default', - 'expire' => 60, + 'retry_after' => 90, ], 'beanstalkd' => [ 'driver' => 'beanstalkd', 'host' => 'localhost', 'queue' => 'default', - 'ttr' => 60, + 'retry_after' => 90, ], 'sqs' => [ @@ -61,7 +61,7 @@ 'driver' => 'redis', 'connection' => 'default', 'queue' => 'default', - 'expire' => 60, + 'retry_after' => 90, ], ], diff --git a/example/config/services.php b/example/config/services.php index 287b1186..4460f0ec 100644 --- a/example/config/services.php +++ b/example/config/services.php @@ -8,7 +8,7 @@ |-------------------------------------------------------------------------- | | This file is for storing the credentials for third party services such - | as Stripe, Mailgun, Mandrill, and others. This file provides a sane + | as Stripe, Mailgun, SparkPost and others. This file provides a sane | default location for this type of information, allowing packages | to have a conventional place to find your various credentials. | diff --git a/example/config/session.php b/example/config/session.php index b501055b..e2779ad8 100644 --- a/example/config/session.php +++ b/example/config/session.php @@ -85,6 +85,19 @@ 'table' => 'sessions', + /* + |-------------------------------------------------------------------------- + | Session Cache Store + |-------------------------------------------------------------------------- + | + | When using the "apc" or "memcached" session drivers, you may specify a + | cache store that should be used for these sessions. This value must + | correspond with one of the application's configured cache stores. + | + */ + + 'store' => null, + /* |-------------------------------------------------------------------------- | Session Sweeping Lottery @@ -135,7 +148,7 @@ | */ - 'domain' => null, + 'domain' => env('SESSION_DOMAIN', null), /* |-------------------------------------------------------------------------- @@ -148,7 +161,7 @@ | */ - 'secure' => false, + 'secure' => env('SESSION_SECURE_COOKIE', false), /* |-------------------------------------------------------------------------- From c8ef5f61d33f9224e58a6431e6a9188e67ce7dca Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Wed, 5 Apr 2017 15:15:56 +0000 Subject: [PATCH 10/21] Shift Asset configuration --- example/gulpfile.js | 9 ++++++--- example/package.json | 10 ++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/example/gulpfile.js b/example/gulpfile.js index dc6f1ebb..442dd3fd 100644 --- a/example/gulpfile.js +++ b/example/gulpfile.js @@ -1,4 +1,6 @@ -var elixir = require('laravel-elixir'); +const elixir = require('laravel-elixir'); + +require('laravel-elixir-vue-2'); /* |-------------------------------------------------------------------------- @@ -11,6 +13,7 @@ var elixir = require('laravel-elixir'); | */ -elixir(function(mix) { - mix.sass('app.scss'); +elixir(mix => { + mix.sass('app.scss') + .webpack('app.js'); }); diff --git a/example/package.json b/example/package.json index c4a056b6..e9993aa8 100644 --- a/example/package.json +++ b/example/package.json @@ -5,8 +5,14 @@ "dev": "gulp watch" }, "devDependencies": { + "bootstrap-sass": "^3.3.7", "gulp": "^3.9.1", - "laravel-elixir": "^5.0.0", - "bootstrap-sass": "^3.0.0" + "jquery": "^3.1.0", + "laravel-elixir": "^6.0.0-9", + "laravel-elixir-vue-2": "^0.2.0", + "laravel-elixir-webpack-official": "^1.0.2", + "lodash": "^4.16.2", + "vue": "^2.0.1", + "vue-resource": "^1.0.3" } } From b565dd0ba45c40872908e66306c43a054abb536b Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Wed, 5 Apr 2017 15:16:01 +0000 Subject: [PATCH 11/21] Shift Laravel dependencies --- example/composer.json | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/example/composer.json b/example/composer.json index f30e7297..73b58a13 100644 --- a/example/composer.json +++ b/example/composer.json @@ -1,20 +1,23 @@ { "name": "laravel/laravel", "description": "The Laravel Framework.", - "keywords": ["framework", "laravel"], + "keywords": [ + "framework", + "laravel" + ], "license": "MIT", "type": "project", "require": { - "php": ">=5.5.9", - "laravel/framework": "5.2.*", + "php": ">=5.6.4", + "laravel/framework": "5.3.*", "bkwld/decoy": "*" }, "require-dev": { "fzaninotto/faker": "~1.4", "mockery/mockery": "0.9.*", - "phpunit/phpunit": "~4.0", - "symfony/css-selector": "2.8.*|3.0.*", - "symfony/dom-crawler": "2.8.*|3.0.*" + "phpunit/phpunit": "~5.0", + "symfony/css-selector": "3.1.*", + "symfony/dom-crawler": "3.1.*" }, "autoload": { "classmap": [ @@ -50,4 +53,4 @@ "config": { "preferred-install": "dist" } -} +} \ No newline at end of file From 4a921ddc84ba9d64d84de0116f2fc2c42cb42d4d Mon Sep 17 00:00:00 2001 From: Michael Starks Date: Wed, 5 Apr 2017 13:47:50 -0700 Subject: [PATCH 12/21] updating auth traits and routes --- classes/Controllers/Login.php | 7 +++---- classes/Routing/Router.php | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/classes/Controllers/Login.php b/classes/Controllers/Login.php index b8902f63..f127d911 100644 --- a/classes/Controllers/Login.php +++ b/classes/Controllers/Login.php @@ -5,7 +5,6 @@ use Auth; use Former; use Illuminate\Routing\Controller; -use Illuminate\Foundation\Auth\ThrottlesLogins; use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Foundation\Validation\ValidatesRequests; @@ -15,7 +14,7 @@ */ class Login extends Controller { - use AuthenticatesUsers, ThrottlesLogins, ValidatesRequests; + use AuthenticatesUsers, ValidatesRequests; /** * Use the guest middleware to redirect logged in admins away from the login @@ -25,7 +24,7 @@ class Login extends Controller */ public function __construct() { - $this->middleware('decoy.guest', ['except' => 'getLogout']); + $this->middleware('decoy.guest', ['except' => 'logout']); } /** @@ -55,7 +54,7 @@ public function showLoginForm() public function logout() { // Logout the session - Auth::guard($this->getGuard())->logout(); + Auth::logout(); // Redirect back to previous page so that switching users takes you back to // your previous page. diff --git a/classes/Routing/Router.php b/classes/Routing/Router.php index 6a79f022..e2de9ada 100644 --- a/classes/Routing/Router.php +++ b/classes/Routing/Router.php @@ -83,17 +83,17 @@ public function registerLogin() { Route::get('/', [ 'as' => 'decoy::account@login', - 'uses' => '\Bkwld\Decoy\Controllers\Login@getLogin', + 'uses' => '\Bkwld\Decoy\Controllers\Login@showLoginForm', ]); Route::post('/', [ 'as' => 'decoy::account@postLogin', - 'uses' => '\Bkwld\Decoy\Controllers\Login@postLogin', + 'uses' => '\Bkwld\Decoy\Controllers\Login@login', ]); Route::get('logout', [ 'as' => 'decoy::account@logout', - 'uses' => '\Bkwld\Decoy\Controllers\Login@getLogout', + 'uses' => '\Bkwld\Decoy\Controllers\Login@logout', ]); } From ffda1ec821b3a5bf9c081218ae8a3a5cad548bc6 Mon Sep 17 00:00:00 2001 From: Michael Starks Date: Wed, 5 Apr 2017 14:59:23 -0700 Subject: [PATCH 13/21] Lists have been changed to pluck --- classes/Controllers/Elements.php | 2 +- classes/Input/Localize.php | 2 +- classes/Models/Change.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/Controllers/Elements.php b/classes/Controllers/Elements.php index 5db5853b..33936d2a 100644 --- a/classes/Controllers/Elements.php +++ b/classes/Controllers/Elements.php @@ -58,7 +58,7 @@ public function index($locale = null, $tab = null) // If handling a deep link to a tab, verify that the passed tab // slug is a real key in the data. Else 404. - if ($tab && !in_array($tab, $elements->lists('page_label') + if ($tab && !in_array($tab, $elements->pluck('page_label') ->map(function ($title) { return Str::slug($title); }) diff --git a/classes/Input/Localize.php b/classes/Input/Localize.php index 66cae77e..6896e1ca 100644 --- a/classes/Input/Localize.php +++ b/classes/Input/Localize.php @@ -121,7 +121,7 @@ public function localizableLocales() Config::get('decoy.site.locales'), // ... the locales of other localizations ... - $this->other()->lists('locale')->flip()->toArray(), + $this->other()->pluck('locale')->flip()->toArray(), // ... and the model's locale [$this->item->locale => null] diff --git a/classes/Models/Change.php b/classes/Models/Change.php index 6f8532e3..0f115425 100644 --- a/classes/Models/Change.php +++ b/classes/Models/Change.php @@ -130,7 +130,7 @@ public static function log(Model $model, $action, Admin $admin = null) */ public static function getActions() { - return static::groupBy('action')->lists('action', 'action'); + return static::groupBy('action')->pluck('action', 'action'); } /** @@ -144,7 +144,7 @@ public static function getAdmins() return static::groupBy('admin_id') ->join('admins', 'admins.id', '=', 'admin_id') ->select(DB::raw('changes.id, CONCAT(first_name, " ", last_name) name')) - ->lists('name', 'id'); + ->pluck('name', 'id'); } /** From ec0c7fd62352c1bc5500520939c81c2e6275e05e Mon Sep 17 00:00:00 2001 From: Michael Starks Date: Wed, 5 Apr 2017 15:41:31 -0700 Subject: [PATCH 14/21] Removed deprecated getFiles --- classes/Observers/ValidateExistingFiles.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/Observers/ValidateExistingFiles.php b/classes/Observers/ValidateExistingFiles.php index 2faad0b9..1205ec70 100644 --- a/classes/Observers/ValidateExistingFiles.php +++ b/classes/Observers/ValidateExistingFiles.php @@ -38,13 +38,13 @@ public function onValidating($model, $validation) // For each of the file rules, if the input has a value, make a file // instance for it if it's a local path. - $files = $validation->getFiles(); $data = $validation->getData(); + foreach ($rules as $attribute => $rules) { // Skip if a file was uploaded for this attribtue or if the existing data // is undefined - if (isset($files[$attribute]) || empty($data[$attribute])) { + if (empty($data[$attribute]) || is_a($data[$attribute], File::class)) { continue; } @@ -55,6 +55,6 @@ public function onValidating($model, $validation) // Replace the files and data with the updated set. `setData()` expects the // data to contain files in it. But `getData()` strips out the files. Thus, // they need to be merged back in before being set. - $validation->setData(array_merge($files, $data)); + $validation->setData(array_merge($data)); } } From 3a7ca82e893276417ea1bf104972492d6c07e03e Mon Sep 17 00:00:00 2001 From: Michael Starks Date: Wed, 5 Apr 2017 15:41:53 -0700 Subject: [PATCH 15/21] The first function takes value first now --- classes/Models/Traits/HasImages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Models/Traits/HasImages.php b/classes/Models/Traits/HasImages.php index 7cd23af8..4204a6dd 100644 --- a/classes/Models/Traits/HasImages.php +++ b/classes/Models/Traits/HasImages.php @@ -58,7 +58,7 @@ public function images() */ public function img($name = null) { - return $this->images->first(function ($key, Image $image) use ($name) { + return $this->images->first(function (Image $image, $key) use ($name) { return $image->getAttribute('name') == $name; // When the $name isn't found, return an empty Image object so all the From 8c99ca231fc7de8559d197ce8f2d0daf3175d0be Mon Sep 17 00:00:00 2001 From: Michael Starks Date: Thu, 6 Apr 2017 10:45:00 -0700 Subject: [PATCH 16/21] Updating sluggable to 4.0 to fix lists() issue --- classes/Models/Base.php | 41 ++++++++++++++++++++----------------- classes/ServiceProvider.php | 2 +- composer.json | 8 ++++---- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/classes/Models/Base.php b/classes/Models/Base.php index 0a5ce473..2a18466b 100644 --- a/classes/Models/Base.php +++ b/classes/Models/Base.php @@ -14,14 +14,14 @@ use Bkwld\Upchuck\SupportsUploads; use Bkwld\Library\Utils\Collection; use Bkwld\Decoy\Exceptions\Exception; -use Cviebrock\EloquentSluggable\SluggableTrait; +use Cviebrock\EloquentSluggable\Sluggable; +use Cviebrock\EloquentSluggable\SluggableScopeHelpers; use Bkwld\Decoy\Collections\Base as BaseCollection; -use Cviebrock\EloquentSluggable\SluggableInterface; use Illuminate\Database\Eloquent\Model as Eloquent; use Illuminate\Database\Eloquent\ModelNotFoundException; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -abstract class Base extends Eloquent implements SluggableInterface +abstract class Base extends Eloquent { /** @@ -29,11 +29,11 @@ abstract class Base extends Eloquent implements SluggableInterface * negligible. */ use Cloneable, - SluggableTrait, + Sluggable, + SluggableScopeHelpers, SupportsUploads, - Traits\CanSerializeTransform { - needsSlugging as traitNeedsSlugging; - } + Traits\CanSerializeTransform + ; /** * Use the Decoy Base Collection @@ -195,12 +195,18 @@ public function changes() * Tell sluggable where to get the source for the slug and apply other * customizations. * - * @var array + * @return array */ - protected $sluggable = [ - 'build_from' => 'admin_title', - 'max_length' => 100, - ]; + public function sluggable() + { + if (!$this->needsSlugging()) return []; + return [ + 'slug' => [ + 'source' => 'admin_title', + 'maxLength' => 100, + ] + ]; + } /** * Check for a validation rule for a slug column @@ -209,11 +215,7 @@ public function changes() */ protected function needsSlugging() { - if (!array_key_exists('slug', static::$rules)) { - return false; - } - - return $this->traitNeedsSlugging(); + return array_key_exists('slug', static::$rules); } //--------------------------------------------------------------------------- @@ -636,12 +638,13 @@ public function scopeOtherLocalizations($query) * Find by the slug and fail if missing. Invokes methods from the * Sluggable trait. * - * @param string $string + * @param string $string + * @param array $columns * @return Illuminate\Database\Eloquent\Model * * @throws Illuminate\Database\Eloquent\ModelNotFoundException */ - public static function findBySlugOrFail($slug) + public static function findBySlugOrFail($slug, array $columns = ['*']) { // Model not found, throw exception if (!$item = static::findBySlug($slug)) { diff --git a/classes/ServiceProvider.php b/classes/ServiceProvider.php index 7fc5c60d..4ea142a5 100644 --- a/classes/ServiceProvider.php +++ b/classes/ServiceProvider.php @@ -341,7 +341,7 @@ private function registerPackages() $this->app->register('Bkwld\Upchuck\ServiceProvider'); // Creation of slugs - $this->app->register('Cviebrock\EloquentSluggable\SluggableServiceProvider'); + $this->app->register('Cviebrock\EloquentSluggable\ServiceProvider'); // Support for cloning models $this->app->register('Bkwld\Cloner\ServiceProvider'); diff --git a/composer.json b/composer.json index db44757c..ef19fefb 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "bkwld/laravel-haml": "~2.0", "bkwld/library": "~4.0", "bkwld/upchuck": "^2.0.1", - "cviebrock/eloquent-sluggable": "~3.0", + "cviebrock/eloquent-sluggable": "~4.0", "illuminate/support": "^5.0", "illuminate/console": "^5.0", "symfony/yaml": "~2.5 || ^3.0", @@ -41,12 +41,12 @@ "jenssegers/agent": "~2.1" }, "require-dev": { - "laravel/framework": "5.2.*", + "laravel/framework": "5.3.*", "fzaninotto/faker": "~1.4", "mockery/mockery": "0.9.*", "phpunit/phpunit": "~5.7", - "symfony/css-selector": "2.8.*|3.0.*", - "symfony/dom-crawler": "2.8.*|3.0.*", + "symfony/css-selector": "3.1.*", + "symfony/dom-crawler": "3.1.*", "doctrine/dbal": "^2.5", "satooshi/php-coveralls": "^1.0", "adlawson/vfs": "^0.12.1", From dff5bc0d7a4ec3ed438ace23b43bd64943e7ff22 Mon Sep 17 00:00:00 2001 From: Michael Starks Date: Thu, 6 Apr 2017 11:09:04 -0700 Subject: [PATCH 17/21] Using value, key for checking element images --- classes/Controllers/Elements.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Controllers/Elements.php b/classes/Controllers/Elements.php index 33936d2a..41987c6a 100644 --- a/classes/Controllers/Elements.php +++ b/classes/Controllers/Elements.php @@ -288,7 +288,7 @@ protected function storeImage(Element $el, $input) // Check for the image in the input. If isn't found, make no changes. $name = $el->inputName(); if (!$data = array_first($input['images'], - function ($id, $data) use ($name) { + function ($data, $id) use ($name) { return $data['name'] == $name; })) { return; From c78031cbe962dae007f5d2f71cf87d845407d408 Mon Sep 17 00:00:00 2001 From: Michael Starks Date: Thu, 6 Apr 2017 11:50:51 -0700 Subject: [PATCH 18/21] Allow file validator to pass when deleting a file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Laravel 5.3’s file validator required a file to be present but it won’t be when deleting a file. Creating an empty File instance to satisfy the validator --- classes/Observers/ValidateExistingFiles.php | 37 +++++++++++++++++---- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/classes/Observers/ValidateExistingFiles.php b/classes/Observers/ValidateExistingFiles.php index 1205ec70..a8ca957a 100644 --- a/classes/Observers/ValidateExistingFiles.php +++ b/classes/Observers/ValidateExistingFiles.php @@ -39,17 +39,28 @@ public function onValidating($model, $validation) // For each of the file rules, if the input has a value, make a file // instance for it if it's a local path. $data = $validation->getData(); - foreach ($rules as $attribute => $rules) { - // Skip if a file was uploaded for this attribtue or if the existing data - // is undefined - if (empty($data[$attribute]) || is_a($data[$attribute], File::class)) { + // Test that the attribute is in the data. It may not be for images + // attributes or other nested models + if (!array_key_exists($attribute, $data)) { + continue; + + // Skip if a file was uploaded for this attribtue + } else if (is_a($data[$attribute], File::class)) { continue; - } + + // If the value is empty, because the user is deleting the file + // instance, make an empty File instance that will pass the file + // check but fail required checks + } else if (empty($data[$attribute])) { + $data[$attribute] = new File('', false); // Create the file instance and clear the data instance - $data[$attribute] = new File(Config::get('upchuck.disk.path').'/'.app('upchuck')->path($data[$attribute])); + } else { + $data[$attribute] = $this->makeFileFromPath($data[$attribute]); + } + } // Replace the files and data with the updated set. `setData()` expects the @@ -57,4 +68,18 @@ public function onValidating($model, $validation) // they need to be merged back in before being set. $validation->setData(array_merge($data)); } + + /** + * Make a file instance using uphuck from the string input value + * + * @param string $path + * @return File + */ + public function makeFileFromPath($path) + { + $upchuck_path = app('upchuck')->path($path); + $absolute_path = Config::get('upchuck.disk.path').'/'.$upchuck_path; + return new File($absolute_path); + + } } From c9655553e20827c68d81709e47a9b250def3838d Mon Sep 17 00:00:00 2001 From: Michael Starks Date: Thu, 6 Apr 2017 15:10:46 -0700 Subject: [PATCH 19/21] Upgrading reset password flow for 5.3 --- classes/Controllers/ForgotPassword.php | 42 +++++++++++++++++++++++++ classes/Controllers/ResetPassword.php | 37 +--------------------- classes/Models/Admin.php | 16 +++++++++- classes/Notifications/ResetPassword.php | 36 +++++++++++++++++++++ classes/Routing/Router.php | 12 +++---- 5 files changed, 100 insertions(+), 43 deletions(-) create mode 100644 classes/Controllers/ForgotPassword.php create mode 100644 classes/Notifications/ResetPassword.php diff --git a/classes/Controllers/ForgotPassword.php b/classes/Controllers/ForgotPassword.php new file mode 100644 index 00000000..61a87974 --- /dev/null +++ b/classes/Controllers/ForgotPassword.php @@ -0,0 +1,42 @@ + 'required|email', + ]); + + // Set the breadcrumbs + app('decoy.breadcrumbs')->set([ + route('decoy::account@login') => 'Login', + url()->current() => 'Forgot Password', + ]); + + // Show the page + $this->title = 'Forgot Password'; + $this->description = 'You know the drill.'; + + return $this->populateView('decoy::account.forgot'); + } +} diff --git a/classes/Controllers/ResetPassword.php b/classes/Controllers/ResetPassword.php index 4c85451e..701eb58a 100644 --- a/classes/Controllers/ResetPassword.php +++ b/classes/Controllers/ResetPassword.php @@ -18,41 +18,6 @@ class ResetPassword extends Base { use ResetsPasswords; - /** - * Display the form to request a password reset link. - * - * @return \Illuminate\Http\Response - */ - public function showLinkRequestForm() - { - // Pass validation rules - Former::withRules([ - 'email' => 'required|email', - ]); - - // Set the breadcrumbs - app('decoy.breadcrumbs')->set([ - route('decoy::account@login') => 'Login', - url()->current() => 'Forgot Password', - ]); - - // Show the page - $this->title = 'Forgot Password'; - $this->description = 'You know the drill.'; - - return $this->populateView('decoy::account.forgot'); - } - - /** - * Get the e-mail subject line to be used for the reset link email. - * - * @return string - */ - protected function getEmailSubject() - { - return 'Recover access to '.Decoy::site(); - } - /** * Display the password reset view for the given token. * @@ -120,6 +85,6 @@ protected function resetPassword($user, $password) 'remember_token' => Str::random(60), ])->save(); - Auth::guard($this->getGuard())->login($user); + Auth::login($user); } } diff --git a/classes/Models/Admin.php b/classes/Models/Admin.php index b68f5480..570179e4 100644 --- a/classes/Models/Admin.php +++ b/classes/Models/Admin.php @@ -12,11 +12,13 @@ use DecoyURL; use Bkwld\Library\Utils\Text; use Bkwld\Decoy\Auth\AuthInterface; +use Bkwld\Decoy\Notifications\ResetPassword; use Illuminate\Auth\Authenticatable; use Illuminate\Contracts\Auth\Access\Gate; use Illuminate\Auth\Passwords\CanResetPassword; use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; +use Illuminate\Notifications\Notifiable; class Admin extends Base implements AuthInterface, @@ -25,7 +27,7 @@ class Admin extends Base implements { // Note, not using the Authorizable trait because I've defined my own versions // for backwards compatability with Decoy 4 and also to have a tigher syntax. - use Authenticatable, CanResetPassword, Traits\HasImages; + use Authenticatable, CanResetPassword, Traits\HasImages, Notifiable; /** * The table associated with the model. Explicitly declaring so that sub @@ -248,6 +250,18 @@ public function cannot($action, $controller) return $this->cant($action, $controller); } + /** + * Send the password reset notification. This overrides a method inheritted + * from the CanResetPassword trait + * + * @param string $token + * @return void + */ + public function sendPasswordResetNotification($token) + { + $this->notify(new ResetPassword($token)); + } + /** * A shorthand for getting the admin name as a string * diff --git a/classes/Notifications/ResetPassword.php b/classes/Notifications/ResetPassword.php new file mode 100644 index 00000000..2589eb7b --- /dev/null +++ b/classes/Notifications/ResetPassword.php @@ -0,0 +1,36 @@ +token); + + // Send the message + return (new MailMessage) + ->subject('Recover access to '.Decoy::site()) + ->line('You are receiving this email because we received a password reset request for your account.') + ->action('Reset Password', $url) + ->line('If you did not request a password reset, no further action is required.'); + } + +} diff --git a/classes/Routing/Router.php b/classes/Routing/Router.php index e2de9ada..6307d90d 100644 --- a/classes/Routing/Router.php +++ b/classes/Routing/Router.php @@ -105,19 +105,19 @@ public function registerLogin() public function registerResetPassword() { Route::get('forgot', ['as' => 'decoy::account@forgot', - 'uses' => '\Bkwld\Decoy\Controllers\ResetPassword@getEmail', + 'uses' => '\Bkwld\Decoy\Controllers\ForgotPassword@showLinkRequestForm', ]); Route::post('forgot', ['as' => 'decoy::account@postForgot', - 'uses' => '\Bkwld\Decoy\Controllers\ResetPassword@postEmail', + 'uses' => '\Bkwld\Decoy\Controllers\ForgotPassword@sendResetLinkEmail', ]); - Route::get('reset/{code}', ['as' => 'decoy::account@reset', - 'uses' => '\Bkwld\Decoy\Controllers\ResetPassword@getReset', + Route::get('password/reset/{code}', ['as' => 'decoy::account@reset', + 'uses' => '\Bkwld\Decoy\Controllers\ResetPassword@showResetForm', ]); - Route::post('reset/{code}', ['as' => 'decoy::account@postReset', - 'uses' => '\Bkwld\Decoy\Controllers\ResetPassword@postReset', + Route::post('password/reset/{code}', ['as' => 'decoy::account@postReset', + 'uses' => '\Bkwld\Decoy\Controllers\ResetPassword@reset', ]); } From 7612030722da5227554b1893df8e365cc6a91340 Mon Sep 17 00:00:00 2001 From: Michael Starks Date: Thu, 6 Apr 2017 15:11:03 -0700 Subject: [PATCH 20/21] Adding a redirect assertion to FileTest --- tests/Integration/FileTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Integration/FileTest.php b/tests/Integration/FileTest.php index ad3e2955..9dcd000c 100644 --- a/tests/Integration/FileTest.php +++ b/tests/Integration/FileTest.php @@ -91,6 +91,7 @@ public function testImageUploadStore() '_save' => 'save', ]), [], $files); + $this->assertResponseStatus(302); $article = Article::findBySlug('example-title'); $this->assertNotEmpty($article->img()->url); } From 9d15c7f8054d6f22689db39132a2d480537d78ee Mon Sep 17 00:00:00 2001 From: Michael Starks Date: Thu, 6 Apr 2017 15:11:20 -0700 Subject: [PATCH 21/21] Adjusted the url for AdminTest with new password reset flow --- tests/Integration/AdminTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Integration/AdminTest.php b/tests/Integration/AdminTest.php index 05359e83..faa6fb60 100644 --- a/tests/Integration/AdminTest.php +++ b/tests/Integration/AdminTest.php @@ -109,7 +109,7 @@ public function testResetPasswordFormIndex() 'created_at' => Carbon::now(), ]); - $response = $this->get('admin/reset/'.$token); + $response = $this->get('admin/password/reset/'.$token); $this->assertResponseOk(); } @@ -129,7 +129,7 @@ public function testResetPasswordFormSave() 'created_at' => Carbon::now(), ]); - $response = $this->post('admin/reset/'.$token, [ + $response = $this->post('admin/password/reset/'.$token, [ 'email' => 'test@domain.com', 'password' => 'farting', 'password_confirmation' => 'farting',