Skip to content

Commit

Permalink
Merge branch '5.11.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
weotch committed Jul 13, 2018
2 parents c6b963d + 7b163a2 commit 7a4acfa
Show file tree
Hide file tree
Showing 23 changed files with 162 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: php

php:
- 7.0.15
- 7.1
- 7.2

install:
- composer install
Expand Down
6 changes: 4 additions & 2 deletions classes/Models/Change.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function shouldLogChange($action)
public static function log(Model $model, $action, Admin $admin = null)
{
// Create a new change instance
if (static::shouldWriteChange($model)) {
if (static::shouldWriteChange($model, $action)) {
$changed = static::getChanged($model, $action);
$change = static::createLog($model, $action, $admin, $changed);
}
Expand Down Expand Up @@ -125,10 +125,12 @@ public static function log(Model $model, $action, Admin $admin = null)
* besides these that changed.
*
* @param Model $model The model being touched
* @param string $action
* @return boolean
*/
static private function shouldWriteChange(Model $model)
static private function shouldWriteChange(Model $model, $action)
{
if (in_array($action, ['created', 'deleted'])) return true;
$changed_attributes = array_keys($model->getDirty());
$ignored = ['updated_at', 'public'];
$loggable = array_diff($changed_attributes, $ignored);
Expand Down
1 change: 0 additions & 1 deletion classes/Models/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public static function all()
$commands['Laravel']['Seed'] = App::make('command.seed');
$commands['Laravel']['Cache clear'] = App::make('command.cache.clear');
$commands['Laravel']['Clear compiled classes'] = App::make('command.clear-compiled');
$commands['Laravel']['Optimize classes'] = App::make('command.optimize');

// Return matching commands
return $commands;
Expand Down
28 changes: 4 additions & 24 deletions classes/Models/Traits/Loggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Bkwld\Decoy\Models\Image;
use Decoy;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

/**
* Enable logging changes to models
Expand Down Expand Up @@ -48,7 +49,8 @@ public function changes()
*/
public static function bootLoggable()
{
// Automatically eager load the images relationship
// Add scope that will fetch trashed versions of models when the
// Change::QUERY_KEY is present.
static::addGlobalScope(static::$LOGGABLE_SCOPE, function (Builder $builder) {
static::showTrashedVersion($builder);
});
Expand Down Expand Up @@ -83,7 +85,7 @@ private static function showTrashedVersion(Builder $builder)
{
if (($change = static::lookupRequestedChange())
&& static::builderMatchesChange($change, $builder)) {
static::includeTrashed($change, $builder);
$builder->withoutGlobalScope(SoftDeletingScope::class);
}
}

Expand Down Expand Up @@ -149,28 +151,6 @@ private static function builderMatchesChange(Change $change, Builder $builder)
});
}

/**
* Manually remove already added soft deleted where conditions. This is
* necessary since withTrashed() can't be called on a Builder.
* http://yo.bkwld.com/1K04151B2h3M
*
* @param Change $change
* @param Builder $builder
* @return void
*/
private static function includeTrashed(Change $change, Builder $builder)
{
$class = $change->model;
$table = (new $class)->getTable();
foreach($builder->getQuery()->wheres as $key => $where) {
if ($where['column'] == $table.'.deleted_at'
&& $where['type'] == 'Null') {
unset($builder->getQuery()->wheres[$key]);
break;
}
}
}

/**
* Replace all the attributes with those from the specified Change specified
* in the reqeust query.
Expand Down
10 changes: 7 additions & 3 deletions classes/Observers/ValidateExistingFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

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

/**
* When a form is updated (as opposed to created) the previous files are
Expand Down Expand Up @@ -77,16 +78,19 @@ public function onValidating($event, $payload)
}

/**
* Make a file instance using uphuck from the string input value
* Make an UploadedFile instance using Upchuck from the string input value
*
* @param string $path
* @return File
* @return UploadedFile
*/
public function makeFileFromPath($path)
{
$upchuck_path = app('upchuck')->path($path);
$absolute_path = config('upchuck.disk.path').'/'.$upchuck_path;
return new File($absolute_path);
return new UploadedFile(
$absolute_path, basename($absolute_path),
null, null, // Default mime and error
true); // Enable test mode so local file will be pass as uploaded
}

}
6 changes: 6 additions & 0 deletions classes/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Foundation\AliasLoader;
use Illuminate\Contracts\Auth\Access\Gate;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;

class ServiceProvider extends BaseServiceProvider
Expand Down Expand Up @@ -121,6 +122,11 @@ public function usingAdmin()

// Delegate events to Decoy observers
$this->delegateAdminObservers();

// Use Boostrap 3 classes in Laravel 5.6
if (method_exists(Paginator::class, 'useBootstrapThree')) {
Paginator::useBootstrapThree();
}
}

/**
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,26 @@
"cviebrock/eloquent-sluggable": "~4.0",
"illuminate/support": "^5.0",
"illuminate/console": "^5.0",
"symfony/yaml": "~2.5 || ^3.0",
"symfony/yaml": "~2.5 || ^3.0 || ^4.0",
"zencoder/zencoder-php": "~2.2",
"jenssegers/agent": "~2.1",
"league/csv": "^9.1",
"doctrine/dbal": "^2.5"
},
"require-dev": {
"laravel/framework": "5.4.*|5.5.*",
"laravel/framework": "5.4.* || 5.5.* || 5.6.*",
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~6.0",
"symfony/css-selector": "3.1.*",
"symfony/dom-crawler": "3.1.*",
"satooshi/php-coveralls": "^1.0",
"phpunit/phpunit": "~6.0 || ~7.0",
"symfony/css-selector": "3.1.* || ^4.0",
"symfony/dom-crawler": "3.1.* || ^4.0",
"php-coveralls/php-coveralls": "^1.0 || ^2.0",
"adlawson/vfs": "^0.12.1",
"league/flysystem": "^1.0",
"league/flysystem-vfs": "^1.0",
"laravel/tinker": "^1.0",
"fideloper/proxy": "~3.3"
"fideloper/proxy": "~3.3 || ^4.0"
},
"conflict": {
"anahkiasen/html-object": "1.4.1",
Expand Down
8 changes: 7 additions & 1 deletion example/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
Expand All @@ -15,6 +16,7 @@ DB_PASSWORD=secret
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
Expand All @@ -31,3 +33,7 @@ MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
3 changes: 2 additions & 1 deletion example/app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;

Expand Down Expand Up @@ -50,7 +51,7 @@ protected function validator(array $data)
return Validator::make($data, [
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
'password' => Hash::make($data['password']),
]);
}

Expand Down
2 changes: 2 additions & 0 deletions example/app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ class Kernel extends HttpKernel
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
];
}
12 changes: 3 additions & 9 deletions example/app/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,9 @@ class TrustProxies extends Middleware
protected $proxies;

/**
* The current proxy header mappings.
* The headers that should be used to detect proxies.
*
* @var array
* @var int
*/
protected $headers = [
Request::HEADER_FORWARDED => 'FORWARDED',
Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR',
Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST',
Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
];
protected $headers = Request::HEADER_X_FORWARDED_ALL;
}
14 changes: 8 additions & 6 deletions example/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
"type": "project",
"require": {
"php": ">=7.0.0",
"fideloper/proxy": "~3.3",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"bkwld/decoy": "5.10.x-dev"
"fideloper/proxy": "~3.3 || ^4.0",
"laravel/framework": "5.5.* || 5.6.*",
"laravel/tinker": "^1.0",
"bkwld/decoy": "5.11.x-dev"
},
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~6.0"
"phpunit/phpunit": "~6.0 || ~7.0"
},
"autoload": {
"classmap": [
Expand Down Expand Up @@ -61,5 +61,7 @@
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
17 changes: 0 additions & 17 deletions example/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,6 @@

'cipher' => 'AES-256-CBC',

/*
|--------------------------------------------------------------------------
| Logging Configuration
|--------------------------------------------------------------------------
|
| Here you may configure the log settings for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Settings: "single", "daily", "syslog", "errorlog"
|
*/

'log' => env('APP_LOG', 'single'),

'log_level' => env('APP_LOG_LEVEL', 'debug'),

/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
Expand Down
3 changes: 2 additions & 1 deletion example/config/filesystems.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
| may even configure multiple disks of the same driver. Defaults have
| been setup for each driver as an example of the required options.
|
| Supported Drivers: "local", "ftp", "s3", "rackspace"
| Supported Drivers: "local", "ftp", "sftp", "s3", "rackspace"
|
*/

Expand All @@ -61,6 +61,7 @@
'secret' => env('AWS_SECRET'),
'region' => env('AWS_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
],

],
Expand Down
20 changes: 20 additions & 0 deletions example/config/hashing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Default Hash Driver
|--------------------------------------------------------------------------
|
| This option controls the default hash driver that will be used to hash
| passwords for your application. By default, the bcrypt algorithm is
| used; however, you remain free to modify this option if you wish.
|
| Supported: "bcrypt", "argon"
|
*/

'driver' => 'bcrypt',

];
Loading

0 comments on commit 7a4acfa

Please sign in to comment.