Skip to content

Commit

Permalink
Merge branch 'laravel-5.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
brokenhd committed Apr 10, 2017
2 parents 53b9a04 + 1186dfb commit e1bf943
Show file tree
Hide file tree
Showing 48 changed files with 312 additions and 304 deletions.
6 changes: 0 additions & 6 deletions classes/Controllers/ResetPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ public function showResetForm(Request $request, $token = null)
'password_confirmation' => 'required|same:password',
]);

// Lookup the admin
$user = Admin::where('token', $token)
->join('password_resets', 'password_resets.email', '=', 'admins.email')
->firstOrFail();

// Set the breadcrumbs
app('decoy.breadcrumbs')->set([
route('decoy::account@login') => 'Login',
Expand All @@ -53,7 +48,6 @@ public function showResetForm(Request $request, $token = null)
$this->description = 'Almost done.';

return $this->populateView('decoy::account.reset', [
'user' => $user,
'token' => $token,
]);
}
Expand Down
4 changes: 2 additions & 2 deletions classes/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public function handling()

/**
* Force Decoy to believe that it's handling or not handling the request
*
*
* @param boolean $bool
* @return void
*/
Expand All @@ -254,7 +254,7 @@ public function locale($locale = null)
&& ($locales = Config::get('decoy.site.locales'))
&& is_array($locales)
&& isset($locales[$locale])) {
return Session::set('locale', $locale);
return Session::put('locale', $locale);
}

// Return the current locale or default to first one. Store it in a local var
Expand Down
2 changes: 1 addition & 1 deletion classes/Models/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected static function boot()
return false;
}
$image->populateFileMeta();
}, config('upchuck.priority', 0) + 1);
});

// If the image is deleted, delete Croppa crops
static::updating(function (Image $image) {
Expand Down
10 changes: 7 additions & 3 deletions classes/Observers/Changes.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ class Changes
/**
* Handle all Eloquent model events
*
* @param Bkwld\Decoy\Models\Base $model
* @param string $event
* @param array $payload Contains:
* - Bkwld\Decoy\Models\Base $model
*/
public function handle($model)
public function handle($event, $payload)
{
list($model) = $payload;

// Don't log the Change model events
if (is_a($model, Models\Change::class)) {
return;
Expand Down Expand Up @@ -57,7 +61,7 @@ public function handle($model)
}

// Get the action of the event
preg_match('#eloquent\.(\w+)#', Event::firing(), $matches);
preg_match('#eloquent\.(\w+)#', $event, $matches);
$action = $matches[1];
if (!in_array($action, $this->supported)) {
return;
Expand Down
11 changes: 8 additions & 3 deletions classes/Observers/Encoding.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ class Encoding
/**
* Start a new encode if a new encodable file was uploaded
*
* @param Bkwld\Decoy\Models\Base $model
* @param string $event
* @param array $payload Contains:
* - Bkwld\Decoy\Models\Base $model
* @return void
*/
public function onSaving($model)
public function onSaving($event, $payload)
{
list($model) = $payload;

if (!$this->isEncodable($model)) {
return;
}
Expand All @@ -36,10 +40,11 @@ public function onSaving($model)
/**
* Delete all encodes on the model
*
* @param string $event
* @param Bkwld\Decoy\Models\Base $model
* @return void
*/
public function onDeleted($model)
public function onDeleted($event, $model)
{
if (!$this->isEncodable($model)) {
return;
Expand Down
9 changes: 7 additions & 2 deletions classes/Observers/Localize.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ class Localize
/**
* Called on model saving
*
* @param Bkwld\Decoy\Models\Base $model
* @param string $event
* @param array $payload Contains:
* - Bkwld\Decoy\Models\Base $model
* @return void
*/
public function handle($model)
public function handle($event, $payload)
{
list($model) = $payload;

if (!empty($model->locale)
&& empty($model->locale_group)
&& !is_a($model, Element::class) // Elements don't have groups
Expand Down
9 changes: 7 additions & 2 deletions classes/Observers/ManyToManyChecklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ class ManyToManyChecklist
* Take input from a Many to Many Checklist and commit it to the db. Called
* on model saved.
*
* @param Bkwld\Decoy\Models\Base $model
* @param string $event
* @param array $payload Contains:
* - Bkwld\Decoy\Models\Base $model
* @return void
*/
public function handle($model)
public function handle($event, $payload)
{
list($model) = $payload;

// Check for matching input elements
foreach (Request::input() as $key => $val) {
if (preg_match('#^'.self::PREFIX.'(.+)#', $key, $matches)) {
Expand Down
14 changes: 7 additions & 7 deletions classes/Observers/ModelCallbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ class ModelCallbacks
/**
* Handle all model events, both Eloquent and Decoy
*
* @param Bkwld\Decoy\Models\Base $model
* @param string $event
* @param array $payload Contains:
* - Bkwld\Decoy\Models\Base $model
* @return void
*/
public function handle($model)
public function handle($event, $payload)
{
// Get the name of the event. Examples:
// - eloquent.saving: Person
// - decoy::model.validating: Person
$event = Event::firing();
list($model) = $payload;

// Get the action from the event name
preg_match('#\.(\w+)#', $event, $matches);
Expand All @@ -31,7 +31,7 @@ public function handle($model)
// any additional event arguments to it
$method = 'on'.Str::studly($action);
if (method_exists($model, $method)) {
return call_user_func_array([$model, $method], array_slice(func_get_args(), 1));
return call_user_func_array([$model, $method], array_slice($payload, 1));
}
}
}
17 changes: 11 additions & 6 deletions classes/Observers/ValidateExistingFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Bkwld\Decoy\Observers;

use Config;
// Deps
use Symfony\Component\HttpFoundation\File\File;

/**
Expand All @@ -15,14 +15,19 @@ class ValidateExistingFiles
/**
* Massage validation handling
*
* @param Bkwld\Decoy\Models\Base $model
* @param Illuminate\Validation\Validator $validation
* @param string $event
* @param array $payload Contains:
* - Bkwld\Decoy\Models\Base
* - Illuminate\Validation\Validator
* @return void
*/
public function onValidating($model, $validation)
public function onValidating($event, $payload)
{
// Destructure payload
list($model, $validation) = $payload;

// Only act on locally hosted files
if (Config::get('upchuck.disk.driver') != 'local') {
if (config('upchuck.disk.driver') != 'local') {
return;
}

Expand Down Expand Up @@ -78,7 +83,7 @@ public function onValidating($model, $validation)
public function makeFileFromPath($path)
{
$upchuck_path = app('upchuck')->path($path);
$absolute_path = Config::get('upchuck.disk.path').'/'.$upchuck_path;
$absolute_path = config('upchuck.disk.path').'/'.$upchuck_path;
return new File($absolute_path);

}
Expand Down
3 changes: 2 additions & 1 deletion classes/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,15 @@ protected function delegateAdminObservers()
*/
protected function registerMiddlewares()
{

// Register middleware individually
foreach ([
'decoy.auth' => Middleware\Auth::class,
'decoy.edit-redirect' => Middleware\EditRedirect::class,
'decoy.guest' => Middleware\Guest::class,
'decoy.save-redirect' => Middleware\SaveRedirect::class,
] as $key => $class) {
$this->app['router']->middleware($key, $class);
$this->app['router']->aliasMiddleware($key, $class);
}

// This group is used by public decoy routes
Expand Down
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
],
"require": {
"php": ">=5.4.0",
"weotch/former": "^4.0.7",
"weotch/former": "^4.1.0",
"anahkiasen/html-object": "~1.3",
"bkwld/cloner": "^3.2.2",
"bkwld/croppa": "~4.0",
"bkwld/laravel-haml": "~2.0",
"bkwld/library": "~4.0",
"bkwld/upchuck": "^2.0.1",
"bkwld/upchuck": "^2.1.0",
"cviebrock/eloquent-sluggable": "~4.0",
"illuminate/support": "^5.0",
"illuminate/console": "^5.0",
Expand All @@ -41,7 +41,7 @@
"jenssegers/agent": "~2.1"
},
"require-dev": {
"laravel/framework": "5.3.*",
"laravel/framework": "5.4.*",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.7",
Expand All @@ -51,10 +51,12 @@
"satooshi/php-coveralls": "^1.0",
"adlawson/vfs": "^0.12.1",
"league/flysystem": "^1.0",
"league/flysystem-vfs": "^1.0"
"league/flysystem-vfs": "^1.0",
"laravel/tinker": "^1.0"
},
"conflict": {
"anahkiasen/html-object": "1.4.1"
"anahkiasen/html-object": "1.4.1",
"laravel/framework": "<5.4.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 0 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ Next, see the [quick start](quick-start) for tips on your first install.

## Compatibility

Decoy *currently* only works with **Laravel 5.0 - 5.2**.

Decoy is tested to support the following browsers:

- Latest Chrome (recommended)
Expand Down
4 changes: 2 additions & 2 deletions example/app/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ class Article extends Base
*/
public function tags()
{
return $this->morphToMany('App\Tag', 'taggable');
return $this->morphToMany(\App\Tag::class, 'taggable');
}

public function slides()
{
return $this->hasMany('App\Slide');
return $this->hasMany(\App\Slide::class);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions example/app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class Kernel extends HttpKernel
*/
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
];

/**
Expand All @@ -27,6 +30,7 @@ class Kernel extends HttpKernel
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
Expand Down
18 changes: 18 additions & 0 deletions example/app/Http/Middleware/TrimStrings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\TrimStrings as BaseTrimmer;

class TrimStrings extends BaseTrimmer
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array
*/
protected $except = [
'password',
'password_confirmation',
];
}
7 changes: 1 addition & 6 deletions example/app/Providers/BroadcastServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ public function boot()
{
Broadcast::routes();

/*
* Authenticate the user's personal channel...
*/
Broadcast::channel('App.User.*', function ($user, $userId) {
return (int) $user->id === (int) $userId;
});
require base_path('routes/channels.php');
}
}
20 changes: 7 additions & 13 deletions example/app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,9 @@ public function map()
*/
protected function mapWebRoutes()
{
Route::group([
'middleware' => 'web',
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/web.php');
});
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}

/**
Expand All @@ -68,12 +65,9 @@ protected function mapWebRoutes()
*/
protected function mapApiRoutes()
{
Route::group([
'middleware' => 'api',
'namespace' => $this->namespace,
'prefix' => 'api',
], function ($router) {
require base_path('routes/api.php');
});
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
}
2 changes: 1 addition & 1 deletion example/app/Slide.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ class Slide extends Base
*/
public function article()
{
return $this->belongsTo('App\Article');
return $this->belongsTo(\App\Article::class);
}
}
2 changes: 1 addition & 1 deletion example/app/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Tag extends Base
*/
public function articles()
{
return $this->morphedByMany('App\Article', 'taggable');
return $this->morphedByMany(\App\Article::class, 'taggable');
}

/**
Expand Down
Loading

0 comments on commit e1bf943

Please sign in to comment.