diff --git a/src/Illuminate/Cache/DynamoDbStore.php b/src/Illuminate/Cache/DynamoDbStore.php index 8e2fda7ff55e..31b8dc48ef01 100644 --- a/src/Illuminate/Cache/DynamoDbStore.php +++ b/src/Illuminate/Cache/DynamoDbStore.php @@ -285,7 +285,7 @@ public function add($key, $value, $seconds) ], 'ExpressionAttributeValues' => [ ':now' => [ - 'N' => (string) Carbon::now()->getTimestamp(), + 'N' => (string) $this->currentTime(), ], ], ]); @@ -326,7 +326,7 @@ public function increment($key, $value = 1) ], 'ExpressionAttributeValues' => [ ':now' => [ - 'N' => (string) Carbon::now()->getTimestamp(), + 'N' => (string) $this->currentTime(), ], ':amount' => [ 'N' => (string) $value, @@ -371,7 +371,7 @@ public function decrement($key, $value = 1) ], 'ExpressionAttributeValues' => [ ':now' => [ - 'N' => (string) Carbon::now()->getTimestamp(), + 'N' => (string) $this->currentTime(), ], ':amount' => [ 'N' => (string) $value, @@ -469,7 +469,7 @@ protected function toTimestamp($seconds) { return $seconds > 0 ? $this->availableAt($seconds) - : Carbon::now()->getTimestamp(); + : $this->currentTime(); } /** diff --git a/src/Illuminate/Cache/FileStore.php b/src/Illuminate/Cache/FileStore.php index b18e568f6407..9d5e2e95c872 100755 --- a/src/Illuminate/Cache/FileStore.php +++ b/src/Illuminate/Cache/FileStore.php @@ -290,9 +290,11 @@ protected function getPayload($key) // just return null. Otherwise, we'll get the contents of the file and get // the expiration UNIX timestamps from the start of the file's contents. try { - $expire = substr( - $contents = $this->files->get($path, true), 0, 10 - ); + if (is_null($contents = $this->files->get($path, true))) { + return $this->emptyPayload(); + } + + $expire = substr($contents, 0, 10); } catch (Exception) { return $this->emptyPayload(); } diff --git a/src/Illuminate/Collections/Arr.php b/src/Illuminate/Collections/Arr.php index c14465c6b3fa..d1e4a40ae686 100644 --- a/src/Illuminate/Collections/Arr.php +++ b/src/Illuminate/Collections/Arr.php @@ -476,9 +476,7 @@ public static function keyBy($array, $keyBy) */ public static function prependKeysWith($array, $prependWith) { - return Collection::make($array)->mapWithKeys(function ($item, $key) use ($prependWith) { - return [$prependWith.$key => $item]; - })->all(); + return static::mapWithKeys($array, fn ($item, $key) => [$prependWith.$key => $item]); } /** diff --git a/src/Illuminate/Database/DatabaseManager.php b/src/Illuminate/Database/DatabaseManager.php index 84602917ea1a..daefffee9f88 100755 --- a/src/Illuminate/Database/DatabaseManager.php +++ b/src/Illuminate/Database/DatabaseManager.php @@ -101,16 +101,39 @@ public function connection($name = null) $this->makeConnection($database), $type ); - if ($this->app->bound('events')) { - $this->app['events']->dispatch( - new ConnectionEstablished($this->connections[$name]) - ); - } + $this->dispatchConnectionEstablishedEvent($this->connections[$name]); } return $this->connections[$name]; } + /** + * Get a database connection instance from the given configuration. + * + * @param string $name + * @param array $config + * @param bool $force + * @return \Illuminate\Database\ConnectionInterface + */ + public function connectUsing(string $name, array $config, bool $force = false) + { + if ($force) { + $this->purge($name); + } + + if (isset($this->connections[$name])) { + throw new RuntimeException("Cannot establish connection [$name] because another connection with that name already exists."); + } + + $connection = $this->configure( + $this->factory->make($config, $name), null + ); + + $this->dispatchConnectionEstablishedEvent($connection); + + return tap($connection, fn ($connection) => $this->connections[$name] = $connection); + } + /** * Parse the connection into an array of the name and read / write type. * @@ -209,6 +232,23 @@ protected function configure(Connection $connection, $type) return $connection; } + /** + * Dispatch the ConnectionEstablished event if the event dispatcher is available. + * + * @param \Illuminate\Database\Connection $connection + * @return void + */ + protected function dispatchConnectionEstablishedEvent(Connection $connection) + { + if (! $this->app->bound('events')) { + return; + } + + $this->app['events']->dispatch( + new ConnectionEstablished($connection) + ); + } + /** * Prepare the read / write mode for database connection instance. * diff --git a/src/Illuminate/Database/Eloquent/Casts/AsArrayObject.php b/src/Illuminate/Database/Eloquent/Casts/AsArrayObject.php index 2ee6b56e0901..5ee80d0bb4f0 100644 --- a/src/Illuminate/Database/Eloquent/Casts/AsArrayObject.php +++ b/src/Illuminate/Database/Eloquent/Casts/AsArrayObject.php @@ -25,7 +25,7 @@ public function get($model, $key, $value, $attributes) $data = Json::decode($attributes[$key]); - return is_array($data) ? new ArrayObject($data) : null; + return is_array($data) ? new ArrayObject($data, ArrayObject::ARRAY_AS_PROPS) : null; } public function set($model, $key, $value, $attributes) diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php index ba9ce025c45a..694c8c720db0 100755 --- a/src/Illuminate/Database/Query/Builder.php +++ b/src/Illuminate/Database/Query/Builder.php @@ -83,7 +83,7 @@ class Builder implements BuilderContract /** * The columns that should be returned. * - * @var array + * @var array|null */ public $columns; @@ -1380,7 +1380,7 @@ public function orWhereNotNull($column) * Add a "where date" statement to the query. * * @param \Illuminate\Contracts\Database\Query\Expression|string $column - * @param string $operator + * @param \DateTimeInterface|string|null $operator * @param \DateTimeInterface|string|null $value * @param string $boolean * @return $this @@ -1404,7 +1404,7 @@ public function whereDate($column, $operator, $value = null, $boolean = 'and') * Add an "or where date" statement to the query. * * @param \Illuminate\Contracts\Database\Query\Expression|string $column - * @param string $operator + * @param \DateTimeInterface|string|null $operator * @param \DateTimeInterface|string|null $value * @return $this */ @@ -1421,7 +1421,7 @@ public function orWhereDate($column, $operator, $value = null) * Add a "where time" statement to the query. * * @param \Illuminate\Contracts\Database\Query\Expression|string $column - * @param string $operator + * @param \DateTimeInterface|string|null $operator * @param \DateTimeInterface|string|null $value * @param string $boolean * @return $this @@ -1445,7 +1445,7 @@ public function whereTime($column, $operator, $value = null, $boolean = 'and') * Add an "or where time" statement to the query. * * @param \Illuminate\Contracts\Database\Query\Expression|string $column - * @param string $operator + * @param \DateTimeInterface|string|null $operator * @param \DateTimeInterface|string|null $value * @return $this */ @@ -1462,7 +1462,7 @@ public function orWhereTime($column, $operator, $value = null) * Add a "where day" statement to the query. * * @param \Illuminate\Contracts\Database\Query\Expression|string $column - * @param string $operator + * @param \DateTimeInterface|string|int|null $operator * @param \DateTimeInterface|string|int|null $value * @param string $boolean * @return $this @@ -1490,7 +1490,7 @@ public function whereDay($column, $operator, $value = null, $boolean = 'and') * Add an "or where day" statement to the query. * * @param \Illuminate\Contracts\Database\Query\Expression|string $column - * @param string $operator + * @param \DateTimeInterface|string|int|null $operator * @param \DateTimeInterface|string|int|null $value * @return $this */ @@ -1507,7 +1507,7 @@ public function orWhereDay($column, $operator, $value = null) * Add a "where month" statement to the query. * * @param \Illuminate\Contracts\Database\Query\Expression|string $column - * @param string $operator + * @param \DateTimeInterface|string|int|null $operator * @param \DateTimeInterface|string|int|null $value * @param string $boolean * @return $this @@ -1535,7 +1535,7 @@ public function whereMonth($column, $operator, $value = null, $boolean = 'and') * Add an "or where month" statement to the query. * * @param \Illuminate\Contracts\Database\Query\Expression|string $column - * @param string $operator + * @param \DateTimeInterface|string|int|null $operator * @param \DateTimeInterface|string|int|null $value * @return $this */ @@ -1552,7 +1552,7 @@ public function orWhereMonth($column, $operator, $value = null) * Add a "where year" statement to the query. * * @param \Illuminate\Contracts\Database\Query\Expression|string $column - * @param string $operator + * @param \DateTimeInterface|string|int|null $operator * @param \DateTimeInterface|string|int|null $value * @param string $boolean * @return $this @@ -1576,7 +1576,7 @@ public function whereYear($column, $operator, $value = null, $boolean = 'and') * Add an "or where year" statement to the query. * * @param \Illuminate\Contracts\Database\Query\Expression|string $column - * @param string $operator + * @param \DateTimeInterface|string|int|null $operator * @param \DateTimeInterface|string|int|null $value * @return $this */ diff --git a/src/Illuminate/Database/Schema/Builder.php b/src/Illuminate/Database/Schema/Builder.php index 94d655c0f1ca..c1a55cc49b50 100755 --- a/src/Illuminate/Database/Schema/Builder.php +++ b/src/Illuminate/Database/Schema/Builder.php @@ -5,11 +5,14 @@ use Closure; use Illuminate\Container\Container; use Illuminate\Database\Connection; +use Illuminate\Support\Traits\Macroable; use InvalidArgumentException; use LogicException; class Builder { + use Macroable; + /** * The database connection instance. * diff --git a/src/Illuminate/Foundation/Console/AboutCommand.php b/src/Illuminate/Foundation/Console/AboutCommand.php index b393c60f1d6a..20c24e8e7c11 100644 --- a/src/Illuminate/Foundation/Console/AboutCommand.php +++ b/src/Illuminate/Foundation/Console/AboutCommand.php @@ -302,4 +302,16 @@ protected function toSearchKeyword(string $value) { return (string) Str::of($value)->lower()->snake(); } + + /** + * Flush the registered about data. + * + * @return void + */ + public static function flushState() + { + static::$data = []; + + static::$customDataResolvers = []; + } } diff --git a/src/Illuminate/Foundation/Exceptions/Handler.php b/src/Illuminate/Foundation/Exceptions/Handler.php index facb54fe54c1..126d98ba9436 100644 --- a/src/Illuminate/Foundation/Exceptions/Handler.php +++ b/src/Illuminate/Foundation/Exceptions/Handler.php @@ -933,7 +933,7 @@ public function renderForConsole($output, Throwable $e) $message .= '. Did you mean one of these?'; with(new Error($output))->render($message); - with(new BulletList($output))->render($e->getAlternatives()); + with(new BulletList($output))->render($alternatives); $output->writeln(''); } else { diff --git a/src/Illuminate/Foundation/Testing/TestCase.php b/src/Illuminate/Foundation/Testing/TestCase.php index 37825063be0a..ac944c10a17c 100644 --- a/src/Illuminate/Foundation/Testing/TestCase.php +++ b/src/Illuminate/Foundation/Testing/TestCase.php @@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Application; use Illuminate\Foundation\Bootstrap\HandleExceptions; +use Illuminate\Foundation\Console\AboutCommand; use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull; use Illuminate\Foundation\Http\Middleware\TrimStrings; use Illuminate\Queue\Queue; @@ -239,6 +240,7 @@ protected function tearDown(): void $this->originalExceptionHandler = null; $this->originalDeprecationHandler = null; + AboutCommand::flushState(); Artisan::forgetBootstrappers(); Component::flushCache(); Component::forgetComponentsResolver(); diff --git a/src/Illuminate/Foundation/Vite.php b/src/Illuminate/Foundation/Vite.php index 9c0a24d04f98..a81ca1616b96 100644 --- a/src/Illuminate/Foundation/Vite.php +++ b/src/Illuminate/Foundation/Vite.php @@ -55,6 +55,13 @@ class Vite implements Htmlable */ protected $manifestFilename = 'manifest.json'; + /** + * The custom asset path resolver. + * + * @var callable|null + */ + protected $assetPathResolver = null; + /** * The script tag attributes resolvers. * @@ -160,6 +167,19 @@ public function useManifestFilename($filename) return $this; } + /** + * Resolve asset paths using the provided resolver. + * + * @param callable|null $urlResolver + * @return $this + */ + public function createAssetPathsUsing($resolver) + { + $this->assetPathResolver = $resolver; + + return $this; + } + /** * Get the Vite "hot" file path. * @@ -688,7 +708,7 @@ public function content($asset, $buildDirectory = null) */ protected function assetPath($path, $secure = null) { - return asset($path, $secure); + return ($this->assetPathResolver ?? asset(...))($path, $secure); } /** diff --git a/src/Illuminate/Http/Resources/ConditionallyLoadsAttributes.php b/src/Illuminate/Http/Resources/ConditionallyLoadsAttributes.php index 3f25ca052407..9940c3e0cea6 100644 --- a/src/Illuminate/Http/Resources/ConditionallyLoadsAttributes.php +++ b/src/Illuminate/Http/Resources/ConditionallyLoadsAttributes.php @@ -320,6 +320,10 @@ public function whenCounted($relationship, $value = null, $default = null) */ public function whenAggregated($relationship, $column, $aggregate, $value = null, $default = null) { + if (func_num_args() < 5) { + $default = new MissingValue; + } + $attribute = (string) Str::of($relationship)->snake()->append('_')->append($aggregate)->append('_')->finish($column); if (! isset($this->resource->getAttributes()[$attribute])) { diff --git a/src/Illuminate/Pagination/resources/views/simple-tailwind.blade.php b/src/Illuminate/Pagination/resources/views/simple-tailwind.blade.php index 6872cca360d5..ea02400f468c 100644 --- a/src/Illuminate/Pagination/resources/views/simple-tailwind.blade.php +++ b/src/Illuminate/Pagination/resources/views/simple-tailwind.blade.php @@ -2,22 +2,22 @@