package updates

This commit is contained in:
2018-12-19 23:27:43 -06:00
parent aa1da4d4fb
commit 1ffd21369f
1181 changed files with 51194 additions and 11046 deletions

View File

@@ -21,6 +21,8 @@
"doctrine/inflector": "^1.1",
"dragonmantank/cron-expression": "^2.0",
"erusev/parsedown": "^1.7",
"laravel/nexmo-notification-channel": "^1.0",
"laravel/slack-notification-channel": "^1.0",
"league/flysystem": "^1.0.8",
"monolog/monolog": "^1.12",
"nesbot/carbon": "^1.26.3",
@@ -77,6 +79,7 @@
"aws/aws-sdk-php": "^3.0",
"doctrine/dbal": "^2.6",
"filp/whoops": "^2.1.4",
"guzzlehttp/guzzle": "^6.3",
"league/flysystem-cached-adapter": "^1.0",
"mockery/mockery": "^1.0",
"moontoast/math": "^1.1",
@@ -115,6 +118,7 @@
"ext-posix": "Required to use all features of the queue worker.",
"aws/aws-sdk-php": "Required to use the SQS queue driver and SES mail driver (^3.0).",
"doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.6).",
"filp/whoops": "Required for friendly error pages in development (^2.1.4).",
"fzaninotto/faker": "Required to use the eloquent factory builder (^1.4).",
"guzzlehttp/guzzle": "Required to use the Mailgun and Mandrill mail drivers and the ping methods on schedules (^6.0).",
"laravel/tinker": "Required to use the tinker console command (^1.0).",

View File

@@ -385,7 +385,6 @@ class Gate implements GateContract
* Determine if the callback allows guests.
*
* @param callable $callback
* @param array $arguments
* @return bool
*/
protected function callbackAllowsGuests($callback)
@@ -452,7 +451,7 @@ class Gate implements GateContract
* @param string $ability
* @param array $arguments
* @param bool $result
* @return void
* @return bool|null
*/
protected function callAfterCallbacks($user, $ability, array $arguments, $result)
{

View File

@@ -19,7 +19,7 @@ class HomeController extends Controller
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index()
{

View File

@@ -12,7 +12,7 @@
@csrf
<div class="form-group row">
<label for="email" class="col-sm-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required autofocus>
@@ -57,9 +57,11 @@
{{ __('Login') }}
</button>
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}
</a>
@if (Route::has('password.request'))
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}
</a>
@endif
</div>
</div>
</form>

View File

@@ -13,7 +13,7 @@
<script src="{{ asset('js/app.js') }}" defer></script>
<!-- Fonts -->
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
<link rel="dns-prefetch" href="//fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet" type="text/css">
<!-- Styles -->
@@ -43,11 +43,11 @@
<li class="nav-item">
<a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
</li>
<li class="nav-item">
@if (Route::has('register'))
@if (Route::has('register'))
<li class="nav-item">
<a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
@endif
</li>
</li>
@endif
@else
<li class="nav-item dropdown">
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>

View File

@@ -146,7 +146,7 @@ class PasswordBroker implements PasswordBrokerContract
public function validateNewPassword(array $credentials)
{
if (isset($this->passwordValidator)) {
list($password, $confirm) = [
[$password, $confirm] = [
$credentials['password'],
$credentials['password_confirmation'],
];
@@ -167,7 +167,7 @@ class PasswordBroker implements PasswordBrokerContract
*/
protected function validatePasswordWithDefaults(array $credentials)
{
list($password, $confirm) = [
[$password, $confirm] = [
$credentials['password'],
$credentials['password_confirmation'],
];

View File

@@ -83,6 +83,6 @@ class Recaller
{
$segments = explode('|', $this->recaller);
return count($segments) == 3 && trim($segments[0]) !== '' && trim($segments[1]) !== '';
return count($segments) === 3 && trim($segments[0]) !== '' && trim($segments[1]) !== '';
}
}

View File

@@ -62,7 +62,7 @@ class CacheManager implements FactoryContract
* Get a cache driver instance.
*
* @param string|null $driver
* @return mixed
* @return \Illuminate\Contracts\Cache\Repository
*/
public function driver($driver = null)
{
@@ -278,6 +278,25 @@ class CacheManager implements FactoryContract
$this->app['config']['cache.default'] = $name;
}
/**
* Unset the given driver instances.
*
* @param array|string|null $name
* @return $this
*/
public function forgetDriver($name = null)
{
$name = $name ?? $this->getDefaultDriver();
foreach ((array) $name as $cacheName) {
if (isset($this->stores[$cacheName])) {
unset($this->stores[$cacheName]);
}
}
return $this;
}
/**
* Register a custom driver creator Closure.
*

View File

@@ -60,7 +60,7 @@ class ClearCommand extends Command
*/
public function handle()
{
$this->laravel['events']->fire(
$this->laravel['events']->dispatch(
'cache:clearing', [$this->argument('store'), $this->tags()]
);
@@ -72,7 +72,7 @@ class ClearCommand extends Command
return $this->error('Failed to clear cache. Make sure you have the appropriate permissions.');
}
$this->laravel['events']->fire(
$this->laravel['events']->dispatch(
'cache:cleared', [$this->argument('store'), $this->tags()]
);

View File

@@ -78,7 +78,7 @@ class MemcachedConnector
*/
protected function setCredentials($memcached, $credentials)
{
list($username, $password) = $credentials;
[$username, $password] = $credentials;
$memcached->setOption(Memcached::OPT_BINARY_PROTOCOL, true);

View File

@@ -12,6 +12,13 @@ class MemcachedStore extends TaggableStore implements LockProvider, Store
{
use InteractsWithTime;
/**
* The maximum value that can be specified as an expiration delta.
*
* @var int
*/
const REALTIME_MAXDELTA_IN_MINUTES = 43200;
/**
* The Memcached instance.
*
@@ -103,7 +110,9 @@ class MemcachedStore extends TaggableStore implements LockProvider, Store
*/
public function put($key, $value, $minutes)
{
$this->memcached->set($this->prefix.$key, $value, $this->toTimestamp($minutes));
$this->memcached->set(
$this->prefix.$key, $value, $this->calculateExpiration($minutes)
);
}
/**
@@ -121,7 +130,9 @@ class MemcachedStore extends TaggableStore implements LockProvider, Store
$prefixedValues[$this->prefix.$key] = $value;
}
$this->memcached->setMulti($prefixedValues, $this->toTimestamp($minutes));
$this->memcached->setMulti(
$prefixedValues, $this->calculateExpiration($minutes)
);
}
/**
@@ -134,7 +145,9 @@ class MemcachedStore extends TaggableStore implements LockProvider, Store
*/
public function add($key, $value, $minutes)
{
return $this->memcached->add($this->prefix.$key, $value, $this->toTimestamp($minutes));
return $this->memcached->add(
$this->prefix.$key, $value, $this->calculateExpiration($minutes)
);
}
/**
@@ -206,6 +219,17 @@ class MemcachedStore extends TaggableStore implements LockProvider, Store
return $this->memcached->flush();
}
/**
* Get the expiration time of the key.
*
* @param int $minutes
* @return int
*/
protected function calculateExpiration($minutes)
{
return $this->toTimestamp($minutes);
}
/**
* Get the UNIX timestamp for the given number of minutes.
*

View File

@@ -70,6 +70,17 @@ class Repository implements CacheContract, ArrayAccess
return ! is_null($this->get($key));
}
/**
* Determine if an item doesn't exist in the cache.
*
* @param string $key
* @return bool
*/
public function missing($key)
{
return ! $this->has($key);
}
/**
* Retrieve an item from the cache by key.
*
@@ -308,7 +319,7 @@ class Repository implements CacheContract, ArrayAccess
}
/**
* Get an item from the cache, or store the default value.
* Get an item from the cache, or execute the given Closure and store the result.
*
* @param string $key
* @param \DateTimeInterface|\DateInterval|float|int $minutes
@@ -332,9 +343,9 @@ class Repository implements CacheContract, ArrayAccess
}
/**
* Get an item from the cache, or store the default value forever.
* Get an item from the cache, or execute the given Closure and store the result forever.
*
* @param string $key
* @param string $key
* @param \Closure $callback
* @return mixed
*/
@@ -344,9 +355,9 @@ class Repository implements CacheContract, ArrayAccess
}
/**
* Get an item from the cache, or store the default value forever.
* Get an item from the cache, or execute the given Closure and store the result forever.
*
* @param string $key
* @param string $key
* @param \Closure $callback
* @return mixed
*/
@@ -554,7 +565,7 @@ class Repository implements CacheContract, ArrayAccess
$duration = $this->parseDateInterval($duration);
if ($duration instanceof DateTimeInterface) {
$duration = Carbon::now()->diffInSeconds(Carbon::createFromTimestamp($duration->getTimestamp()), false) / 60;
$duration = Carbon::now()->diffInRealSeconds($duration, false) / 60;
}
return (int) ($duration * 60) > 0 ? $duration : null;

View File

@@ -65,7 +65,7 @@ class Repository implements ArrayAccess, ConfigContract
foreach ($keys as $key => $default) {
if (is_numeric($key)) {
list($key, $default) = [$default, null];
[$key, $default] = [$default, null];
}
$config[$key] = Arr::get($this->items, $key, $default);

View File

@@ -80,7 +80,7 @@ class Application extends SymfonyApplication implements ApplicationContract
$input = $input ?: new ArgvInput
);
$this->events->fire(
$this->events->dispatch(
new Events\CommandStarting(
$commandName, $input, $output = $output ?: new ConsoleOutput
)
@@ -88,7 +88,7 @@ class Application extends SymfonyApplication implements ApplicationContract
$exitCode = parent::run($input, $output);
$this->events->fire(
$this->events->dispatch(
new Events\CommandFinished($commandName, $input, $output, $exitCode)
);

View File

@@ -123,7 +123,7 @@ class Command extends SymfonyCommand
*/
protected function configureUsingFluentDefinition()
{
list($name, $arguments, $options) = Parser::parse($this->signature);
[$name, $arguments, $options] = Parser::parse($this->signature);
parent::__construct($this->name = $name);
@@ -543,6 +543,14 @@ class Command extends SymfonyCommand
return $level;
}
/**
* {@inheritdoc}
*/
public function isHidden()
{
return $this->hidden;
}
/**
* Get the console command arguments.
*

View File

@@ -48,7 +48,7 @@ trait ConfirmableTrait
protected function getDefaultConfirmCallback()
{
return function () {
return $this->getLaravel()->environment() == 'production';
return $this->getLaravel()->environment() === 'production';
};
}
}

View File

@@ -46,6 +46,7 @@ abstract class GeneratorCommand extends Command
* Execute the console command.
*
* @return bool|null
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function handle()
{
@@ -152,6 +153,7 @@ abstract class GeneratorCommand extends Command
*
* @param string $name
* @return string
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
protected function buildClass($name)
{
@@ -171,7 +173,7 @@ abstract class GeneratorCommand extends Command
{
$stub = str_replace(
['DummyNamespace', 'DummyRootNamespace', 'NamespacedDummyUserModel'],
[$this->getNamespace($name), $this->rootNamespace(), config('auth.providers.users.model')],
[$this->getNamespace($name), $this->rootNamespace(), $this->userProviderModel()],
$stub
);
@@ -223,6 +225,20 @@ abstract class GeneratorCommand extends Command
return $this->laravel->getNamespace();
}
/**
* Get the model for the default guard's user provider.
*
* @return string|null
*/
protected function userProviderModel()
{
$guard = config('auth.defaults.guard');
$provider = config("auth.guards.{$guard}.provider");
return config("auth.providers.{$provider}.model");
}
/**
* Get the console command arguments.
*

View File

@@ -82,7 +82,7 @@ class Parser
*/
protected static function parseArgument($token)
{
list($token, $description) = static::extractDescription($token);
[$token, $description] = static::extractDescription($token);
switch (true) {
case Str::endsWith($token, '?*'):
@@ -108,7 +108,7 @@ class Parser
*/
protected static function parseOption($token)
{
list($token, $description) = static::extractDescription($token);
[$token, $description] = static::extractDescription($token);
$matches = preg_split('/\s*\|\s*/', $token, 2);

View File

@@ -163,7 +163,7 @@ class Event
*/
public function getDefaultOutput()
{
return (DIRECTORY_SEPARATOR == '\\') ? 'NUL' : '/dev/null';
return (DIRECTORY_SEPARATOR === '\\') ? 'NUL' : '/dev/null';
}
/**

View File

@@ -165,7 +165,7 @@ trait ManagesFrequencies
$segments = explode(':', $time);
return $this->spliceIntoPosition(2, (int) $segments[0])
->spliceIntoPosition(1, count($segments) == 2 ? (int) $segments[1] : '0');
->spliceIntoPosition(1, count($segments) === 2 ? (int) $segments[1] : '0');
}
/**

View File

@@ -49,7 +49,7 @@ class BoundMethod
// We will assume an @ sign is used to delimit the class name from the method
// name. We will split on this @ sign and then build a callable array that
// we can pass right back into the "call" method for dependency binding.
$method = count($segments) == 2
$method = count($segments) === 2
? $segments[1] : $defaultMethod;
if (is_null($method)) {
@@ -122,8 +122,10 @@ class BoundMethod
/**
* Get the proper reflection instance for the given callback.
*
* @param callable|string $callback
* @param callable|string $callback
* @return \ReflectionFunctionAbstract
*
* @throws \ReflectionException
*/
protected static function getCallReflector($callback)
{

View File

@@ -3,6 +3,7 @@
namespace Illuminate\Container;
use Closure;
use Exception;
use ArrayAccess;
use LogicException;
use ReflectionClass;
@@ -195,7 +196,7 @@ class Container implements ArrayAccess, ContainerContract
public function isShared($abstract)
{
return isset($this->instances[$abstract]) ||
(isset($this->bindings[$abstract]['shared']) &&
(isset($this->bindings[$abstract]['shared']) &&
$this->bindings[$abstract]['shared'] === true);
}
@@ -220,11 +221,11 @@ class Container implements ArrayAccess, ContainerContract
*/
public function bind($abstract, $concrete = null, $shared = false)
{
$this->dropStaleInstances($abstract);
// If no concrete type was given, we will simply set the concrete type to the
// abstract type. After that, the concrete type to be registered as shared
// without being forced to state their classes in both of the parameters.
$this->dropStaleInstances($abstract);
if (is_null($concrete)) {
$concrete = $abstract;
}
@@ -613,11 +614,15 @@ class Container implements ArrayAccess, ContainerContract
*/
public function get($id)
{
if ($this->has($id)) {
try {
return $this->resolve($id);
}
} catch (Exception $e) {
if ($this->has($id)) {
throw $e;
}
throw new EntryNotFoundException;
throw new EntryNotFoundException;
}
}
/**
@@ -774,7 +779,7 @@ class Container implements ArrayAccess, ContainerContract
$reflector = new ReflectionClass($concrete);
// If the type is not instantiable, the developer is attempting to resolve
// an abstract type such as an Interface of Abstract Class and there is
// an abstract type such as an Interface or Abstract Class and there is
// no binding registered for the abstractions so we need to bail out.
if (! $reflector->isInstantiable()) {
return $this->notInstantiable($concrete);

View File

@@ -16,6 +16,7 @@
"require": {
"php": "^7.1.3",
"illuminate/contracts": "5.7.*",
"illuminate/support": "5.7.*",
"psr/container": "^1.0"
},
"autoload": {

View File

@@ -81,7 +81,7 @@ interface Repository extends CacheInterface
public function forever($key, $value);
/**
* Get an item from the cache, or store the default value.
* Get an item from the cache, or execute the given Closure and store the result.
*
* @param string $key
* @param \DateTimeInterface|\DateInterval|float|int $minutes
@@ -91,18 +91,18 @@ interface Repository extends CacheInterface
public function remember($key, $minutes, Closure $callback);
/**
* Get an item from the cache, or store the default value forever.
* Get an item from the cache, or execute the given Closure and store the result forever.
*
* @param string $key
* @param string $key
* @param \Closure $callback
* @return mixed
*/
public function sear($key, Closure $callback);
/**
* Get an item from the cache, or store the default value forever.
* Get an item from the cache, or execute the given Closure and store the result forever.
*
* @param string $key
* @param string $key
* @param \Closure $callback
* @return mixed
*/

View File

@@ -26,7 +26,7 @@ interface Store
* Store an item in the cache for a given number of minutes.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @param float|int $minutes
* @return void
*/
@@ -45,7 +45,7 @@ interface Store
* Increment the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return int|bool
*/
public function increment($key, $value = 1);
@@ -54,7 +54,7 @@ interface Store
* Decrement the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return int|bool
*/
public function decrement($key, $value = 1);
@@ -63,7 +63,7 @@ interface Store
* Store an item in the cache indefinitely.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return void
*/
public function forever($key, $value);

View File

@@ -7,18 +7,18 @@ interface Encrypter
/**
* Encrypt the given value.
*
* @param string $value
* @param mixed $value
* @param bool $serialize
* @return string
* @return mixed
*/
public function encrypt($value, $serialize = true);
/**
* Decrypt the given value.
*
* @param string $payload
* @param mixed $payload
* @param bool $unserialize
* @return string
* @return mixed
*/
public function decrypt($payload, $unserialize = true);
}

View File

@@ -61,7 +61,7 @@ interface Filesystem
*
* @param string $path
* @param resource $resource
* @param mixed $options
* @param array $options
* @return bool
*
* @throws \InvalidArgumentException If $resource is not a file handle.

View File

@@ -29,7 +29,7 @@ interface Job
* Release the job back into the queue.
*
* @param int $delay
* @return mixed
* @return void
*/
public function release($delay = 0);

View File

@@ -8,7 +8,7 @@ interface Registrar
* Register a new GET route with the router.
*
* @param string $uri
* @param \Closure|array|string $action
* @param \Closure|array|string|callable $action
* @return \Illuminate\Routing\Route
*/
public function get($uri, $action);
@@ -17,7 +17,7 @@ interface Registrar
* Register a new POST route with the router.
*
* @param string $uri
* @param \Closure|array|string $action
* @param \Closure|array|string|callable $action
* @return \Illuminate\Routing\Route
*/
public function post($uri, $action);
@@ -26,7 +26,7 @@ interface Registrar
* Register a new PUT route with the router.
*
* @param string $uri
* @param \Closure|array|string $action
* @param \Closure|array|string|callable $action
* @return \Illuminate\Routing\Route
*/
public function put($uri, $action);
@@ -35,7 +35,7 @@ interface Registrar
* Register a new DELETE route with the router.
*
* @param string $uri
* @param \Closure|array|string $action
* @param \Closure|array|string|callable $action
* @return \Illuminate\Routing\Route
*/
public function delete($uri, $action);
@@ -44,7 +44,7 @@ interface Registrar
* Register a new PATCH route with the router.
*
* @param string $uri
* @param \Closure|array|string $action
* @param \Closure|array|string|callable $action
* @return \Illuminate\Routing\Route
*/
public function patch($uri, $action);
@@ -53,7 +53,7 @@ interface Registrar
* Register a new OPTIONS route with the router.
*
* @param string $uri
* @param \Closure|array|string $action
* @param \Closure|array|string|callable $action
* @return \Illuminate\Routing\Route
*/
public function options($uri, $action);
@@ -63,7 +63,7 @@ interface Registrar
*
* @param array|string $methods
* @param string $uri
* @param \Closure|array|string $action
* @param \Closure|array|string|callable $action
* @return \Illuminate\Routing\Route
*/
public function match($methods, $uri, $action);

View File

@@ -16,7 +16,7 @@ interface Rule
/**
* Get the validation error message.
*
* @return string
* @return string|array
*/
public function message();
}

View File

@@ -3,13 +3,14 @@
namespace Illuminate\Cookie;
use Illuminate\Support\Arr;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Support\InteractsWithTime;
use Symfony\Component\HttpFoundation\Cookie;
use Illuminate\Contracts\Cookie\QueueingFactory as JarContract;
class CookieJar implements JarContract
{
use InteractsWithTime;
use InteractsWithTime, Macroable;
/**
* The default path (if specified).
@@ -62,7 +63,7 @@ class CookieJar implements JarContract
*/
public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = null, $httpOnly = true, $raw = false, $sameSite = null)
{
list($path, $domain, $secure, $sameSite) = $this->getPathAndDomain($path, $domain, $secure, $sameSite);
[$path, $domain, $secure, $sameSite] = $this->getPathAndDomain($path, $domain, $secure, $sameSite);
$time = ($minutes == 0) ? 0 : $this->availableAt($minutes * 60);
@@ -176,7 +177,7 @@ class CookieJar implements JarContract
*/
public function setDefaultPathAndDomain($path, $domain, $secure = false, $sameSite = null)
{
list($this->path, $this->domain, $this->secure, $this->sameSite) = [$path, $domain, $secure, $sameSite];
[$this->path, $this->domain, $this->secure, $this->sameSite] = [$path, $domain, $secure, $sameSite];
return $this;
}

View File

@@ -751,6 +751,8 @@ class Connection implements ConnectionInterface
public function reconnect()
{
if (is_callable($this->reconnector)) {
$this->doctrineConnection = null;
return call_user_func($this->reconnector, $this);
}

View File

@@ -37,7 +37,7 @@ class Connector
*/
public function createConnection($dsn, array $config, array $options)
{
list($username, $password) = [
[$username, $password] = [
$config['username'] ?? null, $config['password'] ?? null,
];

View File

@@ -59,9 +59,11 @@ class PostgresConnector extends Connector implements ConnectorInterface
*/
protected function configureEncoding($connection, $config)
{
$charset = $config['charset'];
if (! isset($config['charset'])) {
return;
}
$connection->prepare("set names '$charset'")->execute();
$connection->prepare("set names '{$config['charset']}'")->execute();
}
/**

View File

@@ -21,7 +21,7 @@ class SQLiteConnector extends Connector implements ConnectorInterface
// SQLite supports "in-memory" databases that only last as long as the owning
// connection does. These are useful for tests or for short lifetime store
// querying. In-memory databases may only have a single open connection.
if ($config['database'] == ':memory:') {
if ($config['database'] === ':memory:') {
return $this->createConnection('sqlite::memory:', $config, $options);
}

View File

@@ -4,6 +4,16 @@ namespace Illuminate\Database\Console\Migrations;
class TableGuesser
{
const CREATE_PATTERNS = [
'/^create_(\w+)_table$/',
'/^create_(\w+)$/',
];
const CHANGE_PATTERNS = [
'/_(to|from|in)_(\w+)_table$/',
'/_(to|from|in)_(\w+)$/',
];
/**
* Attempt to guess the table name and "creation" status of the given migration.
*
@@ -12,12 +22,16 @@ class TableGuesser
*/
public static function guess($migration)
{
if (preg_match('/^create_(\w+)_table$/', $migration, $matches)) {
return [$matches[1], $create = true];
foreach (self::CREATE_PATTERNS as $pattern) {
if (preg_match($pattern, $migration, $matches)) {
return [$matches[1], $create = true];
}
}
if (preg_match('/_(to|from|in)_(\w+)_table$/', $migration, $matches)) {
return [$matches[2], $create = false];
foreach (self::CHANGE_PATTERNS as $pattern) {
if (preg_match($pattern, $migration, $matches)) {
return [$matches[2], $create = false];
}
}
}
}

View File

@@ -62,7 +62,7 @@ class DatabaseManager implements ConnectionResolverInterface
*/
public function connection($name = null)
{
list($database, $type) = $this->parseConnectionName($name);
[$database, $type] = $this->parseConnectionName($name);
$name = $name ?: $database;
@@ -180,9 +180,9 @@ class DatabaseManager implements ConnectionResolverInterface
*/
protected function setPdoForType(Connection $connection, $type = null)
{
if ($type == 'read') {
if ($type === 'read') {
$connection->setPdo($connection->getReadPdo());
} elseif ($type == 'write') {
} elseif ($type === 'write') {
$connection->setReadPdo($connection->getPdo());
}

View File

@@ -35,6 +35,8 @@ trait DetectsLostConnections
'Physical connection is not usable',
'TCP Provider: Error code 0x68',
'Name or service not known',
'ORA-03114',
'Packets out of order. Expected',
]);
}
}

View File

@@ -240,7 +240,7 @@ class Builder
*/
public function orWhere($column, $operator = null, $value = null)
{
list($value, $operator) = $this->query->prepareValueAndOperator(
[$value, $operator] = $this->query->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
@@ -915,7 +915,7 @@ class Builder
// the parameter list is empty, so we will format the scope name and these
// parameters here. Then, we'll be ready to call the scope on the model.
if (is_int($scope)) {
list($scope, $parameters) = [$parameters, []];
[$scope, $parameters] = [$parameters, []];
}
// Next we'll pass the scope callback to the callScope method which will take
@@ -1114,22 +1114,22 @@ class Builder
$results = [];
foreach ($relations as $name => $constraints) {
// If the "relation" value is actually a numeric key, we can assume that no
// constraints have been specified for the eager load and we'll just put
// an empty Closure with the loader so that we can treat all the same.
// If the "name" value is a numeric key, we can assume that no
// constraints have been specified. We'll just put an empty
// Closure there, so that we can treat them all the same.
if (is_numeric($name)) {
$name = $constraints;
list($name, $constraints) = Str::contains($name, ':')
[$name, $constraints] = Str::contains($name, ':')
? $this->createSelectWithConstraint($name)
: [$name, function () {
//
}];
}
// We need to separate out any nested includes. Which allows the developers
// We need to separate out any nested includes, which allows the developers
// to load deep relationships using "dots" without stating each level of
// the relationship with its own key in the array of eager load names.
// the relationship with its own key in the array of eager-load names.
$results = $this->addNestedWiths($name, $results);
$results[$name] = $constraints;

View File

@@ -63,6 +63,38 @@ class Collection extends BaseCollection implements QueueableCollection
return $this;
}
/**
* Load a set of relationship counts onto the collection.
*
* @param array|string $relations
* @return $this
*/
public function loadCount($relations)
{
if ($this->isEmpty()) {
return $this;
}
$models = $this->first()->newModelQuery()
->whereKey($this->modelKeys())
->select($this->first()->getKeyName())
->withCount(...func_get_args())
->get();
$attributes = Arr::except(
array_keys($models->first()->getAttributes()),
$models->first()->getKeyName()
);
$models->each(function ($model) use ($attributes) {
$this->find($model->getKey())->forceFill(
Arr::only($model->getAttributes(), $attributes)
)->syncOriginalAttributes($attributes);
});
return $this;
}
/**
* Load a set of relationships onto the collection if they are not already eager loaded.
*

View File

@@ -173,7 +173,7 @@ trait GuardsAttributes
*/
public function totallyGuarded()
{
return count($this->getFillable()) == 0 && $this->getGuarded() == ['*'];
return count($this->getFillable()) === 0 && $this->getGuarded() == ['*'];
}
/**

View File

@@ -479,6 +479,8 @@ trait HasAttributes
case 'float':
case 'double':
return $this->fromFloat($value);
case 'decimal':
return $this->asDecimal($value, explode(':', $this->getCasts()[$key], 2)[1]);
case 'string':
return (string) $value;
case 'bool':
@@ -515,6 +517,10 @@ trait HasAttributes
return 'custom_datetime';
}
if ($this->isDecimalCast($this->getCasts()[$key])) {
return 'decimal';
}
return trim(strtolower($this->getCasts()[$key]));
}
@@ -530,6 +536,17 @@ trait HasAttributes
strncmp($cast, 'datetime:', 9) === 0;
}
/**
* Determine if the cast type is a decimal cast.
*
* @param string $cast
* @return bool
*/
protected function isDecimalCast($cast)
{
return strncmp($cast, 'decimal:', 8) === 0;
}
/**
* Set a given attribute on the model.
*
@@ -613,7 +630,7 @@ trait HasAttributes
*/
public function fillJsonAttribute($key, $value)
{
list($key, $path) = explode('->', $key, 2);
[$key, $path] = explode('->', $key, 2);
$this->attributes[$key] = $this->asJson($this->getArrayAttributeWithValue(
$path, $key, $value
@@ -680,6 +697,18 @@ trait HasAttributes
return json_encode($value);
}
/**
* Decode the given JSON back into an array or object.
*
* @param string $value
* @param bool $asObject
* @return mixed
*/
public function fromJson($value, $asObject = false)
{
return json_decode($value, ! $asObject);
}
/**
* Decode the given float.
*
@@ -701,15 +730,15 @@ trait HasAttributes
}
/**
* Decode the given JSON back into an array or object.
* Return a decimal as string.
*
* @param string $value
* @param bool $asObject
* @return mixed
* @param float $value
* @param int $decimals
* @return string
*/
public function fromJson($value, $asObject = false)
protected function asDecimal($value, $decimals)
{
return json_decode($value, ! $asObject);
return number_format($value, $decimals, '.', '');
}
/**
@@ -783,8 +812,8 @@ trait HasAttributes
/**
* Convert a DateTime to a storable string.
*
* @param \DateTime|int $value
* @return string
* @param mixed $value
* @return string|null
*/
public function fromDateTime($value)
{
@@ -981,7 +1010,22 @@ trait HasAttributes
*/
public function syncOriginalAttribute($attribute)
{
$this->original[$attribute] = $this->attributes[$attribute];
return $this->syncOriginalAttributes($attribute);
}
/**
* Sync multiple original attribute with their current values.
*
* @param array|string $attributes
* @return $this
*/
public function syncOriginalAttributes($attributes)
{
$attributes = is_array($attributes) ? $attributes : func_get_args();
foreach ($attributes as $attribute) {
$this->original[$attribute] = $this->attributes[$attribute];
}
return $this;
}

View File

@@ -41,7 +41,6 @@ trait HasRelationships
*/
public static $manyMethods = [
'belongsToMany', 'morphToMany', 'morphedByMany',
'guessBelongsToManyRelation', 'findFirstMethodThatIsntRelation',
];
/**
@@ -91,7 +90,7 @@ trait HasRelationships
{
$instance = $this->newRelatedInstance($related);
list($type, $id) = $this->getMorphs($name, $type, $id);
[$type, $id] = $this->getMorphs($name, $type, $id);
$table = $instance->getTable();
@@ -183,7 +182,7 @@ trait HasRelationships
// use that to get both the class and foreign key that will be utilized.
$name = $name ?: $this->guessBelongsToRelation();
list($type, $id) = $this->getMorphs(
[$type, $id] = $this->getMorphs(
Str::snake($name), $type, $id
);
@@ -266,7 +265,7 @@ trait HasRelationships
*/
protected function guessBelongsToRelation()
{
list($one, $two, $caller) = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
[$one, $two, $caller] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
return $caller['function'];
}
@@ -366,7 +365,7 @@ trait HasRelationships
// Here we will gather up the morph type and ID for the relationship so that we
// can properly query the intermediate table of a relation. Finally, we will
// get the table and create the relationship instances for the developers.
list($type, $id) = $this->getMorphs($name, $type, $id);
[$type, $id] = $this->getMorphs($name, $type, $id);
$table = $instance->getTable();
@@ -546,14 +545,17 @@ trait HasRelationships
}
/**
* Get the relationship name of the belongs to many.
* Get the relationship name of the belongsToMany relationship.
*
* @return string
* @return string|null
*/
protected function guessBelongsToManyRelation()
{
$caller = Arr::first(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), function ($trace) {
return ! in_array($trace['function'], Model::$manyMethods);
return ! in_array(
$trace['function'],
array_merge(static::$manyMethods, ['guessBelongsToManyRelation'])
);
});
return ! is_null($caller) ? $caller['function'] : null;

View File

@@ -43,7 +43,7 @@ trait QueriesRelationships
: 'getRelationExistenceCountQuery';
$hasQuery = $relation->{$method}(
$relation->getRelated()->newQuery(), $this
$relation->getRelated()->newQueryWithoutRelationships(), $this
);
// Next we will call any given callback as an "anonymous" scope so they can get the
@@ -74,6 +74,13 @@ trait QueriesRelationships
{
$relations = explode('.', $relations);
$doesntHave = $operator === '<' && $count === 1;
if ($doesntHave) {
$operator = '>=';
$count = 1;
}
$closure = function ($q) use (&$closure, &$relations, $operator, $count, $callback) {
// In order to nest "has", we need to add count relation constraints on the
// callback Closure. We'll do this by simply passing the Closure its own
@@ -83,7 +90,7 @@ trait QueriesRelationships
: $q->has(array_shift($relations), $operator, $count, 'and', $callback);
};
return $this->has(array_shift($relations), '>=', 1, $boolean, $closure);
return $this->has(array_shift($relations), $doesntHave ? '<' : '>=', 1, $boolean, $closure);
}
/**
@@ -201,8 +208,8 @@ trait QueriesRelationships
unset($alias);
if (count($segments) == 3 && Str::lower($segments[1]) == 'as') {
list($name, $alias) = [$segments[0], $segments[2]];
if (count($segments) === 3 && Str::lower($segments[1]) === 'as') {
[$name, $alias] = [$segments[0], $segments[2]];
}
$relation = $this->getRelationWithoutConstraints($name);

View File

@@ -306,6 +306,8 @@ class FactoryBuilder
* @param array $definition
* @param array $attributes
* @return array
*
* @throws \InvalidArgumentException
*/
protected function applyStates(array $definition, array $attributes = [])
{

View File

@@ -394,6 +394,8 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
$this->getConnectionName()
);
$model->setTable($this->getTable());
return $model;
}
@@ -425,9 +427,9 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public static function on($connection = null)
{
// First we will just create a fresh instance of this model, and then we can
// set the connection on the model so that it is be used for the queries
// we execute, as well as being set on each relationship we retrieve.
// First we will just create a fresh instance of this model, and then we can set the
// connection on the model so that it is used for the queries we execute, as well
// as being set on every relation we retrieve without a custom connection name.
$instance = new static;
$instance->setConnection($connection);
@@ -542,7 +544,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
protected function incrementOrDecrement($column, $amount, $extra, $method)
{
$query = $this->newQuery();
$query = $this->newModelQuery();
if (! $this->exists) {
return $query->{$method}($column, $amount, $extra);
@@ -566,7 +568,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
protected function incrementOrDecrementAttributeValue($column, $amount, $extra, $method)
{
$this->{$column} = $this->{$column} + ($method == 'increment' ? $amount : $amount * -1);
$this->{$column} = $this->{$column} + ($method === 'increment' ? $amount : $amount * -1);
$this->forceFill($extra);
@@ -958,9 +960,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
*/
public function newQueryWithoutRelationships()
{
return $this->registerGlobalScopes(
$this->newEloquentBuilder($this->newBaseQueryBuilder())->setModel($this)
);
return $this->registerGlobalScopes($this->newModelQuery());
}
/**

View File

@@ -7,9 +7,6 @@ use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\Concerns\SupportsDefaultModels;
/**
* @mixin \Illuminate\Database\Eloquent\Builder
*/
class BelongsTo extends Relation
{
use SupportsDefaultModels;
@@ -111,7 +108,9 @@ class BelongsTo extends Relation
// our eagerly loading query so it returns the proper models from execution.
$key = $this->related->getTable().'.'.$this->ownerKey;
$this->query->whereIn($key, $this->getEagerModelKeys($models));
$whereIn = $this->whereInMethod($this->related, $this->ownerKey);
$this->query->{$whereIn}($key, $this->getEagerModelKeys($models));
}
/**

View File

@@ -209,7 +209,12 @@ class BelongsToMany extends Relation
*/
public function addEagerConstraints(array $models)
{
$this->query->whereIn($this->getQualifiedForeignPivotKeyName(), $this->getKeys($models, $this->parentKey));
$whereIn = $this->whereInMethod($this->parent, $this->parentKey);
$this->query->{$whereIn}(
$this->getQualifiedForeignPivotKeyName(),
$this->getKeys($models, $this->parentKey)
);
}
/**
@@ -360,7 +365,7 @@ class BelongsToMany extends Relation
*
* In addition, new pivot records will receive this value.
*
* @param string $column
* @param string|array $column
* @param mixed $value
* @return $this
*/
@@ -514,7 +519,7 @@ class BelongsToMany extends Relation
return $result;
}
throw (new ModelNotFoundException)->setModel(get_class($this->related));
throw (new ModelNotFoundException)->setModel(get_class($this->related), $id);
}
/**
@@ -788,7 +793,7 @@ class BelongsToMany extends Relation
// the related model's timestamps, to make sure these all reflect the changes
// to the parent models. This will help us keep any caching synced up here.
if (count($ids = $this->allRelatedIds()) > 0) {
$this->getRelated()->newQuery()->whereIn($key, $ids)->update($columns);
$this->getRelated()->newModelQuery()->whereIn($key, $ids)->update($columns);
}
}
@@ -1016,6 +1021,16 @@ class BelongsToMany extends Relation
return $this->table.'.'.$this->relatedPivotKey;
}
/**
* Get the parent key for the relationship.
*
* @return string
*/
public function getParentKeyName()
{
return $this->parentKey;
}
/**
* Get the fully qualified parent key name for the relation.
*
@@ -1026,6 +1041,16 @@ class BelongsToMany extends Relation
return $this->parent->qualifyColumn($this->parentKey);
}
/**
* Get the related key for the relationship.
*
* @return string
*/
public function getRelatedKeyName()
{
return $this->relatedKey;
}
/**
* Get the intermediate table for the relationship.
*

View File

@@ -124,7 +124,7 @@ trait AsPivot
*/
protected function getDeleteQuery()
{
return $this->newQuery()->where([
return $this->newModelQuery()->where([
$this->foreignKey => $this->getOriginal($this->foreignKey, $this->getAttribute($this->foreignKey)),
$this->relatedKey => $this->getOriginal($this->relatedKey, $this->getAttribute($this->relatedKey)),
]);
@@ -247,7 +247,7 @@ trait AsPivot
/**
* Get a new query to restore one or more models by their queueable IDs.
*
* @param array|int $ids
* @param array<int> $ids
* @return \Illuminate\Database\Eloquent\Builder
*/
public function newQueryForRestoration($ids)

View File

@@ -64,7 +64,7 @@ trait InteractsWithPivotTable
/**
* Sync the intermediate tables with a list of IDs without detaching.
*
* @param \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|array $ids
* @param \Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Model|array $ids
* @return array
*/
public function syncWithoutDetaching($ids)
@@ -75,7 +75,7 @@ trait InteractsWithPivotTable
/**
* Sync the intermediate tables with a list of IDs or collection of models.
*
* @param \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|array $ids
* @param \Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Model|array $ids
* @param bool $detaching
* @return array
*/
@@ -133,7 +133,7 @@ trait InteractsWithPivotTable
{
return collect($records)->mapWithKeys(function ($attributes, $id) {
if (! is_array($attributes)) {
list($id, $attributes) = [$attributes, []];
[$id, $attributes] = [$attributes, []];
}
return [$id => $attributes];
@@ -258,7 +258,7 @@ trait InteractsWithPivotTable
*/
protected function formatAttachRecord($key, $value, $attributes, $hasTimestamps)
{
list($id, $attributes) = $this->extractAttachIdAndAttributes($key, $value, $attributes);
[$id, $attributes] = $this->extractAttachIdAndAttributes($key, $value, $attributes);
return array_merge(
$this->baseAttachRecord($id, $hasTimestamps), $this->castAttributes($attributes)
@@ -427,7 +427,7 @@ trait InteractsWithPivotTable
*/
public function newPivotStatementForId($id)
{
return $this->newPivotQuery()->where($this->relatedPivotKey, $id);
return $this->newPivotQuery()->whereIn($this->relatedPivotKey, $this->parseIds($id));
}
/**
@@ -507,7 +507,7 @@ trait InteractsWithPivotTable
*/
protected function castKeys(array $keys)
{
return (array) array_map(function ($v) {
return array_map(function ($v) {
return $this->castKey($v);
}, $keys);
}

View File

@@ -146,7 +146,9 @@ class HasManyThrough extends Relation
*/
public function addEagerConstraints(array $models)
{
$this->query->whereIn(
$whereIn = $this->whereInMethod($this->farParent, $this->localKey);
$this->query->{$whereIn}(
$this->getQualifiedFirstKeyName(), $this->getKeys($models, $this->localKey)
);
}
@@ -331,7 +333,7 @@ class HasManyThrough extends Relation
return $result;
}
throw (new ModelNotFoundException)->setModel(get_class($this->related));
throw (new ModelNotFoundException)->setModel(get_class($this->related), $id);
}
/**
@@ -478,10 +480,14 @@ class HasManyThrough extends Relation
*/
public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*'])
{
if ($parentQuery->getQuery()->from == $query->getQuery()->from) {
if ($parentQuery->getQuery()->from === $query->getQuery()->from) {
return $this->getRelationExistenceQueryForSelfRelation($query, $parentQuery, $columns);
}
if ($parentQuery->getQuery()->from === $this->throughParent->getTable()) {
return $this->getRelationExistenceQueryForThroughSelfRelation($query, $parentQuery, $columns);
}
$this->performJoin($query);
return $query->select($columns)->whereColumn(
@@ -501,7 +507,7 @@ class HasManyThrough extends Relation
{
$query->from($query->getModel()->getTable().' as '.$hash = $this->getRelationCountHash());
$query->join($this->throughParent->getTable(), $this->getQualifiedParentKeyName(), '=', $hash.'.'.$this->secondLocalKey);
$query->join($this->throughParent->getTable(), $this->getQualifiedParentKeyName(), '=', $hash.'.'.$this->secondKey);
if ($this->throughParentSoftDeletes()) {
$query->whereNull($this->throughParent->getQualifiedDeletedAtColumn());
@@ -514,6 +520,29 @@ class HasManyThrough extends Relation
);
}
/**
* Add the constraints for a relationship query on the same table as the through parent.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Builder $parentQuery
* @param array|mixed $columns
* @return \Illuminate\Database\Eloquent\Builder
*/
public function getRelationExistenceQueryForThroughSelfRelation(Builder $query, Builder $parentQuery, $columns = ['*'])
{
$table = $this->throughParent->getTable().' as '.$hash = $this->getRelationCountHash();
$query->join($table, $hash.'.'.$this->secondLocalKey, '=', $this->getQualifiedFarKeyName());
if ($this->throughParentSoftDeletes()) {
$query->whereNull($hash.'.'.$this->throughParent->getDeletedAtColumn());
}
return $query->select($columns)->whereColumn(
$parentQuery->getQuery()->from.'.'.$this->localKey, '=', $hash.'.'.$this->firstKey
);
}
/**
* Get a relationship join table hash.
*
@@ -534,6 +563,16 @@ class HasManyThrough extends Relation
return $this->getQualifiedForeignKeyName();
}
/**
* Get the foreign key on the "through" model.
*
* @return string
*/
public function getFirstKeyName()
{
return $this->firstKey;
}
/**
* Get the qualified foreign key on the "through" model.
*
@@ -544,6 +583,16 @@ class HasManyThrough extends Relation
return $this->throughParent->qualifyColumn($this->firstKey);
}
/**
* Get the foreign key on the related model.
*
* @return string
*/
public function getForeignKeyName()
{
return $this->secondKey;
}
/**
* Get the qualified foreign key on the related model.
*
@@ -554,6 +603,16 @@ class HasManyThrough extends Relation
return $this->related->qualifyColumn($this->secondKey);
}
/**
* Get the local key on the far parent model.
*
* @return string
*/
public function getLocalKeyName()
{
return $this->localKey;
}
/**
* Get the qualified local key on the far parent model.
*
@@ -563,4 +622,14 @@ class HasManyThrough extends Relation
{
return $this->farParent->qualifyColumn($this->localKey);
}
/**
* Get the local key on the intermediary model.
*
* @return string
*/
public function getSecondLocalKeyName()
{
return $this->secondLocalKey;
}
}

View File

@@ -81,7 +81,9 @@ abstract class HasOneOrMany extends Relation
*/
public function addEagerConstraints(array $models)
{
$this->query->whereIn(
$whereIn = $this->whereInMethod($this->parent, $this->localKey);
$this->query->{$whereIn}(
$this->foreignKey, $this->getKeys($models, $this->localKey)
);
}
@@ -151,7 +153,7 @@ abstract class HasOneOrMany extends Relation
{
$value = $dictionary[$key];
return $type == 'one' ? reset($value) : $this->related->newCollection($value);
return $type === 'one' ? reset($value) : $this->related->newCollection($value);
}
/**
@@ -420,4 +422,14 @@ abstract class HasOneOrMany extends Relation
{
return $this->foreignKey;
}
/**
* Get the local key for the relationship.
*
* @return string
*/
public function getLocalKeyName()
{
return $this->localKey;
}
}

View File

@@ -124,7 +124,7 @@ class MorphPivot extends Pivot
/**
* Get a new query to restore multiple models by their queueable IDs.
*
* @param array|int $ids
* @param array<int> $ids
* @return \Illuminate\Database\Eloquent\Builder
*/
protected function newQueryForCollectionRestoration(array $ids)

View File

@@ -7,9 +7,6 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
/**
* @mixin \Illuminate\Database\Eloquent\Builder
*/
class MorphTo extends BelongsTo
{
/**

View File

@@ -181,4 +181,14 @@ class MorphToMany extends BelongsToMany
{
return $this->morphClass;
}
/**
* Get the indicator for a reverse relationship.
*
* @return bool
*/
public function getInverse()
{
return $this->inverse;
}
}

View File

@@ -307,6 +307,22 @@ abstract class Relation
return $this->related->getUpdatedAtColumn();
}
/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
*/
protected function whereInMethod(Model $model, $key)
{
return $model->getKeyName() === last(explode('.', $key))
&& $model->getIncrementing()
&& in_array($model->getKeyType(), ['int', 'integer'])
? 'whereIntegerInRaw'
: 'whereIn';
}
/**
* Set or get the morph map for polymorphic relations.
*

View File

@@ -428,7 +428,7 @@ class Migrator
public function getMigrationFiles($paths)
{
return Collection::make($paths)->flatMap(function ($path) {
return $this->files->glob($path.'/*_*.php');
return Str::endsWith($path, '.php') ? [$path] : $this->files->glob($path.'/*_*.php');
})->filter()->sortBy(function ($file) {
return $this->getMigrationName($file);
})->values()->keyBy(function ($file) {

View File

@@ -235,7 +235,7 @@ class Builder
*/
public function selectSub($query, $as)
{
list($query, $bindings) = $this->createSub($query);
[$query, $bindings] = $this->createSub($query);
return $this->selectRaw(
'('.$query.') as '.$this->grammar->wrap($as), $bindings
@@ -271,7 +271,7 @@ class Builder
*/
public function fromSub($query, $as)
{
list($query, $bindings) = $this->createSub($query);
[$query, $bindings] = $this->createSub($query);
return $this->fromRaw('('.$query.') as '.$this->grammar->wrap($as), $bindings);
}
@@ -440,7 +440,7 @@ class Builder
*/
public function joinSub($query, $as, $first, $operator = null, $second = null, $type = 'inner', $where = false)
{
list($query, $bindings) = $this->createSub($query);
[$query, $bindings] = $this->createSub($query);
$expression = '('.$query.') as '.$this->grammar->wrap($as);
@@ -592,7 +592,7 @@ class Builder
// Here we will make some assumptions about the operator. If only 2 values are
// passed to the method, we will assume that the operator is an equals sign
// and keep going. Otherwise, we'll require the operator to be passed in.
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
@@ -607,7 +607,7 @@ class Builder
// assume that the developer is just short-cutting the '=' operators and
// we will set the operators to '=' and set the values appropriately.
if ($this->invalidOperator($operator)) {
list($value, $operator) = [$operator, '='];
[$value, $operator] = [$operator, '='];
}
// If the value is a Closure, it means the developer is performing an entire
@@ -726,7 +726,7 @@ class Builder
*/
public function orWhere($column, $operator = null, $value = null)
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
@@ -755,7 +755,7 @@ class Builder
// assume that the developer is just short-cutting the '=' operators and
// we will set the operators to '=' and set the values appropriately.
if ($this->invalidOperator($operator)) {
list($second, $operator) = [$operator, '='];
[$second, $operator] = [$operator, '='];
}
// Finally, we will add this where clause into this array of clauses that we
@@ -857,11 +857,7 @@ class Builder
// Finally we'll add a binding for each values unless that value is an expression
// in which case we will just skip over it since it will be the query as a raw
// string and not as a parameterized place-holder to be replaced by the PDO.
foreach ($values as $value) {
if (! $value instanceof Expression) {
$this->addBinding($value, 'where');
}
}
$this->addBinding($this->cleanBindings($values), 'where');
return $this;
}
@@ -948,6 +944,45 @@ class Builder
return $this;
}
/**
* Add a "where in raw" clause for integer values to the query.
*
* @param string $column
* @param \Illuminate\Contracts\Support\Arrayable|array $values
* @param string $boolean
* @param bool $not
* @return $this
*/
public function whereIntegerInRaw($column, $values, $boolean = 'and', $not = false)
{
$type = $not ? 'NotInRaw' : 'InRaw';
if ($values instanceof Arrayable) {
$values = $values->toArray();
}
foreach ($values as &$value) {
$value = (int) $value;
}
$this->wheres[] = compact('type', 'column', 'values', 'boolean');
return $this;
}
/**
* Add a "where not in raw" clause for integer values to the query.
*
* @param string $column
* @param \Illuminate\Contracts\Support\Arrayable|array $values
* @param string $boolean
* @return $this
*/
public function whereIntegerNotInRaw($column, $values, $boolean = 'and')
{
return $this->whereIntegerInRaw($column, $values, $boolean, true);
}
/**
* Add a "where null" clause to the query.
*
@@ -1067,7 +1102,7 @@ class Builder
*/
public function whereDate($column, $operator, $value = null, $boolean = 'and')
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
@@ -1088,7 +1123,7 @@ class Builder
*/
public function orWhereDate($column, $operator, $value = null)
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
@@ -1106,7 +1141,7 @@ class Builder
*/
public function whereTime($column, $operator, $value = null, $boolean = 'and')
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
@@ -1127,7 +1162,7 @@ class Builder
*/
public function orWhereTime($column, $operator, $value = null)
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
@@ -1145,7 +1180,7 @@ class Builder
*/
public function whereDay($column, $operator, $value = null, $boolean = 'and')
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
@@ -1166,7 +1201,7 @@ class Builder
*/
public function orWhereDay($column, $operator, $value = null)
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
@@ -1184,7 +1219,7 @@ class Builder
*/
public function whereMonth($column, $operator, $value = null, $boolean = 'and')
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
@@ -1205,7 +1240,7 @@ class Builder
*/
public function orWhereMonth($column, $operator, $value = null)
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
@@ -1223,7 +1258,7 @@ class Builder
*/
public function whereYear($column, $operator, $value = null, $boolean = 'and')
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
@@ -1244,7 +1279,7 @@ class Builder
*/
public function orWhereYear($column, $operator, $value = null)
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
@@ -1526,7 +1561,7 @@ class Builder
{
$type = 'JsonLength';
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
@@ -1549,7 +1584,7 @@ class Builder
*/
public function orWhereJsonLength($column, $operator, $value = null)
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
@@ -1652,7 +1687,7 @@ class Builder
// Here we will make some assumptions about the operator. If only 2 values are
// passed to the method, we will assume that the operator is an equals sign
// and keep going. Otherwise, we'll require the operator to be passed in.
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
@@ -1660,7 +1695,7 @@ class Builder
// assume that the developer is just short-cutting the '=' operators and
// we will set the operators to '=' and set the values appropriately.
if ($this->invalidOperator($operator)) {
list($value, $operator) = [$operator, '='];
[$value, $operator] = [$operator, '='];
}
$this->havings[] = compact('type', 'column', 'operator', 'value', 'boolean');
@@ -1682,13 +1717,33 @@ class Builder
*/
public function orHaving($column, $operator = null, $value = null)
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
return $this->having($column, $operator, $value, 'or');
}
/**
* Add a "having between " clause to the query.
*
* @param string $column
* @param array $values
* @param string $boolean
* @param bool $not
* @return \Illuminate\Database\Query\Builder|static
*/
public function havingBetween($column, array $values, $boolean = 'and', $not = false)
{
$type = 'between';
$this->havings[] = compact('type', 'column', 'values', 'boolean', 'not');
$this->addBinding($this->cleanBindings($values), 'having');
return $this;
}
/**
* Add a raw having clause to the query.
*
@@ -1731,7 +1786,7 @@ class Builder
{
$this->{$this->unions ? 'unionOrders' : 'orders'}[] = [
'column' => $column,
'direction' => strtolower($direction) == 'asc' ? 'asc' : 'desc',
'direction' => strtolower($direction) === 'asc' ? 'asc' : 'desc',
];
return $this;
@@ -2106,8 +2161,10 @@ class Builder
*/
protected function runPaginationCountQuery($columns = ['*'])
{
return $this->cloneWithout(['columns', 'orders', 'limit', 'offset'])
->cloneWithoutBindings(['select', 'order'])
$without = $this->unions ? ['orders', 'limit', 'offset'] : ['columns', 'orders', 'limit', 'offset'];
return $this->cloneWithout($without)
->cloneWithoutBindings($this->unions ? ['order'] : ['select', 'order'])
->setAggregate('count', $this->withoutSelectAliases($columns))
->get()->all();
}
@@ -2420,8 +2477,8 @@ class Builder
*/
public function aggregate($function, $columns = ['*'])
{
$results = $this->cloneWithout(['columns'])
->cloneWithoutBindings(['select'])
$results = $this->cloneWithout($this->unions ? [] : ['columns'])
->cloneWithoutBindings($this->unions ? [] : ['select'])
->setAggregate($function, $columns)
->get($columns);
@@ -2545,7 +2602,7 @@ class Builder
/**
* Insert a new record and get the value of the primary key.
*
* @param array $values
* @param array $values
* @param string|null $sequence
* @return int
*/
@@ -2558,6 +2615,23 @@ class Builder
return $this->processor->processInsertGetId($this, $sql, $values, $sequence);
}
/**
* Insert new records into the table using a subquery.
*
* @param array $columns
* @param \Closure|\Illuminate\Database\Query\Builder|string $query
* @return bool
*/
public function insertUsing(array $columns, $query)
{
[$sql, $bindings] = $this->createSub($query);
return $this->connection->insert(
$this->grammar->compileInsertUsing($this, $columns, $sql),
$this->cleanBindings($bindings)
);
}
/**
* Update a record in the database.
*
@@ -2594,7 +2668,7 @@ class Builder
*
* @param string $column
* @param float|int $amount
* @param array $extra
* @param array $extra
* @return int
*/
public function increment($column, $amount = 1, array $extra = [])
@@ -2615,7 +2689,7 @@ class Builder
*
* @param string $column
* @param float|int $amount
* @param array $extra
* @param array $extra
* @return int
*/
public function decrement($column, $amount = 1, array $extra = [])

View File

@@ -46,6 +46,10 @@ class Grammar extends BaseGrammar
*/
public function compileSelect(Builder $query)
{
if ($query->unions && $query->aggregate) {
return $this->compileUnionAggregate($query);
}
// If the query does not have any columns set, we'll set the columns to the
// * character to just get all of the columns from the database. Then we
// can build the query and concatenate all the pieces together as one.
@@ -81,7 +85,7 @@ class Grammar extends BaseGrammar
// To compile the query, we'll spin through each component of the query and
// see if that component exists. If it does we'll just call the compiler
// function for the component which is responsible for making the SQL.
if (! is_null($query->$component)) {
if (isset($query->$component) && ! is_null($query->$component)) {
$method = 'compile'.ucfirst($component);
$sql[$component] = $this->$method($query, $query->$component);
@@ -159,7 +163,9 @@ class Grammar extends BaseGrammar
$nestedJoins = is_null($join->joins) ? '' : ' '.$this->compileJoins($query, $join->joins);
return trim("{$join->type} join {$table}{$nestedJoins} {$this->compileWheres($join)}");
$tableAndNestedJoins = is_null($join->joins) ? $table : '('.$table.$nestedJoins.')';
return trim("{$join->type} join {$tableAndNestedJoins} {$this->compileWheres($join)}");
})->implode(' ');
}
@@ -273,6 +279,24 @@ class Grammar extends BaseGrammar
return '1 = 1';
}
/**
* Compile a "where not in raw" clause.
*
* For safety, whereIntegerInRaw ensures this method is only used with integer values.
*
* @param \Illuminate\Database\Query\Builder $query
* @param array $where
* @return string
*/
protected function whereNotInRaw(Builder $query, $where)
{
if (! empty($where['values'])) {
return $this->wrap($where['column']).' not in ('.implode(', ', $where['values']).')';
}
return '1 = 1';
}
/**
* Compile a where in sub-select clause.
*
@@ -297,6 +321,24 @@ class Grammar extends BaseGrammar
return $this->wrap($where['column']).' not in ('.$this->compileSelect($where['query']).')';
}
/**
* Compile a "where in raw" clause.
*
* For safety, whereIntegerInRaw ensures this method is only used with integer values.
*
* @param \Illuminate\Database\Query\Builder $query
* @param array $where
* @return string
*/
protected function whereInRaw(Builder $query, $where)
{
if (! empty($where['values'])) {
return $this->wrap($where['column']).' in ('.implode(', ', $where['values']).')';
}
return '0 = 1';
}
/**
* Compile a "where null" clause.
*
@@ -606,6 +648,8 @@ class Grammar extends BaseGrammar
// clause into SQL based on the components that make it up from builder.
if ($having['type'] === 'Raw') {
return $having['boolean'].' '.$having['sql'];
} elseif ($having['type'] === 'between') {
return $this->compileHavingBetween($having);
}
return $this->compileBasicHaving($having);
@@ -626,6 +670,25 @@ class Grammar extends BaseGrammar
return $having['boolean'].' '.$column.' '.$having['operator'].' '.$parameter;
}
/**
* Compile a "between" having clause.
*
* @param array $having
* @return string
*/
protected function compileHavingBetween($having)
{
$between = $having['not'] ? 'not between' : 'between';
$column = $this->wrap($having['column']);
$min = $this->parameter(head($having['values']));
$max = $this->parameter(last($having['values']));
return $having['boolean'].' '.$column.' '.$between.' '.$min.' and '.$max;
}
/**
* Compile the "order by" portions of the query.
*
@@ -735,6 +798,21 @@ class Grammar extends BaseGrammar
return $conjunction.$union['query']->toSql();
}
/**
* Compile a union aggregate query into SQL.
*
* @param \Illuminate\Database\Query\Builder $query
* @return string
*/
protected function compileUnionAggregate(Builder $query)
{
$sql = $this->compileAggregate($query, $query->aggregate);
$query->aggregate = null;
return $sql.' from ('.$this->compileSelect($query).') as '.$this->wrapTable('temp_table');
}
/**
* Compile an exists statement into SQL.
*
@@ -791,6 +869,19 @@ class Grammar extends BaseGrammar
return $this->compileInsert($query, $values);
}
/**
* Compile an insert statement using a subquery into SQL.
*
* @param \Illuminate\Database\Query\Builder $query
* @param array $columns
* @param string $sql
* @return string
*/
public function compileInsertUsing(Builder $query, array $columns, string $sql)
{
return "insert into {$this->wrapTable($query->from)} ({$this->columnize($columns)}) $sql";
}
/**
* Compile an update statement into SQL.
*

View File

@@ -43,6 +43,10 @@ class MySqlGrammar extends Grammar
*/
public function compileSelect(Builder $query)
{
if ($query->unions && $query->aggregate) {
return $this->compileUnionAggregate($query);
}
$sql = parent::compileSelect($query);
if ($query->unions) {
@@ -74,7 +78,7 @@ class MySqlGrammar extends Grammar
*/
protected function compileJsonLength($column, $operator, $value)
{
list($field, $path) = $this->wrapJsonFieldAndPath($column);
[$field, $path] = $this->wrapJsonFieldAndPath($column);
return 'json_length('.$field.$path.') '.$operator.' '.$value;
}
@@ -194,7 +198,7 @@ class MySqlGrammar extends Grammar
*/
protected function compileJsonUpdateColumn($key, JsonExpression $value)
{
list($field, $path) = $this->wrapJsonFieldAndPath($key);
[$field, $path] = $this->wrapJsonFieldAndPath($key);
return "{$field} = json_set({$field}{$path}, {$value->getValue()})";
}

View File

@@ -360,7 +360,7 @@ class PostgresGrammar extends Grammar
*/
public function compileTruncate(Builder $query)
{
return ['truncate '.$this->wrapTable($query->from).' restart identity' => []];
return ['truncate '.$this->wrapTable($query->from).' restart identity cascade' => []];
}
/**

View File

@@ -46,6 +46,10 @@ class SQLiteGrammar extends Grammar
*/
public function compileSelect(Builder $query)
{
if ($query->unions && $query->aggregate) {
return $this->compileUnionAggregate($query);
}
$sql = parent::compileSelect($query);
if ($query->unions) {
@@ -153,7 +157,7 @@ class SQLiteGrammar extends Grammar
*/
protected function compileJsonLength($column, $operator, $value)
{
list($field, $path) = $this->wrapJsonFieldAndPath($column);
[$field, $path] = $this->wrapJsonFieldAndPath($column);
return 'json_array_length('.$field.$path.') '.$operator.' '.$value;
}
@@ -303,8 +307,6 @@ class SQLiteGrammar extends Grammar
$path = count($parts) > 1 ? ', '.$this->wrapJsonPath($parts[1]) : '';
$selector = 'json_extract('.$field.$path.')';
return $selector;
return 'json_extract('.$field.$path.')';
}
}

View File

@@ -126,7 +126,7 @@ class SqlServerGrammar extends Grammar
*/
protected function compileJsonContains($column, $value)
{
list($field, $path) = $this->wrapJsonFieldAndPath($column);
[$field, $path] = $this->wrapJsonFieldAndPath($column);
return $value.' in (select [value] from openjson('.$field.$path.'))';
}
@@ -152,7 +152,7 @@ class SqlServerGrammar extends Grammar
*/
protected function compileJsonLength($column, $operator, $value)
{
list($field, $path) = $this->wrapJsonFieldAndPath($column);
[$field, $path] = $this->wrapJsonFieldAndPath($column);
return '(select count(*) from openjson('.$field.$path.')) '.$operator.' '.$value;
}
@@ -349,7 +349,7 @@ class SqlServerGrammar extends Grammar
*/
public function compileUpdate(Builder $query, $values)
{
list($table, $alias) = $this->parseUpdateTable($query->from);
[$table, $alias] = $this->parseUpdateTable($query->from);
// Each one of the columns in the update statements needs to be wrapped in the
// keyword identifiers, also a place-holder needs to be created for each of

View File

@@ -24,6 +24,8 @@ class JsonExpression extends Expression
*
* @param mixed $value
* @return string
*
* @throws \InvalidArgumentException
*/
protected function getJsonBindingParameter($value)
{

View File

@@ -10,6 +10,30 @@ use Illuminate\Database\Schema\Grammars\SQLiteGrammar as SchemaGrammar;
class SQLiteConnection extends Connection
{
/**
* Create a new database connection instance.
*
* @param \PDO|\Closure $pdo
* @param string $database
* @param string $tablePrefix
* @param array $config
* @return void
*/
public function __construct($pdo, $database = '', $tablePrefix = '', array $config = [])
{
parent::__construct($pdo, $database, $tablePrefix, $config);
$enableForeignKeyConstraints = $this->getForeignKeyConstraintsConfigurationValue();
if ($enableForeignKeyConstraints === null) {
return;
}
$enableForeignKeyConstraints
? $this->getSchemaBuilder()->enableForeignKeyConstraints()
: $this->getSchemaBuilder()->disableForeignKeyConstraints();
}
/**
* Get the default query grammar instance.
*
@@ -63,4 +87,14 @@ class SQLiteConnection extends Connection
{
return new DoctrineDriver;
}
/**
* Get the database connection foreign key constraints configuration option.
*
* @return bool|null
*/
protected function getForeignKeyConstraintsConfigurationValue()
{
return $this->getConfig('foreign_key_constraints');
}
}

View File

@@ -134,6 +134,8 @@ class Blueprint
*
* @param \Illuminate\Database\Connection $connection
* @return void
*
* @throws \BadMethodCallException
*/
protected function ensureCommandsAreValid(Connection $connection)
{
@@ -249,7 +251,7 @@ class Blueprint
protected function creating()
{
return collect($this->commands)->contains(function ($command) {
return $command->name == 'create';
return $command->name === 'create';
});
}

View File

@@ -5,16 +5,21 @@ namespace Illuminate\Database\Schema;
use Illuminate\Support\Fluent;
/**
* Class ColumnDefinition.
* @method ColumnDefinition after(string $column) Place the column "after" another column (MySQL)
* @method ColumnDefinition always() Used as a modifier for generatedAs() (PostgreSQL)
* @method ColumnDefinition autoIncrement() Set INTEGER columns as auto-increment (primary key)
* @method ColumnDefinition change() Change the column
* @method ColumnDefinition charset(string $charset) Specify a character set for the column (MySQL)
* @method ColumnDefinition collation(string $collation) Specify a collation for the column (MySQL/SQL Server)
* @method ColumnDefinition comment(string $comment) Add a comment to the column (MySQL)
* @method ColumnDefinition default(string $value) Specify a "default" value for the column
* @method ColumnDefinition first(string $column) Place the column "first" in the table (MySQL)
* @method ColumnDefinition nullable($value = true) Allow NULL values to be inserted into the column
* @method ColumnDefinition storedAs($expression) Create a stored generated column (MySQL)
* @method ColumnDefinition default(mixed $value) Specify a "default" value for the column
* @method ColumnDefinition first() Place the column "first" in the table (MySQL)
* @method ColumnDefinition generatedAs(string $expression) Create a SQL compliant identity column (PostgreSQL)
* @method ColumnDefinition index() Add an index
* @method ColumnDefinition nullable(bool $value = true) Allow NULL values to be inserted into the column
* @method ColumnDefinition primary() Add a primary index
* @method ColumnDefinition spatialIndex() Add a spatial index
* @method ColumnDefinition storedAs(string $expression) Create a stored generated column (MySQL)
* @method ColumnDefinition unique() Add a unique index
* @method ColumnDefinition unsigned() Set the INTEGER column as UNSIGNED (MySQL)
* @method ColumnDefinition useCurrent() Set the TIMESTAMP column to use CURRENT_TIMESTAMP as default value
@@ -22,4 +27,5 @@ use Illuminate\Support\Fluent;
*/
class ColumnDefinition extends Fluent
{
//
}

View File

@@ -118,7 +118,7 @@ class ChangeColumn
$options['length'] = static::calculateDoctrineTextLength($fluent['type']);
}
if ($fluent['type'] == 'json') {
if ($fluent['type'] === 'json') {
$options['customSchemaOptions'] = [
'collation' => '',
];
@@ -206,6 +206,6 @@ class ChangeColumn
*/
protected static function mapFluentValueToDoctrine($option, $value)
{
return $option == 'notnull' ? ! $value : $value;
return $option === 'notnull' ? ! $value : $value;
}
}

View File

@@ -166,6 +166,10 @@ class PostgresGrammar extends Grammar
$sql .= $command->initiallyImmediate ? ' initially immediate' : ' initially deferred';
}
if (! is_null($command->notValid)) {
$sql .= ' not valid';
}
return $sql;
}
@@ -445,7 +449,7 @@ class PostgresGrammar extends Grammar
*/
protected function typeInteger(Fluent $column)
{
return $column->autoIncrement ? 'serial' : 'integer';
return $this->generatableColumn('integer', $column);
}
/**
@@ -456,7 +460,7 @@ class PostgresGrammar extends Grammar
*/
protected function typeBigInteger(Fluent $column)
{
return $column->autoIncrement ? 'bigserial' : 'bigint';
return $this->generatableColumn('bigint', $column);
}
/**
@@ -467,7 +471,7 @@ class PostgresGrammar extends Grammar
*/
protected function typeMediumInteger(Fluent $column)
{
return $column->autoIncrement ? 'serial' : 'integer';
return $this->generatableColumn('integer', $column);
}
/**
@@ -478,7 +482,7 @@ class PostgresGrammar extends Grammar
*/
protected function typeTinyInteger(Fluent $column)
{
return $column->autoIncrement ? 'smallserial' : 'smallint';
return $this->generatableColumn('smallint', $column);
}
/**
@@ -489,7 +493,42 @@ class PostgresGrammar extends Grammar
*/
protected function typeSmallInteger(Fluent $column)
{
return $column->autoIncrement ? 'smallserial' : 'smallint';
return $this->generatableColumn('smallint', $column);
}
/**
* Create the column definition for a generatable column.
*
* @param string $type
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function generatableColumn($type, Fluent $column)
{
if (! $column->autoIncrement && is_null($column->generatedAs)) {
return $type;
}
if ($column->autoIncrement && is_null($column->generatedAs)) {
return with([
'integer' => 'serial',
'bigint' => 'bigserial',
'smallint' => 'smallserial',
])[$type];
}
$options = '';
if (! is_bool($column->generatedAs) && ! empty($column->generatedAs)) {
$options = sprintf(' (%s)', $column->generatedAs);
}
return sprintf(
'%s generated %s as identity%s',
$type,
$column->always ? 'always' : 'by default',
$options
);
}
/**
@@ -854,7 +893,7 @@ class PostgresGrammar extends Grammar
*/
protected function modifyIncrement(Blueprint $blueprint, Fluent $column)
{
if (in_array($column->type, $this->serials) && $column->autoIncrement) {
if ((in_array($column->type, $this->serials) || ($column->generatedAs !== null)) && $column->autoIncrement) {
return ' primary key';
}
}

View File

@@ -12,7 +12,7 @@ class PostgresBuilder extends Builder
*/
public function hasTable($table)
{
list($schema, $table) = $this->parseSchemaAndTable($table);
[$schema, $table] = $this->parseSchemaAndTable($table);
$table = $this->connection->getTablePrefix().$table;
@@ -107,7 +107,7 @@ class PostgresBuilder extends Builder
*/
public function getColumnListing($table)
{
list($schema, $table) = $this->parseSchemaAndTable($table);
[$schema, $table] = $this->parseSchemaAndTable($table);
$table = $this->connection->getTablePrefix().$table;

View File

@@ -108,7 +108,7 @@ abstract class Seeder
/**
* Run the database seeds.
*
* @return void
* @return dynamic
*
* @throws \InvalidArgumentException
*/

View File

@@ -25,7 +25,7 @@ class SqlServerConnection extends Connection
public function transaction(Closure $callback, $attempts = 1)
{
for ($a = 1; $a <= $attempts; $a++) {
if ($this->getDriverName() == 'sqlsrv') {
if ($this->getDriverName() === 'sqlsrv') {
return parent::transaction($callback);
}

View File

@@ -67,7 +67,7 @@ class Encrypter implements EncrypterContract
*/
public static function generateKey($cipher)
{
return random_bytes($cipher == 'AES-128-CBC' ? 16 : 32);
return random_bytes($cipher === 'AES-128-CBC' ? 16 : 32);
}
/**

View File

@@ -195,7 +195,7 @@ class Dispatcher implements DispatcherContract
// When the given "event" is actually an object we will assume it is an event
// object and use the class as the event name and this event itself as the
// payload to the handler, which makes object based events quite simple.
list($event, $payload) = $this->parseEventAndPayload(
[$event, $payload] = $this->parseEventAndPayload(
$event, $payload
);
@@ -238,7 +238,7 @@ class Dispatcher implements DispatcherContract
protected function parseEventAndPayload($event, $payload)
{
if (is_object($event)) {
list($payload, $event) = [[$event], get_class($event)];
[$payload, $event] = [[$event], get_class($event)];
}
return [$event, Arr::wrap($payload)];
@@ -389,7 +389,7 @@ class Dispatcher implements DispatcherContract
*/
protected function createClassCallable($listener)
{
list($class, $method) = $this->parseClassCallable($listener);
[$class, $method] = $this->parseClassCallable($listener);
if ($this->handlerShouldBeQueued($class)) {
return $this->createQueuedHandlerCallable($class, $method);
@@ -472,7 +472,7 @@ class Dispatcher implements DispatcherContract
*/
protected function queueHandler($class, $method, $arguments)
{
list($listener, $job) = $this->createListenerAndJob($class, $method, $arguments);
[$listener, $job] = $this->createListenerAndJob($class, $method, $arguments);
$connection = $this->resolveQueue()->connection(
$listener->connection ?? null

View File

@@ -122,6 +122,30 @@ class Filesystem
return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
}
/**
* Write the contents of a file, replacing it atomically if it already exists.
*
* @param string $path
* @param string $content
* @return void
*/
public function replace($path, $content)
{
// If the path already exists and is a symlink, get the real path...
clearstatcache(true, $path);
$path = realpath($path) ?: $path;
$tempPath = tempnam(dirname($path), basename($path));
// Fix permissions of tempPath because `tempnam()` creates it with permissions set to 0600...
chmod($tempPath, 0777 - umask());
file_put_contents($tempPath, $content);
rename($tempPath, $path);
}
/**
* Prepend to a file.
*

View File

@@ -29,7 +29,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
*
* @var string
*/
const VERSION = '5.7.8';
const VERSION = '5.7.19';
/**
* The base path for the Laravel installation.
@@ -184,9 +184,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
protected function registerBaseServiceProviders()
{
$this->register(new EventServiceProvider($this));
$this->register(new LogServiceProvider($this));
$this->register(new RoutingServiceProvider($this));
}
@@ -201,11 +199,11 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
$this->hasBeenBootstrapped = true;
foreach ($bootstrappers as $bootstrapper) {
$this['events']->fire('bootstrapping: '.$bootstrapper, [$this]);
$this['events']->dispatch('bootstrapping: '.$bootstrapper, [$this]);
$this->make($bootstrapper)->bootstrap($this);
$this['events']->fire('bootstrapped: '.$bootstrapper, [$this]);
$this['events']->dispatch('bootstrapped: '.$bootstrapper, [$this]);
}
}
@@ -494,7 +492,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
*/
public function isLocal()
{
return $this['env'] == 'local';
return $this['env'] === 'local';
}
/**
@@ -517,6 +515,10 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
*/
public function runningInConsole()
{
if (isset($_ENV['APP_RUNNING_IN_CONSOLE'])) {
return $_ENV['APP_RUNNING_IN_CONSOLE'] === 'true';
}
return php_sapi_name() === 'cli' || php_sapi_name() === 'phpdbg';
}
@@ -889,7 +891,7 @@ class Application extends Container implements ApplicationContract, HttpKernelIn
*/
public function getCachedConfigPath()
{
return $this->bootstrapPath().'/cache/config.php';
return $_ENV['APP_CONFIG_CACHE'] ?? $this->bootstrapPath().'/cache/config.php';
}
/**

View File

@@ -18,7 +18,7 @@ trait AuthorizesRequests
*/
public function authorize($ability, $arguments = [])
{
list($ability, $arguments) = $this->parseAbilityAndArguments($ability, $arguments);
[$ability, $arguments] = $this->parseAbilityAndArguments($ability, $arguments);
return app(Gate::class)->authorize($ability, $arguments);
}
@@ -35,7 +35,7 @@ trait AuthorizesRequests
*/
public function authorizeForUser($user, $ability, $arguments = [])
{
list($ability, $arguments) = $this->parseAbilityAndArguments($ability, $arguments);
[$ability, $arguments] = $this->parseAbilityAndArguments($ability, $arguments);
return app(Gate::class)->forUser($user)->authorize($ability, $arguments);
}

View File

@@ -58,10 +58,12 @@ trait AuthenticatesUsers
*
* @param \Illuminate\Http\Request $request
* @return void
*
* @throws \Illuminate\Validation\ValidationException
*/
protected function validateLogin(Request $request)
{
$this->validate($request, [
$request->validate([
$this->username() => 'required|string',
'password' => 'required|string',
]);

View File

@@ -37,7 +37,7 @@ trait ResetsPasswords
*/
public function reset(Request $request)
{
$this->validate($request, $this->rules(), $this->validationErrorMessages());
$request->validate($this->rules(), $this->validationErrorMessages());
// Here we will attempt to reset the user's password. If it is successful we
// will update the password on an actual user model and persist it to the

View File

@@ -47,7 +47,7 @@ trait SendsPasswordResetEmails
*/
protected function validateEmail(Request $request)
{
$this->validate($request, ['email' => 'required|email']);
$request->validate(['email' => 'required|email']);
}
/**

View File

@@ -4,6 +4,7 @@ namespace Illuminate\Foundation\Auth;
use Illuminate\Http\Request;
use Illuminate\Auth\Events\Verified;
use Illuminate\Auth\Access\AuthorizationException;
trait VerifiesEmails
{
@@ -27,11 +28,15 @@ trait VerifiesEmails
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
* @throws \Illuminate\Auth\Access\AuthorizationException
*/
public function verify(Request $request)
{
if ($request->route('id') == $request->user()->getKey() &&
$request->user()->markEmailAsVerified()) {
if ($request->route('id') != $request->user()->getKey()) {
throw new AuthorizationException;
}
if ($request->user()->markEmailAsVerified()) {
event(new Verified($request->user()));
}

View File

@@ -37,7 +37,7 @@ class ChannelMakeCommand extends GeneratorCommand
{
return str_replace(
'DummyUser',
class_basename(config('auth.providers.users.model')),
class_basename($this->userProviderModel()),
parent::buildClass($name)
);
}

View File

@@ -48,12 +48,15 @@ class ConfigCacheCommand extends Command
* Execute the console command.
*
* @return void
*
* @throws \LogicException
*/
public function handle()
{
$this->call('config:clear');
$config = $this->getFreshConfiguration();
$configPath = $this->laravel->getCachedConfigPath();
$this->files->put(

View File

@@ -98,7 +98,7 @@ class Kernel implements KernelContract
*/
protected function defineConsoleSchedule()
{
$this->app->singleton(Schedule::class, function ($app) {
$this->app->singleton(Schedule::class, function () {
return new Schedule;
});
@@ -354,7 +354,7 @@ class Kernel implements KernelContract
}
/**
* Report the exception to the exception handler.
* Render the given exception.
*
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @param \Exception $e

View File

@@ -71,7 +71,7 @@ class ModelMakeCommand extends GeneratorCommand
$this->call('make:factory', [
'name' => "{$factory}Factory",
'--model' => $this->argument('name'),
'--model' => $this->qualifyClass($this->getNameInput()),
]);
}

View File

@@ -54,13 +54,15 @@ class PolicyMakeCommand extends GeneratorCommand
*/
protected function replaceUserNamespace($stub)
{
if (! config('auth.providers.users.model')) {
$model = $this->userProviderModel();
if (! $model) {
return $stub;
}
return str_replace(
$this->rootNamespace().'User',
config('auth.providers.users.model'),
$model,
$stub
);
}
@@ -90,7 +92,7 @@ class PolicyMakeCommand extends GeneratorCommand
$model = class_basename(trim($model, '\\'));
$dummyUser = class_basename(config('auth.providers.users.model'));
$dummyUser = class_basename($this->userProviderModel());
$dummyModel = Str::camel($model) === 'user' ? 'model' : $model;

View File

@@ -12,7 +12,9 @@ class PresetCommand extends Command
*
* @var string
*/
protected $signature = 'preset { type : The preset type (none, bootstrap, vue, react) }';
protected $signature = 'preset
{ type : The preset type (none, bootstrap, vue, react) }
{ --option=* : Pass an option to the preset command }';
/**
* The console command description.
@@ -25,6 +27,8 @@ class PresetCommand extends Command
* Execute the console command.
*
* @return void
*
* @throws \InvalidArgumentException
*/
public function handle()
{

View File

@@ -55,5 +55,6 @@ class None extends Preset
{
file_put_contents(resource_path('sass/app.scss'), ''.PHP_EOL);
copy(__DIR__.'/none-stubs/app.js', resource_path('js/app.js'));
copy(__DIR__.'/none-stubs/bootstrap.js', resource_path('js/bootstrap.js'));
}
}

View File

@@ -30,7 +30,7 @@ class Vue extends Preset
*/
protected static function updatePackageArray(array $packages)
{
return ['vue' => '^2.5.7'] + Arr::except($packages, [
return ['vue' => '^2.5.17'] + Arr::except($packages, [
'babel-preset-react',
'react',
'react-dom',

View File

@@ -0,0 +1,43 @@
window._ = require('lodash');
/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the
* CSRF token as a header based on the value of the "XSRF" token cookie.
*/
window.axios = require('axios');
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
/**
* Next we will register the CSRF Token as a common header with Axios so that
* all outgoing HTTP requests automatically have it attached. This is just
* a simple convenience so we don't have to attach every token manually.
*/
let token = document.head.querySelector('meta[name="csrf-token"]');
if (token) {
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}
/**
* Echo exposes an expressive API for subscribing to channels and listening
* for events that are broadcast by Laravel. Echo and event broadcasting
* allows your team to easily build robust real-time web applications.
*/
// import Echo from 'laravel-echo'
// window.Pusher = require('pusher-js');
// window.Echo = new Echo({
// broadcaster: 'pusher',
// key: process.env.MIX_PUSHER_APP_KEY,
// cluster: process.env.MIX_PUSHER_APP_CLUSTER,
// encrypted: true
// });

View File

@@ -1,4 +1,4 @@
let mix = require('laravel-mix');
const mix = require('laravel-mix');
/*
|--------------------------------------------------------------------------

View File

@@ -1,4 +1,4 @@
let mix = require('laravel-mix');
const mix = require('laravel-mix');
/*
|--------------------------------------------------------------------------

View File

@@ -90,7 +90,7 @@ class VendorPublishCommand extends Command
return;
}
list($this->provider, $this->tags) = [
[$this->provider, $this->tags] = [
$this->option('provider'), (array) $this->option('tag'),
];
@@ -140,11 +140,11 @@ class VendorPublishCommand extends Command
*/
protected function parseChoice($choice)
{
list($type, $value) = explode(': ', strip_tags($choice));
[$type, $value] = explode(': ', strip_tags($choice));
if ($type == 'Provider') {
if ($type === 'Provider') {
$this->provider = $value;
} elseif ($type == 'Tag') {
} elseif ($type === 'Tag') {
$this->tags = [$value];
}
}

View File

@@ -0,0 +1,11 @@
@extends('errors::illustrated-layout')
@section('code', '401')
@section('title', __('Unauthorized'))
@section('image')
<div style="background-image: url({{ asset('/svg/403.svg') }});" class="absolute pin bg-cover bg-no-repeat md:bg-left lg:bg-center">
</div>
@endsection
@section('message', __('Sorry, you are not authorized to access this page.'))

View File

@@ -1,11 +1,11 @@
@extends('errors::illustrated-layout')
@section('code', '403')
@section('title', __('Unauthorized'))
@section('title', __('Forbidden'))
@section('image')
<div style="background-image: url('/svg/403.svg');" class="absolute pin bg-cover bg-no-repeat md:bg-left lg:bg-center">
<div style="background-image: url({{ asset('/svg/403.svg') }});" class="absolute pin bg-cover bg-no-repeat md:bg-left lg:bg-center">
</div>
@endsection
@section('message', __('Sorry, you are not authorized to access this page.'))
@section('message', __($exception->getMessage() ?: __('Sorry, you are forbidden from accessing this page.')))

View File

@@ -4,7 +4,7 @@
@section('title', __('Page Not Found'))
@section('image')
<div style="background-image: url('/svg/404.svg');" class="absolute pin bg-cover bg-no-repeat md:bg-left lg:bg-center">
<div style="background-image: url({{ asset('/svg/404.svg') }});" class="absolute pin bg-cover bg-no-repeat md:bg-left lg:bg-center">
</div>
@endsection

View File

@@ -4,7 +4,7 @@
@section('title', __('Page Expired'))
@section('image')
<div style="background-image: url('/svg/403.svg');" class="absolute pin bg-cover bg-no-repeat md:bg-left lg:bg-center">
<div style="background-image: url({{ asset('/svg/403.svg') }});" class="absolute pin bg-cover bg-no-repeat md:bg-left lg:bg-center">
</div>
@endsection

View File

@@ -4,7 +4,7 @@
@section('title', __('Too Many Requests'))
@section('image')
<div style="background-image: url('/svg/403.svg');" class="absolute pin bg-cover bg-no-repeat md:bg-left lg:bg-center">
<div style="background-image: url({{ asset('/svg/403.svg') }});" class="absolute pin bg-cover bg-no-repeat md:bg-left lg:bg-center">
</div>
@endsection

View File

@@ -4,7 +4,7 @@
@section('title', __('Error'))
@section('image')
<div style="background-image: url('/svg/500.svg');" class="absolute pin bg-cover bg-no-repeat md:bg-left lg:bg-center">
<div style="background-image: url({{ asset('/svg/500.svg') }});" class="absolute pin bg-cover bg-no-repeat md:bg-left lg:bg-center">
</div>
@endsection

View File

@@ -4,8 +4,8 @@
@section('title', __('Service Unavailable'))
@section('image')
<div style="background-image: url('/svg/503.svg');" class="absolute pin bg-cover bg-no-repeat md:bg-left lg:bg-center">
<div style="background-image: url({{ asset('/svg/503.svg') }});" class="absolute pin bg-cover bg-no-repeat md:bg-left lg:bg-center">
</div>
@endsection
@section('message', __($exception->getMessage() ?: 'Sorry, we are doing some maintenance. Please check back soon.'))
@section('message', __($exception->getMessage() ?: __('Sorry, we are doing some maintenance. Please check back soon.')))

Some files were not shown because too many files have changed in this diff Show More