Skip to content

Commit

Permalink
Merge branch '10.x'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Illuminate/View/ComponentAttributeBag.php
#	tests/View/Blade/BladeEchoHandlerTest.php
  • Loading branch information
driesvints committed Jan 9, 2024
2 parents 3a530f3 + ab9f7c4 commit 1ee9fdb
Show file tree
Hide file tree
Showing 36 changed files with 480 additions and 86 deletions.
8 changes: 4 additions & 4 deletions src/Illuminate/Cache/DynamoDbStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public function add($key, $value, $seconds)
],
'ExpressionAttributeValues' => [
':now' => [
'N' => (string) Carbon::now()->getTimestamp(),
'N' => (string) $this->currentTime(),
],
],
]);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -469,7 +469,7 @@ protected function toTimestamp($seconds)
{
return $seconds > 0
? $this->availableAt($seconds)
: Carbon::now()->getTimestamp();
: $this->currentTime();
}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/Illuminate/Cache/FileStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 1 addition & 3 deletions src/Illuminate/Collections/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

/**
Expand Down
50 changes: 45 additions & 5 deletions src/Illuminate/Database/DatabaseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Casts/AsArrayObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 11 additions & 11 deletions src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Builder implements BuilderContract
/**
* The columns that should be returned.
*
* @var array
* @var array|null
*/
public $columns;

Expand Down Expand Up @@ -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
Expand All @@ -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
*/
Expand All @@ -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
Expand All @@ -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
*/
Expand All @@ -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
Expand Down Expand Up @@ -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
*/
Expand All @@ -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
Expand Down Expand Up @@ -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
*/
Expand All @@ -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
Expand All @@ -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
*/
Expand Down
3 changes: 3 additions & 0 deletions src/Illuminate/Database/Schema/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
12 changes: 12 additions & 0 deletions src/Illuminate/Foundation/Console/AboutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
}
}
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions src/Illuminate/Foundation/Testing/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -239,6 +240,7 @@ protected function tearDown(): void
$this->originalExceptionHandler = null;
$this->originalDeprecationHandler = null;

AboutCommand::flushState();
Artisan::forgetBootstrappers();
Component::flushCache();
Component::forgetComponentsResolver();
Expand Down
22 changes: 21 additions & 1 deletion src/Illuminate/Foundation/Vite.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
<nav role="navigation" aria-label="Pagination Navigation" class="flex justify-between">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<span class="relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5 rounded-md">
<span class="relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5 rounded-md dark:text-gray-600 dark:bg-gray-800 dark:border-gray-600">
{!! __('pagination.previous') !!}
</span>
@else
<a href="{{ $paginator->previousPageUrl() }}" rel="prev" class="relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 leading-5 rounded-md hover:text-gray-500 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-700 transition ease-in-out duration-150">
<a href="{{ $paginator->previousPageUrl() }}" rel="prev" class="relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 leading-5 rounded-md hover:text-gray-500 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-700 transition ease-in-out duration-150 dark:bg-gray-800 dark:border-gray-600 dark:text-gray-300 dark:focus:border-blue-700 dark:active:bg-gray-700 dark:active:text-gray-300">
{!! __('pagination.previous') !!}
</a>
@endif

{{-- Next Page Link --}}
@if ($paginator->hasMorePages())
<a href="{{ $paginator->nextPageUrl() }}" rel="next" class="relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 leading-5 rounded-md hover:text-gray-500 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-700 transition ease-in-out duration-150">
<a href="{{ $paginator->nextPageUrl() }}" rel="next" class="relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 leading-5 rounded-md hover:text-gray-500 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-700 transition ease-in-out duration-150 dark:bg-gray-800 dark:border-gray-600 dark:text-gray-300 dark:focus:border-blue-700 dark:active:bg-gray-700 dark:active:text-gray-300">
{!! __('pagination.next') !!}
</a>
@else
<span class="relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5 rounded-md">
<span class="relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5 rounded-md dark:text-gray-600 dark:bg-gray-800 dark:border-gray-600">
{!! __('pagination.next') !!}
</span>
@endif
Expand Down
Loading

0 comments on commit 1ee9fdb

Please sign in to comment.