From 047eb0f671cc9aced99f76e670c07f343ceecc71 Mon Sep 17 00:00:00 2001 From: "S.a Mahmoudzadeh" <36761585+saMahmoudzadeh@users.noreply.github.com> Date: Wed, 24 Apr 2024 23:20:22 +0330 Subject: [PATCH 001/325] fix grammar (#9597) --- context.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/context.md b/context.md index 18a6a4569ce..4f70e34ca6f 100644 --- a/context.md +++ b/context.md @@ -155,7 +155,7 @@ Context::when( ### Stacks -Context offers the ability to create "stacks", which are lists of data stored in the order that they where added. You can add information to a stack by invoking the `push` method: +Context offers the ability to create "stacks", which are lists of data stored in the order that they were added. You can add information to a stack by invoking the `push` method: ```php use Illuminate\Support\Facades\Context; From 303e0d608f86f80b3f9abdbd77d1e44654d2f4fa Mon Sep 17 00:00:00 2001 From: NRDev <144210397+nrdevau@users.noreply.github.com> Date: Thu, 25 Apr 2024 07:12:54 +1000 Subject: [PATCH 002/325] [11.x] Update authorization.md - include Vue JS approaches (#9596) * Update authorization.md - include Vue JS approaches Would be great to see the Inertia approach when using authorization in the frontend. I'm not super happy about the Warning copy, but figured this would be a good way to get the discussion happening around this * formatting --------- Co-authored-by: Taylor Otwell --- authorization.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/authorization.md b/authorization.md index 6c1c79b202b..a817390e487 100644 --- a/authorization.md +++ b/authorization.md @@ -22,6 +22,7 @@ - [Via Middleware](#via-middleware) - [Via Blade Templates](#via-blade-templates) - [Supplying Additional Context](#supplying-additional-context) +- [Authorization & Inertia](#authorization-and-inertia) ## Introduction @@ -728,3 +729,45 @@ When attempting to determine if the authenticated user can update a given post, return redirect('/posts'); } + + +## Authorization & Inertia + +Although authorization must always be handled on the server, it can often be convenient to provide your frontend application with authorization data in order to properly render your application's UI. Laravel does not define a required convention for exposing authorization information to an Inertia powered frontend. + +However, if you are using one of Laravel's Inertia-based [starter kits](/docs/{{version}}/starter-kits), your application already contains a `HandleInertiaRequests` middleware. Within this middleware's `share` method, you may return shared data that will provided to all Inertia pages in your application. This shared data can serve as a convenient location to define authorization information for the user: + +```php + + */ + public function share(Request $request) + { + return [ + ...parent::share($request), + 'auth' => [ + 'user' => $request->user(), + 'permissions' => [ + 'post' => [ + 'create' => $request->user()->can('create', Post::class), + ], + ], + ], + ]; + } +} +``` From 4fd723ac5fe53fdc58c4e64febb3683e1975d1f8 Mon Sep 17 00:00:00 2001 From: "S.a Mahmoudzadeh" <36761585+saMahmoudzadeh@users.noreply.github.com> Date: Thu, 25 Apr 2024 17:28:28 +0330 Subject: [PATCH 003/325] fixes grammar (#9603) --- scheduling.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scheduling.md b/scheduling.md index ec35a5bc564..9afd97f8ca0 100644 --- a/scheduling.md +++ b/scheduling.md @@ -389,7 +389,7 @@ On most operating systems, cron jobs are limited to running a maximum of once pe When sub-minute tasks are defined within your application, the `schedule:run` command will continue running until the end of the current minute instead of exiting immediately. This allows the command to invoke all required sub-minute tasks throughout the minute. -Since sub-minute tasks that take longer than expected to run could delay the execution of later sub-minute tasks, it is recommend that all sub-minute tasks dispatch queued jobs or background commands to handle the actual task processing: +Since sub-minute tasks that take longer than expected to run could delay the execution of later sub-minute tasks, it is recommended that all sub-minute tasks dispatch queued jobs or background commands to handle the actual task processing: use App\Jobs\DeleteRecentUsers; From 50d6c959ca6d215772055239a2a763538bf4ccb3 Mon Sep 17 00:00:00 2001 From: Chris Loftus <68920+chrisloftus@users.noreply.github.com> Date: Thu, 25 Apr 2024 15:17:36 +0100 Subject: [PATCH 004/325] Response `json()` method mixed return type (#9602) --- http-client.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http-client.md b/http-client.md index c49aaa57d8f..ca74f4d5fa9 100644 --- a/http-client.md +++ b/http-client.md @@ -35,7 +35,7 @@ To make requests, you may use the `head`, `get`, `post`, `put`, `patch`, and `de The `get` method returns an instance of `Illuminate\Http\Client\Response`, which provides a variety of methods that may be used to inspect the response: $response->body() : string; - $response->json($key = null, $default = null) : array|mixed; + $response->json($key = null, $default = null) : mixed; $response->object() : object; $response->collect($key = null) : Illuminate\Support\Collection; $response->status() : int; From 387f6977a4ea13943cc5079fb178bdccf55ba74a Mon Sep 17 00:00:00 2001 From: Steve Bauman Date: Thu, 25 Apr 2024 10:23:43 -0400 Subject: [PATCH 005/325] Add `URL::query()` method documentation (#9598) * Add url()->query() method documentation * Fix typo * Update urls.md --------- Co-authored-by: Taylor Otwell --- urls.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/urls.md b/urls.md index 5d454d5e75a..ab71f573d3d 100644 --- a/urls.md +++ b/urls.md @@ -28,6 +28,32 @@ The `url` helper may be used to generate arbitrary URLs for your application. Th // http://example.com/posts/1 +To generate a URL with query string parameters, you may use the `query` method: + + echo url()->query('/posts', ['search' => 'Laravel']); + + // https://example.com/posts?search=Laravel + + echo url()->query('/posts?sort=latest', ['search' => 'Laravel']); + + // http://example.com/posts?sort=latest&search=Laravel + +Providing query string parameters that already exist in the path will overwrite their existing value: + + echo url()->query('/posts?sort=latest', ['sort' => 'oldest']); + + // http://example.com/posts?sort=oldest + +Arrays of values may also be passed as query parameters. These values will be properly keyed and encoded in the generated URL: + + echo $url = url()->query('/posts', ['columns' => ['title', 'body']]); + + // http://example.com/posts?columns%5B0%5D=title&columns%5B1%5D=body + + echo urldecode($url); + + // http://example.com/posts?columns[0]=title&columns[1]=body + ### Accessing the Current URL From 2c81d29aaa90791945a33c88c8e8608f173a68e1 Mon Sep 17 00:00:00 2001 From: Steve Thomas Date: Fri, 26 Apr 2024 00:45:13 +1000 Subject: [PATCH 006/325] Add a section on authentication throttling (#9600) * Add a section on authentication throttling * wording * note instead of warning * formatting --------- Co-authored-by: Taylor Otwell --- fortify.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fortify.md b/fortify.md index 4a0b0bf547c..4e6c83dbbf4 100644 --- a/fortify.md +++ b/fortify.md @@ -205,6 +205,15 @@ Fortify::authenticateThrough(function (Request $request) { }); ``` +#### Authentication Throttling + +By default, Fortify will throttle authentication attempts using the `EnsureLoginIsNotThrottled` middleware. This middleware throttles attempts that are unique to a username and IP address combination. + +Some applications may require a different approach to throttling authentication attempts, such as throttling by IP address alone. Therefore, Fortify allows you to specify your own [rate limiter](/docs/{{version}}/routing#rate-limiting) via the `fortify.limiters.login` configuration option. Of course, this configuration option is located in your application's `config/fortify.php` configuration file. + +> [!NOTE] +> Utilizing a mixture of throttling, [two factor authentication](/docs/{{version}}/fortify#two-factor-authentication), and an external web application firewall (WAF) will provide the most robust defense for your legitimate application users. + ### Customizing Redirects From 3f53d0aa4dbcc18f51c547f366a4acf8b1baac4b Mon Sep 17 00:00:00 2001 From: Aron Rotteveel Date: Thu, 25 Apr 2024 17:22:15 +0200 Subject: [PATCH 007/325] [11.x] Write documentation for notification middleware (#9594) * Write documentation for notification middleware * Make code block stylign align with rest of docs * More little markdown tweaks * Minor wording tweaks * formatting * Formatting --------- Co-authored-by: Taylor Otwell --- notifications.md | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/notifications.md b/notifications.md index 84dddd24c15..e6676d8d99b 100644 --- a/notifications.md +++ b/notifications.md @@ -169,9 +169,6 @@ If you would like to delay the delivery of the notification, you may chain the ` $user->notify((new InvoicePaid($invoice))->delay($delay)); - -#### Delaying Notifications per Channel - You may pass an array to the `delay` method to specify the delay amount for specific channels: $user->notify((new InvoicePaid($invoice))->delay([ @@ -253,6 +250,27 @@ If you would like to specify a specific queue that should be used for each notif ]; } + +#### Queued Notification Middleware + +Queued notifications may define middleware [just like queued jobs](/docs/{{version}}/queues#job-middleware). To get started, define a `middleware` method on your notification class. The `middleware` method will receive `$notifiable` and `$channel` variables, which allow you to customize the returned middleware based on the notification's destination: + + use Illuminate\Queue\Middleware\RateLimited; + + /** + * Get the middleware the notification job should pass through. + * + * @return array + */ + public function middleware(object $notifiable, string $channel) + { + return match ($channel) { + 'email' => [new RateLimited('postmark')], + 'slack' => [new RateLimited('slack')], + default => [], + }; + } + #### Queued Notifications and Database Transactions From d67ea35774a93da23f751c0b3059c747d3da7d0a Mon Sep 17 00:00:00 2001 From: Janos Horvath Date: Thu, 25 Apr 2024 20:35:45 +0200 Subject: [PATCH 008/325] Update instructions to install the beta release of the package without downgrading application's minimum-stability setting (#9604) --- pulse.md | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/pulse.md b/pulse.md index 79f787a71a5..680a6435c0b 100644 --- a/pulse.md +++ b/pulse.md @@ -35,17 +35,10 @@ For in-depth debugging of individual events, check out [Laravel Telescope](/docs > [!WARNING] > Pulse's first-party storage implementation currently requires a MySQL, MariaDB, or PostgreSQL database. If you are using a different database engine, you will need a separate MySQL, MariaDB, or PostgreSQL database for your Pulse data. -Since Pulse is currently in beta, you may need to adjust your application's `composer.json` file to allow beta package releases to be installed: - -```json -"minimum-stability": "beta", -"prefer-stable": true -``` - -Then, you may use the Composer package manager to install Pulse into your Laravel project: +Since Pulse is currently in beta, you will need to explicitly install the beta release: ```sh -composer require laravel/pulse +composer require laravel/pulse:@beta ``` Next, you should publish the Pulse configuration and migration files using the `vendor:publish` Artisan command: From ed143722f3e0584b26d8b6bebbd2e3d3424994a3 Mon Sep 17 00:00:00 2001 From: Milwad <98118400+milwad-dev@users.noreply.github.com> Date: Mon, 29 Apr 2024 16:55:10 +0330 Subject: [PATCH 009/325] [11.x] Add note for `make:provider` command (#9607) * Update providers.md * Update providers.md * Update providers.md --------- Co-authored-by: Taylor Otwell --- providers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers.md b/providers.md index e17d9c15635..4d6c2709e1d 100644 --- a/providers.md +++ b/providers.md @@ -26,7 +26,7 @@ All user-defined service providers are registered in the `bootstrap/providers.ph All service providers extend the `Illuminate\Support\ServiceProvider` class. Most service providers contain a `register` and a `boot` method. Within the `register` method, you should **only bind things into the [service container](/docs/{{version}}/container)**. You should never attempt to register any event listeners, routes, or any other piece of functionality within the `register` method. -The Artisan CLI can generate a new provider via the `make:provider` command: +The Artisan CLI can generate a new provider via the `make:provider` command. Laravel will automatically register your new provider in your application's `bootstrap/providers.php` file: ```shell php artisan make:provider RiakServiceProvider From 71c87a53e238d1d96dbcf970e07082da93bcb8cc Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 29 Apr 2024 08:26:57 -0500 Subject: [PATCH 010/325] wip --- facades.md | 1 + 1 file changed, 1 insertion(+) diff --git a/facades.md b/facades.md index e8ecca5e55c..1d849e0658b 100644 --- a/facades.md +++ b/facades.md @@ -326,6 +326,7 @@ Request | [Illuminate\Http\Request](https://laravel.com/api/{{version}}/Illumi Response | [Illuminate\Contracts\Routing\ResponseFactory](https://laravel.com/api/{{version}}/Illuminate/Contracts/Routing/ResponseFactory.html) |   Response (Instance) | [Illuminate\Http\Response](https://laravel.com/api/{{version}}/Illuminate/Http/Response.html) |   Route | [Illuminate\Routing\Router](https://laravel.com/api/{{version}}/Illuminate/Routing/Router.html) | `router` +Schedule | [Illuminate\Console\Scheduling\Schedule](https://laravel.com/api/{{version}}/Illuminate/Console/Scheduling/Schedule.html) |   Schema | [Illuminate\Database\Schema\Builder](https://laravel.com/api/{{version}}/Illuminate/Database/Schema/Builder.html) |   Session | [Illuminate\Session\SessionManager](https://laravel.com/api/{{version}}/Illuminate/Session/SessionManager.html) | `session` Session (Instance) | [Illuminate\Session\Store](https://laravel.com/api/{{version}}/Illuminate/Session/Store.html) | `session.store` From 2c88575e6855e4a61e8f98ce8a0a7b693fd5800d Mon Sep 17 00:00:00 2001 From: Hafez Divandari Date: Mon, 29 Apr 2024 18:05:19 +0330 Subject: [PATCH 011/325] remove incomplete section (#9611) --- http-tests.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/http-tests.md b/http-tests.md index b645e30b1e8..13e2e095c06 100644 --- a/http-tests.md +++ b/http-tests.md @@ -878,11 +878,6 @@ You may use the `component` method to evaluate and render a [Blade component](/d $view->assertSee('Taylor'); - -## Testing Exceptions - -If you are testing a - ## Available Assertions From ec089da122a82f89f8035aea5c918522b139b783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 29 Apr 2024 22:46:33 +0200 Subject: [PATCH 012/325] [11.x] Update FrankenPHP docs (#9613) * [11.x] Update FrankenPHP docs * Update deployment.md * Update octane.md --------- Co-authored-by: Taylor Otwell --- deployment.md | 12 ++++++++++++ octane.md | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/deployment.md b/deployment.md index 6bbc2c07f18..e6af9290a33 100644 --- a/deployment.md +++ b/deployment.md @@ -4,6 +4,7 @@ - [Server Requirements](#server-requirements) - [Server Configuration](#server-configuration) - [Nginx](#nginx) + - [FrankenPHP](#frankenphp) - [Optimization](#optimization) - [Caching Configuration](#optimizing-configuration-loading) - [Caching Events](#caching-events) @@ -87,6 +88,17 @@ server { } ``` + +### FrankenPHP + +[FrankenPHP](https://frankenphp.dev/) may also be used to serve your Laravel applications. FrankenPHP is a modern PHP application server written in Go. To serve a Laravel PHP application using FrankenPHP, you may simply invoke its `php-server` command: + +```shell +frankenphp php-server -r public/ +``` + +To take advantage of more powerful features supported by FrankenPHP, such as its [Laravel Octane](/docs/{{version}}/octane) integration, HTTP/3, modern compression, or the ability to package Laravel applications as standalone binaries, please consult FrankenPHP's [Laravel documentation](https://frankenphp.dev/docs/laravel/). + ## Optimization diff --git a/octane.md b/octane.md index be0154e289e..2aee14ceb1d 100644 --- a/octane.md +++ b/octane.md @@ -56,7 +56,7 @@ php artisan octane:install > [!WARNING] > FrankenPHP's Octane integration is in beta and should be used with caution in production. -[FrankenPHP](https://frankenphp.dev) is a PHP application server, written in Go, that supports modern web features like early hints and Zstandard compression. When you install Octane and choose FrankenPHP as your server, Octane will automatically download and install the FrankenPHP binary for you. +[FrankenPHP](https://frankenphp.dev) is a PHP application server, written in Go, that supports modern web features like early hints, Brotli, and Zstandard compression. When you install Octane and choose FrankenPHP as your server, Octane will automatically download and install the FrankenPHP binary for you. #### FrankenPHP via Laravel Sail From bf44ac6afe222bb2af94a13dda285718fd215ab6 Mon Sep 17 00:00:00 2001 From: Nico <3315078+nicolus@users.noreply.github.com> Date: Tue, 30 Apr 2024 14:36:07 +0200 Subject: [PATCH 013/325] Add note about standard "Forwarded" header in Trusted proxies (#9615) * Add note about standard "Forwarded" header in Trusted proxies This configuration is required for applications behind a proxy that uses the standard Forward: "" header described in RFC 7239, like HAproxy with the "option forwarded" directive. * Update requests.md --------- Co-authored-by: Taylor Otwell --- requests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requests.md b/requests.md index e2dbc005f27..9f3f1f9482c 100644 --- a/requests.md +++ b/requests.md @@ -620,7 +620,7 @@ In addition to configuring the trusted proxies, you may also configure the proxy }) > [!NOTE] -> If you are using AWS Elastic Load Balancing, your `headers` value should be `Request::HEADER_X_FORWARDED_AWS_ELB`. For more information on the constants that may be used in the `headers` value, check out Symfony's documentation on [trusting proxies](https://symfony.com/doc/7.0/deployment/proxies.html). +> If you are using AWS Elastic Load Balancing, the `headers` value should be `Request::HEADER_X_FORWARDED_AWS_ELB`. If your load balancer uses the standard `Forwarded` header from [RFC 7239](https://www.rfc-editor.org/rfc/rfc7239#section-4), the `headers` value should be `Request::HEADER_FORWARDED`. For more information on the constants that may be used in the `headers` value, check out Symfony's documentation on [trusting proxies](https://symfony.com/doc/7.0/deployment/proxies.html). #### Trusting All Proxies From 32acc19e0f6476497faf63b864e4551e324760f8 Mon Sep 17 00:00:00 2001 From: "S.a Mahmoudzadeh" <36761585+saMahmoudzadeh@users.noreply.github.com> Date: Tue, 30 Apr 2024 16:06:39 +0330 Subject: [PATCH 014/325] fixes cashier-paddle.md (#9614) --- cashier-paddle.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cashier-paddle.md b/cashier-paddle.md index e3e8201ce88..345dfaf1475 100644 --- a/cashier-paddle.md +++ b/cashier-paddle.md @@ -160,7 +160,7 @@ Paddle relies on its own JavaScript library to initiate the Paddle checkout widg ### Currency Configuration -You can specify a locale to be used when formatting money values for display on invoices. Internally, Cashier utilizes [PHP's `NumberFormatter` class](https://www.php.net/manual/en/class.numberformatter.php) class to set the currency locale: +You can specify a locale to be used when formatting money values for display on invoices. Internally, Cashier utilizes [PHP's `NumberFormatter` class](https://www.php.net/manual/en/class.numberformatter.php) to set the currency locale: ```ini CASHIER_CURRENCY_LOCALE=nl_BE @@ -703,7 +703,7 @@ To create a subscription, first retrieve an instance of your billable model from The first argument given to the `subscribe` method is the specific price the user is subscribing to. This value should correspond to the price's identifier in Paddle. The `returnTo` method accepts a URL that your user will be redirected to after they successfully complete the checkout. The second argument passed to the `subscribe` method should be the internal "type" of the subscription. If your application only offers a single subscription, you might call this `default` or `primary`. This subscription type is only for internal application usage and is not meant to be displayed to users. In addition, it should not contain spaces and it should never be changed after creating the subscription. -You may also provide an array of custom meta data regarding the subscription using the `customData` method: +You may also provide an array of custom metadata regarding the subscription using the `customData` method: $checkout = $request->user()->subscribe($premium = 12345, 'default') ->customData(['key' => 'value']) @@ -722,7 +722,7 @@ After the user has finished their checkout, a `subscription_created` webhook wil ### Checking Subscription Status -Once a user is subscribed to your application, you may check their subscription status using a variety of convenient methods. First, the `subscribed` method returns `true` if the user has an valid subscription, even if the subscription is currently within its trial period: +Once a user is subscribed to your application, you may check their subscription status using a variety of convenient methods. First, the `subscribed` method returns `true` if the user has a valid subscription, even if the subscription is currently within its trial period: if ($user->subscribed()) { // ... From f0acbe976cf851fae97a8f1af44451ac0bdf9537 Mon Sep 17 00:00:00 2001 From: Haider Ali <47752310+haider00125@users.noreply.github.com> Date: Tue, 30 Apr 2024 17:37:14 +0500 Subject: [PATCH 015/325] Fixing method name and example code under Price Preview section (#9616) * Fixing method name. * Fixing example code. --- cashier-paddle.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cashier-paddle.md b/cashier-paddle.md index 345dfaf1475..dbf236467ce 100644 --- a/cashier-paddle.md +++ b/cashier-paddle.md @@ -579,7 +579,7 @@ The currency will be determined based on the IP address of the request; however, use Laravel\Paddle\Cashier; - $prices = Cashier::productPrices(['pri_123', 'pri_456'], ['address' => [ + $prices = Cashier::previewPrices(['pri_123', 'pri_456'], ['address' => [ 'country_code' => 'BE', 'postal_code' => '1234', ]]); @@ -599,7 +599,7 @@ You may also display the subtotal price and tax amount separately: ```blade
    @foreach ($prices as $price) -
  • {{ $price->product_title }} - {{ $price->subtotal() }} (+ {{ $price->tax() }} tax)
  • +
  • {{ $price->product['name'] }} - {{ $price->subtotal() }} (+ {{ $price->tax() }} tax)
  • @endforeach
``` From 660a5099feeafcd66c38555b274851e630074178 Mon Sep 17 00:00:00 2001 From: Frans Slabbekoorn Date: Tue, 30 Apr 2024 16:42:45 +0200 Subject: [PATCH 016/325] fix: consistent parameter typing across request methods (#9617) * fix: consistent parameter typing across request methods * Update requests.md --------- Co-authored-by: Taylor Otwell --- requests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requests.md b/requests.md index 9f3f1f9482c..9bc0797de15 100644 --- a/requests.md +++ b/requests.md @@ -431,7 +431,7 @@ To determine if a given key is absent from the request, you may use the `missing // ... } - $request->whenMissing('name', function (array $input) { + $request->whenMissing('name', function () { // The "name" value is missing... }, function () { // The "name" value is present... From ea461f727a1b206a43a79e6b2185fd49ad3fef6b Mon Sep 17 00:00:00 2001 From: Davey Shafik Date: Tue, 30 Apr 2024 07:44:52 -0700 Subject: [PATCH 017/325] [1.x] Adds `--repair` option documentation (#9606) * Add `with-exit-status` flag docs for Pint * Update pint.md --------- Co-authored-by: Taylor Otwell --- pint.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pint.md b/pint.md index 50d6719a97a..2156e920e85 100644 --- a/pint.md +++ b/pint.md @@ -47,7 +47,7 @@ Pint will display a thorough list of all of the files that it updates. You can v ./vendor/bin/pint -v ``` -If you would like Pint to simply inspect your code for style errors without actually changing the files, you may use the `--test` option: +If you would like Pint to simply inspect your code for style errors without actually changing the files, you may use the `--test` option. Pint will return a non-zero exit code if any code style errors are found: ```shell ./vendor/bin/pint --test @@ -59,6 +59,12 @@ If you would like Pint to only modify the files that have uncommitted changes ac ./vendor/bin/pint --dirty ``` +If you would like Pint to fix any files with code style errors but also exit with a non-zero exit code if any errors were fixed, you may use the `--repair` option: + +```shell +./vendor/bin/pint --repair +``` + ## Configuring Pint From 6b5618c420d04e88421e60fb6e42802d260e0a9c Mon Sep 17 00:00:00 2001 From: Julius Kiekbusch Date: Tue, 30 Apr 2024 19:16:33 +0200 Subject: [PATCH 018/325] [11.x] Pulse v1 (#9618) * Pulse v1 * Update pulse.md --------- Co-authored-by: Taylor Otwell --- pulse.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pulse.md b/pulse.md index 680a6435c0b..f4b7e990ee8 100644 --- a/pulse.md +++ b/pulse.md @@ -35,10 +35,10 @@ For in-depth debugging of individual events, check out [Laravel Telescope](/docs > [!WARNING] > Pulse's first-party storage implementation currently requires a MySQL, MariaDB, or PostgreSQL database. If you are using a different database engine, you will need a separate MySQL, MariaDB, or PostgreSQL database for your Pulse data. -Since Pulse is currently in beta, you will need to explicitly install the beta release: +You may install Pulse using the Composer package manager: ```sh -composer require laravel/pulse:@beta +composer require laravel/pulse ``` Next, you should publish the Pulse configuration and migration files using the `vendor:publish` Artisan command: From 654fcea669deeb0653085567856aa07dd6875340 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 30 Apr 2024 20:51:20 +0100 Subject: [PATCH 019/325] Puts frankenphp out of beta (#9620) --- octane.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/octane.md b/octane.md index 2aee14ceb1d..1c4b32deec5 100644 --- a/octane.md +++ b/octane.md @@ -53,9 +53,6 @@ php artisan octane:install ### FrankenPHP -> [!WARNING] -> FrankenPHP's Octane integration is in beta and should be used with caution in production. - [FrankenPHP](https://frankenphp.dev) is a PHP application server, written in Go, that supports modern web features like early hints, Brotli, and Zstandard compression. When you install Octane and choose FrankenPHP as your server, Octane will automatically download and install the FrankenPHP binary for you. From e8ca8ae7d0c4932510de8905684fcfb7197f1a4b Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Thu, 2 May 2024 01:31:34 +1000 Subject: [PATCH 020/325] [11.x] Document disable highlighting (#9623) * Document disable highlighting * Update pulse.md --------- Co-authored-by: Taylor Otwell --- pulse.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pulse.md b/pulse.md index f4b7e990ee8..3d33ef69c63 100644 --- a/pulse.md +++ b/pulse.md @@ -214,6 +214,12 @@ The `` card shows the database queries in your ap By default, slow queries are grouped based on the SQL query (without bindings) and the location where it occurred, but you may choose to not capture the location if you wish to group solely on the SQL query. +If you encounter rendering performance issues due to extremely large SQL queries receiving syntax highlighting, you may disable highlighting by adding the `disable-highlighting` prop: + +```blade + +``` + See the [slow queries recorder](#slow-queries-recorder) documentation for more information. From f1eccbe0a9714c79f5c9943ef444d4968189ff28 Mon Sep 17 00:00:00 2001 From: Milwad <98118400+milwad-dev@users.noreply.github.com> Date: Wed, 1 May 2024 19:02:13 +0330 Subject: [PATCH 021/325] Update facades.md (#9621) --- facades.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/facades.md b/facades.md index 1d849e0658b..9b72a8cf783 100644 --- a/facades.md +++ b/facades.md @@ -303,6 +303,8 @@ Date | [Illuminate\Support\DateFactory](https://laravel.com/api/{{version}}/Il DB | [Illuminate\Database\DatabaseManager](https://laravel.com/api/{{version}}/Illuminate/Database/DatabaseManager.html) | `db` DB (Instance) | [Illuminate\Database\Connection](https://laravel.com/api/{{version}}/Illuminate/Database/Connection.html) | `db.connection` Event | [Illuminate\Events\Dispatcher](https://laravel.com/api/{{version}}/Illuminate/Events/Dispatcher.html) | `events` +Exceptions | [Illuminate\Foundation\Exceptions\Handler](https://laravel.com/api/{{version}}/Illuminate/Foundation/Exceptions/Handler.html) |   +Exceptions (Instance) | [Illuminate\Contracts\Debug\ExceptionHandler](https://laravel.com/api/{{version}}/Illuminate/Contracts/Debug/ExceptionHandler.html) |   File | [Illuminate\Filesystem\Filesystem](https://laravel.com/api/{{version}}/Illuminate/Filesystem/Filesystem.html) | `files` Gate | [Illuminate\Contracts\Auth\Access\Gate](https://laravel.com/api/{{version}}/Illuminate/Contracts/Auth/Access/Gate.html) |   Hash | [Illuminate\Contracts\Hashing\Hasher](https://laravel.com/api/{{version}}/Illuminate/Contracts/Hashing/Hasher.html) | `hash` From 3f3c6b6fda3ec3e6e223ff60b96b8f453982b6b9 Mon Sep 17 00:00:00 2001 From: Ellie Rider Date: Fri, 3 May 2024 13:20:58 -0400 Subject: [PATCH 022/325] Helpers - Fix context example (#9630) Looks like it was a typo, the example used `config` instead of `context` --- helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers.md b/helpers.md index 23cd72599c4..5906469c047 100644 --- a/helpers.md +++ b/helpers.md @@ -1714,7 +1714,7 @@ The `context` function gets the value from the [current context](/docs/{{version $value = context('trace_id'); - $value = config('trace_id', $default); + $value = context('trace_id', $default); You may set context values by passing an array of key / value pairs: From 28d91301f943da492a88c686fa81bfe6082fcfb0 Mon Sep 17 00:00:00 2001 From: Raphael Cunha Date: Fri, 3 May 2024 13:23:46 -0400 Subject: [PATCH 023/325] Remove extra "to" word in Multi-select section (#9628) --- prompts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prompts.md b/prompts.md index 726cd69686d..d61dbb0c668 100644 --- a/prompts.md +++ b/prompts.md @@ -372,7 +372,7 @@ If the `options` argument is an associative array, then the closure will receive ### Multi-select -If you need to the user to be able to select multiple options, you may use the `multiselect` function: +If you need the user to be able to select multiple options, you may use the `multiselect` function: ```php use function Laravel\Prompts\multiselect; From c371a706b9cfecde2e4e7e99f1db792f1df41868 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolaev Date: Fri, 3 May 2024 20:24:29 +0300 Subject: [PATCH 024/325] Fix typos in sail.md (#9626) * Fix typos in sail.md * Update sail.md --- sail.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sail.md b/sail.md index a2a87744b2b..3811046a3d6 100644 --- a/sail.md +++ b/sail.md @@ -249,14 +249,14 @@ To connect to your application's Redis database from your local machine, you may ### Meilisearch -If you chose to install the [Meilisearch](https://www.meilisearch.com) service when installing Sail, your application's `docker-compose.yml` file will contain an entry for this powerful search-engine that is [compatible](https://github.com/meilisearch/meilisearch-laravel-scout) with [Laravel Scout](/docs/{{version}}/scout). Once you have started your containers, you may connect to the Meilisearch instance within your application by setting your `MEILISEARCH_HOST` environment variable to `http://meilisearch:7700`. +If you chose to install the [Meilisearch](https://www.meilisearch.com) service when installing Sail, your application's `docker-compose.yml` file will contain an entry for this powerful search engine that is integrated with [Laravel Scout](/docs/{{version}}/scout). Once you have started your containers, you may connect to the Meilisearch instance within your application by setting your `MEILISEARCH_HOST` environment variable to `http://meilisearch:7700`. From your local machine, you may access Meilisearch's web based administration panel by navigating to `http://localhost:7700` in your web browser. ### Typesense -If you chose to install the [Typesense](https://typesense.org) service when installing Sail, your application's `docker-compose.yml` file will contain an entry for this lightning fast, open-source search-engine that is natively integrated with [Laravel Scout](/docs/{{version}}/scout#typesense). Once you have started your containers, you may connect to the Typesense instance within your application by setting the following environment variables: +If you chose to install the [Typesense](https://typesense.org) service when installing Sail, your application's `docker-compose.yml` file will contain an entry for this lightning fast, open-source search engine that is natively integrated with [Laravel Scout](/docs/{{version}}/scout#typesense). Once you have started your containers, you may connect to the Typesense instance within your application by setting the following environment variables: ```ini TYPESENSE_HOST=typesense @@ -381,7 +381,7 @@ When Sail is running, you may access the Mailpit web interface at: http://localh ## Container CLI -Sometimes you may wish to start a Bash session within your application's container. You may use the `shell` command to connect to your application's container, allowing you to inspect its files and installed services as well execute arbitrary shell commands within the container: +Sometimes you may wish to start a Bash session within your application's container. You may use the `shell` command to connect to your application's container, allowing you to inspect its files and installed services as well as execute arbitrary shell commands within the container: ```shell sail shell @@ -517,7 +517,7 @@ sail debug migrate To debug your application while interacting with the application via a web browser, follow the [instructions provided by Xdebug](https://xdebug.org/docs/step_debug#web-application) for initiating an Xdebug session from the web browser. -If you're using PhpStorm, please review JetBrain's documentation regarding [zero-configuration debugging](https://www.jetbrains.com/help/phpstorm/zero-configuration-debugging.html). +If you're using PhpStorm, please review JetBrains' documentation regarding [zero-configuration debugging](https://www.jetbrains.com/help/phpstorm/zero-configuration-debugging.html). > [!WARNING] > Laravel Sail relies on `artisan serve` to serve your application. The `artisan serve` command only accepts the `XDEBUG_CONFIG` and `XDEBUG_MODE` variables as of Laravel version 8.53.0. Older versions of Laravel (8.52.0 and below) do not support these variables and will not accept debug connections. From 8ae1833164edd0ca78825724d23ef1f6550b961a Mon Sep 17 00:00:00 2001 From: Nikolay Nikolaev Date: Fri, 3 May 2024 20:24:42 +0300 Subject: [PATCH 025/325] Fix typo in octane.md (#9625) --- octane.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/octane.md b/octane.md index 1c4b32deec5..4cdae9776f4 100644 --- a/octane.md +++ b/octane.md @@ -104,7 +104,7 @@ Typically, you should access your FrankenPHP Sail application via `https://local #### FrankenPHP via Docker -Using FrankenPHP's official Docker images can offer improved performance and the use additional extensions not included with static installations of FrankenPHP. In addition, the official Docker images provide support for running FrankenPHP on platforms it doesn't natively support, such as Windows. FrankenPHP's official Docker images are suitable for both local development and production usage. +Using FrankenPHP's official Docker images can offer improved performance and the use of additional extensions not included with static installations of FrankenPHP. In addition, the official Docker images provide support for running FrankenPHP on platforms it doesn't natively support, such as Windows. FrankenPHP's official Docker images are suitable for both local development and production usage. You may use the following Dockerfile as a starting point for containerizing your FrankenPHP powered Laravel application: From eee7d1f93f20cc9e79265dd1e3a3277ad2392573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Sun, 5 May 2024 17:35:04 +0200 Subject: [PATCH 026/325] Fix typo in horizon (#9633) --- horizon.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/horizon.md b/horizon.md index 0d55a87780c..a8d86dd7332 100644 --- a/horizon.md +++ b/horizon.md @@ -89,7 +89,7 @@ You may add additional supervisors to a given environment if you would like to d #### Maintenance Mode -While your application is in [maintainance mode](/docs/{{version}}/configuration#maintenance-mode), queued jobs will not be processed by Horizon unless the supervisor's `force` option is defined as `true` within the Horizon configuration file: +While your application is in [maintenance mode](/docs/{{version}}/configuration#maintenance-mode), queued jobs will not be processed by Horizon unless the supervisor's `force` option is defined as `true` within the Horizon configuration file: 'environments' => [ 'production' => [ From 8d7fffe5ca35892bf72eaffd7af46718d1e1585a Mon Sep 17 00:00:00 2001 From: Md Eamin Hossain Date: Sun, 5 May 2024 21:35:30 +0600 Subject: [PATCH 027/325] Update variable type hint in OrderShipmentStatusUpdated event (#9632) --- broadcasting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/broadcasting.md b/broadcasting.md index 0f3611264c1..385b1b01516 100644 --- a/broadcasting.md +++ b/broadcasting.md @@ -361,7 +361,7 @@ When a user is viewing one of their orders, we don't want them to have to refres /** * The order instance. * - * @var \App\Order + * @var \App\Models\Order */ public $order; } From de690fc41dba45345a4ae0a03cffd54d40dd43e6 Mon Sep 17 00:00:00 2001 From: Ryuta Hamasaki Date: Mon, 6 May 2024 00:45:34 +0900 Subject: [PATCH 028/325] remove the repetitive "return" (#9631) --- pulse.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pulse.md b/pulse.md index 3d33ef69c63..cee4f18a671 100644 --- a/pulse.md +++ b/pulse.md @@ -665,7 +665,7 @@ class TopSellers extends Card } ``` -The `aggregate` method returns return a collection of PHP `stdClass` objects. Each object will contain the `key` property captured earlier, along with keys for each of the requested aggregates: +The `aggregate` method returns a collection of PHP `stdClass` objects. Each object will contain the `key` property captured earlier, along with keys for each of the requested aggregates: ``` @foreach ($topSellers as $seller) From 78e4cab11471130f2e66a405a1ed82d84f1ce7a7 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 6 May 2024 13:11:26 -0400 Subject: [PATCH 029/325] wip --- pulse.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pulse.md b/pulse.md index cee4f18a671..546d30e264e 100644 --- a/pulse.md +++ b/pulse.md @@ -214,10 +214,10 @@ The `` card shows the database queries in your ap By default, slow queries are grouped based on the SQL query (without bindings) and the location where it occurred, but you may choose to not capture the location if you wish to group solely on the SQL query. -If you encounter rendering performance issues due to extremely large SQL queries receiving syntax highlighting, you may disable highlighting by adding the `disable-highlighting` prop: +If you encounter rendering performance issues due to extremely large SQL queries receiving syntax highlighting, you may disable highlighting by adding the `without-highlighting` prop: ```blade - + ``` See the [slow queries recorder](#slow-queries-recorder) documentation for more information. From 851b548090eec94055f1f82595b3f8ca429b280b Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 6 May 2024 15:03:04 -0400 Subject: [PATCH 030/325] resend driver --- mail.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/mail.md b/mail.md index b29c720bfd4..c43884c9f68 100644 --- a/mail.md +++ b/mail.md @@ -36,7 +36,7 @@ ## Introduction -Sending email doesn't have to be complicated. Laravel provides a clean, simple email API powered by the popular [Symfony Mailer](https://symfony.com/doc/7.0/mailer.html) component. Laravel and Symfony Mailer provide drivers for sending email via SMTP, Mailgun, Postmark, Amazon SES, and `sendmail`, allowing you to quickly get started sending mail through a local or cloud based service of your choice. +Sending email doesn't have to be complicated. Laravel provides a clean, simple email API powered by the popular [Symfony Mailer](https://symfony.com/doc/7.0/mailer.html) component. Laravel and Symfony Mailer provide drivers for sending email via SMTP, Mailgun, Postmark, Resend, Amazon SES, and `sendmail`, allowing you to quickly get started sending mail through a local or cloud based service of your choice. ### Configuration @@ -48,7 +48,7 @@ Within your `mail` configuration file, you will find a `mailers` configuration a ### Driver / Transport Prerequisites -The API based drivers such as Mailgun, Postmark, and MailerSend are often simpler and faster than sending mail via SMTP servers. Whenever possible, we recommend that you use one of these drivers. +The API based drivers such as Mailgun, Postmark, Resend, and MailerSend are often simpler and faster than sending mail via SMTP servers. Whenever possible, we recommend that you use one of these drivers. #### Mailgun Driver @@ -113,6 +113,21 @@ If you would like to specify the Postmark message stream that should be used by This way you are also able to set up multiple Postmark mailers with different message streams. + +#### Resend Driver + +To use the Resend driver, install Resend's PHP SDK via Composer: + +```shell +composer require resend/resend-php +``` + +Next, set the `default` option in your application's `config/mail.php` configuration file to `resend`. After configuring your application's default mailer, ensure that your `config/services.php` configuration file contains the following options: + + 'resend' => [ + 'key' => env('RESEND_KEY'), + ], + #### SES Driver From 2a1a27a4d5f9614ab92770833db16c09bd4b8eca Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 6 May 2024 15:03:41 -0400 Subject: [PATCH 031/325] wip --- mail.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mail.md b/mail.md index c43884c9f68..bd7e3c36997 100644 --- a/mail.md +++ b/mail.md @@ -89,7 +89,7 @@ If you are not using the United States [Mailgun region](https://documentation.ma #### Postmark Driver -To use the Postmark driver, install Symfony's Postmark Mailer transport via Composer: +To use the [Postmark](https://postmarkapp.com/) driver, install Symfony's Postmark Mailer transport via Composer: ```shell composer require symfony/postmark-mailer symfony/http-client @@ -116,7 +116,7 @@ This way you are also able to set up multiple Postmark mailers with different me #### Resend Driver -To use the Resend driver, install Resend's PHP SDK via Composer: +To use the [Resend](https://resend.com/) driver, install Resend's PHP SDK via Composer: ```shell composer require resend/resend-php From fb0794e067f28b0704ba9c366f543d23135db70b Mon Sep 17 00:00:00 2001 From: Haider Ali <47752310+haider00125@users.noreply.github.com> Date: Tue, 7 May 2024 05:18:03 +0500 Subject: [PATCH 032/325] Fix event handler example code. (#9638) --- cashier-paddle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cashier-paddle.md b/cashier-paddle.md index dbf236467ce..aea70492b43 100644 --- a/cashier-paddle.md +++ b/cashier-paddle.md @@ -1235,7 +1235,7 @@ Both events contain the full payload of the Paddle webhook. For example, if you */ public function handle(WebhookReceived $event): void { - if ($event->payload['alert_name'] === 'transaction_billed') { + if ($event->payload['event_type'] === 'transaction.billed') { // Handle the incoming event... } } From 52c2336e200427998407c2b7c123584374155c2a Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 7 May 2024 08:59:46 +0200 Subject: [PATCH 033/325] Update cashier-paddle.md --- cashier-paddle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cashier-paddle.md b/cashier-paddle.md index aea70492b43..c84f3445a27 100644 --- a/cashier-paddle.md +++ b/cashier-paddle.md @@ -1220,7 +1220,7 @@ Cashier automatically handles subscription cancelation on failed charges and oth - `Laravel\Paddle\Events\WebhookReceived` - `Laravel\Paddle\Events\WebhookHandled` -Both events contain the full payload of the Paddle webhook. For example, if you wish to handle the `transaction_billed` webhook, you may register a [listener](/docs/{{version}}/events#defining-listeners) that will handle the event: +Both events contain the full payload of the Paddle webhook. For example, if you wish to handle the `transaction.billed` webhook, you may register a [listener](/docs/{{version}}/events#defining-listeners) that will handle the event: Date: Thu, 9 May 2024 04:21:46 +1000 Subject: [PATCH 034/325] Rename component prop (#9635) From 86518f934aa146fac6947d63ba5f5efbd6f8837d Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Thu, 9 May 2024 04:26:58 +1000 Subject: [PATCH 035/325] [11.x] Pulse: Ignore offline servers (#9622) * Document ignore-after prop * Improve example * Update pulse.md --------- Co-authored-by: Taylor Otwell --- pulse.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pulse.md b/pulse.md index 546d30e264e..55ecf0e1a77 100644 --- a/pulse.md +++ b/pulse.md @@ -169,6 +169,12 @@ public function boot(): void The `` card displays system resource usage for all servers running the `pulse:check` command. Please refer to the documentation regarding the [servers recorder](#servers-recorder) for more information on system resource reporting. +If you replace a server in your infrastructure, you may wish to stop displaying the inactive server in the Pulse dashboard after a given duration. You may accomplish this using the `ignore-after` prop, which accepts the number of seconds after which inactive servers should be removed from the Pulse dashboard. Alternatively, you may provide a relative time formatted string, such as `1 hour` or `3 days and 1 hour`: + +```blade + +``` + #### Application Usage From 43a416d09aa91530e8d6f24532acd7509c67ce82 Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Thu, 9 May 2024 04:27:13 +1000 Subject: [PATCH 036/325] Namespace folio make command (#9510) --- folio.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/folio.md b/folio.md index 13406521094..9efb7edc619 100644 --- a/folio.md +++ b/folio.md @@ -109,7 +109,7 @@ php artisan folio:list You may create a nested route by creating one or more directories within one of Folio's directories. For instance, to create a page that is accessible via `/user/profile`, create a `profile.blade.php` template within the `pages/user` directory: ```bash -php artisan make:folio user/profile +php artisan folio:page user/profile # pages/user/profile.blade.php → /user/profile ``` @@ -120,10 +120,10 @@ php artisan make:folio user/profile Sometimes, you may wish to make a given page the "index" of a directory. By placing an `index.blade.php` template within a Folio directory, any requests to the root of that directory will be routed to that page: ```bash -php artisan make:folio index +php artisan folio:page index # pages/index.blade.php → / -php artisan make:folio users/index +php artisan folio:page users/index # pages/users/index.blade.php → /users ``` @@ -133,7 +133,7 @@ php artisan make:folio users/index Often, you will need to have segments of the incoming request's URL injected into your page so that you can interact with them. For example, you may need to access the "ID" of the user whose profile is being displayed. To accomplish this, you may encapsulate a segment of the page's filename in square brackets: ```bash -php artisan make:folio "users/[id]" +php artisan folio:page "users/[id]" # pages/users/[id].blade.php → /users/1 ``` @@ -149,7 +149,7 @@ Captured segments can be accessed as variables within your Blade template: To capture multiple segments, you can prefix the encapsulated segment with three dots `...`: ```bash -php artisan make:folio "users/[...ids]" +php artisan folio:page "users/[...ids]" # pages/users/[...ids].blade.php → /users/1/2/3 ``` @@ -170,7 +170,7 @@ When capturing multiple segments, the captured segments will be injected into th If a wildcard segment of your page template's filename corresponds one of your application's Eloquent models, Folio will automatically take advantage of Laravel's route model binding capabilities and attempt to inject the resolved model instance into your page: ```bash -php artisan make:folio "users/[User]" +php artisan folio:page "users/[User]" # pages/users/[User].blade.php → /users/1 ``` @@ -194,7 +194,7 @@ On Windows, you should use `-` to separate the model name from the key: `[Post-s By default, Folio will search for your model within your application's `app/Models` directory. However, if needed, you may specify the fully-qualified model class name in your template's filename: ```bash -php artisan make:folio "users/[.App.Models.User]" +php artisan folio:page "users/[.App.Models.User]" # pages/users/[.App.Models.User].blade.php → /users/1 ``` From 6d89df95cecd6c23227a306bd32ca21ac92ff767 Mon Sep 17 00:00:00 2001 From: Maarten Paauw Date: Thu, 9 May 2024 19:17:34 +0200 Subject: [PATCH 037/325] Update socialite.md (#9643) Add Slack OpenID provider to Socialite documentation --- socialite.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/socialite.md b/socialite.md index ae937cf24eb..54a27175346 100644 --- a/socialite.md +++ b/socialite.md @@ -39,7 +39,7 @@ When upgrading to a new major version of Socialite, it's important that you care Before using Socialite, you will need to add credentials for the OAuth providers your application utilizes. Typically, these credentials may be retrieved by creating a "developer application" within the dashboard of the service you will be authenticating with. -These credentials should be placed in your application's `config/services.php` configuration file, and should use the key `facebook`, `twitter` (OAuth 1.0), `twitter-oauth-2` (OAuth 2.0), `linkedin-openid`, `google`, `github`, `gitlab`, `bitbucket`, or `slack`, depending on the providers your application requires: +These credentials should be placed in your application's `config/services.php` configuration file, and should use the key `facebook`, `twitter` (OAuth 1.0), `twitter-oauth-2` (OAuth 2.0), `linkedin-openid`, `google`, `github`, `gitlab`, `bitbucket`, `slack`, or `slack-openid`, depending on the providers your application requires: 'github' => [ 'client_id' => env('GITHUB_CLIENT_ID'), From 62db09bab113a7b2236e96e0f47ab2f44aede3b7 Mon Sep 17 00:00:00 2001 From: Haider Ali <47752310+haider00125@users.noreply.github.com> Date: Sat, 11 May 2024 00:23:10 +0500 Subject: [PATCH 038/325] Fixing typo in extend trial example code (#9646) --- cashier-paddle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cashier-paddle.md b/cashier-paddle.md index c84f3445a27..48acd5dbb92 100644 --- a/cashier-paddle.md +++ b/cashier-paddle.md @@ -1170,7 +1170,7 @@ You may use the `onGenericTrial` method if you wish to know specifically that th You can extend an existing trial period on a subscription by invoking the `extendTrial` method and specifying the moment in time that the trial should end: - $user->subsription()->extendTrial(now()->addDays(5)); + $user->subscription()->extendTrial(now()->addDays(5)); Or, you may immediately activate a subscription by ending its trial by calling the `activate` method on the subscription: From f1e6124543f53c2a425356f0ec469f092e51740d Mon Sep 17 00:00:00 2001 From: Ehsan Mahmoodi Date: Fri, 10 May 2024 22:54:10 +0330 Subject: [PATCH 039/325] Update horizon.md (#9645) --- horizon.md | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/horizon.md b/horizon.md index a8d86dd7332..8e90e2bed3b 100644 --- a/horizon.md +++ b/horizon.md @@ -185,23 +185,7 @@ Alternatively, the job you wish to silence can implement the `Laravel\Horizon\Co ## Upgrading Horizon -When upgrading to a new major version of Horizon, it's important that you carefully review [the upgrade guide](https://github.com/laravel/horizon/blob/master/UPGRADE.md). In addition, when upgrading to any new Horizon version, you should re-publish Horizon's assets: - -```shell -php artisan horizon:publish -``` - -To keep the assets up-to-date and avoid issues in future updates, you may add the `vendor:publish --tag=laravel-assets` command to the `post-update-cmd` scripts in your application's `composer.json` file: - -```json -{ - "scripts": { - "post-update-cmd": [ - "@php artisan vendor:publish --tag=laravel-assets --ansi --force" - ] - } -} -``` +When upgrading to a new major version of Horizon, it's important that you carefully review [the upgrade guide](https://github.com/laravel/horizon/blob/master/UPGRADE.md). ## Running Horizon From 54adbdad2c77a91bb259879125a8d833c5f36088 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 10 May 2024 14:36:38 -0500 Subject: [PATCH 040/325] [11.x] add documentation for new "contains" validation rule (#9644) * add documentation for new "contains" validation rule https://github.com/laravel/framework/pull/51348 * Update validation.md --------- Co-authored-by: Taylor Otwell --- validation.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/validation.md b/validation.md index 2154256744b..1f24309e2ea 100644 --- a/validation.md +++ b/validation.md @@ -879,6 +879,7 @@ Below is a list of all available validation rules and their function: [Between](#rule-between) [Boolean](#rule-boolean) [Confirmed](#rule-confirmed) +[Contains](#rule-contains) [Current Password](#rule-current-password) [Date](#rule-date) [Date Equals](#rule-date-equals) @@ -1097,6 +1098,11 @@ The field under validation must be able to be cast as a boolean. Accepted input The field under validation must have a matching field of `{field}_confirmation`. For example, if the field under validation is `password`, a matching `password_confirmation` field must be present in the input. + +#### contains:_foo_,_bar_,... + +The field under validation must be an array that contains all of the given parameter values. + #### current_password From 61b0dcfaefb563e820976bda299554c65441af30 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 10 May 2024 15:06:40 -0500 Subject: [PATCH 041/325] minor grammar (#9648) - add missing word in `authorization.md`. - consistently use "an SPA" vs "a SPA". there were of mix of uses in the docs, and "an" is more appropriate as "SPA" starts with a vowel sound. --- authorization.md | 2 +- csrf.md | 2 +- sanctum.md | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/authorization.md b/authorization.md index a817390e487..f894ce11a72 100644 --- a/authorization.md +++ b/authorization.md @@ -735,7 +735,7 @@ When attempting to determine if the authenticated user can update a given post, Although authorization must always be handled on the server, it can often be convenient to provide your frontend application with authorization data in order to properly render your application's UI. Laravel does not define a required convention for exposing authorization information to an Inertia powered frontend. -However, if you are using one of Laravel's Inertia-based [starter kits](/docs/{{version}}/starter-kits), your application already contains a `HandleInertiaRequests` middleware. Within this middleware's `share` method, you may return shared data that will provided to all Inertia pages in your application. This shared data can serve as a convenient location to define authorization information for the user: +However, if you are using one of Laravel's Inertia-based [starter kits](/docs/{{version}}/starter-kits), your application already contains a `HandleInertiaRequests` middleware. Within this middleware's `share` method, you may return shared data that will be provided to all Inertia pages in your application. This shared data can serve as a convenient location to define authorization information for the user: ```php ### CSRF Tokens & SPAs -If you are building a SPA that is utilizing Laravel as an API backend, you should consult the [Laravel Sanctum documentation](/docs/{{version}}/sanctum) for information on authenticating with your API and protecting against CSRF vulnerabilities. +If you are building an SPA that is utilizing Laravel as an API backend, you should consult the [Laravel Sanctum documentation](/docs/{{version}}/sanctum) for information on authenticating with your API and protecting against CSRF vulnerabilities. ### Excluding URIs From CSRF Protection diff --git a/sanctum.md b/sanctum.md index b3080fad3d6..8830c7d5b9f 100644 --- a/sanctum.md +++ b/sanctum.md @@ -42,7 +42,7 @@ Laravel Sanctum offers this feature by storing user API tokens in a single datab #### SPA Authentication -Second, Sanctum exists to offer a simple way to authenticate single page applications (SPAs) that need to communicate with a Laravel powered API. These SPAs might exist in the same repository as your Laravel application or might be an entirely separate repository, such as a SPA created using Vue CLI or a Next.js application. +Second, Sanctum exists to offer a simple way to authenticate single page applications (SPAs) that need to communicate with a Laravel powered API. These SPAs might exist in the same repository as your Laravel application or might be an entirely separate repository, such as an SPA created using Vue CLI or a Next.js application. For this feature, Sanctum does not use tokens of any kind. Instead, Sanctum uses Laravel's built-in cookie based session authentication services. Typically, Sanctum utilizes Laravel's `web` authentication guard to accomplish this. This provides the benefits of CSRF protection, session authentication, as well as protects against leakage of the authentication credentials via XSS. @@ -60,7 +60,7 @@ You may install Laravel Sanctum via the `install:api` Artisan command: php artisan install:api ``` -Next, if you plan to utilize Sanctum to authenticate a SPA, please refer to the [SPA Authentication](#spa-authentication) section of this documentation. +Next, if you plan to utilize Sanctum to authenticate an SPA, please refer to the [SPA Authentication](#spa-authentication) section of this documentation. ## Configuration @@ -267,7 +267,7 @@ Next, you should instruct Laravel that incoming requests from your SPA can authe #### CORS and Cookies -If you are having trouble authenticating with your application from a SPA that executes on a separate subdomain, you have likely misconfigured your CORS (Cross-Origin Resource Sharing) or session cookie settings. +If you are having trouble authenticating with your application from an SPA that executes on a separate subdomain, you have likely misconfigured your CORS (Cross-Origin Resource Sharing) or session cookie settings. The `config/cors.php` configuration file is not published by default. If you need to customize Laravel's CORS options, you should publish the complete `cors` configuration file using the `config:publish` Artisan command: From 9ff2aaeef0449657bbcfbf2da09fcb0509b85078 Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Tue, 14 May 2024 03:05:59 +1000 Subject: [PATCH 042/325] Pulse thresolds (#9652) * Document per-x thresholds * Fix class reference * wip --------- Co-authored-by: Taylor Otwell --- pulse.md | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/pulse.md b/pulse.md index 55ecf0e1a77..30c57ecdf8e 100644 --- a/pulse.md +++ b/pulse.md @@ -309,6 +309,20 @@ The `SlowJobs` recorder captures information about slow jobs occurring in your a You may optionally adjust the slow job threshold, [sample rate](#sampling), and ignored job patterns. +You may have some jobs that you expect to take longer than others. In those cases, you may configure per-job thresholds: + +```php +Recorders\SlowJobs::class => [ + // ... + 'threshold' => [ + '#^App\\Jobs\\GenerateYearlyReports$#' => 5000, + 'default' => env('PULSE_SLOW_JOBS_THRESHOLD', 1000), + ], +], +``` + +If no regular expression patterns match the job's classname, then the `'default'` value will be used. + #### Slow Outgoing Requests @@ -316,10 +330,24 @@ The `SlowOutgoingRequests` recorder captures information about outgoing HTTP req You may optionally adjust the slow outgoing request threshold, [sample rate](#sampling), and ignored URL patterns. +You may have some outgoing requests that you expect to take longer than others. In those cases, you may configure per-request thresholds: + +```php +Recorders\SlowOutgoingRequests::class => [ + // ... + 'threshold' => [ + '#backup.zip$#' => 5000, + 'default' => env('PULSE_SLOW_OUTGOING_REQUESTS_THRESHOLD', 1000), + ], +], +``` + +If no regular expression patterns match the request's URL, then the `'default'` value will be used. + You may also configure URL grouping so that similar URLs are grouped as a single entry. For example, you may wish to remove unique IDs from URL paths or group by domain only. Groups are configured using a regular expression to "find and replace" parts of the URL. Some examples are included in the configuration file: ```php -Recorders\OutgoingRequests::class => [ +Recorders\SlowOutgoingRequests::class => [ // ... 'groups' => [ // '#^https://api\.github\.com/repos/.*$#' => 'api.github.com/repos/*', @@ -338,6 +366,20 @@ The `SlowQueries` recorder captures any database queries in your application tha You may optionally adjust the slow query threshold, [sample rate](#sampling), and ignored query patterns. You may also configure whether to capture the query location. The captured location will be displayed on the Pulse dashboard which can help to track down the query origin; however, if the same query is made in multiple locations then it will appear multiple times for each unique location. +You may have some queries that you expect to take longer than others. In those cases, you may configure per-query thresholds: + +```php +Recorders\SlowQueries::class => [ + // ... + 'threshold' => [ + '#^insert into `yearly_reports`#' => 5000, + 'default' => env('PULSE_SLOW_QUERIES_THRESHOLD', 1000), + ], +], +``` + +If no regular expression patterns match the query's SQL, then the `'default'` value will be used. + #### Slow Requests @@ -345,6 +387,20 @@ The `Requests` recorder captures information about requests made to your applica You may optionally adjust the slow route threshold, [sample rate](#sampling), and ignored paths. +You may have some requests that you expect to take longer than others. In those cases, you may configure per-request thresholds: + +```php +Recorders\SlowRequests::class => [ + // ... + 'threshold' => [ + '#^/admin/#' => 5000, + 'default' => env('PULSE_SLOW_REQUESTS_THRESHOLD', 1000), + ], +], +``` + +If no regular expression patterns match the request's URL, then the `'default'` value will be used. + #### Servers From b8bf6ca8a64bd05c27e4ef2b6eddbd961d02bf2b Mon Sep 17 00:00:00 2001 From: "Alex P. Gates" Date: Mon, 13 May 2024 12:08:43 -0500 Subject: [PATCH 043/325] Add details about Carbon 3 upgrade (#9653) Adds a bit more context about changes to Carbon 3's `diffIn*`changes. --- upgrade.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upgrade.md b/upgrade.md index 064f853be10..eb3ffb22f4a 100644 --- a/upgrade.md +++ b/upgrade.md @@ -414,7 +414,7 @@ public function scalar($query, $bindings = [], $useReadPdo = true); **Likelihood Of Impact: Medium** -Laravel 11 supports both Carbon 2 and Carbon 3. Carbon is a date manipulation library utilized extensively by Laravel and packages throughout the ecosystem. If you install Carbon 3, you should review Carbon's [change log](https://github.com/briannesbitt/Carbon/releases/tag/3.0.0). +Laravel 11 supports both Carbon 2 and Carbon 3. Carbon is a date manipulation library utilized extensively by Laravel and packages throughout the ecosystem. If you upgrade to Carbon 3, be aware that `diffIn*` methods now return floating-point numbers and may return negative values to indicate time direction, which is a significant change from Carbon 2. Review Carbon's [change log](https://github.com/briannesbitt/Carbon/releases/tag/3.0.0) for detailed information on how to handle these and other changes. ### Mail From 98800e08b321f2e591cefb104c9ece3645b41ab9 Mon Sep 17 00:00:00 2001 From: Milwad <98118400+milwad-dev@users.noreply.github.com> Date: Mon, 13 May 2024 20:45:33 +0330 Subject: [PATCH 044/325] [11.x] Add `whereIn` example with enum class (#9649) * Update routing.md * Update routing.md --------- Co-authored-by: Taylor Otwell --- routing.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/routing.md b/routing.md index eb8cd83a4b3..091ff88ee05 100644 --- a/routing.md +++ b/routing.md @@ -323,6 +323,10 @@ For convenience, some commonly used regular expression patterns have helper meth Route::get('/category/{category}', function (string $category) { // ... })->whereIn('category', ['movie', 'song', 'painting']); + + Route::get('/category/{category}', function (string $category) { + // ... + })->whereIn('category', CategoryEnum::cases()); If the incoming request does not match the route pattern constraints, a 404 HTTP response will be returned. From 2a9cd61538f0b9d340d11f178129b090a183bcbd Mon Sep 17 00:00:00 2001 From: Ahmed shamim Date: Mon, 13 May 2024 23:15:58 +0600 Subject: [PATCH 045/325] Hide X-powered-by in nginx config (#9651) --- deployment.md | 1 + 1 file changed, 1 insertion(+) diff --git a/deployment.md b/deployment.md index e6af9290a33..421ccaf8c5b 100644 --- a/deployment.md +++ b/deployment.md @@ -80,6 +80,7 @@ server { fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; + fastcgi_hide_header X-Powered-By; } location ~ /\.(?!well-known).* { From 0dd21627d08a2bc060714f86c308f1c6e284b0de Mon Sep 17 00:00:00 2001 From: janne-stuvia <161812605+janne-stuvia@users.noreply.github.com> Date: Mon, 13 May 2024 19:50:40 +0200 Subject: [PATCH 046/325] Adding ',' in the example (#9657) --- precognition.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/precognition.md b/precognition.md index 3877cd0993e..4dc62c6de60 100644 --- a/precognition.md +++ b/precognition.md @@ -630,7 +630,7 @@ protected function rules() 'avatar' => [ ...$this->isPrecognitive() ? [] : ['required'], 'image', - 'mimes:jpg,png' + 'mimes:jpg,png', 'dimensions:ratio=3/2', ], // ... From bdf7135378f88ea5d47e8a8306462c65232b7a34 Mon Sep 17 00:00:00 2001 From: Milwad <98118400+milwad-dev@users.noreply.github.com> Date: Mon, 13 May 2024 21:20:50 +0330 Subject: [PATCH 047/325] Update routing.md (#9656) --- routing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routing.md b/routing.md index 091ff88ee05..94a27da6983 100644 --- a/routing.md +++ b/routing.md @@ -317,7 +317,7 @@ For convenience, some commonly used regular expression patterns have helper meth })->whereUuid('id'); Route::get('/user/{id}', function (string $id) { - // + // ... })->whereUlid('id'); Route::get('/category/{category}', function (string $category) { From 147284468a475e2b294d9679e4d970d3a8104782 Mon Sep 17 00:00:00 2001 From: Edgaras <55696268+Edgaraszs@users.noreply.github.com> Date: Sat, 18 May 2024 00:37:35 +0300 Subject: [PATCH 048/325] [11.x] Adds documentation on GitHub Actions with Laravel Pint (#9661) * docs: laravel pint usage with github actions * Fixes Pint documentation with GitHub Actions * Update pint.md --------- Co-authored-by: Nuno Maduro Co-authored-by: Taylor Otwell --- pint.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/pint.md b/pint.md index 2156e920e85..dcf69c9c294 100644 --- a/pint.md +++ b/pint.md @@ -7,6 +7,8 @@ - [Presets](#presets) - [Rules](#rules) - [Excluding Files / Folders](#excluding-files-or-folders) +- [Continuous Integration](#continuous-integration) + - [GitHub Actions](#running-tests-on-github-actions) ## Introduction @@ -156,3 +158,47 @@ If you would like to exclude a file by providing an exact path to the file, you ] } ``` + + +## Continuous Integration + + +### GitHub Actions + +To automate linting your project with Laravel Pint, you can configure [GitHub Actions](https://github.com/features/actions) to run Pint whenever new code is pushed to GitHub. First, be sure to grant "Read and write permissions" to workflows within GitHub at **Settings > Actions > General > Workflow permissions**. Then, create a `.github/workflows/lint.yml` file with the following content: + +```yaml +name: Fix Code Style + +on: [push] + +jobs: + lint: + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + php: [8.3] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: json, dom, curl, libxml, mbstring + coverage: none + + - name: Install Pint + run: composer global require laravel/pint + + - name: Run Pint + run: pint + + - name: Commit linted files + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "Fixes coding style" +``` From 782f498fdbac5fedffc491f5e6f512d5603e87a7 Mon Sep 17 00:00:00 2001 From: Janos Horvath Date: Tue, 21 May 2024 19:39:10 +0200 Subject: [PATCH 049/325] Fix typo in passing named argument (#9666) previous code was still working but not for the right reasons --- collections.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collections.md b/collections.md index fc9c1cb5fb1..b4317bd22a1 100644 --- a/collections.md +++ b/collections.md @@ -2131,7 +2131,7 @@ The `search` method searches the collection for the given value and returns its The search is done using a "loose" comparison, meaning a string with an integer value will be considered equal to an integer of the same value. To use "strict" comparison, pass `true` as the second argument to the method: - collect([2, 4, 6, 8])->search('4', $strict = true); + collect([2, 4, 6, 8])->search('4', strict: true); // false From 57be710a7a19ef854ddcb658e1bdb89958ab8571 Mon Sep 17 00:00:00 2001 From: Len Woodward Date: Wed, 22 May 2024 08:09:17 -0700 Subject: [PATCH 050/325] [11.x] Adds documentation for Command::fail method (#9669) * [11.x] Adds documentation for Command::fail method * Update artisan.md --------- Co-authored-by: Taylor Otwell --- artisan.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/artisan.md b/artisan.md index 6009fdb38a5..6c6f92da589 100644 --- a/artisan.md +++ b/artisan.md @@ -158,6 +158,19 @@ Let's take a look at an example command. Note that we are able to request any de > [!NOTE] > For greater code reuse, it is good practice to keep your console commands light and let them defer to application services to accomplish their tasks. In the example above, note that we inject a service class to do the "heavy lifting" of sending the e-mails. + +#### Exit Codes + +If nothing is returned from the `handle` method and the command executes successfully, the command will exit with a `0` exit code, indicating success. However, the `handle` method may optionally return an integer to manually specify command's exit code: + + $this->error('Something went wrong.'); + + return 1; + +If you would like to "fail" the command from another method within the command, you may utilize the `fail` method. The `fail` method will immediately terminate execution of the command and return an exit code of `1`: + + $this->fail('Something went wrong.'); + ### Closure Commands From b4ad31972d5e8a4859b3fc860f85879ba17c0a12 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 22 May 2024 10:10:33 -0500 Subject: [PATCH 051/325] wip --- artisan.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/artisan.md b/artisan.md index 6c6f92da589..645163c9c81 100644 --- a/artisan.md +++ b/artisan.md @@ -167,7 +167,7 @@ If nothing is returned from the `handle` method and the command executes success return 1; -If you would like to "fail" the command from another method within the command, you may utilize the `fail` method. The `fail` method will immediately terminate execution of the command and return an exit code of `1`: +If you would like to "fail" the command from any method within the command, you may utilize the `fail` method. The `fail` method will immediately terminate execution of the command and return an exit code of `1`: $this->fail('Something went wrong.'); From 0638b0001a8f66274a2c0129d1ccda0f09dc056f Mon Sep 17 00:00:00 2001 From: Mahmudul Hasan Date: Mon, 27 May 2024 19:42:36 +0600 Subject: [PATCH 052/325] Fix invalid route declarations (#9677) - Fixed invalid view route declarations in quickstart-selling-products section --- billing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/billing.md b/billing.md index f29dafaf9f0..24bf203762b 100644 --- a/billing.md +++ b/billing.md @@ -266,8 +266,8 @@ To charge customers for non-recurring, single-charge products, we'll utilize Cas ]); })->name('checkout'); - Route::view('checkout.success')->name('checkout-success'); - Route::view('checkout.cancel')->name('checkout-cancel'); + Route::view('/checkout/success', 'checkout.success')->name('checkout-success'); + Route::view('/checkout/cancel', 'checkout.cancel')->name('checkout-cancel'); As you can see in the example above, we will utilize Cashier's provided `checkout` method to redirect the customer to Stripe Checkout for a given "price identifier". When using Stripe, "prices" refer to [defined prices for specific products](https://stripe.com/docs/products-prices/how-products-and-prices-work). From fddaff4f44b4094e73c61ae81234fe5139cc7425 Mon Sep 17 00:00:00 2001 From: Chris Arter Date: Mon, 27 May 2024 09:45:58 -0400 Subject: [PATCH 053/325] [11.x] Documents removeAllFromSearch method (#9676) * documents removeAllFromSearch method * Update scout.md --------- Co-authored-by: Taylor Otwell --- scout.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scout.md b/scout.md index 535fb5bb18b..2a2c28246bb 100644 --- a/scout.md +++ b/scout.md @@ -595,6 +595,10 @@ Or, if you already have a collection of Eloquent models in memory, you may call $orders->unsearchable(); +To remove all of the model records from their corresponding index, you may invoke the `removeAllFromSearch` method: + + Order::removeAllFromSearch(); + ### Pausing Indexing From cdcb337a5d0fca73777d3453dd263eea02e81095 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 28 May 2024 14:49:33 -0500 Subject: [PATCH 054/325] wip --- prompts.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/prompts.md b/prompts.md index d61dbb0c668..1c29bfdb2ee 100644 --- a/prompts.md +++ b/prompts.md @@ -421,6 +421,14 @@ $categories = multiselect( ); ``` +You may allow the user to easily select all options via the `canSelectAll` argument: + +$categories = multiselect( + label: 'What categories should be assigned?', + options: Category::pluck('name', 'id'), + canSelectAll: true +); + #### Requiring a Value From 83acdf1ce7b6ba0940b1bfbbab95ad5a609f88f4 Mon Sep 17 00:00:00 2001 From: Hany Mohamed Date: Thu, 30 May 2024 20:13:22 +0400 Subject: [PATCH 055/325] Fix typo in shouldQueue method description (#9682) --- events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/events.md b/events.md index 719b17954cf..2a8bbfc6f20 100644 --- a/events.md +++ b/events.md @@ -328,7 +328,7 @@ If you would like to define the listener's queue connection, queue name, or dela #### Conditionally Queueing Listeners -Sometimes, you may need to determine whether a listener should be queued based on some data that are only available at runtime. To accomplish this, a `shouldQueue` method may be added to a listener to determine whether the listener should be queued. If the `shouldQueue` method returns `false`, the listener will not be executed: +Sometimes, you may need to determine whether a listener should be queued based on some data that are only available at runtime. To accomplish this, a `shouldQueue` method may be added to a listener to determine whether the listener should be queued. If the `shouldQueue` method returns `false`, the listener will not be queued: Date: Fri, 31 May 2024 18:27:52 +0200 Subject: [PATCH 056/325] Update matchAll to include first only matching group (#9683) * Update matchAll to include first only matching group * Update strings.md --------- Co-authored-by: Taylor Otwell --- strings.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings.md b/strings.md index 102f67d31f3..43551e42bb8 100644 --- a/strings.md +++ b/strings.md @@ -2031,7 +2031,7 @@ The `matchAll` method will return a collection containing the portions of a stri // collect(['bar', 'bar']) -If you specify a matching group within the expression, Laravel will return a collection of that group's matches: +If you specify a matching group within the expression, Laravel will return a collection of the first matching group's matches: use Illuminate\Support\Str; From 0dc4bc30eaa44c960dce4b4e0d4397b953167571 Mon Sep 17 00:00:00 2001 From: William David Edwards Date: Thu, 6 Jun 2024 16:16:22 +0200 Subject: [PATCH 057/325] Remove libevent and libev from Reverb docs. Deprecated from React's event loop in https://github.com/reactphp/event-loop/pull/273 (#9693) --- reverb.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/reverb.md b/reverb.md index 48065d6dba1..e1ecb5a0dee 100644 --- a/reverb.md +++ b/reverb.md @@ -225,13 +225,9 @@ forge hard nofile 10000 Under the hood, Reverb uses a ReactPHP event loop to manage WebSocket connections on the server. By default, this event loop is powered by `stream_select`, which doesn't require any additional extensions. However, `stream_select` is typically limited to 1,024 open files. As such, if you plan to handle more than 1,000 concurrent connections, you will need to use an alternative event loop not bound to the same restrictions. -Reverb will automatically switch to an `ext-event`, `ext-ev`, or `ext-uv` powered loop when available. All of these PHP extensions are available for install via PECL: +Reverb will automatically switch to an `ext-uv` powered loop when available. This PHP extension is available for install via PECL: ```sh -pecl install event -# or -pecl install ev -# or pecl install uv ``` From 45770c3785bddd5a79d0fe8f5a8bfa5cd81867e6 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 6 Jun 2024 22:37:56 +0800 Subject: [PATCH 058/325] docs(migrations): NoPendingMigrations - nothing to migrate event (#9692) * docs(migrations): NoPendingMigrations - nothing to migrate event Add ed`NoPendingMigrations` event when there is nothing to migrate * Update migrations.md --------- Co-authored-by: Taylor Otwell --- migrations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/migrations.md b/migrations.md index 6df04a5d488..e5a31935952 100644 --- a/migrations.md +++ b/migrations.md @@ -1221,5 +1221,6 @@ For convenience, each migration operation will dispatch an [event](/docs/{{versi | `Illuminate\Database\Events\MigrationsEnded` | A batch of migrations has finished executing. | | `Illuminate\Database\Events\MigrationStarted` | A single migration is about to be executed. | | `Illuminate\Database\Events\MigrationEnded` | A single migration has finished executing. | +| `Illuminate\Database\Events\NoPendingMigrations` | A migration command found no pending migrations. | | `Illuminate\Database\Events\SchemaDumped` | A database schema dump has completed. | | `Illuminate\Database\Events\SchemaLoaded` | An existing database schema dump has loaded. | From ef9f016ecda27acfad32d402290c2ac9a48072a3 Mon Sep 17 00:00:00 2001 From: Milwad Khosravi <98118400+milwad-dev@users.noreply.github.com> Date: Sun, 9 Jun 2024 19:59:01 +0330 Subject: [PATCH 059/325] [11.x] Add example for `updateOrInsert` method in queries (#9695) * Update queries.md * Update queries.md * Update queries.md --------- Co-authored-by: Taylor Otwell --- queries.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/queries.md b/queries.md index 94ff47f6905..ca6417d44d3 100644 --- a/queries.md +++ b/queries.md @@ -1026,6 +1026,22 @@ The `updateOrInsert` method will attempt to locate a matching database record us ['votes' => '2'] ); +You may provide a closure to the `updateOrInsert` method to customize the attributes that are updated or inserted into the database based on the existence of a matching record: + +```php +DB::table('users')->updateOrInsert( + ['user_id' => $user_id], + fn ($exists) => $exists ? [ + 'name' => $data['name'], + 'email' => $data['email'], + ] : [ + 'name' => $data['name'], + 'email' => $data['email'], + 'marketable' => true, + ], +); +``` + ### Updating JSON Columns From 38e549f8ec44e64769390ffd965728055f3b443b Mon Sep 17 00:00:00 2001 From: David Lambauer Date: Mon, 10 Jun 2024 17:12:23 +0200 Subject: [PATCH 060/325] table() expects an array, collection given (#9698) --- prompts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prompts.md b/prompts.md index 1c29bfdb2ee..fb7d19eab18 100644 --- a/prompts.md +++ b/prompts.md @@ -805,7 +805,7 @@ use function Laravel\Prompts\table; table( ['Name', 'Email'], - User::all(['name', 'email']) + User::all(['name', 'email'])->toArray() ); ``` From ec9ff5137928e2e6932664514b112ae12aaf7901 Mon Sep 17 00:00:00 2001 From: maru0914 <56859729+maru0914@users.noreply.github.com> Date: Tue, 11 Jun 2024 00:13:03 +0900 Subject: [PATCH 061/325] Remove unnecessary imports from the first example (#9697) --- container.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/container.md b/container.md index fbe5fa2c496..1fe0e8921cc 100644 --- a/container.md +++ b/container.md @@ -29,9 +29,7 @@ Let's look at a simple example: namespace App\Http\Controllers; - use App\Http\Controllers\Controller; use App\Repositories\UserRepository; - use App\Models\User; use Illuminate\View\View; class UserController extends Controller From 669bb1c9dbb19687837e6062fab81a0fbe255858 Mon Sep 17 00:00:00 2001 From: Cas Ebbers <617080+CasEbb@users.noreply.github.com> Date: Tue, 11 Jun 2024 20:55:33 +0200 Subject: [PATCH 062/325] Fix call to Model::increment() (#9699) --- eloquent.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eloquent.md b/eloquent.md index 0a5cd0d4135..a4142ed29a1 100644 --- a/eloquent.md +++ b/eloquent.md @@ -313,7 +313,7 @@ If you need to customize the names of the columns used to store the timestamps, If you would like to perform model operations without the model having its `updated_at` timestamp modified, you may operate on the model within a closure given to the `withoutTimestamps` method: - Model::withoutTimestamps(fn () => $post->increment(['reads'])); + Model::withoutTimestamps(fn () => $post->increment('reads')); ### Database Connections From 39d960362f89761836c2f59d6aa51173fb94bd18 Mon Sep 17 00:00:00 2001 From: Volodya Kurshudyan <70023120+xurshudyan@users.noreply.github.com> Date: Wed, 12 Jun 2024 17:59:39 +0400 Subject: [PATCH 063/325] Add default value in `Cache::pull` method (#9702) * Add default value in Cache::pull method * Update cache.md --------- Co-authored-by: Xurshudyan Co-authored-by: Taylor Otwell --- cache.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cache.md b/cache.md index 169e6b63711..e2a6751eee7 100644 --- a/cache.md +++ b/cache.md @@ -209,6 +209,8 @@ If you need to retrieve an item from the cache and then delete the item, you may $value = Cache::pull('key'); + $value = Cache::pull('key', 'default'); + ### Storing Items in the Cache From 329323efb2a054fa1b6fcdd93cdd264622283d8f Mon Sep 17 00:00:00 2001 From: Wes Hooper Date: Wed, 12 Jun 2024 15:05:37 +0100 Subject: [PATCH 064/325] Clarify exclusions for fallback HTTP error pages (#9701) * Clarify exclusions for fallback HTTP error pages * Update errors.md --------- Co-authored-by: Taylor Otwell --- errors.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/errors.md b/errors.md index 038caec7b8e..c04a842ceea 100644 --- a/errors.md +++ b/errors.md @@ -410,4 +410,6 @@ php artisan vendor:publish --tag=laravel-errors #### Fallback HTTP Error Pages -You may also define a "fallback" error page for a given series of HTTP status codes. This page will be rendered if there is not a corresponding page for the specific HTTP status code that occurred. To accomplish this, define a `4xx.blade.php` template and a `5xx.blade.php` template in your application's `resources/views/errors` directory. +You may also define a "fallback" error page for a given series of HTTP status codes. This page will be rendered if there is not a corresponding page for the specific HTTP status code that occurred. To accomplish this, define a `4xx.blade.php` template and a `5xx.blade.php` template in your application's `resources/views/errors` directory. + +When defining fallback error pages, the fallback pages will not affect `404`, `500`, and `503` error responses since Laravel has internal, dedicated pages for these status codes. To customize the pages rendered for these status codes, you should define a custom error page for each of them individually. From 9555e96b0920afefda9c4f5440fce758f2180be4 Mon Sep 17 00:00:00 2001 From: Gustavo Karkow <14905932+karkowg@users.noreply.github.com> Date: Thu, 13 Jun 2024 21:42:44 -0400 Subject: [PATCH 065/325] Document using wildcards in Horizon environments (#9706) * document wildcard in horizon environments * Update horizon.md --------- Co-authored-by: Taylor Otwell --- horizon.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/horizon.md b/horizon.md index 8e90e2bed3b..66d44d8999a 100644 --- a/horizon.md +++ b/horizon.md @@ -74,6 +74,18 @@ After installation, the primary Horizon configuration option that you should fam ], ], +You may also define a wildcard environment (`*`) which will be used when no other matching environment is found: + + 'environments' => [ + // ... + + '*' => [ + 'supervisor-1' => [ + 'maxProcesses' => 3, + ], + ], + ], + When you start Horizon, it will use the worker process configuration options for the environment that your application is running on. Typically, the environment is determined by the value of the `APP_ENV` [environment variable](/docs/{{version}}/configuration#determining-the-current-environment). For example, the default `local` Horizon environment is configured to start three worker processes and automatically balance the number of worker processes assigned to each queue. The default `production` environment is configured to start a maximum of 10 worker processes and automatically balance the number of worker processes assigned to each queue. > [!WARNING] From 64eb35ea054ff657e27aba694e8c1a8fae8d2f80 Mon Sep 17 00:00:00 2001 From: Anthony Cooper Date: Tue, 18 Jun 2024 18:22:04 +0100 Subject: [PATCH 066/325] Fix Lottery helper method name (#9711) --- helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers.md b/helpers.md index 5906469c047..d1db1245855 100644 --- a/helpers.md +++ b/helpers.md @@ -2360,7 +2360,7 @@ Laravel provides some simple methods to allow you to easily test your applicatio Lottery::fix([true, false]); // Lottery will return to normal behavior... - Lottery::determineResultsNormally(); + Lottery::determineResultNormally(); ### Pipeline From 92826a1f2422358b0d17bea19e13ecfa1e1aff6f Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 18 Jun 2024 12:23:15 -0500 Subject: [PATCH 067/325] Revert "Fix Lottery helper method name (#9711)" (#9712) This reverts commit 64eb35ea054ff657e27aba694e8c1a8fae8d2f80. --- helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers.md b/helpers.md index d1db1245855..5906469c047 100644 --- a/helpers.md +++ b/helpers.md @@ -2360,7 +2360,7 @@ Laravel provides some simple methods to allow you to easily test your applicatio Lottery::fix([true, false]); // Lottery will return to normal behavior... - Lottery::determineResultNormally(); + Lottery::determineResultsNormally(); ### Pipeline From c6cffbab1697acf7e53bd52646ec72b432635113 Mon Sep 17 00:00:00 2001 From: Ryuta Hamasaki Date: Wed, 19 Jun 2024 02:47:08 +0900 Subject: [PATCH 068/325] [11.x] Add `before` and `after` methods to Collection (#9700) * add documentation for "before" method * add documentation for "after" method * mark "after" method as the first collection method * formatting --------- Co-authored-by: Taylor Otwell --- collections.md | 58 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/collections.md b/collections.md index b4317bd22a1..38124cf783f 100644 --- a/collections.md +++ b/collections.md @@ -94,9 +94,11 @@ For the majority of the remaining collection documentation, we'll discuss each m
+[after](#method-after) [all](#method-all) [average](#method-average) [avg](#method-avg) +[before](#method-before) [chunk](#method-chunk) [chunkWhile](#method-chunkwhile) [collapse](#method-collapse) @@ -255,8 +257,37 @@ For the majority of the remaining collection documentation, we'll discuss each m } + +#### `after()` {.collection-method .first-collection-method} + +The `after` method returns the item after the given item. `null` is returned if the given item is not found or is the last item: + + $collection = collect([1, 2, 3, 4, 5]); + + $collection->after(3); + + // 4 + + $collection->after(5); + + // null + +This method searches for the given item using "loose" comparison, meaning a string containing an integer value will be considered equal to an integer of the same value. To use "strict" comparison, you may provide the `strict` argument to the method: + + collect([2, 4, 6, 8])->after('4', strict: true); + + // null + +Alternatively, you may provide your own closure to search for the first item that passes a given truth test: + + collect([2, 4, 6, 8])->after(function (int $item, int $key) { + return $item > 5; + }); + + // 8 + -#### `all()` {.collection-method .first-collection-method} +#### `all()` {.collection-method} The `all` method returns the underlying array represented by the collection: @@ -287,6 +318,31 @@ The `avg` method returns the [average value](https://en.wikipedia.org/wiki/Avera // 2 + +#### `before()` {.collection-method} + +The `before` method is the opposite of the [`after`](#method-after) method. It returns the item before the given item. `null` is returned if the given item is not found or is the first item: + + $collection = collect([1, 2, 3, 4, 5]); + + $collection->before(3); + + // 2 + + $collection->before(1); + + // null + + collect([2, 4, 6, 8])->before('4', strict: true); + + // null + + collect([2, 4, 6, 8])->before(function (int $item, int $key) { + return $item > 5; + }); + + // 4 + #### `chunk()` {.collection-method} From c802e4ce57c4e56b43e0b59a8a588b68bbecf26b Mon Sep 17 00:00:00 2001 From: HarryLee186 <34167106+HarryLee186@users.noreply.github.com> Date: Thu, 20 Jun 2024 08:29:55 +0100 Subject: [PATCH 069/325] Update upgrade.md to include Scout dependency (#9714) --- upgrade.md | 1 + 1 file changed, 1 insertion(+) diff --git a/upgrade.md b/upgrade.md index eb3ffb22f4a..f1c49f053ca 100644 --- a/upgrade.md +++ b/upgrade.md @@ -79,6 +79,7 @@ You should update the following dependencies in your application's `composer.jso - `laravel/octane` to `^2.3` (If installed) - `laravel/passport` to `^12.0` (If installed) - `laravel/sanctum` to `^4.0` (If installed) +- `laravel/scout` to `^10.0` (If installed) - `laravel/spark-stripe` to `^5.0` (If installed) - `laravel/telescope` to `^5.0` (If installed) - `inertiajs/inertia-laravel` to `^1.0` (If installed) From 910898f77947c560ed9e1017b15314229a4bd1b6 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Thu, 20 Jun 2024 16:37:04 +0200 Subject: [PATCH 070/325] Remove notes from bootstrap/providers.php (#9715) Follows the default from `laravel/laravel`, see https://github.com/laravel/laravel/commit/dd6777099d757eb714b2dd8b12709ed440e9a1d2. --- providers.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/providers.md b/providers.md index 4d6c2709e1d..f68718dfb67 100644 --- a/providers.md +++ b/providers.md @@ -149,8 +149,6 @@ All service providers are registered in the `bootstrap/providers.php` configurat Date: Fri, 21 Jun 2024 00:07:41 +0200 Subject: [PATCH 071/325] Add Herd installation guide (#9717) * add Herd setup instructions * wip * use official lowercase letters for nginx and dnsmasq * wip * wip --------- Co-authored-by: Marcel Pociot Co-authored-by: Taylor Otwell --- installation.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/installation.md b/installation.md index 56c43e782a9..beeff46dcfd 100644 --- a/installation.md +++ b/installation.md @@ -7,6 +7,9 @@ - [Environment Based Configuration](#environment-based-configuration) - [Databases and Migrations](#databases-and-migrations) - [Directory Configuration](#directory-configuration) +- [Local Installation Using Herd](#local-installation-using-herd) + - [Herd on macOS](#herd-on-macos) + - [Herd on Windows](#herd-on-windows) - [Docker Installation Using Sail](#docker-installation-using-sail) - [Sail on macOS](#sail-on-macos) - [Sail on Windows](#sail-on-windows) @@ -53,7 +56,7 @@ Laravel combines the best packages in the PHP ecosystem to offer the most robust ## Creating a Laravel Project -Before creating your first Laravel project, make sure that your local machine has PHP and [Composer](https://getcomposer.org) installed. If you are developing on macOS or Windows, PHP and Composer can be installed in minutes via [Laravel Herd](https://herd.laravel.com). In addition, we recommend [installing Node and NPM](https://nodejs.org). +Before creating your first Laravel project, make sure that your local machine has PHP and [Composer](https://getcomposer.org) installed. If you are developing on macOS or Windows, PHP, Composer, Node and NPM can be installed in minutes via [Laravel Herd](#local-installation-using-herd). After you have installed PHP and Composer, you may create a new Laravel project via Composer's `create-project` command: @@ -124,13 +127,63 @@ php artisan migrate ``` > [!NOTE] -> If you are developing on macOS and need to install MySQL, PostgreSQL, or Redis locally, consider using [DBngin](https://dbngin.com/). +> If you are developing on macOS or Windows and need to install MySQL, PostgreSQL, or Redis locally, consider using [Herd Pro](https://herd.laravel.com/#plans). ### Directory Configuration Laravel should always be served out of the root of the "web directory" configured for your web server. You should not attempt to serve a Laravel application out of a subdirectory of the "web directory". Attempting to do so could expose sensitive files present within your application. + +## Local Installation Using Herd + +[Laravel Herd](https://herd.laravel.com) is a blazing fast, native Laravel and PHP development environment for macOS and Windows. Herd includes everything you need to get started with Laravel development, including PHP and Nginx. + +Once you install Herd, you're ready to start developing with Laravel. Herd includes command line tools for `php`, `composer`, `laravel`, `expose`, `node`, `npm`, and `nvm`. + +> [!NOTE] +> [Herd Pro](https://herd.laravel.com/#plans) augments Herd with additional powerful features, such as the ability to create and manage local MySQL, Postgres, and Redis databases, as well as local mail viewing and log monitoring. + + +### Herd on macOS + +If you develop on macOS, you can download the Herd installer from the [Herd website](https://herd.laravel.com). The installer automatically downloads the latest version of PHP and configures your Mac to always run [Nginx](https://www.nginx.com/) in the background. + +Herd for macOS uses [dnsmasq](https://en.wikipedia.org/wiki/Dnsmasq) to support "parked" directories. Any Laravel application in a parked directory will automatically be served by Herd. By default, Herd creates a parked directory at `~/Herd` and you can access any Laravel application in this directory on the `.test` domain using its directory name. + +After installing Herd, the fastest way to create a new Laravel project is using the Laravel CLI, which is bundled with Herd: + +```nothing +cd ~/Herd +laravel new my-app +cd my-app +herd open +``` + +Of course, you can always manage your parked directories and other PHP settings via Herd's UI, which can be opened from the Herd menu in your system tray. + +You can learn more about Herd by checking out the [Herd documentation](https://herd.laravel.com/docs). + + +### Herd on Windows + +You can download the Windows installer for Herd on the [Herd website](https://herd.laravel.com/windows). After the installation finishes, you can start Herd to complete the onboarding process and access the Herd UI for the first time. + +The Herd UI is accessible by left-clicking on Herd's system tray icon. A right-click opens the quick menu with access to all tools that you need on a daily basis. + +During installation, Herd creates a "parked" directory in your home directory at `%USERPROFILE%\Herd`. Any Laravel application in a parked directory will automatically be served by Herd, and you can access any Laravel application in this directory on the `.test` domain using its directory name. + +After installing Herd, the fastest way to create a new Laravel project is using the Laravel CLI, which is bundled with Herd. To get started, open Powershell and run the following commands: + +```nothing +cd ~\Herd +laravel new my-app +cd my-app +herd open +``` + +You can learn more about Herd by checking out the [Herd documentation for Windows](https://herd.laravel.com/docs/windows). + ## Docker Installation Using Sail From e7889864abbe68b9591dbca38809fd03599b8adf Mon Sep 17 00:00:00 2001 From: Spencer Williams Date: Fri, 21 Jun 2024 08:55:55 -0700 Subject: [PATCH 072/325] Add crucial note about folder permissions to deployment.md (#9718) * Add crucial note about folder permissions * This will help old and new devs understand which folders the framework needs to write in so that folder permissions are not too open. * Add new folder-permissions anchor to top list of links * Update deployment.md --------- Co-authored-by: Taylor Otwell --- deployment.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/deployment.md b/deployment.md index 421ccaf8c5b..1cc4a57297f 100644 --- a/deployment.md +++ b/deployment.md @@ -5,6 +5,7 @@ - [Server Configuration](#server-configuration) - [Nginx](#nginx) - [FrankenPHP](#frankenphp) + - [Directory Permissions](#directory-permissions) - [Optimization](#optimization) - [Caching Configuration](#optimizing-configuration-loading) - [Caching Events](#caching-events) @@ -100,6 +101,11 @@ frankenphp php-server -r public/ To take advantage of more powerful features supported by FrankenPHP, such as its [Laravel Octane](/docs/{{version}}/octane) integration, HTTP/3, modern compression, or the ability to package Laravel applications as standalone binaries, please consult FrankenPHP's [Laravel documentation](https://frankenphp.dev/docs/laravel/). + +### Directory Permissions + +Laravel will need to write to the `bootstrap/cache` and `storage` directories, so you should ensure the web server process owner has permission to write to these directories. + ## Optimization From 33d43e187d466be64edb49b63f135a268fd7fb2c Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Mon, 24 Jun 2024 17:09:13 +0200 Subject: [PATCH 073/325] Update Homestead entry in package list (#9721) --- contributions.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contributions.md b/contributions.md index 9d2b7dd050a..4e25e01ea6f 100644 --- a/contributions.md +++ b/contributions.md @@ -36,8 +36,7 @@ The Laravel source code is managed on GitHub, and there are repositories for eac - [Laravel Envoy](https://github.com/laravel/envoy) - [Laravel Folio](https://github.com/laravel/folio) - [Laravel Framework](https://github.com/laravel/framework) -- [Laravel Homestead](https://github.com/laravel/homestead) -- [Laravel Homestead Build Scripts](https://github.com/laravel/settler) +- [Laravel Homestead](https://github.com/laravel/homestead) ([Build Scripts](https://github.com/laravel/settler)) - [Laravel Horizon](https://github.com/laravel/horizon) - [Laravel Jetstream](https://github.com/laravel/jetstream) - [Laravel Passport](https://github.com/laravel/passport) From e6443d6177b0de2d6a620fd7a9be8569f74fd839 Mon Sep 17 00:00:00 2001 From: maru0914 <56859729+maru0914@users.noreply.github.com> Date: Fri, 28 Jun 2024 01:09:35 +0900 Subject: [PATCH 074/325] Add concrete domain name directory to example code (#9725) --- events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/events.md b/events.md index 2a8bbfc6f20..2c84b318632 100644 --- a/events.md +++ b/events.md @@ -71,7 +71,7 @@ By default, Laravel will automatically find and register your event listeners by If you plan to store your listeners in a different directory or within multiple directories, you may instruct Laravel to scan those directories using the `withEvents` method in your application's `bootstrap/app.php` file: ->withEvents(discover: [ - __DIR__.'/../app/Domain/Listeners', + __DIR__.'/../app/Domain/Orders/Listeners', ]) The `event:list` command may be used to list all of the listeners registered within your application: From 5f9c66744b1ba6cc2de8c533a061a9a953baa83b Mon Sep 17 00:00:00 2001 From: Gabi Suciu Date: Fri, 28 Jun 2024 23:05:33 +0300 Subject: [PATCH 075/325] Added missing dependency upgrade `livewire/livewire` (#9727) --- upgrade.md | 1 + 1 file changed, 1 insertion(+) diff --git a/upgrade.md b/upgrade.md index f1c49f053ca..a5d380c972e 100644 --- a/upgrade.md +++ b/upgrade.md @@ -82,6 +82,7 @@ You should update the following dependencies in your application's `composer.jso - `laravel/scout` to `^10.0` (If installed) - `laravel/spark-stripe` to `^5.0` (If installed) - `laravel/telescope` to `^5.0` (If installed) +- `livewire/livewire` to `^3.4` (If installed) - `inertiajs/inertia-laravel` to `^1.0` (If installed)
From 0117812a0237bfcb1989336b146d6bfbe8b8b696 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Mon, 1 Jul 2024 21:49:35 +0100 Subject: [PATCH 076/325] [11.x] Adds warning for Reverb URI (#9730) * add warning for reverb uri * Update reverb.md * Update reverb.md --------- Co-authored-by: Taylor Otwell --- reverb.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reverb.md b/reverb.md index e1ecb5a0dee..627068d2965 100644 --- a/reverb.md +++ b/reverb.md @@ -257,6 +257,9 @@ server { } ``` +> [!WARNING] +> Reverb listens for WebSocket connections at `/app` and handles API requests at `/apps`. You should ensure the web server handling Reverb requests can serve both of these URIs. If you are using [Laravel Forge](https://forge.laravel.com) to manage your servers, your Reverb server will be correctly configured by default. + Typically, web servers are configured to limit the number of allowed connections in order to prevent overloading the server. To increase the number of allowed connections on an Nginx web server to 10,000, the `worker_rlimit_nofile` and `worker_connections` values of the `nginx.conf` file should be updated: ```nginx From 2256340f468601a95a63fc1c1b61e3762e9b97e1 Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Wed, 3 Jul 2024 04:04:37 +1000 Subject: [PATCH 077/325] [11.x] Document Str::chop* methods (#9726) * Document Str::chop* methods * formatting --------- Co-authored-by: Taylor Otwell --- strings.md | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/strings.md b/strings.md index 43551e42bb8..ff3566a28ce 100644 --- a/strings.md +++ b/strings.md @@ -43,6 +43,8 @@ Laravel includes a variety of functions for manipulating string values. Many of [Str::betweenFirst](#method-str-between-first) [Str::camel](#method-camel-case) [Str::charAt](#method-char-at) +[Str::chopStart](#method-str-chop-start) +[Str::chopEnd](#method-str-chop-end) [Str::contains](#method-str-contains) [Str::containsAll](#method-str-contains-all) [Str::endsWith](#method-ends-with) @@ -134,6 +136,8 @@ Laravel includes a variety of functions for manipulating string values. Many of [camel](#method-fluent-str-camel) [charAt](#method-fluent-str-char-at) [classBasename](#method-fluent-str-class-basename) +[chopStart](#method-fluent-str-chop-start) +[chopEnd](#method-fluent-str-chop-end) [contains](#method-fluent-str-contains) [containsAll](#method-fluent-str-contains-all) [dirname](#method-fluent-str-dirname) @@ -377,6 +381,44 @@ The `Str::charAt` method returns the character at the specified index. If the in // 's' + +#### `Str::chopStart()` {.collection-method} + +The `Str::chopStart` method removes the first occurrence of the given value only if the value appears at the start of the string: + + use Illuminate\Support\Str; + + $url = Str::chopStart('https://laravel.com', 'https://'); + + // 'laravel.com' + +You may also pass an array as the second argument. If the string starts with any of the values in the array then that value will be removed from string: + + use Illuminate\Support\Str; + + $url = Str::chopStart('http://laravel.com', ['https://', 'http://']); + + // 'laravel.com' + + +#### `Str::chopEnd()` {.collection-method} + +The `Str::chopEnd` method removes the last occurrence of the given value only if the value appears at the end of the string: + + use Illuminate\Support\Str; + + $url = Str::chopEnd('app/Models/Photograph.php', '.php'); + + // 'app/Models/Photograph' + +You may also pass an array as the second argument. If the string ends with any of the values in the array then that value will be removed from string: + + use Illuminate\Support\Str; + + $url = Str::chopEnd('laravel.com/index.php', ['/index.html', '/index.php']); + + // 'laravel.com' + #### `Str::contains()` {.collection-method} @@ -1587,6 +1629,44 @@ The `classBasename` method returns the class name of the given class with the cl // 'Baz' + +#### `chopStart` {.collection-method} + +The `chopStart` method removes the first occurrence of the given value only if the value appears at the start of the string: + + use Illuminate\Support\Str; + + $url = Str::of('https://laravel.com')->chopStart('https://'); + + // 'laravel.com' + +You may also pass an array. If the string starts with any of the values in the array then that value will be removed from string: + + use Illuminate\Support\Str; + + $url = Str::of('http://laravel.com')->chopStart(['https://', 'http://']); + + // 'laravel.com' + + +#### `chopEnd` {.collection-method} + +The `chopEnd` method removes the last occurrence of the given value only if the value appears at the end of the string: + + use Illuminate\Support\Str; + + $url = Str::of('https://laravel.com')->chopEnd('https://'); + + // 'laravel.com' + +You may also pass an array. If the string ends with any of the values in the array then that value will be removed from string: + + use Illuminate\Support\Str; + + $url = Str::of('http://laravel.com')->chopEnd(['https://', 'http://']); + + // 'laravel.com' + #### `contains` {.collection-method} From 0599e7c4b9509b7e7dd311069debaca1c27b08b1 Mon Sep 17 00:00:00 2001 From: Milwad Khosravi <98118400+milwad-dev@users.noreply.github.com> Date: Thu, 4 Jul 2024 00:30:14 +0330 Subject: [PATCH 078/325] [1.x] Add `multiply` method to collection (#9731) * add `multiply` method to collection * Update collections.md * Update collections.md --------- Co-authored-by: Taylor Otwell --- collections.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/collections.md b/collections.md index 38124cf783f..c4cfff89371 100644 --- a/collections.md +++ b/collections.md @@ -163,6 +163,7 @@ For the majority of the remaining collection documentation, we'll discuss each m [mergeRecursive](#method-mergerecursive) [min](#method-min) [mode](#method-mode) +[multiply](#method-multiply) [nth](#method-nth) [only](#method-only) [pad](#method-pad) @@ -1689,6 +1690,29 @@ The `mode` method returns the [mode value](https://en.wikipedia.org/wiki/Mode_(s // [1, 2] + +#### `multiply()` {.collection-method} + +The `multiply` method creates the specified number of copies of all items in the collection: + +```php +$users = collect([ + ['name' => 'User #1', 'email' => 'user1@example.com'], + ['name' => 'User #2', 'email' => 'user2@example.com'], +])->multiply(3); + +/* + [ + ['name' => 'User #1', 'email' => 'user1@example.com'], + ['name' => 'User #2', 'email' => 'user2@example.com'], + ['name' => 'User #1', 'email' => 'user1@example.com'], + ['name' => 'User #2', 'email' => 'user2@example.com'], + ['name' => 'User #1', 'email' => 'user1@example.com'], + ['name' => 'User #2', 'email' => 'user2@example.com'], + ] +*/ +``` + #### `nth()` {.collection-method} From ae9631f61bd97b40e61aa0e81375d115414bc8d1 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Thu, 4 Jul 2024 16:13:43 +0200 Subject: [PATCH 079/325] Remove tax warning for single charges (#9733) --- billing.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/billing.md b/billing.md index 24bf203762b..dbc9b1e58a6 100644 --- a/billing.md +++ b/billing.md @@ -200,9 +200,6 @@ Once tax calculation has been enabled, any new subscriptions and any one-off inv For this feature to work properly, your customer's billing details, such as the customer's name, address, and tax ID, need to be synced to Stripe. You may use the [customer data synchronization](#syncing-customer-data-with-stripe) and [Tax ID](#tax-ids) methods offered by Cashier to accomplish this. -> [!WARNING] -> No tax is calculated for [single charges](#single-charges) or [single charge checkouts](#single-charge-checkouts). - ### Logging From 3ab73d96f69f08d996ec613d2382855dd79710ef Mon Sep 17 00:00:00 2001 From: Philip Downer Date: Thu, 4 Jul 2024 08:14:37 -0600 Subject: [PATCH 080/325] Fixes grammar for queue/connection customization heading (#9732) --- queues.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queues.md b/queues.md index 57c3f6fecde..723b65bba01 100644 --- a/queues.md +++ b/queues.md @@ -933,7 +933,7 @@ When chaining jobs, you may use the `catch` method to specify a closure that sho > Since chain callbacks are serialized and executed at a later time by the Laravel queue, you should not use the `$this` variable within chain callbacks. -### Customizing The Queue a Connection +### Customizing the Queue and Connection #### Dispatching to a Particular Queue From eb257374f1b48862572c496e1e500ba550dd807a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20H?= <36476318+Tamas-hi@users.noreply.github.com> Date: Fri, 5 Jul 2024 17:59:44 +0200 Subject: [PATCH 081/325] Update broadcasting.md (#9741) Since Laravel Reverb is no longer in beta, we can remove the info message from the documentation. --- broadcasting.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/broadcasting.md b/broadcasting.md index 385b1b01516..6fb7ebad010 100644 --- a/broadcasting.md +++ b/broadcasting.md @@ -91,10 +91,10 @@ Before broadcasting any events, you should first configure and run a [queue work ### Reverb -When running the `install:broadcasting` command, you will be prompted to install [Laravel Reverb](/docs/{{version}}/reverb). Of course, you may also install Reverb manually using the Composer package manager. Since Reverb is currently in beta, you will need to explicitly install the beta release: +When running the `install:broadcasting` command, you will be prompted to install [Laravel Reverb](/docs/{{version}}/reverb). Of course, you may also install Reverb manually using the Composer package manager. ```sh -composer require laravel/reverb:@beta +composer require laravel/reverb ``` Once the package is installed, you may run Reverb's installation command to publish the configuration, add Reverb's required environment variables, and enable event broadcasting in your application: From c1e2f0e094846ec98e618c36a3d09966fca8ce61 Mon Sep 17 00:00:00 2001 From: Maru <56859729+maru0914@users.noreply.github.com> Date: Sat, 6 Jul 2024 00:59:58 +0900 Subject: [PATCH 082/325] Remove an unnecessary double quote (#9739) --- helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers.md b/helpers.md index 5906469c047..aaac1146fa0 100644 --- a/helpers.md +++ b/helpers.md @@ -1867,7 +1867,7 @@ An array of contextual data may also be passed to the function: #### `literal()` {.collection-method} -"The `literal` function creates a new [stdClass](https://www.php.net/manual/en/class.stdclass.php) instance with the given named arguments as properties: +The `literal` function creates a new [stdClass](https://www.php.net/manual/en/class.stdclass.php) instance with the given named arguments as properties: $obj = literal( name: 'Joe', From fd2151dcac919bba2935dc325b9490c2185fe594 Mon Sep 17 00:00:00 2001 From: Maru <56859729+maru0914@users.noreply.github.com> Date: Sat, 6 Jul 2024 01:00:32 +0900 Subject: [PATCH 083/325] Fix results of Number::currency() example (#9738) --- helpers.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helpers.md b/helpers.md index aaac1146fa0..7f2ecbba42e 100644 --- a/helpers.md +++ b/helpers.md @@ -1218,15 +1218,15 @@ The `Number::currency` method returns the currency representation of the given v $currency = Number::currency(1000); - // $1,000 + // $1,000.00 $currency = Number::currency(1000, in: 'EUR'); - // €1,000 + // €1,000.00 $currency = Number::currency(1000, in: 'EUR', locale: 'de'); - // 1.000 € + // 1.000,00 € #### `Number::fileSize()` {.collection-method} From 8fbc1e3a96523dbf21116b58e213e69d110350a6 Mon Sep 17 00:00:00 2001 From: Jonathan Goode Date: Fri, 5 Jul 2024 17:03:07 +0100 Subject: [PATCH 084/325] Align with `waitForRoute()` making it more obvious how to pass parameters (#9740) --- dusk.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dusk.md b/dusk.md index 6987eb7d3c2..22acb86dccc 100644 --- a/dusk.md +++ b/dusk.md @@ -423,7 +423,7 @@ The `visit` method may be used to navigate to a given URI within your applicatio You may use the `visitRoute` method to navigate to a [named route](/docs/{{version}}/routing#named-routes): - $browser->visitRoute('login'); + $browser->visitRoute($routeName, $parameters); You may navigate "back" and "forward" using the `back` and `forward` methods: From a39ad9cb9e0512df3cba8163a405616683373459 Mon Sep 17 00:00:00 2001 From: Jonas Staudenmeir Date: Mon, 8 Jul 2024 16:42:43 +0200 Subject: [PATCH 085/325] Improve database support for JSON queries (#9744) --- queries.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/queries.md b/queries.md index ca6417d44d3..8646b135512 100644 --- a/queries.md +++ b/queries.md @@ -552,7 +552,7 @@ WHERE published = true AND ( ### JSON Where Clauses -Laravel also supports querying JSON column types on databases that provide support for JSON column types. Currently, this includes MySQL 8.0+, PostgreSQL 12.0+, SQL Server 2017+, and SQLite 3.39.0+ (with the [JSON1 extension](https://www.sqlite.org/json1.html)). To query a JSON column, use the `->` operator: +Laravel also supports querying JSON column types on databases that provide support for JSON column types. Currently, this includes MariaDB 10.3+, MySQL 8.0+, PostgreSQL 12.0+, SQL Server 2017+, and SQLite 3.39.0+. To query a JSON column, use the `->` operator: $users = DB::table('users') ->where('preferences->dining->meal', 'salad') @@ -564,7 +564,7 @@ You may use `whereJsonContains` to query JSON arrays: ->whereJsonContains('options->languages', 'en') ->get(); -If your application uses the MySQL or PostgreSQL databases, you may pass an array of values to the `whereJsonContains` method: +If your application uses the MariaDB, MySQL, or PostgreSQL databases, you may pass an array of values to the `whereJsonContains` method: $users = DB::table('users') ->whereJsonContains('options->languages', ['en', 'de']) @@ -1045,7 +1045,7 @@ DB::table('users')->updateOrInsert( ### Updating JSON Columns -When updating a JSON column, you should use `->` syntax to update the appropriate key in the JSON object. This operation is supported on MySQL 5.7+ and PostgreSQL 9.5+: +When updating a JSON column, you should use `->` syntax to update the appropriate key in the JSON object. This operation is supported on MariaDB 10.3+, MySQL 5.7+, and PostgreSQL 9.5+: $affected = DB::table('users') ->where('id', 1) From 714d793e2cdb215897ca5f3618a54ef9505ba802 Mon Sep 17 00:00:00 2001 From: Anne Douwe Bouma Date: Mon, 8 Jul 2024 16:43:52 +0200 Subject: [PATCH 086/325] Precognition: Replace attribute `for` with `htmlFor` in React example (#9743) The `for` attribute is not allowed in JSX syntax and should be replaced with `htmlFor` --- precognition.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/precognition.md b/precognition.md index 4dc62c6de60..600c96ae9b2 100644 --- a/precognition.md +++ b/precognition.md @@ -247,7 +247,7 @@ export default function Form() { return (
- + {form.invalid('name') &&
{form.errors.name}
} - + Date: Tue, 9 Jul 2024 02:27:24 +0300 Subject: [PATCH 087/325] [11.x] Update cache.md (#9745) Updated cache lock --- cache.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cache.md b/cache.md index e2a6751eee7..dc896d2a3db 100644 --- a/cache.md +++ b/cache.md @@ -325,7 +325,7 @@ If the lock is not available at the moment you request it, you may instruct Lara } catch (LockTimeoutException $e) { // Unable to acquire lock... } finally { - $lock?->release(); + $lock->release(); } The example above may be simplified by passing a closure to the `block` method. When a closure is passed to this method, Laravel will attempt to acquire the lock for the specified number of seconds and will automatically release the lock once the closure has been executed: From fe305fbe9abdd1e8e1c8b2af182407f375b8de83 Mon Sep 17 00:00:00 2001 From: Milwad Khosravi <98118400+milwad-dev@users.noreply.github.com> Date: Tue, 9 Jul 2024 03:30:26 +0330 Subject: [PATCH 088/325] [11.x] Add `pairs` method to Number (#9742) * Update helpers.md * Update helpers.md * Improve database support for JSON queries (#9744) * Precognition: Replace attribute `for` with `htmlFor` in React example (#9743) The `for` attribute is not allowed in JSX syntax and should be replaced with `htmlFor` * Update helpers.md * Update helpers.md * Update helpers.md --------- Co-authored-by: Jonas Staudenmeir Co-authored-by: Anne Douwe Bouma Co-authored-by: Taylor Otwell --- helpers.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/helpers.md b/helpers.md index 7f2ecbba42e..3baf5b3fa19 100644 --- a/helpers.md +++ b/helpers.md @@ -97,6 +97,7 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct [Number::forHumans](#method-number-for-humans) [Number::format](#method-number-format) [Number::ordinal](#method-number-ordinal) +[Number::pairs](#method-number-pairs) [Number::percentage](#method-number-percentage) [Number::spell](#method-number-spell) [Number::useLocale](#method-number-use-locale) @@ -1308,6 +1309,23 @@ The `Number::ordinal` method returns a number's ordinal representation: // 21st + +#### `Number::pairs()` {.collection-method} + +The `Number::pairs` method generates an array of number pairs (sub-ranges) based on a specified range and step value. This method can be useful for dividing a larger range of numbers into smaller, manageable sub-ranges for things like pagination or batching tasks. The `pairs` method returns an array of arrays, where each inner array represents a pair (sub-range) of numbers: + +```php +use Illuminate\Support\Number; + +$result = Number::pairs(25, 10); + +// [[1, 10], [11, 20], [21, 25]] + +$result = Number::pairs(25, 10, offset: 0); + +// [[0, 10], [10, 20], [20, 25]] +``` + #### `Number::percentage()` {.collection-method} From a70cb211a1998c65f1457e0a88bfcfedbd523a3a Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Wed, 10 Jul 2024 01:03:18 +1000 Subject: [PATCH 089/325] [11.x] Document Pennant's `before` hook (#9746) * Document Pennant's `before` hook * Update pennant.md --------- Co-authored-by: Taylor Otwell --- pennant.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/pennant.md b/pennant.md index 1669713113b..3970e9bcdeb 100644 --- a/pennant.md +++ b/pennant.md @@ -10,6 +10,7 @@ - [The `HasFeatures` Trait](#the-has-features-trait) - [Blade Directive](#blade-directive) - [Middleware](#middleware) + - [Intercepting Feature Checks](#intercepting-feature-checks) - [In-Memory Cache](#in-memory-cache) - [Scope](#scope) - [Specifying the Scope](#specifying-the-scope) @@ -123,6 +124,7 @@ When writing a feature class, you only need to define a `resolve` method, which namespace App\Features; +use App\Models\User; use Illuminate\Support\Lottery; class NewApi @@ -402,6 +404,78 @@ public function boot(): void } ``` + +### Intercepting Feature Checks + +Sometimes it can be useful to perform some in-memory checks before retrieving the stored value of a given feature. Imagine you are developing a new API behind a feature flag and want the ability to disable the new API without losing any of the resolved feature values in storage. If you notice a bug in the new API, you could easily disable it for everyone except internal team members, fix the bug, and then re-enable the new API for the users that previously had access to the feature. + +You can achieve this with a [class-based feature's](#class-based-features) `before` method. When present, the `before` method is always run in-memory before retrieving the value from storage. If a non-`null` value is returned from the method, it will be used in place of the feature's stored value for the duration of the request: + +```php +isInternalTeamMember(); + } + } + + /** + * Resolve the feature's initial value. + */ + public function resolve(User $user): mixed + { + return match (true) { + $user->isInternalTeamMember() => true, + $user->isHighTrafficCustomer() => false, + default => Lottery::odds(1 / 100), + }; + } +} +``` + +You could also use this feature to schedule the global rollout of a feature that was previously behind a feature flag: + +```php +isInternalTeamMember(); + } + + if (Carbon::parse(Config::get('features.new-api.rollout-date'))->isPast()) { + return true; + } + } + + // ... +} +``` + ### In-Memory Cache From c87c7d16189dec8535f25239c117c300a15a75d9 Mon Sep 17 00:00:00 2001 From: Iman Date: Wed, 10 Jul 2024 22:48:40 +0330 Subject: [PATCH 090/325] Add docs for the `empty` preset (#9747) * Add docs for the `empty` preset * Update pint.md --------- Co-authored-by: Taylor Otwell --- pint.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pint.md b/pint.md index dcf69c9c294..f7da25d53d4 100644 --- a/pint.md +++ b/pint.md @@ -87,7 +87,7 @@ pint --config vendor/my-company/coding-style/pint.json ### Presets -Presets defines a set of rules that can be used to fix code style issues in your code. By default, Pint uses the `laravel` preset, which fixes issues by following the opinionated coding style of Laravel. However, you may specify a different preset by providing the `--preset` option to Pint: +Presets define a set of rules that can be used to fix code style issues in your code. By default, Pint uses the `laravel` preset, which fixes issues by following the opinionated coding style of Laravel. However, you may specify a different preset by providing the `--preset` option to Pint: ```shell pint --preset psr12 @@ -101,14 +101,14 @@ If you wish, you may also set the preset in your project's `pint.json` file: } ``` -Pint's currently supported presets are: `laravel`, `per`, `psr12`, and `symfony`. +Pint's currently supported presets are: `laravel`, `per`, `psr12`, `symfony`, and `empty`. ### Rules Rules are style guidelines that Pint will use to fix code style issues in your code. As mentioned above, presets are predefined groups of rules that should be perfect for most PHP projects, so you typically will not need to worry about the individual rules they contain. -However, if you wish, you may enable or disable specific rules in your `pint.json` file: +However, if you wish, you may enable or disable specific rules in your `pint.json` file or use the `empty` preset and define the rules from scratch: ```json { From 111cc1d62d3e4123c73cd7ab5082cc0c9b7416d4 Mon Sep 17 00:00:00 2001 From: Jonas Staudenmeir Date: Fri, 12 Jul 2024 16:07:06 +0200 Subject: [PATCH 091/325] [11.x] Explicitly document MariaDB support (#9751) * Explicitly document MariaDB support * Explicitly document MariaDB support --- eloquent.md | 2 +- migrations.md | 32 ++++++++++++++++---------------- queries.md | 6 +++--- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/eloquent.md b/eloquent.md index a4142ed29a1..c31d51832bd 100644 --- a/eloquent.md +++ b/eloquent.md @@ -897,7 +897,7 @@ Eloquent's `upsert` method may be used to update or create records in a single, ], uniqueBy: ['departure', 'destination'], update: ['price']); > [!WARNING] -> All databases except SQL Server require the columns in the second argument of the `upsert` method to have a "primary" or "unique" index. In addition, the MySQL database driver ignores the second argument of the `upsert` method and always uses the "primary" and "unique" indexes of the table to detect existing records. +> All databases except SQL Server require the columns in the second argument of the `upsert` method to have a "primary" or "unique" index. In addition, the MariaDB and MySQL database drivers ignore the second argument of the `upsert` method and always use the "primary" and "unique" indexes of the table to detect existing records. ## Deleting Models diff --git a/migrations.md b/migrations.md index e5a31935952..58f869b185f 100644 --- a/migrations.md +++ b/migrations.md @@ -71,7 +71,7 @@ php artisan schema:dump --database=testing --prune You should commit your database schema file to source control so that other new developers on your team may quickly create your application's initial database structure. > [!WARNING] -> Migration squashing is only available for the MySQL, PostgreSQL, and SQLite databases and utilizes the database's command-line client. +> Migration squashing is only available for the MariaDB, MySQL, PostgreSQL, and SQLite databases and utilizes the database's command-line client. ## Migration Structure @@ -290,7 +290,7 @@ If you want to perform a schema operation on a database connection that is not y $table->id(); }); -In addition, a few other properties and methods may be used to define other aspects of the table's creation. The `engine` property may be used to specify the table's storage engine when using MySQL: +In addition, a few other properties and methods may be used to define other aspects of the table's creation. The `engine` property may be used to specify the table's storage engine when using MariaDB or MySQL: Schema::create('users', function (Blueprint $table) { $table->engine('InnoDB'); @@ -298,7 +298,7 @@ In addition, a few other properties and methods may be used to define other aspe // ... }); -The `charset` and `collation` properties may be used to specify the character set and collation for the created table when using MySQL: +The `charset` and `collation` properties may be used to specify the character set and collation for the created table when using MariaDB or MySQL: Schema::create('users', function (Blueprint $table) { $table->charset('utf8mb4'); @@ -315,7 +315,7 @@ The `temporary` method may be used to indicate that the table should be "tempora // ... }); -If you would like to add a "comment" to a database table, you may invoke the `comment` method on the table instance. Table comments are currently only supported by MySQL and PostgreSQL: +If you would like to add a "comment" to a database table, you may invoke the `comment` method on the table instance. Table comments are currently only supported by MariaDB, MySQL, and PostgreSQL: Schema::create('calculations', function (Blueprint $table) { $table->comment('Business calculations'); @@ -941,21 +941,21 @@ The following table contains all of the available column modifiers. This list do Modifier | Description -------- | ----------- -`->after('column')` | Place the column "after" another column (MySQL). +`->after('column')` | Place the column "after" another column (MariaDB / MySQL). `->autoIncrement()` | Set INTEGER columns as auto-incrementing (primary key). -`->charset('utf8mb4')` | Specify a character set for the column (MySQL). +`->charset('utf8mb4')` | Specify a character set for the column (MariaDB / MySQL). `->collation('utf8mb4_unicode_ci')` | Specify a collation for the column. -`->comment('my comment')` | Add a comment to a column (MySQL / PostgreSQL). +`->comment('my comment')` | Add a comment to a column (MariaDB / MySQL / PostgreSQL). `->default($value)` | Specify a "default" value for the column. -`->first()` | Place the column "first" in the table (MySQL). -`->from($integer)` | Set the starting value of an auto-incrementing field (MySQL / PostgreSQL). -`->invisible()` | Make the column "invisible" to `SELECT *` queries (MySQL). +`->first()` | Place the column "first" in the table (MariaDB / MySQL). +`->from($integer)` | Set the starting value of an auto-incrementing field (MariaDB / MySQL / PostgreSQL). +`->invisible()` | Make the column "invisible" to `SELECT *` queries (MariaDB / MySQL). `->nullable($value = true)` | Allow NULL values to be inserted into the column. -`->storedAs($expression)` | Create a stored generated column (MySQL / PostgreSQL / SQLite). -`->unsigned()` | Set INTEGER columns as UNSIGNED (MySQL). +`->storedAs($expression)` | Create a stored generated column (MariaDB / MySQL / PostgreSQL / SQLite). +`->unsigned()` | Set INTEGER columns as UNSIGNED (MariaDB / MySQL). `->useCurrent()` | Set TIMESTAMP columns to use CURRENT_TIMESTAMP as default value. -`->useCurrentOnUpdate()` | Set TIMESTAMP columns to use CURRENT_TIMESTAMP when a record is updated (MySQL). -`->virtualAs($expression)` | Create a virtual generated column (MySQL / SQLite). +`->useCurrentOnUpdate()` | Set TIMESTAMP columns to use CURRENT_TIMESTAMP when a record is updated (MariaDB / MySQL). +`->virtualAs($expression)` | Create a virtual generated column (MariaDB / MySQL / SQLite). `->generatedAs($expression)` | Create an identity column with specified sequence options (PostgreSQL). `->always()` | Defines the precedence of sequence values over input for an identity column (PostgreSQL). @@ -992,7 +992,7 @@ The `default` modifier accepts a value or an `Illuminate\Database\Query\Expressi #### Column Order -When using the MySQL database, the `after` method may be used to add columns after an existing column in the schema: +When using the MariaDB or MySQL database, the `after` method may be used to add columns after an existing column in the schema: $table->after('password', function (Blueprint $table) { $table->string('address_line1'); @@ -1101,7 +1101,7 @@ Command | Description `$table->primary(['id', 'parent_id']);` | Adds composite keys. `$table->unique('email');` | Adds a unique index. `$table->index('state');` | Adds an index. -`$table->fullText('body');` | Adds a full text index (MySQL / PostgreSQL). +`$table->fullText('body');` | Adds a full text index (MariaDB / MySQL / PostgreSQL). `$table->fullText('body')->language('english');` | Adds a full text index of the specified language (PostgreSQL). `$table->spatialIndex('location');` | Adds a spatial index (except SQLite). diff --git a/queries.md b/queries.md index 8646b135512..e873bd8fadb 100644 --- a/queries.md +++ b/queries.md @@ -804,9 +804,9 @@ Or, you may need to construct a "where" clause that compares a column to the res ### Full Text Where Clauses > [!WARNING] -> Full text where clauses are currently supported by MySQL and PostgreSQL. +> Full text where clauses are currently supported by MariaDB, MySQL, and PostgreSQL. -The `whereFullText` and `orWhereFullText` methods may be used to add full text "where" clauses to a query for columns that have [full text indexes](/docs/{{version}}/migrations#available-index-types). These methods will be transformed into the appropriate SQL for the underlying database system by Laravel. For example, a `MATCH AGAINST` clause will be generated for applications utilizing MySQL: +The `whereFullText` and `orWhereFullText` methods may be used to add full text "where" clauses to a query for columns that have [full text indexes](/docs/{{version}}/migrations#available-index-types). These methods will be transformed into the appropriate SQL for the underlying database system by Laravel. For example, a `MATCH AGAINST` clause will be generated for applications utilizing MariaDB or MySQL: $users = DB::table('users') ->whereFullText('bio', 'web developer') @@ -1002,7 +1002,7 @@ The `upsert` method will insert records that do not exist and update the records In the example above, Laravel will attempt to insert two records. If a record already exists with the same `departure` and `destination` column values, Laravel will update that record's `price` column. > [!WARNING] -> All databases except SQL Server require the columns in the second argument of the `upsert` method to have a "primary" or "unique" index. In addition, the MySQL database driver ignores the second argument of the `upsert` method and always uses the "primary" and "unique" indexes of the table to detect existing records. +> All databases except SQL Server require the columns in the second argument of the `upsert` method to have a "primary" or "unique" index. In addition, the MariaDB and MySQL database drivers ignore the second argument of the `upsert` method and always use the "primary" and "unique" indexes of the table to detect existing records. ## Update Statements From ded3003a722af87b42cece21cda026273a22f30a Mon Sep 17 00:00:00 2001 From: Tyler Smith Date: Fri, 12 Jul 2024 07:12:08 -0700 Subject: [PATCH 092/325] Elaborate on Laravel installer's features (#9750) * Elaborate on Laravel installer's features * Update installation.md --------- Co-authored-by: Taylor Otwell --- installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation.md b/installation.md index beeff46dcfd..43c643a3038 100644 --- a/installation.md +++ b/installation.md @@ -64,7 +64,7 @@ After you have installed PHP and Composer, you may create a new Laravel project composer create-project laravel/laravel example-app ``` -Or, you may create new Laravel projects by globally installing [the Laravel installer](https://github.com/laravel/installer) via Composer: +Or, you may create new Laravel projects by globally installing [the Laravel installer](https://github.com/laravel/installer) via Composer. The Laravel installer allows you to select your preferred testing framework, database, and starter kit when creating new applications: ```nothing composer global require laravel/installer From bc259b0c5291bd5c5fb0390c1a838656a09271bc Mon Sep 17 00:00:00 2001 From: Mike Scott Date: Fri, 12 Jul 2024 16:09:33 +0100 Subject: [PATCH 093/325] Corrected typo in `assetReleased` to `assertReleased` (#9752) Trivial typo change, added missing 'r'. --- queues.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queues.md b/queues.md index 723b65bba01..290edd6b062 100644 --- a/queues.md +++ b/queues.md @@ -2411,7 +2411,7 @@ In addition, you may occasionally need to test an individual job's interaction w Sometimes, you may need to test that a queued job [releases itself back onto the queue](#manually-releasing-a-job). Or, you may need to test that the job deleted itself. You may test these queue interactions by instantiating the job and invoking the `withFakeQueueInteractions` method. -Once the job's queue interactions have been faked, you may invoke the `handle` method on the job. After invoking the job, the `assetReleased`, `assertDeleted`, and `assertFailed` methods may be used to make assertions against the job's queue interactions: +Once the job's queue interactions have been faked, you may invoke the `handle` method on the job. After invoking the job, the `assertReleased`, `assertDeleted`, and `assertFailed` methods may be used to make assertions against the job's queue interactions: ```php use App\Jobs\ProcessPodcast; From 98c439491fca8234a43a8edd00d144cbcafadabe Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 12 Jul 2024 13:04:24 -0500 Subject: [PATCH 094/325] update docs for foundation queueable --- context.md | 2 +- horizon.md | 9 +++------ queues.md | 36 +++++++++++------------------------- 3 files changed, 15 insertions(+), 32 deletions(-) diff --git a/context.md b/context.md index 4f70e34ca6f..1ef39c20f83 100644 --- a/context.md +++ b/context.md @@ -76,7 +76,7 @@ When the job is dispatched, any information currently stored in the context is c ```php class ProcessPodcast implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + use Queueable; // ... diff --git a/horizon.md b/horizon.md index 66d44d8999a..3e34b47cf28 100644 --- a/horizon.md +++ b/horizon.md @@ -189,7 +189,7 @@ Alternatively, the job you wish to silence can implement the `Laravel\Horizon\Co class ProcessPodcast implements ShouldQueue, Silenced { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + use Queueable; // ... } @@ -307,15 +307,12 @@ Horizon allows you to assign “tags” to jobs, including mailables, broadcast namespace App\Jobs; use App\Models\Video; - use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; - use Illuminate\Foundation\Bus\Dispatchable; - use Illuminate\Queue\InteractsWithQueue; - use Illuminate\Queue\SerializesModels; + use Illuminate\Foundation\Queue\Queueable; class RenderVideo implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + use Queueable; /** * Create a new job instance. diff --git a/queues.md b/queues.md index 57c3f6fecde..1554454412f 100644 --- a/queues.md +++ b/queues.md @@ -181,15 +181,12 @@ Job classes are very simple, normally containing only a `handle` method that is use App\Models\Podcast; use App\Services\AudioProcessor; - use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; - use Illuminate\Foundation\Bus\Dispatchable; - use Illuminate\Queue\InteractsWithQueue; - use Illuminate\Queue\SerializesModels; + use Illuminate\Foundation\Queue\Queueable; class ProcessPodcast implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + use Queueable; /** * Create a new job instance. @@ -207,7 +204,7 @@ Job classes are very simple, normally containing only a `handle` method that is } } -In this example, note that we were able to pass an [Eloquent model](/docs/{{version}}/eloquent) directly into the queued job's constructor. Because of the `SerializesModels` trait that the job is using, Eloquent models and their loaded relationships will be gracefully serialized and unserialized when the job is processing. +In this example, note that we were able to pass an [Eloquent model](/docs/{{version}}/eloquent) directly into the queued job's constructor. Because of the `Queueable` trait that the job is using, Eloquent models and their loaded relationships will be gracefully serialized and unserialized when the job is processing. If your queued job accepts an Eloquent model in its constructor, only the identifier for the model will be serialized onto the queue. When the job is actually handled, the queue system will automatically re-retrieve the full model instance and its loaded relationships from the database. This approach to model serialization allows for much smaller job payloads to be sent to your queue driver. @@ -973,15 +970,12 @@ Alternatively, you may specify the job's queue by calling the `onQueue` method w namespace App\Jobs; - use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; - use Illuminate\Foundation\Bus\Dispatchable; - use Illuminate\Queue\InteractsWithQueue; - use Illuminate\Queue\SerializesModels; + use Illuminate\Foundation\Queue\Queueable; class ProcessPodcast implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + use Queueable; /** * Create a new job instance. @@ -1036,15 +1030,12 @@ Alternatively, you may specify the job's connection by calling the `onConnection namespace App\Jobs; - use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; - use Illuminate\Foundation\Bus\Dispatchable; - use Illuminate\Queue\InteractsWithQueue; - use Illuminate\Queue\SerializesModels; + use Illuminate\Foundation\Queue\Queueable; class ProcessPodcast implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + use Queueable; /** * Create a new job instance. @@ -1277,15 +1268,12 @@ To define a batchable job, you should [create a queueable job](#creating-jobs) a namespace App\Jobs; use Illuminate\Bus\Batchable; - use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; - use Illuminate\Foundation\Bus\Dispatchable; - use Illuminate\Queue\InteractsWithQueue; - use Illuminate\Queue\SerializesModels; + use Illuminate\Foundation\Queue\Queueable; class ImportCsv implements ShouldQueue { - use Batchable, Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + use Batchable, Queueable; /** * Execute the job. @@ -1932,15 +1920,13 @@ When a particular job fails, you may want to send an alert to your users or reve use App\Models\Podcast; use App\Services\AudioProcessor; - use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; - use Illuminate\Queue\InteractsWithQueue; - use Illuminate\Queue\SerializesModels; + use Illuminate\Foundation\Queue\Queueable; use Throwable; class ProcessPodcast implements ShouldQueue { - use InteractsWithQueue, Queueable, SerializesModels; + use Queueable; /** * Create a new job instance. From df370906ae04c91bad1acf44487e7471a8290510 Mon Sep 17 00:00:00 2001 From: TENIOS <40282681+TENIOS@users.noreply.github.com> Date: Mon, 15 Jul 2024 21:58:17 +0700 Subject: [PATCH 095/325] Fix typos in Authorization (#9761) --- authorization.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/authorization.md b/authorization.md index f894ce11a72..d795ac76c09 100644 --- a/authorization.md +++ b/authorization.md @@ -188,7 +188,7 @@ When using the `Gate::authorize` method, which throws an `AuthorizationException // The action is authorized... - + #### Customizing The HTTP Response Status When an action is denied via a Gate, a `403` HTTP response is returned; however, it can sometimes be useful to return an alternative HTTP status code. You may customize the HTTP status code returned for a failed authorization check using the `denyWithStatus` static constructor on the `Illuminate\Auth\Access\Response` class: @@ -384,7 +384,7 @@ When using the `Gate::authorize` method, which throws an `AuthorizationException // The action is authorized... - + #### Customizing the HTTP Response Status When an action is denied via a policy method, a `403` HTTP response is returned; however, it can sometimes be useful to return an alternative HTTP status code. You may customize the HTTP status code returned for a failed authorization check using the `denyWithStatus` static constructor on the `Illuminate\Auth\Access\Response` class: From 89fca51366bd2495622ebf3c2f413793bc18e256 Mon Sep 17 00:00:00 2001 From: TENIOS <40282681+TENIOS@users.noreply.github.com> Date: Mon, 15 Jul 2024 21:58:47 +0700 Subject: [PATCH 096/325] Fix errors directory in URL Generation (#9759) * Update errors directory in url generation docs * Use named arguments in `view` method --- errors.md | 2 +- urls.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/errors.md b/errors.md index c04a842ceea..1562d825a85 100644 --- a/errors.md +++ b/errors.md @@ -187,7 +187,7 @@ The closure passed to the `render` method should return an instance of `Illumina ->withExceptions(function (Exceptions $exceptions) { $exceptions->render(function (InvalidOrderException $e, Request $request) { - return response()->view('errors.invalid-order', [], 500); + return response()->view('errors.invalid-order', status: 500); }); }) diff --git a/urls.md b/urls.md index ab71f573d3d..35a730ae271 100644 --- a/urls.md +++ b/urls.md @@ -177,7 +177,7 @@ When someone visits a signed URL that has expired, they will receive a generic e ->withExceptions(function (Exceptions $exceptions) { $exceptions->render(function (InvalidSignatureException $e) { - return response()->view('error.link-expired', [], 403); + return response()->view('errors.link-expired', status: 403); }); }) From 7e9db237fa22681070c7dc42553fc62205443eb7 Mon Sep 17 00:00:00 2001 From: Gin Date: Mon, 15 Jul 2024 22:00:23 +0700 Subject: [PATCH 097/325] Update upgrade.md: Move Spatie Once Package notice to Medium impact list (#9758) Move "Spatie Once Package" item to Medium Impact Changes according to the detail part: "Likelihood Of Impact: Medium" --- upgrade.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upgrade.md b/upgrade.md index a5d380c972e..c8eea49b09b 100644 --- a/upgrade.md +++ b/upgrade.md @@ -24,6 +24,7 @@ - [Carbon 3](#carbon-3) - [Password Rehashing](#password-rehashing) - [Per-Second Rate Limiting](#per-second-rate-limiting) +- [Spatie Once Package](#spatie-once-package) @@ -35,7 +36,6 @@ - [Doctrine DBAL Removal](#doctrine-dbal-removal) - [Eloquent Model `casts` Method](#eloquent-model-casts-method) - [Spatial Types](#spatial-types) -- [Spatie Once Package](#spatie-once-package) - [The `Enumerable` Contract](#the-enumerable-contract) - [The `UserProvider` Contract](#the-user-provider-contract) - [The `Authenticatable` Contract](#the-authenticatable-contract) From cfc8e5cce55b283a18c463a7026ee2c0a9b74de6 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 15 Jul 2024 15:00:20 -0500 Subject: [PATCH 098/325] wip --- container.md | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/container.md b/container.md index 1fe0e8921cc..9030788ac7b 100644 --- a/container.md +++ b/container.md @@ -29,30 +29,30 @@ Let's look at a simple example: namespace App\Http\Controllers; - use App\Repositories\UserRepository; + use App\Services\AppleMusic; use Illuminate\View\View; - class UserController extends Controller + class PodcastController extends Controller { /** * Create a new controller instance. */ public function __construct( - protected UserRepository $users, + protected AppleMusic $apple, ) {} /** - * Show the profile for the given user. + * Show information about the given podcast. */ public function show(string $id): View { - $user = $this->users->find($id); - - return view('user.profile', ['user' => $user]); + return view('podcasts.show', [ + 'podcast' => $this->apple->findPodcast($id) + ]); } } -In this example, the `UserController` needs to retrieve users from a data source. So, we will **inject** a service that is able to retrieve users. In this context, our `UserRepository` most likely uses [Eloquent](/docs/{{version}}/eloquent) to retrieve user information from the database. However, since the repository is injected, we are able to easily swap it out with another implementation. We are also able to easily "mock", or create a dummy implementation of the `UserRepository` when testing our application. +In this example, the `PodcastController` needs to retrieve podcasts from a data source such as Apple Music. So, we will **inject** a service that is able to retrieve podcasts. Since the service is injected, we are able to easily "mock", or create a dummy implementation of the `AppleMusic` service when testing our application. A deep understanding of the Laravel service container is essential to building a powerful, large application, as well as for contributing to the Laravel core itself. @@ -394,26 +394,23 @@ For example, you may type-hint a repository defined by your application in a con namespace App\Http\Controllers; - use App\Repositories\UserRepository; - use App\Models\User; + use App\Services\AppleMusic; - class UserController extends Controller + class PodcastController extends Controller { /** * Create a new controller instance. */ public function __construct( - protected UserRepository $users, + protected AppleMusic $apple, ) {} /** - * Show the user with the given ID. + * Show information about the given podcast. */ - public function show(string $id): User + public function show(string $id): Podcast { - $user = $this->users->findOrFail($id); - - return $user; + return $this->apple->findPodcast($id); } } @@ -426,14 +423,14 @@ Sometimes you may wish to invoke a method on an object instance while allowing t namespace App; - use App\Repositories\UserRepository; + use App\Services\AppleMusic; - class UserReport + class PodcastStats { /** - * Generate a new user report. + * Generate a new podcast stats report. */ - public function generate(UserRepository $repository): array + public function generate(AppleMusic $apple): array { return [ // ... @@ -443,17 +440,17 @@ Sometimes you may wish to invoke a method on an object instance while allowing t You may invoke the `generate` method via the container like so: - use App\UserReport; + use App\PodcastStats; use Illuminate\Support\Facades\App; - $report = App::call([new UserReport, 'generate']); + $stats = App::call([new PodcastStats, 'generate']); The `call` method accepts any PHP callable. The container's `call` method may even be used to invoke a closure while automatically injecting its dependencies: - use App\Repositories\UserRepository; + use App\Services\AppleMusic; use Illuminate\Support\Facades\App; - $result = App::call(function (UserRepository $repository) { + $result = App::call(function (AppleMusic $apple) { // ... }); From 215a683e25f17c77925f8cadac7cedab3c395154 Mon Sep 17 00:00:00 2001 From: TENIOS <40282681+TENIOS@users.noreply.github.com> Date: Tue, 16 Jul 2024 04:42:46 +0700 Subject: [PATCH 099/325] Use consistent uppercase for DOCTYPE (#9762) This is in line with the Google HTML guide and with other files in the framework. https://google.github.io/styleguide/htmlcssguide.html#HTML_Validity --- vite.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vite.md b/vite.md index c14bbca2bef..0b8d56c4489 100644 --- a/vite.md +++ b/vite.md @@ -201,7 +201,7 @@ If your file changes are not being reflected in the browser while the developmen With your Vite entry points configured, you may now reference them in a `@vite()` Blade directive that you add to the `` of your application's root template: ```blade - + {{-- ... --}} @@ -212,7 +212,7 @@ With your Vite entry points configured, you may now reference them in a `@vite() If you're importing your CSS via JavaScript, you only need to include the JavaScript entry point: ```blade - + {{-- ... --}} From 0a0ab0c44caedef6902a2b03425c0b803d83e688 Mon Sep 17 00:00:00 2001 From: PovilasKorop Date: Tue, 16 Jul 2024 16:50:55 +0300 Subject: [PATCH 100/325] Container: replace word "repository" with "service" (#9763) --- container.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container.md b/container.md index 9030788ac7b..dc804e9ba04 100644 --- a/container.md +++ b/container.md @@ -388,7 +388,7 @@ If you would like to have the Laravel container instance itself injected into a Alternatively, and importantly, you may type-hint the dependency in the constructor of a class that is resolved by the container, including [controllers](/docs/{{version}}/controllers), [event listeners](/docs/{{version}}/events), [middleware](/docs/{{version}}/middleware), and more. Additionally, you may type-hint dependencies in the `handle` method of [queued jobs](/docs/{{version}}/queues). In practice, this is how most of your objects should be resolved by the container. -For example, you may type-hint a repository defined by your application in a controller's constructor. The repository will automatically be resolved and injected into the class: +For example, you may type-hint a service defined by your application in a controller's constructor. The service will automatically be resolved and injected into the class: Date: Tue, 16 Jul 2024 13:56:11 -0400 Subject: [PATCH 101/325] Example of `assertSent` to email address (#9767) * Example of `assertSent` to email address * Update mail.md --------- Co-authored-by: Taylor Otwell --- mail.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mail.md b/mail.md index bd7e3c36997..b1ba0ab615f 100644 --- a/mail.md +++ b/mail.md @@ -700,7 +700,7 @@ Laravel's mail capabilities are powered by Symfony Mailer. Laravel allows you to use Illuminate\Mail\Mailables\Envelope; use Symfony\Component\Mime\Email; - + /** * Get the message envelope. */ @@ -1133,6 +1133,12 @@ test('orders can be shipped', function () { // Assert a mailable was sent twice... Mail::assertSent(OrderShipped::class, 2); + // Assert a mailable was sent to an email address... + Mail::assertSent(OrderShipped::class, 'example@laravel.com'); + + // Assert a mailable was sent to multiple email addresses... + Mail::assertSent(OrderShipped::class, ['example@laravel.com', '...']); + // Assert a mailable was not sent... Mail::assertNotSent(AnotherMailable::class); @@ -1167,6 +1173,12 @@ class ExampleTest extends TestCase // Assert a mailable was sent twice... Mail::assertSent(OrderShipped::class, 2); + // Assert a mailable was sent to an email address... + Mail::assertSent(OrderShipped::class, 'example@laravel.com'); + + // Assert a mailable was sent to multiple email addresses... + Mail::assertSent(OrderShipped::class, ['example@laravel.com', '...']); + // Assert a mailable was not sent... Mail::assertNotSent(AnotherMailable::class); From ce7e2f4cbd61092f04d543a2c180f54cb94d0229 Mon Sep 17 00:00:00 2001 From: TENIOS <40282681+TENIOS@users.noreply.github.com> Date: Thu, 18 Jul 2024 22:42:51 +0700 Subject: [PATCH 102/325] Remove whitespaces (#9775) --- artisan.md | 2 +- console-tests.md | 2 +- controllers.md | 2 +- csrf.md | 4 ++-- events.md | 2 +- localization.md | 2 +- logging.md | 4 ++-- migrations.md | 2 +- queries.md | 2 +- reverb.md | 2 +- validation.md | 6 +++--- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/artisan.md b/artisan.md index 645163c9c81..1681994dd65 100644 --- a/artisan.md +++ b/artisan.md @@ -669,7 +669,7 @@ If necessary, you may also manually register commands by providing the command's SendEmails::class, ]) - When Artisan boots, all the commands in your application will be resolved by the [service container](/docs/{{version}}/container) and registered with Artisan. +When Artisan boots, all the commands in your application will be resolved by the [service container](/docs/{{version}}/container) and registered with Artisan. ## Programmatically Executing Commands diff --git a/console-tests.md b/console-tests.md index b949302012a..9b8c8d991fe 100644 --- a/console-tests.md +++ b/console-tests.md @@ -108,7 +108,7 @@ public function test_console_command(): void } ``` - The `expectsOutputToContain` and `doesntExpectOutputToContain` methods may be used to make assertions against a portion of the output: +The `expectsOutputToContain` and `doesntExpectOutputToContain` methods may be used to make assertions against a portion of the output: ```php tab=Pest test('console command', function () { diff --git a/controllers.md b/controllers.md index d85b60ef152..b49e0712e1f 100644 --- a/controllers.md +++ b/controllers.md @@ -337,7 +337,7 @@ By default, `Route::resource` will create the route parameters for your resource 'users' => 'admin_user' ]); - The example above generates the following URI for the resource's `show` route: +The example above generates the following URI for the resource's `show` route: /users/{admin_user} diff --git a/csrf.md b/csrf.md index 897600bd96f..fb825fb71b1 100644 --- a/csrf.md +++ b/csrf.md @@ -28,9 +28,9 @@ Without CSRF protection, a malicious website could create an HTML form that poin ``` - If the malicious website automatically submits the form when the page is loaded, the malicious user only needs to lure an unsuspecting user of your application to visit their website and their email address will be changed in your application. +If the malicious website automatically submits the form when the page is loaded, the malicious user only needs to lure an unsuspecting user of your application to visit their website and their email address will be changed in your application. - To prevent this vulnerability, we need to inspect every incoming `POST`, `PUT`, `PATCH`, or `DELETE` request for a secret session value that the malicious application is unable to access. +To prevent this vulnerability, we need to inspect every incoming `POST`, `PUT`, `PATCH`, or `DELETE` request for a secret session value that the malicious application is unable to access. ## Preventing CSRF Requests diff --git a/events.md b/events.md index 2c84b318632..916aad6b623 100644 --- a/events.md +++ b/events.md @@ -513,7 +513,7 @@ To dispatch an event, you may call the static `dispatch` method on the event. Th } } - If you would like to conditionally dispatch an event, you may use the `dispatchIf` and `dispatchUnless` methods: +If you would like to conditionally dispatch an event, you may use the `dispatchIf` and `dispatchUnless` methods: OrderShipped::dispatchIf($condition, $order); diff --git a/localization.md b/localization.md index c001b512327..ea12a85f5f1 100644 --- a/localization.md +++ b/localization.md @@ -152,7 +152,7 @@ You may retrieve translation strings from your language files using the `__` hel If the specified translation string does not exist, the `__` function will return the translation string key. So, using the example above, the `__` function would return `messages.welcome` if the translation string does not exist. - If you are using your [default translation strings as your translation keys](#using-translation-strings-as-keys), you should pass the default translation of your string to the `__` function; +If you are using your [default translation strings as your translation keys](#using-translation-strings-as-keys), you should pass the default translation of your string to the `__` function; echo __('I love programming.'); diff --git a/logging.md b/logging.md index 2ea1ff8e682..ae71565accf 100644 --- a/logging.md +++ b/logging.md @@ -421,9 +421,9 @@ If you are using a Monolog handler that is capable of providing its own formatte #### Monolog Processors - Monolog can also process messages before logging them. You can create your own processors or use the [existing processors offered by Monolog](https://github.com/Seldaek/monolog/tree/main/src/Monolog/Processor). +Monolog can also process messages before logging them. You can create your own processors or use the [existing processors offered by Monolog](https://github.com/Seldaek/monolog/tree/main/src/Monolog/Processor). - If you would like to customize the processors for a `monolog` driver, add a `processors` configuration value to your channel's configuration: +If you would like to customize the processors for a `monolog` driver, add a `processors` configuration value to your channel's configuration: 'memory' => [ 'driver' => 'monolog', diff --git a/migrations.md b/migrations.md index 58f869b185f..b6f72109926 100644 --- a/migrations.md +++ b/migrations.md @@ -191,7 +191,7 @@ php artisan migrate:rollback --step=5 You may roll back a specific "batch" of migrations by providing the `batch` option to the `rollback` command, where the `batch` option corresponds to a batch value within your application's `migrations` database table. For example, the following command will roll back all migrations in batch three: ```shell - php artisan migrate:rollback --batch=3 +php artisan migrate:rollback --batch=3 ``` If you would like to see the SQL statements that will be executed by the migrations without actually running them, you may provide the `--pretend` flag to the `migrate:rollback` command: diff --git a/queries.md b/queries.md index e873bd8fadb..334d2ed1283 100644 --- a/queries.md +++ b/queries.md @@ -116,7 +116,7 @@ If you would like to retrieve an `Illuminate\Support\Collection` instance contai echo $title; } - You may specify the column that the resulting collection should use as its keys by providing a second argument to the `pluck` method: +You may specify the column that the resulting collection should use as its keys by providing a second argument to the `pluck` method: $titles = DB::table('users')->pluck('title', 'name'); diff --git a/reverb.md b/reverb.md index 627068d2965..ab054f31696 100644 --- a/reverb.md +++ b/reverb.md @@ -283,7 +283,7 @@ The configuration above will allow up to 10,000 Nginx workers per process to be Unix-based operating systems typically limit the number of ports which can be opened on the server. You may see the current allowed range via the following command: ```sh - cat /proc/sys/net/ipv4/ip_local_port_range +cat /proc/sys/net/ipv4/ip_local_port_range # 32768 60999 ``` diff --git a/validation.md b/validation.md index 1f24309e2ea..550a5531b9a 100644 --- a/validation.md +++ b/validation.md @@ -1547,7 +1547,7 @@ The field under validation must not be present in the input data. #### missing_if:_anotherfield_,_value_,... - The field under validation must not be present if the _anotherfield_ field is equal to any _value_. +The field under validation must not be present if the _anotherfield_ field is equal to any _value_. #### missing_unless:_anotherfield_,_value_ @@ -1557,12 +1557,12 @@ The field under validation must not be present unless the _anotherfield_ field i #### missing_with:_foo_,_bar_,... - The field under validation must not be present _only if_ any of the other specified fields are present. +The field under validation must not be present _only if_ any of the other specified fields are present. #### missing_with_all:_foo_,_bar_,... - The field under validation must not be present _only if_ all of the other specified fields are present. +The field under validation must not be present _only if_ all of the other specified fields are present. #### not_in:_foo_,_bar_,... From 6bb6d17a05144e3201e1c9ce3f1f688d41062daa Mon Sep 17 00:00:00 2001 From: TENIOS <40282681+TENIOS@users.noreply.github.com> Date: Thu, 18 Jul 2024 22:43:10 +0700 Subject: [PATCH 103/325] Add `/docs/{{version}}/` prefix to url (#9774) --- rate-limiting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rate-limiting.md b/rate-limiting.md index a1bd0c3b87f..8492dda2231 100644 --- a/rate-limiting.md +++ b/rate-limiting.md @@ -12,7 +12,7 @@ Laravel includes a simple to use rate limiting abstraction which, in conjunction with your application's [cache](cache), provides an easy way to limit any action during a specified window of time. > [!NOTE] -> If you are interested in rate limiting incoming HTTP requests, please consult the [rate limiter middleware documentation](routing#rate-limiting). +> If you are interested in rate limiting incoming HTTP requests, please consult the [rate limiter middleware documentation](/docs/{{version}}/routing#rate-limiting). ### Cache Configuration From 197edc3fb93b922e3adb5a90dc7d018716d08dd0 Mon Sep 17 00:00:00 2001 From: TENIOS <40282681+TENIOS@users.noreply.github.com> Date: Thu, 18 Jul 2024 22:44:02 +0700 Subject: [PATCH 104/325] Remove next (#9772) --- contributions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributions.md b/contributions.md index 4e25e01ea6f..e390461c54d 100644 --- a/contributions.md +++ b/contributions.md @@ -49,7 +49,7 @@ The Laravel source code is managed on GitHub, and there are repositories for eac - [Laravel Scout](https://github.com/laravel/scout) - [Laravel Socialite](https://github.com/laravel/socialite) - [Laravel Telescope](https://github.com/laravel/telescope) -- [Laravel Website](https://github.com/laravel/laravel.com-next) +- [Laravel Website](https://github.com/laravel/laravel.com) From e9cd4fd37890a01043e057467264899c1e85d5ae Mon Sep 17 00:00:00 2001 From: TENIOS <40282681+TENIOS@users.noreply.github.com> Date: Thu, 18 Jul 2024 22:45:10 +0700 Subject: [PATCH 105/325] Update return type & remove deprecated from contracts (#9771) * Update outdated return type * Update contracts table * Remove deprecated `ImplicitRule` from contracts table --- contracts.md | 9 ++++----- validation.md | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/contracts.md b/contracts.md index de852b6a7bb..7ded2f46e9f 100644 --- a/contracts.md +++ b/contracts.md @@ -73,9 +73,9 @@ This table provides a quick reference to all of the Laravel contracts and their | Contract | References Facade | |--------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------| -| [Illuminate\Contracts\Auth\Access\Authorizable](https://github.com/illuminate/contracts/blob/{{version}}/Auth/Access/Authorizable.php) |    | +| [Illuminate\Contracts\Auth\Access\Authorizable](https://github.com/illuminate/contracts/blob/{{version}}/Auth/Access/Authorizable.php) |   | | [Illuminate\Contracts\Auth\Access\Gate](https://github.com/illuminate/contracts/blob/{{version}}/Auth/Access/Gate.php) | `Gate` | -| [Illuminate\Contracts\Auth\Authenticatable](https://github.com/illuminate/contracts/blob/{{version}}/Auth/Authenticatable.php) |    | +| [Illuminate\Contracts\Auth\Authenticatable](https://github.com/illuminate/contracts/blob/{{version}}/Auth/Authenticatable.php) |   | | [Illuminate\Contracts\Auth\CanResetPassword](https://github.com/illuminate/contracts/blob/{{version}}/Auth/CanResetPassword.php) |   | | [Illuminate\Contracts\Auth\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Auth/Factory.php) | `Auth` | | [Illuminate\Contracts\Auth\Guard](https://github.com/illuminate/contracts/blob/{{version}}/Auth/Guard.php) | `Auth::guard()` | @@ -119,7 +119,7 @@ This table provides a quick reference to all of the Laravel contracts and their | [Illuminate\Contracts\Pagination\LengthAwarePaginator](https://github.com/illuminate/contracts/blob/{{version}}/Pagination/LengthAwarePaginator.php) |   | | [Illuminate\Contracts\Pagination\Paginator](https://github.com/illuminate/contracts/blob/{{version}}/Pagination/Paginator.php) |   | | [Illuminate\Contracts\Pipeline\Hub](https://github.com/illuminate/contracts/blob/{{version}}/Pipeline/Hub.php) |   | -| [Illuminate\Contracts\Pipeline\Pipeline](https://github.com/illuminate/contracts/blob/{{version}}/Pipeline/Pipeline.php) | `Pipeline`; | +| [Illuminate\Contracts\Pipeline\Pipeline](https://github.com/illuminate/contracts/blob/{{version}}/Pipeline/Pipeline.php) | `Pipeline`; | | [Illuminate\Contracts\Queue\EntityResolver](https://github.com/illuminate/contracts/blob/{{version}}/Queue/EntityResolver.php) |   | | [Illuminate\Contracts\Queue\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Queue/Factory.php) | `Queue` | | [Illuminate\Contracts\Queue\Job](https://github.com/illuminate/contracts/blob/{{version}}/Queue/Job.php) |   | @@ -145,9 +145,8 @@ This table provides a quick reference to all of the Laravel contracts and their | [Illuminate\Contracts\Translation\Loader](https://github.com/illuminate/contracts/blob/{{version}}/Translation/Loader.php) |   | | [Illuminate\Contracts\Translation\Translator](https://github.com/illuminate/contracts/blob/{{version}}/Translation/Translator.php) | `Lang` | | [Illuminate\Contracts\Validation\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Validation/Factory.php) | `Validator` | -| [Illuminate\Contracts\Validation\ImplicitRule](https://github.com/illuminate/contracts/blob/{{version}}/Validation/ImplicitRule.php) |   | -| [Illuminate\Contracts\Validation\Rule](https://github.com/illuminate/contracts/blob/{{version}}/Validation/Rule.php) |   | | [Illuminate\Contracts\Validation\ValidatesWhenResolved](https://github.com/illuminate/contracts/blob/{{version}}/Validation/ValidatesWhenResolved.php) |   | +| [Illuminate\Contracts\Validation\ValidationRule](https://github.com/illuminate/contracts/blob/{{version}}/Validation/ValidationRule.php) |   | | [Illuminate\Contracts\Validation\Validator](https://github.com/illuminate/contracts/blob/{{version}}/Validation/Validator.php) | `Validator::make()` | | [Illuminate\Contracts\View\Engine](https://github.com/illuminate/contracts/blob/{{version}}/View/Engine.php) |   | | [Illuminate\Contracts\View\Factory](https://github.com/illuminate/contracts/blob/{{version}}/View/Factory.php) | `View` | diff --git a/validation.md b/validation.md index 550a5531b9a..14d7cee184c 100644 --- a/validation.md +++ b/validation.md @@ -311,7 +311,7 @@ As you might have guessed, the `authorize` method is responsible for determining /** * Get the validation rules that apply to the request. * - * @return array + * @return array|string> */ public function rules(): array { From 18dbb77df4a537e4f515d0f9ac9fbd8af4b11624 Mon Sep 17 00:00:00 2001 From: TENIOS <40282681+TENIOS@users.noreply.github.com> Date: Thu, 18 Jul 2024 22:45:22 +0700 Subject: [PATCH 106/325] Add missing slash to routes (#9770) --- controllers.md | 2 +- eloquent-serialization.md | 2 +- routing.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/controllers.md b/controllers.md index b49e0712e1f..edc4ab4096e 100644 --- a/controllers.md +++ b/controllers.md @@ -106,7 +106,7 @@ php artisan make:controller ProvisionServer --invokable [Middleware](/docs/{{version}}/middleware) may be assigned to the controller's routes in your route files: - Route::get('profile', [UserController::class, 'show'])->middleware('auth'); + Route::get('/profile', [UserController::class, 'show'])->middleware('auth'); Or, you may find it convenient to specify middleware within your controller class. To do so, your controller should implement the `HasMiddleware` interface, which dictates that the controller should have a static `middleware` method. From this method, you may return an array of middleware that should be applied to the controller's actions: diff --git a/eloquent-serialization.md b/eloquent-serialization.md index 98e1956a5f0..30821074124 100644 --- a/eloquent-serialization.md +++ b/eloquent-serialization.md @@ -61,7 +61,7 @@ Alternatively, you may cast a model or collection to a string, which will automa Since models and collections are converted to JSON when cast to a string, you can return Eloquent objects directly from your application's routes or controllers. Laravel will automatically serialize your Eloquent models and collections to JSON when they are returned from routes or controllers: - Route::get('users', function () { + Route::get('/users', function () { return User::all(); }); diff --git a/routing.md b/routing.md index 94a27da6983..57169b48c1c 100644 --- a/routing.md +++ b/routing.md @@ -479,7 +479,7 @@ If a group of routes all utilize the same [controller](/docs/{{version}}/control Route groups may also be used to handle subdomain routing. Subdomains may be assigned route parameters just like route URIs, allowing you to capture a portion of the subdomain for usage in your route or controller. The subdomain may be specified by calling the `domain` method before defining the group: Route::domain('{account}.example.com')->group(function () { - Route::get('user/{id}', function (string $account, string $id) { + Route::get('/user/{id}', function (string $account, string $id) { // ... }); }); From 5636016990758c42148b3d10ebfe78f5c1412048 Mon Sep 17 00:00:00 2001 From: TENIOS <40282681+TENIOS@users.noreply.github.com> Date: Thu, 18 Jul 2024 23:02:59 +0700 Subject: [PATCH 107/325] Redirect slash (#9776) * Add slash to `redirect()` helper method * Update pennant.md --- billing.md | 2 +- cashier-paddle.md | 2 +- middleware.md | 4 ++-- pennant.md | 2 +- requests.md | 4 ++-- responses.md | 4 ++-- validation.md | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/billing.md b/billing.md index dbc9b1e58a6..6a03e8ec69a 100644 --- a/billing.md +++ b/billing.md @@ -963,7 +963,7 @@ The `subscribed` method also makes a great candidate for a [route middleware](/d { if ($request->user() && ! $request->user()->subscribed('default')) { // This user is not a paying customer... - return redirect('billing'); + return redirect('/billing'); } return $next($request); diff --git a/cashier-paddle.md b/cashier-paddle.md index 48acd5dbb92..7e7e96bcdf7 100644 --- a/cashier-paddle.md +++ b/cashier-paddle.md @@ -755,7 +755,7 @@ The `subscribed` method also makes a great candidate for a [route middleware](/d { if ($request->user() && ! $request->user()->subscribed()) { // This user is not a paying customer... - return redirect('billing'); + return redirect('/billing'); } return $next($request); diff --git a/middleware.md b/middleware.md index a99d965b9a0..91c0fd0564b 100644 --- a/middleware.md +++ b/middleware.md @@ -27,7 +27,7 @@ To create a new middleware, use the `make:middleware` Artisan command: php artisan make:middleware EnsureTokenIsValid ``` -This command will place a new `EnsureTokenIsValid` class within your `app/Http/Middleware` directory. In this middleware, we will only allow access to the route if the supplied `token` input matches a specified value. Otherwise, we will redirect the users back to the `home` URI: +This command will place a new `EnsureTokenIsValid` class within your `app/Http/Middleware` directory. In this middleware, we will only allow access to the route if the supplied `token` input matches a specified value. Otherwise, we will redirect the users back to the `/home` URI: input('token') !== 'my-secret-token') { - return redirect('home'); + return redirect('/home'); } return $next($request); diff --git a/pennant.md b/pennant.md index 3970e9bcdeb..8ed326d05ad 100644 --- a/pennant.md +++ b/pennant.md @@ -524,7 +524,7 @@ You will notice that the closure we have defined is not expecting a `User`, but ```php if (Feature::for($user->team)->active('billing-v2')) { - return redirect()->to('/billing/v2'); + return redirect('/billing/v2'); } // ... diff --git a/requests.md b/requests.md index 9bc0797de15..aef7f57ae4c 100644 --- a/requests.md +++ b/requests.md @@ -471,11 +471,11 @@ You may also use the `flashOnly` and `flashExcept` methods to flash a subset of Since you often will want to flash input to the session and then redirect to the previous page, you may easily chain input flashing onto a redirect using the `withInput` method: - return redirect('form')->withInput(); + return redirect('/form')->withInput(); return redirect()->route('user.create')->withInput(); - return redirect('form')->withInput( + return redirect('/form')->withInput( $request->except('password') ); diff --git a/responses.md b/responses.md index 30435afc62e..1653629ed5c 100644 --- a/responses.md +++ b/responses.md @@ -152,7 +152,7 @@ By default, thanks to the `Illuminate\Cookie\Middleware\EncryptCookies` middlewa Redirect responses are instances of the `Illuminate\Http\RedirectResponse` class, and contain the proper headers needed to redirect the user to another URL. There are several ways to generate a `RedirectResponse` instance. The simplest method is to use the global `redirect` helper: Route::get('/dashboard', function () { - return redirect('home/dashboard'); + return redirect('/home/dashboard'); }); Sometimes you may wish to redirect the user to their previous location, such as when a submitted form is invalid. You may do so by using the global `back` helper function. Since this feature utilizes the [session](/docs/{{version}}/session), make sure the route calling the `back` function is using the `web` middleware group: @@ -225,7 +225,7 @@ Redirecting to a new URL and [flashing data to the session](/docs/{{version}}/se Route::post('/user/profile', function () { // ... - return redirect('dashboard')->with('status', 'Profile updated!'); + return redirect('/dashboard')->with('status', 'Profile updated!'); }); After the user is redirected, you may display the flashed message from the [session](/docs/{{version}}/session). For example, using [Blade syntax](/docs/{{version}}/blade): diff --git a/validation.md b/validation.md index 14d7cee184c..664ba79390c 100644 --- a/validation.md +++ b/validation.md @@ -559,7 +559,7 @@ If you do not want to use the `validate` method on the request, you may create a ]); if ($validator->fails()) { - return redirect('post/create') + return redirect('/post/create') ->withErrors($validator) ->withInput(); } @@ -611,7 +611,7 @@ You may use the `validateWithBag` method to store the error messages in a [named If you have multiple forms on a single page, you may wish to name the `MessageBag` containing the validation errors, allowing you to retrieve the error messages for a specific form. To achieve this, pass a name as the second argument to `withErrors`: - return redirect('register')->withErrors($validator, 'login'); + return redirect('/register')->withErrors($validator, 'login'); You may then access the named `MessageBag` instance from the `$errors` variable: From 87463da2cce7c09a7e5ecc36664bf115dff6b908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Tom=C3=A9?= Date: Thu, 18 Jul 2024 17:45:05 -0300 Subject: [PATCH 108/325] Update octane.md (#9779) * Update octane.md --max-requests=1 will not work because the number of workers will be bigger than 1 > The number of maximum requests is per worker, and by default, FrankenPHP starts many workers (2 times the number of CPUs). https://github.com/laravel/octane/issues/816#issuecomment-1898126577 * Update octane.md --------- Co-authored-by: Taylor Otwell --- octane.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/octane.md b/octane.md index 4cdae9776f4..c44c9c1dd4b 100644 --- a/octane.md +++ b/octane.md @@ -128,7 +128,7 @@ services: frankenphp: build: context: . - entrypoint: php artisan octane:frankenphp --max-requests=1 + entrypoint: php artisan octane:frankenphp --workers=1 --max-requests=1 ports: - "8000:8000" volumes: From 87c1dc3bbb78949d35a1af957ba76c4469490baa Mon Sep 17 00:00:00 2001 From: TENIOS <40282681+TENIOS@users.noreply.github.com> Date: Fri, 19 Jul 2024 03:46:55 +0700 Subject: [PATCH 109/325] Update markdown tables (#9778) * Update tables * Fix quotes * Update `` examples * Add overflow-auto div to tables * Update requests.md --- authentication.md | 28 ++++---- blade.md | 6 +- cache.md | 12 ++-- configuration.md | 2 +- contracts.md | 164 ++++++++++++++++++++++++---------------------- controllers.md | 78 ++++++++++++++-------- facades.md | 112 +++++++++++++++---------------- logging.md | 38 +++++------ mail.md | 8 +-- middleware.md | 64 ++++++++++-------- migrations.md | 128 +++++++++++++++++++++--------------- notifications.md | 8 +-- pagination.md | 86 +++++++++++++----------- passport.md | 8 +-- requests.md | 1 - scheduling.md | 130 ++++++++++++++++++------------------ valet.md | 26 ++++---- 17 files changed, 487 insertions(+), 412 deletions(-) diff --git a/authentication.md b/authentication.md index dcdbff7f4d0..32248ef9c3a 100644 --- a/authentication.md +++ b/authentication.md @@ -741,17 +741,17 @@ Once the configuration file has been published, you may set the `rehash_on_login Laravel dispatches a variety of [events](/docs/{{version}}/events) during the authentication process. You may [define listeners](/docs/{{version}}/events) for any of the following events: -Event Name | -------------- | -`Illuminate\Auth\Events\Registered` | -`Illuminate\Auth\Events\Attempting` | -`Illuminate\Auth\Events\Authenticated` | -`Illuminate\Auth\Events\Login` | -`Illuminate\Auth\Events\Failed` | -`Illuminate\Auth\Events\Validated` | -`Illuminate\Auth\Events\Verified` | -`Illuminate\Auth\Events\Logout` | -`Illuminate\Auth\Events\CurrentDeviceLogout` | -`Illuminate\Auth\Events\OtherDeviceLogout` | -`Illuminate\Auth\Events\Lockout` | -`Illuminate\Auth\Events\PasswordReset` | +| Event Name | +| --- | +| `Illuminate\Auth\Events\Registered` | +| `Illuminate\Auth\Events\Attempting` | +| `Illuminate\Auth\Events\Authenticated` | +| `Illuminate\Auth\Events\Login` | +| `Illuminate\Auth\Events\Failed` | +| `Illuminate\Auth\Events\Validated` | +| `Illuminate\Auth\Events\Verified` | +| `Illuminate\Auth\Events\Logout` | +| `Illuminate\Auth\Events\CurrentDeviceLogout` | +| `Illuminate\Auth\Events\OtherDeviceLogout` | +| `Illuminate\Auth\Events\Lockout` | +| `Illuminate\Auth\Events\PasswordReset` | diff --git a/blade.md b/blade.md index 44c5db32223..9a99018e9bd 100644 --- a/blade.md +++ b/blade.md @@ -423,8 +423,10 @@ If you are in a nested loop, you may access the parent loop's `$loop` variable v The `$loop` variable also contains a variety of other useful properties: +
+ | Property | Description | -|--------------------|--------------------------------------------------------| +| ------------------ | ------------------------------------------------------ | | `$loop->index` | The index of the current loop iteration (starts at 0). | | `$loop->iteration` | The current loop iteration (starts at 1). | | `$loop->remaining` | The iterations remaining in the loop. | @@ -436,6 +438,8 @@ The `$loop` variable also contains a variety of other useful properties: | `$loop->depth` | The nesting level of the current loop. | | `$loop->parent` | When in a nested loop, the parent's loop variable. | +
+ ### Conditional Classes & Styles diff --git a/cache.md b/cache.md index dc896d2a3db..c7d4757ed0d 100644 --- a/cache.md +++ b/cache.md @@ -440,12 +440,12 @@ Once your extension is registered, update the `CACHE_STORE` environment variable To execute code on every cache operation, you may listen for various [events](/docs/{{version}}/events) dispatched by the cache: -Event Name | -------------- | -`Illuminate\Cache\Events\CacheHit` | -`Illuminate\Cache\Events\CacheMissed` | -`Illuminate\Cache\Events\KeyForgotten` | -`Illuminate\Cache\Events\KeyWritten` | +| Event Name | +| --- | +| `Illuminate\Cache\Events\CacheHit` | +| `Illuminate\Cache\Events\CacheMissed` | +| `Illuminate\Cache\Events\KeyForgotten` | +| `Illuminate\Cache\Events\KeyWritten` | To increase performance, you may disable cache events by setting the `events` configuration option to `false` for a given cache store in your application's `config/cache.php` configuration file: diff --git a/configuration.md b/configuration.md index cc6a81a35fd..ad3ed6a3a43 100644 --- a/configuration.md +++ b/configuration.md @@ -72,7 +72,7 @@ Before loading your application's environment variables, Laravel determines if a All variables in your `.env` files are typically parsed as strings, so some reserved values have been created to allow you to return a wider range of types from the `env()` function: | `.env` Value | `env()` Value | -|--------------|---------------| +| ------------ | ------------- | | true | (bool) true | | (true) | (bool) true | | false | (bool) false | diff --git a/contracts.md b/contracts.md index 7ded2f46e9f..f8c1884f74a 100644 --- a/contracts.md +++ b/contracts.md @@ -71,83 +71,87 @@ When the event listener is resolved, the service container will read the type-hi This table provides a quick reference to all of the Laravel contracts and their equivalent facades: -| Contract | References Facade | -|--------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------| -| [Illuminate\Contracts\Auth\Access\Authorizable](https://github.com/illuminate/contracts/blob/{{version}}/Auth/Access/Authorizable.php) |   | -| [Illuminate\Contracts\Auth\Access\Gate](https://github.com/illuminate/contracts/blob/{{version}}/Auth/Access/Gate.php) | `Gate` | -| [Illuminate\Contracts\Auth\Authenticatable](https://github.com/illuminate/contracts/blob/{{version}}/Auth/Authenticatable.php) |   | -| [Illuminate\Contracts\Auth\CanResetPassword](https://github.com/illuminate/contracts/blob/{{version}}/Auth/CanResetPassword.php) |   | -| [Illuminate\Contracts\Auth\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Auth/Factory.php) | `Auth` | -| [Illuminate\Contracts\Auth\Guard](https://github.com/illuminate/contracts/blob/{{version}}/Auth/Guard.php) | `Auth::guard()` | -| [Illuminate\Contracts\Auth\PasswordBroker](https://github.com/illuminate/contracts/blob/{{version}}/Auth/PasswordBroker.php) | `Password::broker()` | -| [Illuminate\Contracts\Auth\PasswordBrokerFactory](https://github.com/illuminate/contracts/blob/{{version}}/Auth/PasswordBrokerFactory.php) | `Password` | -| [Illuminate\Contracts\Auth\StatefulGuard](https://github.com/illuminate/contracts/blob/{{version}}/Auth/StatefulGuard.php) |   | -| [Illuminate\Contracts\Auth\SupportsBasicAuth](https://github.com/illuminate/contracts/blob/{{version}}/Auth/SupportsBasicAuth.php) |   | -| [Illuminate\Contracts\Auth\UserProvider](https://github.com/illuminate/contracts/blob/{{version}}/Auth/UserProvider.php) |   | -| [Illuminate\Contracts\Bus\Dispatcher](https://github.com/illuminate/contracts/blob/{{version}}/Bus/Dispatcher.php) | `Bus` | -| [Illuminate\Contracts\Bus\QueueingDispatcher](https://github.com/illuminate/contracts/blob/{{version}}/Bus/QueueingDispatcher.php) | `Bus::dispatchToQueue()` | -| [Illuminate\Contracts\Broadcasting\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Broadcasting/Factory.php) | `Broadcast` | -| [Illuminate\Contracts\Broadcasting\Broadcaster](https://github.com/illuminate/contracts/blob/{{version}}/Broadcasting/Broadcaster.php) | `Broadcast::connection()` | -| [Illuminate\Contracts\Broadcasting\ShouldBroadcast](https://github.com/illuminate/contracts/blob/{{version}}/Broadcasting/ShouldBroadcast.php) |   | -| [Illuminate\Contracts\Broadcasting\ShouldBroadcastNow](https://github.com/illuminate/contracts/blob/{{version}}/Broadcasting/ShouldBroadcastNow.php) |   | -| [Illuminate\Contracts\Cache\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Cache/Factory.php) | `Cache` | -| [Illuminate\Contracts\Cache\Lock](https://github.com/illuminate/contracts/blob/{{version}}/Cache/Lock.php) |   | -| [Illuminate\Contracts\Cache\LockProvider](https://github.com/illuminate/contracts/blob/{{version}}/Cache/LockProvider.php) |   | -| [Illuminate\Contracts\Cache\Repository](https://github.com/illuminate/contracts/blob/{{version}}/Cache/Repository.php) | `Cache::driver()` | -| [Illuminate\Contracts\Cache\Store](https://github.com/illuminate/contracts/blob/{{version}}/Cache/Store.php) |   | -| [Illuminate\Contracts\Config\Repository](https://github.com/illuminate/contracts/blob/{{version}}/Config/Repository.php) | `Config` | -| [Illuminate\Contracts\Console\Application](https://github.com/illuminate/contracts/blob/{{version}}/Console/Application.php) |   | -| [Illuminate\Contracts\Console\Kernel](https://github.com/illuminate/contracts/blob/{{version}}/Console/Kernel.php) | `Artisan` | -| [Illuminate\Contracts\Container\Container](https://github.com/illuminate/contracts/blob/{{version}}/Container/Container.php) | `App` | -| [Illuminate\Contracts\Cookie\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Cookie/Factory.php) | `Cookie` | -| [Illuminate\Contracts\Cookie\QueueingFactory](https://github.com/illuminate/contracts/blob/{{version}}/Cookie/QueueingFactory.php) | `Cookie::queue()` | -| [Illuminate\Contracts\Database\ModelIdentifier](https://github.com/illuminate/contracts/blob/{{version}}/Database/ModelIdentifier.php) |   | -| [Illuminate\Contracts\Debug\ExceptionHandler](https://github.com/illuminate/contracts/blob/{{version}}/Debug/ExceptionHandler.php) |   | -| [Illuminate\Contracts\Encryption\Encrypter](https://github.com/illuminate/contracts/blob/{{version}}/Encryption/Encrypter.php) | `Crypt` | -| [Illuminate\Contracts\Events\Dispatcher](https://github.com/illuminate/contracts/blob/{{version}}/Events/Dispatcher.php) | `Event` | -| [Illuminate\Contracts\Filesystem\Cloud](https://github.com/illuminate/contracts/blob/{{version}}/Filesystem/Cloud.php) | `Storage::cloud()` | -| [Illuminate\Contracts\Filesystem\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Filesystem/Factory.php) | `Storage` | -| [Illuminate\Contracts\Filesystem\Filesystem](https://github.com/illuminate/contracts/blob/{{version}}/Filesystem/Filesystem.php) | `Storage::disk()` | -| [Illuminate\Contracts\Foundation\Application](https://github.com/illuminate/contracts/blob/{{version}}/Foundation/Application.php) | `App` | -| [Illuminate\Contracts\Hashing\Hasher](https://github.com/illuminate/contracts/blob/{{version}}/Hashing/Hasher.php) | `Hash` | -| [Illuminate\Contracts\Http\Kernel](https://github.com/illuminate/contracts/blob/{{version}}/Http/Kernel.php) |   | -| [Illuminate\Contracts\Mail\MailQueue](https://github.com/illuminate/contracts/blob/{{version}}/Mail/MailQueue.php) | `Mail::queue()` | -| [Illuminate\Contracts\Mail\Mailable](https://github.com/illuminate/contracts/blob/{{version}}/Mail/Mailable.php) |   | -| [Illuminate\Contracts\Mail\Mailer](https://github.com/illuminate/contracts/blob/{{version}}/Mail/Mailer.php) | `Mail` | -| [Illuminate\Contracts\Notifications\Dispatcher](https://github.com/illuminate/contracts/blob/{{version}}/Notifications/Dispatcher.php) | `Notification` | -| [Illuminate\Contracts\Notifications\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Notifications/Factory.php) | `Notification` | -| [Illuminate\Contracts\Pagination\LengthAwarePaginator](https://github.com/illuminate/contracts/blob/{{version}}/Pagination/LengthAwarePaginator.php) |   | -| [Illuminate\Contracts\Pagination\Paginator](https://github.com/illuminate/contracts/blob/{{version}}/Pagination/Paginator.php) |   | -| [Illuminate\Contracts\Pipeline\Hub](https://github.com/illuminate/contracts/blob/{{version}}/Pipeline/Hub.php) |   | -| [Illuminate\Contracts\Pipeline\Pipeline](https://github.com/illuminate/contracts/blob/{{version}}/Pipeline/Pipeline.php) | `Pipeline`; | -| [Illuminate\Contracts\Queue\EntityResolver](https://github.com/illuminate/contracts/blob/{{version}}/Queue/EntityResolver.php) |   | -| [Illuminate\Contracts\Queue\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Queue/Factory.php) | `Queue` | -| [Illuminate\Contracts\Queue\Job](https://github.com/illuminate/contracts/blob/{{version}}/Queue/Job.php) |   | -| [Illuminate\Contracts\Queue\Monitor](https://github.com/illuminate/contracts/blob/{{version}}/Queue/Monitor.php) | `Queue` | -| [Illuminate\Contracts\Queue\Queue](https://github.com/illuminate/contracts/blob/{{version}}/Queue/Queue.php) | `Queue::connection()` | -| [Illuminate\Contracts\Queue\QueueableCollection](https://github.com/illuminate/contracts/blob/{{version}}/Queue/QueueableCollection.php) |   | -| [Illuminate\Contracts\Queue\QueueableEntity](https://github.com/illuminate/contracts/blob/{{version}}/Queue/QueueableEntity.php) |   | -| [Illuminate\Contracts\Queue\ShouldQueue](https://github.com/illuminate/contracts/blob/{{version}}/Queue/ShouldQueue.php) |   | -| [Illuminate\Contracts\Redis\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Redis/Factory.php) | `Redis` | -| [Illuminate\Contracts\Routing\BindingRegistrar](https://github.com/illuminate/contracts/blob/{{version}}/Routing/BindingRegistrar.php) | `Route` | -| [Illuminate\Contracts\Routing\Registrar](https://github.com/illuminate/contracts/blob/{{version}}/Routing/Registrar.php) | `Route` | -| [Illuminate\Contracts\Routing\ResponseFactory](https://github.com/illuminate/contracts/blob/{{version}}/Routing/ResponseFactory.php) | `Response` | -| [Illuminate\Contracts\Routing\UrlGenerator](https://github.com/illuminate/contracts/blob/{{version}}/Routing/UrlGenerator.php) | `URL` | -| [Illuminate\Contracts\Routing\UrlRoutable](https://github.com/illuminate/contracts/blob/{{version}}/Routing/UrlRoutable.php) |   | -| [Illuminate\Contracts\Session\Session](https://github.com/illuminate/contracts/blob/{{version}}/Session/Session.php) | `Session::driver()` | -| [Illuminate\Contracts\Support\Arrayable](https://github.com/illuminate/contracts/blob/{{version}}/Support/Arrayable.php) |   | -| [Illuminate\Contracts\Support\Htmlable](https://github.com/illuminate/contracts/blob/{{version}}/Support/Htmlable.php) |   | -| [Illuminate\Contracts\Support\Jsonable](https://github.com/illuminate/contracts/blob/{{version}}/Support/Jsonable.php) |   | -| [Illuminate\Contracts\Support\MessageBag](https://github.com/illuminate/contracts/blob/{{version}}/Support/MessageBag.php) |   | -| [Illuminate\Contracts\Support\MessageProvider](https://github.com/illuminate/contracts/blob/{{version}}/Support/MessageProvider.php) |   | -| [Illuminate\Contracts\Support\Renderable](https://github.com/illuminate/contracts/blob/{{version}}/Support/Renderable.php) |   | -| [Illuminate\Contracts\Support\Responsable](https://github.com/illuminate/contracts/blob/{{version}}/Support/Responsable.php) |   | -| [Illuminate\Contracts\Translation\Loader](https://github.com/illuminate/contracts/blob/{{version}}/Translation/Loader.php) |   | -| [Illuminate\Contracts\Translation\Translator](https://github.com/illuminate/contracts/blob/{{version}}/Translation/Translator.php) | `Lang` | -| [Illuminate\Contracts\Validation\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Validation/Factory.php) | `Validator` | -| [Illuminate\Contracts\Validation\ValidatesWhenResolved](https://github.com/illuminate/contracts/blob/{{version}}/Validation/ValidatesWhenResolved.php) |   | -| [Illuminate\Contracts\Validation\ValidationRule](https://github.com/illuminate/contracts/blob/{{version}}/Validation/ValidationRule.php) |   | -| [Illuminate\Contracts\Validation\Validator](https://github.com/illuminate/contracts/blob/{{version}}/Validation/Validator.php) | `Validator::make()` | -| [Illuminate\Contracts\View\Engine](https://github.com/illuminate/contracts/blob/{{version}}/View/Engine.php) |   | -| [Illuminate\Contracts\View\Factory](https://github.com/illuminate/contracts/blob/{{version}}/View/Factory.php) | `View` | -| [Illuminate\Contracts\View\View](https://github.com/illuminate/contracts/blob/{{version}}/View/View.php) | `View::make()` | +
+ +| Contract | References Facade | +| --- | --- | +| [Illuminate\Contracts\Auth\Access\Authorizable](https://github.com/illuminate/contracts/blob/{{version}}/Auth/Access/Authorizable.php) |   | +| [Illuminate\Contracts\Auth\Access\Gate](https://github.com/illuminate/contracts/blob/{{version}}/Auth/Access/Gate.php) | `Gate` | +| [Illuminate\Contracts\Auth\Authenticatable](https://github.com/illuminate/contracts/blob/{{version}}/Auth/Authenticatable.php) |   | +| [Illuminate\Contracts\Auth\CanResetPassword](https://github.com/illuminate/contracts/blob/{{version}}/Auth/CanResetPassword.php) |   | +| [Illuminate\Contracts\Auth\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Auth/Factory.php) | `Auth` | +| [Illuminate\Contracts\Auth\Guard](https://github.com/illuminate/contracts/blob/{{version}}/Auth/Guard.php) | `Auth::guard()` | +| [Illuminate\Contracts\Auth\PasswordBroker](https://github.com/illuminate/contracts/blob/{{version}}/Auth/PasswordBroker.php) | `Password::broker()` | +| [Illuminate\Contracts\Auth\PasswordBrokerFactory](https://github.com/illuminate/contracts/blob/{{version}}/Auth/PasswordBrokerFactory.php) | `Password` | +| [Illuminate\Contracts\Auth\StatefulGuard](https://github.com/illuminate/contracts/blob/{{version}}/Auth/StatefulGuard.php) |   | +| [Illuminate\Contracts\Auth\SupportsBasicAuth](https://github.com/illuminate/contracts/blob/{{version}}/Auth/SupportsBasicAuth.php) |   | +| [Illuminate\Contracts\Auth\UserProvider](https://github.com/illuminate/contracts/blob/{{version}}/Auth/UserProvider.php) |   | +| [Illuminate\Contracts\Broadcasting\Broadcaster](https://github.com/illuminate/contracts/blob/{{version}}/Broadcasting/Broadcaster.php) | `Broadcast::connection()` | +| [Illuminate\Contracts\Broadcasting\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Broadcasting/Factory.php) | `Broadcast` | +| [Illuminate\Contracts\Broadcasting\ShouldBroadcast](https://github.com/illuminate/contracts/blob/{{version}}/Broadcasting/ShouldBroadcast.php) |   | +| [Illuminate\Contracts\Broadcasting\ShouldBroadcastNow](https://github.com/illuminate/contracts/blob/{{version}}/Broadcasting/ShouldBroadcastNow.php) |   | +| [Illuminate\Contracts\Bus\Dispatcher](https://github.com/illuminate/contracts/blob/{{version}}/Bus/Dispatcher.php) | `Bus` | +| [Illuminate\Contracts\Bus\QueueingDispatcher](https://github.com/illuminate/contracts/blob/{{version}}/Bus/QueueingDispatcher.php) | `Bus::dispatchToQueue()` | +| [Illuminate\Contracts\Cache\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Cache/Factory.php) | `Cache` | +| [Illuminate\Contracts\Cache\Lock](https://github.com/illuminate/contracts/blob/{{version}}/Cache/Lock.php) |   | +| [Illuminate\Contracts\Cache\LockProvider](https://github.com/illuminate/contracts/blob/{{version}}/Cache/LockProvider.php) |   | +| [Illuminate\Contracts\Cache\Repository](https://github.com/illuminate/contracts/blob/{{version}}/Cache/Repository.php) | `Cache::driver()` | +| [Illuminate\Contracts\Cache\Store](https://github.com/illuminate/contracts/blob/{{version}}/Cache/Store.php) |   | +| [Illuminate\Contracts\Config\Repository](https://github.com/illuminate/contracts/blob/{{version}}/Config/Repository.php) | `Config` | +| [Illuminate\Contracts\Console\Application](https://github.com/illuminate/contracts/blob/{{version}}/Console/Application.php) |   | +| [Illuminate\Contracts\Console\Kernel](https://github.com/illuminate/contracts/blob/{{version}}/Console/Kernel.php) | `Artisan` | +| [Illuminate\Contracts\Container\Container](https://github.com/illuminate/contracts/blob/{{version}}/Container/Container.php) | `App` | +| [Illuminate\Contracts\Cookie\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Cookie/Factory.php) | `Cookie` | +| [Illuminate\Contracts\Cookie\QueueingFactory](https://github.com/illuminate/contracts/blob/{{version}}/Cookie/QueueingFactory.php) | `Cookie::queue()` | +| [Illuminate\Contracts\Database\ModelIdentifier](https://github.com/illuminate/contracts/blob/{{version}}/Database/ModelIdentifier.php) |   | +| [Illuminate\Contracts\Debug\ExceptionHandler](https://github.com/illuminate/contracts/blob/{{version}}/Debug/ExceptionHandler.php) |   | +| [Illuminate\Contracts\Encryption\Encrypter](https://github.com/illuminate/contracts/blob/{{version}}/Encryption/Encrypter.php) | `Crypt` | +| [Illuminate\Contracts\Events\Dispatcher](https://github.com/illuminate/contracts/blob/{{version}}/Events/Dispatcher.php) | `Event` | +| [Illuminate\Contracts\Filesystem\Cloud](https://github.com/illuminate/contracts/blob/{{version}}/Filesystem/Cloud.php) | `Storage::cloud()` | +| [Illuminate\Contracts\Filesystem\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Filesystem/Factory.php) | `Storage` | +| [Illuminate\Contracts\Filesystem\Filesystem](https://github.com/illuminate/contracts/blob/{{version}}/Filesystem/Filesystem.php) | `Storage::disk()` | +| [Illuminate\Contracts\Foundation\Application](https://github.com/illuminate/contracts/blob/{{version}}/Foundation/Application.php) | `App` | +| [Illuminate\Contracts\Hashing\Hasher](https://github.com/illuminate/contracts/blob/{{version}}/Hashing/Hasher.php) | `Hash` | +| [Illuminate\Contracts\Http\Kernel](https://github.com/illuminate/contracts/blob/{{version}}/Http/Kernel.php) |   | +| [Illuminate\Contracts\Mail\Mailable](https://github.com/illuminate/contracts/blob/{{version}}/Mail/Mailable.php) |   | +| [Illuminate\Contracts\Mail\Mailer](https://github.com/illuminate/contracts/blob/{{version}}/Mail/Mailer.php) | `Mail` | +| [Illuminate\Contracts\Mail\MailQueue](https://github.com/illuminate/contracts/blob/{{version}}/Mail/MailQueue.php) | `Mail::queue()` | +| [Illuminate\Contracts\Notifications\Dispatcher](https://github.com/illuminate/contracts/blob/{{version}}/Notifications/Dispatcher.php) | `Notification`| +| [Illuminate\Contracts\Notifications\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Notifications/Factory.php) | `Notification` | +| [Illuminate\Contracts\Pagination\LengthAwarePaginator](https://github.com/illuminate/contracts/blob/{{version}}/Pagination/LengthAwarePaginator.php) |   | +| [Illuminate\Contracts\Pagination\Paginator](https://github.com/illuminate/contracts/blob/{{version}}/Pagination/Paginator.php) |   | +| [Illuminate\Contracts\Pipeline\Hub](https://github.com/illuminate/contracts/blob/{{version}}/Pipeline/Hub.php) |   | +| [Illuminate\Contracts\Pipeline\Pipeline](https://github.com/illuminate/contracts/blob/{{version}}/Pipeline/Pipeline.php) | `Pipeline` | +| [Illuminate\Contracts\Queue\EntityResolver](https://github.com/illuminate/contracts/blob/{{version}}/Queue/EntityResolver.php) |   | +| [Illuminate\Contracts\Queue\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Queue/Factory.php) | `Queue` | +| [Illuminate\Contracts\Queue\Job](https://github.com/illuminate/contracts/blob/{{version}}/Queue/Job.php) |   | +| [Illuminate\Contracts\Queue\Monitor](https://github.com/illuminate/contracts/blob/{{version}}/Queue/Monitor.php) | `Queue` | +| [Illuminate\Contracts\Queue\Queue](https://github.com/illuminate/contracts/blob/{{version}}/Queue/Queue.php) | `Queue::connection()` | +| [Illuminate\Contracts\Queue\QueueableCollection](https://github.com/illuminate/contracts/blob/{{version}}/Queue/QueueableCollection.php) |   | +| [Illuminate\Contracts\Queue\QueueableEntity](https://github.com/illuminate/contracts/blob/{{version}}/Queue/QueueableEntity.php) |   | +| [Illuminate\Contracts\Queue\ShouldQueue](https://github.com/illuminate/contracts/blob/{{version}}/Queue/ShouldQueue.php) |   | +| [Illuminate\Contracts\Redis\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Redis/Factory.php) | `Redis` | +| [Illuminate\Contracts\Routing\BindingRegistrar](https://github.com/illuminate/contracts/blob/{{version}}/Routing/BindingRegistrar.php) | `Route` | +| [Illuminate\Contracts\Routing\Registrar](https://github.com/illuminate/contracts/blob/{{version}}/Routing/Registrar.php) | `Route` | +| [Illuminate\Contracts\Routing\ResponseFactory](https://github.com/illuminate/contracts/blob/{{version}}/Routing/ResponseFactory.php) | `Response` | +| [Illuminate\Contracts\Routing\UrlGenerator](https://github.com/illuminate/contracts/blob/{{version}}/Routing/UrlGenerator.php) | `URL` | +| [Illuminate\Contracts\Routing\UrlRoutable](https://github.com/illuminate/contracts/blob/{{version}}/Routing/UrlRoutable.php) |   | +| [Illuminate\Contracts\Session\Session](https://github.com/illuminate/contracts/blob/{{version}}/Session/Session.php) | `Session::driver()` | +| [Illuminate\Contracts\Support\Arrayable](https://github.com/illuminate/contracts/blob/{{version}}/Support/Arrayable.php) |   | +| [Illuminate\Contracts\Support\Htmlable](https://github.com/illuminate/contracts/blob/{{version}}/Support/Htmlable.php) |   | +| [Illuminate\Contracts\Support\Jsonable](https://github.com/illuminate/contracts/blob/{{version}}/Support/Jsonable.php) |   | +| [Illuminate\Contracts\Support\MessageBag](https://github.com/illuminate/contracts/blob/{{version}}/Support/MessageBag.php) |   | +| [Illuminate\Contracts\Support\MessageProvider](https://github.com/illuminate/contracts/blob/{{version}}/Support/MessageProvider.php) |   | +| [Illuminate\Contracts\Support\Renderable](https://github.com/illuminate/contracts/blob/{{version}}/Support/Renderable.php) |   | +| [Illuminate\Contracts\Support\Responsable](https://github.com/illuminate/contracts/blob/{{version}}/Support/Responsable.php) |   | +| [Illuminate\Contracts\Translation\Loader](https://github.com/illuminate/contracts/blob/{{version}}/Translation/Loader.php) |   | +| [Illuminate\Contracts\Translation\Translator](https://github.com/illuminate/contracts/blob/{{version}}/Translation/Translator.php) | `Lang` | +| [Illuminate\Contracts\Validation\Factory](https://github.com/illuminate/contracts/blob/{{version}}/Validation/Factory.php) | `Validator` | +| [Illuminate\Contracts\Validation\ValidatesWhenResolved](https://github.com/illuminate/contracts/blob/{{version}}/Validation/ValidatesWhenResolved.php) |   | +| [Illuminate\Contracts\Validation\ValidationRule](https://github.com/illuminate/contracts/blob/{{version}}/Validation/ValidationRule.php) |   | +| [Illuminate\Contracts\Validation\Validator](https://github.com/illuminate/contracts/blob/{{version}}/Validation/Validator.php) | `Validator::make()` | +| [Illuminate\Contracts\View\Engine](https://github.com/illuminate/contracts/blob/{{version}}/View/Engine.php) |   | +| [Illuminate\Contracts\View\Factory](https://github.com/illuminate/contracts/blob/{{version}}/View/Factory.php) | `View` | +| [Illuminate\Contracts\View\View](https://github.com/illuminate/contracts/blob/{{version}}/View/View.php) | `View::make()` | + +
diff --git a/controllers.md b/controllers.md index edc4ab4096e..54fc36bde6a 100644 --- a/controllers.md +++ b/controllers.md @@ -181,15 +181,19 @@ You may even register many resource controllers at once by passing an array to t #### Actions Handled by Resource Controllers -Verb | URI | Action | Route Name -----------|------------------------|--------------|--------------------- -GET | `/photos` | index | photos.index -GET | `/photos/create` | create | photos.create -POST | `/photos` | store | photos.store -GET | `/photos/{photo}` | show | photos.show -GET | `/photos/{photo}/edit` | edit | photos.edit -PUT/PATCH | `/photos/{photo}` | update | photos.update -DELETE | `/photos/{photo}` | destroy | photos.destroy +
+ +| Verb | URI | Action | Route Name | +| --------- | ---------------------- | ------- | -------------- | +| GET | `/photos` | index | photos.index | +| GET | `/photos/create` | create | photos.create | +| POST | `/photos` | store | photos.store | +| GET | `/photos/{photo}` | show | photos.show | +| GET | `/photos/{photo}/edit` | edit | photos.edit | +| PUT/PATCH | `/photos/{photo}` | update | photos.update | +| DELETE | `/photos/{photo}` | destroy | photos.destroy | + +
#### Customizing Missing Model Behavior @@ -305,15 +309,19 @@ Often, it is not entirely necessary to have both the parent and the child IDs wi This route definition will define the following routes: -Verb | URI | Action | Route Name -----------|-----------------------------------|--------------|--------------------- -GET | `/photos/{photo}/comments` | index | photos.comments.index -GET | `/photos/{photo}/comments/create` | create | photos.comments.create -POST | `/photos/{photo}/comments` | store | photos.comments.store -GET | `/comments/{comment}` | show | comments.show -GET | `/comments/{comment}/edit` | edit | comments.edit -PUT/PATCH | `/comments/{comment}` | update | comments.update -DELETE | `/comments/{comment}` | destroy | comments.destroy +
+ +| Verb | URI | Action | Route Name | +| --------- | --------------------------------- | ------- | ---------------------- | +| GET | `/photos/{photo}/comments` | index | photos.comments.index | +| GET | `/photos/{photo}/comments/create` | create | photos.comments.create | +| POST | `/photos/{photo}/comments` | store | photos.comments.store | +| GET | `/comments/{comment}` | show | comments.show | +| GET | `/comments/{comment}/edit` | edit | comments.edit | +| PUT/PATCH | `/comments/{comment}` | update | comments.update | +| DELETE | `/comments/{comment}` | destroy | comments.destroy | + +
### Naming Resource Routes @@ -407,11 +415,15 @@ Route::singleton('profile', ProfileController::class); The singleton resource definition above will register the following routes. As you can see, "creation" routes are not registered for singleton resources, and the registered routes do not accept an identifier since only one instance of the resource may exist: -Verb | URI | Action | Route Name -----------|-----------------------------------|--------------|--------------------- -GET | `/profile` | show | profile.show -GET | `/profile/edit` | edit | profile.edit -PUT/PATCH | `/profile` | update | profile.update +
+ +| Verb | URI | Action | Route Name | +| --------- | --------------- | ------ | -------------- | +| GET | `/profile` | show | profile.show | +| GET | `/profile/edit` | edit | profile.edit | +| PUT/PATCH | `/profile` | update | profile.update | + +
Singleton resources may also be nested within a standard resource: @@ -421,11 +433,15 @@ Route::singleton('photos.thumbnail', ThumbnailController::class); In this example, the `photos` resource would receive all of the [standard resource routes](#actions-handled-by-resource-controller); however, the `thumbnail` resource would be a singleton resource with the following routes: -| Verb | URI | Action | Route Name | -|-----------|----------------------------------|---------|--------------------------| -| GET | `/photos/{photo}/thumbnail` | show | photos.thumbnail.show | -| GET | `/photos/{photo}/thumbnail/edit` | edit | photos.thumbnail.edit | -| PUT/PATCH | `/photos/{photo}/thumbnail` | update | photos.thumbnail.update | +
+ +| Verb | URI | Action | Route Name | +| --------- | -------------------------------- | ------ | ----------------------- | +| GET | `/photos/{photo}/thumbnail` | show | photos.thumbnail.show | +| GET | `/photos/{photo}/thumbnail/edit` | edit | photos.thumbnail.edit | +| PUT/PATCH | `/photos/{photo}/thumbnail` | update | photos.thumbnail.update | + +
#### Creatable Singleton Resources @@ -438,8 +454,10 @@ Route::singleton('photos.thumbnail', ThumbnailController::class)->creatable(); In this example, the following routes will be registered. As you can see, a `DELETE` route will also be registered for creatable singleton resources: +
+ | Verb | URI | Action | Route Name | -|-----------|------------------------------------|---------|--------------------------| +| --------- | ---------------------------------- | ------- | ------------------------ | | GET | `/photos/{photo}/thumbnail/create` | create | photos.thumbnail.create | | POST | `/photos/{photo}/thumbnail` | store | photos.thumbnail.store | | GET | `/photos/{photo}/thumbnail` | show | photos.thumbnail.show | @@ -447,6 +465,8 @@ In this example, the following routes will be registered. As you can see, a `DEL | PUT/PATCH | `/photos/{photo}/thumbnail` | update | photos.thumbnail.update | | DELETE | `/photos/{photo}/thumbnail` | destroy | photos.thumbnail.destroy | +
+ If you would like Laravel to register the `DELETE` route for a singleton resource but not register the creation or storage routes, you may utilize the `destroyable` method: ```php diff --git a/facades.md b/facades.md index 9b72a8cf783..1c8fcbb0bd9 100644 --- a/facades.md +++ b/facades.md @@ -284,61 +284,61 @@ Below you will find every facade and its underlying class. This is a useful tool
-Facade | Class | Service Container Binding -------------- | ------------- | ------------- -App | [Illuminate\Foundation\Application](https://laravel.com/api/{{version}}/Illuminate/Foundation/Application.html) | `app` -Artisan | [Illuminate\Contracts\Console\Kernel](https://laravel.com/api/{{version}}/Illuminate/Contracts/Console/Kernel.html) | `artisan` -Auth | [Illuminate\Auth\AuthManager](https://laravel.com/api/{{version}}/Illuminate/Auth/AuthManager.html) | `auth` -Auth (Instance) | [Illuminate\Contracts\Auth\Guard](https://laravel.com/api/{{version}}/Illuminate/Contracts/Auth/Guard.html) | `auth.driver` -Blade | [Illuminate\View\Compilers\BladeCompiler](https://laravel.com/api/{{version}}/Illuminate/View/Compilers/BladeCompiler.html) | `blade.compiler` -Broadcast | [Illuminate\Contracts\Broadcasting\Factory](https://laravel.com/api/{{version}}/Illuminate/Contracts/Broadcasting/Factory.html) |   -Broadcast (Instance) | [Illuminate\Contracts\Broadcasting\Broadcaster](https://laravel.com/api/{{version}}/Illuminate/Contracts/Broadcasting/Broadcaster.html) |   -Bus | [Illuminate\Contracts\Bus\Dispatcher](https://laravel.com/api/{{version}}/Illuminate/Contracts/Bus/Dispatcher.html) |   -Cache | [Illuminate\Cache\CacheManager](https://laravel.com/api/{{version}}/Illuminate/Cache/CacheManager.html) | `cache` -Cache (Instance) | [Illuminate\Cache\Repository](https://laravel.com/api/{{version}}/Illuminate/Cache/Repository.html) | `cache.store` -Config | [Illuminate\Config\Repository](https://laravel.com/api/{{version}}/Illuminate/Config/Repository.html) | `config` -Cookie | [Illuminate\Cookie\CookieJar](https://laravel.com/api/{{version}}/Illuminate/Cookie/CookieJar.html) | `cookie` -Crypt | [Illuminate\Encryption\Encrypter](https://laravel.com/api/{{version}}/Illuminate/Encryption/Encrypter.html) | `encrypter` -Date | [Illuminate\Support\DateFactory](https://laravel.com/api/{{version}}/Illuminate/Support/DateFactory.html) | `date` -DB | [Illuminate\Database\DatabaseManager](https://laravel.com/api/{{version}}/Illuminate/Database/DatabaseManager.html) | `db` -DB (Instance) | [Illuminate\Database\Connection](https://laravel.com/api/{{version}}/Illuminate/Database/Connection.html) | `db.connection` -Event | [Illuminate\Events\Dispatcher](https://laravel.com/api/{{version}}/Illuminate/Events/Dispatcher.html) | `events` -Exceptions | [Illuminate\Foundation\Exceptions\Handler](https://laravel.com/api/{{version}}/Illuminate/Foundation/Exceptions/Handler.html) |   -Exceptions (Instance) | [Illuminate\Contracts\Debug\ExceptionHandler](https://laravel.com/api/{{version}}/Illuminate/Contracts/Debug/ExceptionHandler.html) |   -File | [Illuminate\Filesystem\Filesystem](https://laravel.com/api/{{version}}/Illuminate/Filesystem/Filesystem.html) | `files` -Gate | [Illuminate\Contracts\Auth\Access\Gate](https://laravel.com/api/{{version}}/Illuminate/Contracts/Auth/Access/Gate.html) |   -Hash | [Illuminate\Contracts\Hashing\Hasher](https://laravel.com/api/{{version}}/Illuminate/Contracts/Hashing/Hasher.html) | `hash` -Http | [Illuminate\Http\Client\Factory](https://laravel.com/api/{{version}}/Illuminate/Http/Client/Factory.html) |   -Lang | [Illuminate\Translation\Translator](https://laravel.com/api/{{version}}/Illuminate/Translation/Translator.html) | `translator` -Log | [Illuminate\Log\LogManager](https://laravel.com/api/{{version}}/Illuminate/Log/LogManager.html) | `log` -Mail | [Illuminate\Mail\Mailer](https://laravel.com/api/{{version}}/Illuminate/Mail/Mailer.html) | `mailer` -Notification | [Illuminate\Notifications\ChannelManager](https://laravel.com/api/{{version}}/Illuminate/Notifications/ChannelManager.html) |   -Password | [Illuminate\Auth\Passwords\PasswordBrokerManager](https://laravel.com/api/{{version}}/Illuminate/Auth/Passwords/PasswordBrokerManager.html) | `auth.password` -Password (Instance) | [Illuminate\Auth\Passwords\PasswordBroker](https://laravel.com/api/{{version}}/Illuminate/Auth/Passwords/PasswordBroker.html) | `auth.password.broker` -Pipeline (Instance) | [Illuminate\Pipeline\Pipeline](https://laravel.com/api/{{version}}/Illuminate/Pipeline/Pipeline.html) |   -Process | [Illuminate\Process\Factory](https://laravel.com/api/{{version}}/Illuminate/Process/Factory.html) |   -Queue | [Illuminate\Queue\QueueManager](https://laravel.com/api/{{version}}/Illuminate/Queue/QueueManager.html) | `queue` -Queue (Instance) | [Illuminate\Contracts\Queue\Queue](https://laravel.com/api/{{version}}/Illuminate/Contracts/Queue/Queue.html) | `queue.connection` -Queue (Base Class) | [Illuminate\Queue\Queue](https://laravel.com/api/{{version}}/Illuminate/Queue/Queue.html) |   -RateLimiter | [Illuminate\Cache\RateLimiter](https://laravel.com/api/{{version}}/Illuminate/Cache/RateLimiter.html) |   -Redirect | [Illuminate\Routing\Redirector](https://laravel.com/api/{{version}}/Illuminate/Routing/Redirector.html) | `redirect` -Redis | [Illuminate\Redis\RedisManager](https://laravel.com/api/{{version}}/Illuminate/Redis/RedisManager.html) | `redis` -Redis (Instance) | [Illuminate\Redis\Connections\Connection](https://laravel.com/api/{{version}}/Illuminate/Redis/Connections/Connection.html) | `redis.connection` -Request | [Illuminate\Http\Request](https://laravel.com/api/{{version}}/Illuminate/Http/Request.html) | `request` -Response | [Illuminate\Contracts\Routing\ResponseFactory](https://laravel.com/api/{{version}}/Illuminate/Contracts/Routing/ResponseFactory.html) |   -Response (Instance) | [Illuminate\Http\Response](https://laravel.com/api/{{version}}/Illuminate/Http/Response.html) |   -Route | [Illuminate\Routing\Router](https://laravel.com/api/{{version}}/Illuminate/Routing/Router.html) | `router` -Schedule | [Illuminate\Console\Scheduling\Schedule](https://laravel.com/api/{{version}}/Illuminate/Console/Scheduling/Schedule.html) |   -Schema | [Illuminate\Database\Schema\Builder](https://laravel.com/api/{{version}}/Illuminate/Database/Schema/Builder.html) |   -Session | [Illuminate\Session\SessionManager](https://laravel.com/api/{{version}}/Illuminate/Session/SessionManager.html) | `session` -Session (Instance) | [Illuminate\Session\Store](https://laravel.com/api/{{version}}/Illuminate/Session/Store.html) | `session.store` -Storage | [Illuminate\Filesystem\FilesystemManager](https://laravel.com/api/{{version}}/Illuminate/Filesystem/FilesystemManager.html) | `filesystem` -Storage (Instance) | [Illuminate\Contracts\Filesystem\Filesystem](https://laravel.com/api/{{version}}/Illuminate/Contracts/Filesystem/Filesystem.html) | `filesystem.disk` -URL | [Illuminate\Routing\UrlGenerator](https://laravel.com/api/{{version}}/Illuminate/Routing/UrlGenerator.html) | `url` -Validator | [Illuminate\Validation\Factory](https://laravel.com/api/{{version}}/Illuminate/Validation/Factory.html) | `validator` -Validator (Instance) | [Illuminate\Validation\Validator](https://laravel.com/api/{{version}}/Illuminate/Validation/Validator.html) |   -View | [Illuminate\View\Factory](https://laravel.com/api/{{version}}/Illuminate/View/Factory.html) | `view` -View (Instance) | [Illuminate\View\View](https://laravel.com/api/{{version}}/Illuminate/View/View.html) |   -Vite | [Illuminate\Foundation\Vite](https://laravel.com/api/{{version}}/Illuminate/Foundation/Vite.html) |   +| Facade | Class | Service Container Binding | +| --- | --- | --- | +| App | [Illuminate\Foundation\Application](https://laravel.com/api/{{version}}/Illuminate/Foundation/Application.html) | `app` | +| Artisan | [Illuminate\Contracts\Console\Kernel](https://laravel.com/api/{{version}}/Illuminate/Contracts/Console/Kernel.html) | `artisan` | +| Auth (Instance) | [Illuminate\Contracts\Auth\Guard](https://laravel.com/api/{{version}}/Illuminate/Contracts/Auth/Guard.html) | `auth.driver` | +| Auth | [Illuminate\Auth\AuthManager](https://laravel.com/api/{{version}}/Illuminate/Auth/AuthManager.html) | `auth` | +| Blade | [Illuminate\View\Compilers\BladeCompiler](https://laravel.com/api/{{version}}/Illuminate/View/Compilers/BladeCompiler.html) | `blade.compiler` | +| Broadcast (Instance) | [Illuminate\Contracts\Broadcasting\Broadcaster](https://laravel.com/api/{{version}}/Illuminate/Contracts/Broadcasting/Broadcaster.html) |   | +| Broadcast | [Illuminate\Contracts\Broadcasting\Factory](https://laravel.com/api/{{version}}/Illuminate/Contracts/Broadcasting/Factory.html) |   | +| Bus | [Illuminate\Contracts\Bus\Dispatcher](https://laravel.com/api/{{version}}/Illuminate/Contracts/Bus/Dispatcher.html) |   | +| Cache (Instance) | [Illuminate\Cache\Repository](https://laravel.com/api/{{version}}/Illuminate/Cache/Repository.html) | `cache.store` | +| Cache | [Illuminate\Cache\CacheManager](https://laravel.com/api/{{version}}/Illuminate/Cache/CacheManager.html) | `cache` | +| Config | [Illuminate\Config\Repository](https://laravel.com/api/{{version}}/Illuminate/Config/Repository.html) | `config` | +| Cookie | [Illuminate\Cookie\CookieJar](https://laravel.com/api/{{version}}/Illuminate/Cookie/CookieJar.html) | `cookie` | +| Crypt | [Illuminate\Encryption\Encrypter](https://laravel.com/api/{{version}}/Illuminate/Encryption/Encrypter.html) | `encrypter` | +| Date | [Illuminate\Support\DateFactory](https://laravel.com/api/{{version}}/Illuminate/Support/DateFactory.html) | `date` | +| DB (Instance) | [Illuminate\Database\Connection](https://laravel.com/api/{{version}}/Illuminate/Database/Connection.html) | `db.connection` | +| DB | [Illuminate\Database\DatabaseManager](https://laravel.com/api/{{version}}/Illuminate/Database/DatabaseManager.html) | `db` | +| Event | [Illuminate\Events\Dispatcher](https://laravel.com/api/{{version}}/Illuminate/Events/Dispatcher.html) | `events` | +| Exceptions (Instance) | [Illuminate\Contracts\Debug\ExceptionHandler](https://laravel.com/api/{{version}}/Illuminate/Contracts/Debug/ExceptionHandler.html) |   | +| Exceptions | [Illuminate\Foundation\Exceptions\Handler](https://laravel.com/api/{{version}}/Illuminate/Foundation/Exceptions/Handler.html) |   | +| File | [Illuminate\Filesystem\Filesystem](https://laravel.com/api/{{version}}/Illuminate/Filesystem/Filesystem.html) | `files` | +| Gate | [Illuminate\Contracts\Auth\Access\Gate](https://laravel.com/api/{{version}}/Illuminate/Contracts/Auth/Access/Gate.html) |   | +| Hash | [Illuminate\Contracts\Hashing\Hasher](https://laravel.com/api/{{version}}/Illuminate/Contracts/Hashing/Hasher.html) | `hash` | +| Http | [Illuminate\Http\Client\Factory](https://laravel.com/api/{{version}}/Illuminate/Http/Client/Factory.html) |   | +| Lang | [Illuminate\Translation\Translator](https://laravel.com/api/{{version}}/Illuminate/Translation/Translator.html) | `translator` | +| Log | [Illuminate\Log\LogManager](https://laravel.com/api/{{version}}/Illuminate/Log/LogManager.html) | `log` | +| Mail | [Illuminate\Mail\Mailer](https://laravel.com/api/{{version}}/Illuminate/Mail/Mailer.html) | `mailer` | +| Notification | [Illuminate\Notifications\ChannelManager](https://laravel.com/api/{{version}}/Illuminate/Notifications/ChannelManager.html) |   | +| Password (Instance) | [Illuminate\Auth\Passwords\PasswordBroker](https://laravel.com/api/{{version}}/Illuminate/Auth/Passwords/PasswordBroker.html) | `auth.password.broker` | +| Password | [Illuminate\Auth\Passwords\PasswordBrokerManager](https://laravel.com/api/{{version}}/Illuminate/Auth/Passwords/PasswordBrokerManager.html) | `auth.password` | +| Pipeline (Instance) | [Illuminate\Pipeline\Pipeline](https://laravel.com/api/{{version}}/Illuminate/Pipeline/Pipeline.html) |   | +| Process | [Illuminate\Process\Factory](https://laravel.com/api/{{version}}/Illuminate/Process/Factory.html) |   | +| Queue (Base Class) | [Illuminate\Queue\Queue](https://laravel.com/api/{{version}}/Illuminate/Queue/Queue.html) |   | +| Queue (Instance) | [Illuminate\Contracts\Queue\Queue](https://laravel.com/api/{{version}}/Illuminate/Contracts/Queue/Queue.html) | `queue.connection` | +| Queue | [Illuminate\Queue\QueueManager](https://laravel.com/api/{{version}}/Illuminate/Queue/QueueManager.html) | `queue` | +| RateLimiter | [Illuminate\Cache\RateLimiter](https://laravel.com/api/{{version}}/Illuminate/Cache/RateLimiter.html) |   | +| Redirect | [Illuminate\Routing\Redirector](https://laravel.com/api/{{version}}/Illuminate/Routing/Redirector.html) | `redirect` | +| Redis (Instance) | [Illuminate\Redis\Connections\Connection](https://laravel.com/api/{{version}}/Illuminate/Redis/Connections/Connection.html) | `redis.connection` | +| Redis | [Illuminate\Redis\RedisManager](https://laravel.com/api/{{version}}/Illuminate/Redis/RedisManager.html) | `redis` | +| Request | [Illuminate\Http\Request](https://laravel.com/api/{{version}}/Illuminate/Http/Request.html) | `request` | +| Response (Instance) | [Illuminate\Http\Response](https://laravel.com/api/{{version}}/Illuminate/Http/Response.html) |   | +| Response | [Illuminate\Contracts\Routing\ResponseFactory](https://laravel.com/api/{{version}}/Illuminate/Contracts/Routing/ResponseFactory.html) |   | +| Route | [Illuminate\Routing\Router](https://laravel.com/api/{{version}}/Illuminate/Routing/Router.html) | `router` | +| Schedule | [Illuminate\Console\Scheduling\Schedule](https://laravel.com/api/{{version}}/Illuminate/Console/Scheduling/Schedule.html) |   | +| Schema | [Illuminate\Database\Schema\Builder](https://laravel.com/api/{{version}}/Illuminate/Database/Schema/Builder.html) |   | +| Session (Instance) | [Illuminate\Session\Store](https://laravel.com/api/{{version}}/Illuminate/Session/Store.html) | `session.store` | +| Session | [Illuminate\Session\SessionManager](https://laravel.com/api/{{version}}/Illuminate/Session/SessionManager.html) | `session` | +| Storage (Instance) | [Illuminate\Contracts\Filesystem\Filesystem](https://laravel.com/api/{{version}}/Illuminate/Contracts/Filesystem/Filesystem.html) | `filesystem.disk` | +| Storage | [Illuminate\Filesystem\FilesystemManager](https://laravel.com/api/{{version}}/Illuminate/Filesystem/FilesystemManager.html) | `filesystem` | +| URL | [Illuminate\Routing\UrlGenerator](https://laravel.com/api/{{version}}/Illuminate/Routing/UrlGenerator.html) | `url` | +| Validator (Instance) | [Illuminate\Validation\Validator](https://laravel.com/api/{{version}}/Illuminate/Validation/Validator.html) |   | +| Validator | [Illuminate\Validation\Factory](https://laravel.com/api/{{version}}/Illuminate/Validation/Factory.html) | `validator` | +| View (Instance) | [Illuminate\View\View](https://laravel.com/api/{{version}}/Illuminate/View/View.html) |   | +| View | [Illuminate\View\Factory](https://laravel.com/api/{{version}}/Illuminate/View/Factory.html) | `view` | +| Vite | [Illuminate\Foundation\Vite](https://laravel.com/api/{{version}}/Illuminate/Foundation/Vite.html) |   |
diff --git a/logging.md b/logging.md index ae71565accf..01a203e8690 100644 --- a/logging.md +++ b/logging.md @@ -41,17 +41,17 @@ Each log channel is powered by a "driver". The driver determines how and where t
-Name | Description -------------- | ------------- -`custom` | A driver that calls a specified factory to create a channel -`daily` | A `RotatingFileHandler` based Monolog driver which rotates daily -`errorlog` | An `ErrorLogHandler` based Monolog driver -`monolog` | A Monolog factory driver that may use any supported Monolog handler -`papertrail` | A `SyslogUdpHandler` based Monolog driver -`single` | A single file or path based logger channel (`StreamHandler`) -`slack` | A `SlackWebhookHandler` based Monolog driver -`stack` | A wrapper to facilitate creating "multi-channel" channels -`syslog` | A `SyslogHandler` based Monolog driver +| Name | Description | +| ------------ | -------------------------------------------------------------------- | +| `custom` | A driver that calls a specified factory to create a channel. | +| `daily` | A `RotatingFileHandler` based Monolog driver which rotates daily. | +| `errorlog` | An `ErrorLogHandler` based Monolog driver. | +| `monolog` | A Monolog factory driver that may use any supported Monolog handler. | +| `papertrail` | A `SyslogUdpHandler` based Monolog driver. | +| `single` | A single file or path based logger channel (`StreamHandler`). | +| `slack` | A `SlackWebhookHandler` based Monolog driver. | +| `stack` | A wrapper to facilitate creating "multi-channel" channels. | +| `syslog` | A `SyslogHandler` based Monolog driver. |
@@ -79,11 +79,11 @@ The `single` and `daily` channels have three optional configuration options: `bu
-Name | Description | Default -------------- | ------------- | ------------- -`bubble` | Indicates if messages should bubble up to other channels after being handled | `true` -`locking` | Attempt to lock the log file before writing to it | `false` -`permission` | The log file's permissions | `0644` +| Name | Description | Default | +| ------------ | ----------------------------------------------------------------------------- | ------- | +| `bubble` | Indicates if messages should bubble up to other channels after being handled. | `true` | +| `locking` | Attempt to lock the log file before writing to it. | `false` | +| `permission` | The log file's permissions. | `0644` |
@@ -91,9 +91,9 @@ Additionally, the retention policy for the `daily` channel can be configured via
-Name | Description | Default -------------- |-------------------------------------------------------------------| ------------- -`days` | The number of days that daily log files should be retained | `7` +| Name | Description | Default | +| ------ | ----------------------------------------------------------- | ------- | +| `days` | The number of days that daily log files should be retained. | `7` |
diff --git a/mail.md b/mail.md index b1ba0ab615f..df469d22326 100644 --- a/mail.md +++ b/mail.md @@ -799,10 +799,10 @@ The table component allows you to transform a Markdown table into an HTML table. ```blade -| Laravel | Table | Example | -| ------------- |:-------------:| --------:| -| Col 2 is | Centered | $10 | -| Col 3 is | Right-Aligned | $20 | +| Laravel | Table | Example | +| ------------- | :-----------: | ------------: | +| Col 2 is | Centered | $10 | +| Col 3 is | Right-Aligned | $20 | ``` diff --git a/middleware.md b/middleware.md index 91c0fd0564b..b56ca30820a 100644 --- a/middleware.md +++ b/middleware.md @@ -222,18 +222,26 @@ Middleware groups may be assigned to routes and controller actions using the sam Laravel includes predefined `web` and `api` middleware groups that contain common middleware you may want to apply to your web and API routes. Remember, Laravel automatically applies these middleware groups to the corresponding `routes/web.php` and `routes/api.php` files: -| The `web` Middleware Group -|-------------- -| `Illuminate\Cookie\Middleware\EncryptCookies` -| `Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse` -| `Illuminate\Session\Middleware\StartSession` -| `Illuminate\View\Middleware\ShareErrorsFromSession` -| `Illuminate\Foundation\Http\Middleware\ValidateCsrfToken` -| `Illuminate\Routing\Middleware\SubstituteBindings` - -| The `api` Middleware Group -|-------------- -| `Illuminate\Routing\Middleware\SubstituteBindings` +
+ +| The `web` Middleware Group | +| --- | +| `Illuminate\Cookie\Middleware\EncryptCookies` | +| `Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse` | +| `Illuminate\Session\Middleware\StartSession` | +| `Illuminate\View\Middleware\ShareErrorsFromSession` | +| `Illuminate\Foundation\Http\Middleware\ValidateCsrfToken` | +| `Illuminate\Routing\Middleware\SubstituteBindings` | + +
+ +
+ +| The `api` Middleware Group | +| --- | +| `Illuminate\Routing\Middleware\SubstituteBindings` | + +
If you would like to append or prepend middleware to these groups, you may use the `web` and `api` methods within your application's `bootstrap/app.php` file. The `web` and `api` methods are convenient alternatives to the `appendToGroup` method: @@ -312,20 +320,24 @@ Once the middleware alias has been defined in your application's `bootstrap/app. For convenience, some of Laravel's built-in middleware are aliased by default. For example, the `auth` middleware is an alias for the `Illuminate\Auth\Middleware\Authenticate` middleware. Below is a list of the default middleware aliases: -| Alias | Middleware -|-------|------------ -`auth` | `Illuminate\Auth\Middleware\Authenticate` -`auth.basic` | `Illuminate\Auth\Middleware\AuthenticateWithBasicAuth` -`auth.session` | `Illuminate\Session\Middleware\AuthenticateSession` -`cache.headers` | `Illuminate\Http\Middleware\SetCacheHeaders` -`can` | `Illuminate\Auth\Middleware\Authorize` -`guest` | `Illuminate\Auth\Middleware\RedirectIfAuthenticated` -`password.confirm` | `Illuminate\Auth\Middleware\RequirePassword` -`precognitive` | `Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests` -`signed` | `Illuminate\Routing\Middleware\ValidateSignature` -`subscribed` | `\Spark\Http\Middleware\VerifyBillableIsSubscribed` -`throttle` | `Illuminate\Routing\Middleware\ThrottleRequests` or `Illuminate\Routing\Middleware\ThrottleRequestsWithRedis` -`verified` | `Illuminate\Auth\Middleware\EnsureEmailIsVerified` +
+ +| Alias | Middleware | +| --- | --- | +| `auth` | `Illuminate\Auth\Middleware\Authenticate` | +| `auth.basic` | `Illuminate\Auth\Middleware\AuthenticateWithBasicAuth` | +| `auth.session` | `Illuminate\Session\Middleware\AuthenticateSession` | +| `cache.headers` | `Illuminate\Http\Middleware\SetCacheHeaders` | +| `can` | `Illuminate\Auth\Middleware\Authorize` | +| `guest` | `Illuminate\Auth\Middleware\RedirectIfAuthenticated` | +| `password.confirm` | `Illuminate\Auth\Middleware\RequirePassword` | +| `precognitive` | `Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests` | +| `signed` | `Illuminate\Routing\Middleware\ValidateSignature` | +| `subscribed` | `\Spark\Http\Middleware\VerifyBillableIsSubscribed` | +| `throttle` | `Illuminate\Routing\Middleware\ThrottleRequests` or `Illuminate\Routing\Middleware\ThrottleRequestsWithRedis` | +| `verified` | `Illuminate\Auth\Middleware\EnsureEmailIsVerified` | + +
### Sorting Middleware diff --git a/migrations.md b/migrations.md index b6f72109926..7f8dcb89817 100644 --- a/migrations.md +++ b/migrations.md @@ -939,25 +939,29 @@ In addition to the column types listed above, there are several column "modifier The following table contains all of the available column modifiers. This list does not include [index modifiers](#creating-indexes): -Modifier | Description --------- | ----------- -`->after('column')` | Place the column "after" another column (MariaDB / MySQL). -`->autoIncrement()` | Set INTEGER columns as auto-incrementing (primary key). -`->charset('utf8mb4')` | Specify a character set for the column (MariaDB / MySQL). -`->collation('utf8mb4_unicode_ci')` | Specify a collation for the column. -`->comment('my comment')` | Add a comment to a column (MariaDB / MySQL / PostgreSQL). -`->default($value)` | Specify a "default" value for the column. -`->first()` | Place the column "first" in the table (MariaDB / MySQL). -`->from($integer)` | Set the starting value of an auto-incrementing field (MariaDB / MySQL / PostgreSQL). -`->invisible()` | Make the column "invisible" to `SELECT *` queries (MariaDB / MySQL). -`->nullable($value = true)` | Allow NULL values to be inserted into the column. -`->storedAs($expression)` | Create a stored generated column (MariaDB / MySQL / PostgreSQL / SQLite). -`->unsigned()` | Set INTEGER columns as UNSIGNED (MariaDB / MySQL). -`->useCurrent()` | Set TIMESTAMP columns to use CURRENT_TIMESTAMP as default value. -`->useCurrentOnUpdate()` | Set TIMESTAMP columns to use CURRENT_TIMESTAMP when a record is updated (MariaDB / MySQL). -`->virtualAs($expression)` | Create a virtual generated column (MariaDB / MySQL / SQLite). -`->generatedAs($expression)` | Create an identity column with specified sequence options (PostgreSQL). -`->always()` | Defines the precedence of sequence values over input for an identity column (PostgreSQL). +
+ +| Modifier | Description | +| ----------------------------------- | ---------------------------------------------------------------------------------------------- | +| `->after('column')` | Place the column "after" another column (MariaDB / MySQL). | +| `->autoIncrement()` | Set `INTEGER` columns as auto-incrementing (primary key). | +| `->charset('utf8mb4')` | Specify a character set for the column (MariaDB / MySQL). | +| `->collation('utf8mb4_unicode_ci')` | Specify a collation for the column. | +| `->comment('my comment')` | Add a comment to a column (MariaDB / MySQL / PostgreSQL). | +| `->default($value)` | Specify a "default" value for the column. | +| `->first()` | Place the column "first" in the table (MariaDB / MySQL). | +| `->from($integer)` | Set the starting value of an auto-incrementing field (MariaDB / MySQL / PostgreSQL). | +| `->invisible()` | Make the column "invisible" to `SELECT *` queries (MariaDB / MySQL). | +| `->nullable($value = true)` | Allow `NULL` values to be inserted into the column. | +| `->storedAs($expression)` | Create a stored generated column (MariaDB / MySQL / PostgreSQL / SQLite). | +| `->unsigned()` | Set `INTEGER` columns as `UNSIGNED` (MariaDB / MySQL). | +| `->useCurrent()` | Set `TIMESTAMP` columns to use `CURRENT_TIMESTAMP` as default value. | +| `->useCurrentOnUpdate()` | Set `TIMESTAMP` columns to use `CURRENT_TIMESTAMP` when a record is updated (MariaDB / MySQL). | +| `->virtualAs($expression)` | Create a virtual generated column (MariaDB / MySQL / SQLite). | +| `->generatedAs($expression)` | Create an identity column with specified sequence options (PostgreSQL). | +| `->always()` | Defines the precedence of sequence values over input for an identity column (PostgreSQL). | + +
#### Default Expressions @@ -1054,14 +1058,18 @@ You may drop multiple columns from a table by passing an array of column names t Laravel provides several convenient methods related to dropping common types of columns. Each of these methods is described in the table below: -Command | Description -------- | ----------- -`$table->dropMorphs('morphable');` | Drop the `morphable_id` and `morphable_type` columns. -`$table->dropRememberToken();` | Drop the `remember_token` column. -`$table->dropSoftDeletes();` | Drop the `deleted_at` column. -`$table->dropSoftDeletesTz();` | Alias of `dropSoftDeletes()` method. -`$table->dropTimestamps();` | Drop the `created_at` and `updated_at` columns. -`$table->dropTimestampsTz();` | Alias of `dropTimestamps()` method. +
+ +| Command | Description | +| ----------------------------------- | ----------------------------------------------------- | +| `$table->dropMorphs('morphable');` | Drop the `morphable_id` and `morphable_type` columns. | +| `$table->dropRememberToken();` | Drop the `remember_token` column. | +| `$table->dropSoftDeletes();` | Drop the `deleted_at` column. | +| `$table->dropSoftDeletesTz();` | Alias of `dropSoftDeletes()` method. | +| `$table->dropTimestamps();` | Drop the `created_at` and `updated_at` columns. | +| `$table->dropTimestampsTz();` | Alias of `dropTimestamps()` method. | + +
## Indexes @@ -1095,15 +1103,19 @@ When creating an index, Laravel will automatically generate an index name based Laravel's schema builder blueprint class provides methods for creating each type of index supported by Laravel. Each index method accepts an optional second argument to specify the name of the index. If omitted, the name will be derived from the names of the table and column(s) used for the index, as well as the index type. Each of the available index methods is described in the table below: -Command | Description -------- | ----------- -`$table->primary('id');` | Adds a primary key. -`$table->primary(['id', 'parent_id']);` | Adds composite keys. -`$table->unique('email');` | Adds a unique index. -`$table->index('state');` | Adds an index. -`$table->fullText('body');` | Adds a full text index (MariaDB / MySQL / PostgreSQL). -`$table->fullText('body')->language('english');` | Adds a full text index of the specified language (PostgreSQL). -`$table->spatialIndex('location');` | Adds a spatial index (except SQLite). +
+ +| Command | Description | +| ------------------------------------------------ | -------------------------------------------------------------- | +| `$table->primary('id');` | Adds a primary key. | +| `$table->primary(['id', 'parent_id']);` | Adds composite keys. | +| `$table->unique('email');` | Adds a unique index. | +| `$table->index('state');` | Adds an index. | +| `$table->fullText('body');` | Adds a full text index (MariaDB / MySQL / PostgreSQL). | +| `$table->fullText('body')->language('english');` | Adds a full text index of the specified language (PostgreSQL). | +| `$table->spatialIndex('location');` | Adds a spatial index (except SQLite). | + +
### Renaming Indexes @@ -1117,13 +1129,17 @@ To rename an index, you may use the `renameIndex` method provided by the schema To drop an index, you must specify the index's name. By default, Laravel automatically assigns an index name based on the table name, the name of the indexed column, and the index type. Here are some examples: -Command | Description -------- | ----------- -`$table->dropPrimary('users_id_primary');` | Drop a primary key from the "users" table. -`$table->dropUnique('users_email_unique');` | Drop a unique index from the "users" table. -`$table->dropIndex('geo_state_index');` | Drop a basic index from the "geo" table. -`$table->dropFullText('posts_body_fulltext');` | Drop a full text index from the "posts" table. -`$table->dropSpatialIndex('geo_location_spatialindex');` | Drop a spatial index from the "geo" table (except SQLite). +
+ +| Command | Description | +| -------------------------------------------------------- | ----------------------------------------------------------- | +| `$table->dropPrimary('users_id_primary');` | Drop a primary key from the "users" table. | +| `$table->dropUnique('users_email_unique');` | Drop a unique index from the "users" table. | +| `$table->dropIndex('geo_state_index');` | Drop a basic index from the "geo" table. | +| `$table->dropFullText('posts_body_fulltext');` | Drop a full text index from the "posts" table. | +| `$table->dropSpatialIndex('geo_location_spatialindex');` | Drop a spatial index from the "geo" table (except SQLite). | + +
If you pass an array of columns into a method that drops indexes, the conventional index name will be generated based on the table name, columns, and index type: @@ -1168,8 +1184,10 @@ You may also specify the desired action for the "on delete" and "on update" prop An alternative, expressive syntax is also provided for these actions: +
+ | Method | Description | -|-------------------------------|---------------------------------------------------| +| ----------------------------- | ------------------------------------------------- | | `$table->cascadeOnUpdate();` | Updates should cascade. | | `$table->restrictOnUpdate();` | Updates should be restricted. | | `$table->noActionOnUpdate();` | No action on updates. | @@ -1177,6 +1195,8 @@ An alternative, expressive syntax is also provided for these actions: | `$table->restrictOnDelete();` | Deletes should be restricted. | | `$table->nullOnDelete();` | Deletes should set the foreign key value to null. | +
+ Any additional [column modifiers](#column-modifiers) must be called before the `constrained` method: $table->foreignId('user_id') @@ -1215,12 +1235,16 @@ You may enable or disable foreign key constraints within your migrations by usin For convenience, each migration operation will dispatch an [event](/docs/{{version}}/events). All of the following events extend the base `Illuminate\Database\Events\MigrationEvent` class: - Class | Description --------|------- -| `Illuminate\Database\Events\MigrationsStarted` | A batch of migrations is about to be executed. | -| `Illuminate\Database\Events\MigrationsEnded` | A batch of migrations has finished executing. | -| `Illuminate\Database\Events\MigrationStarted` | A single migration is about to be executed. | -| `Illuminate\Database\Events\MigrationEnded` | A single migration has finished executing. | +
+ +| Class | Description | +| ------------------------------------------------ | ------------------------------------------------ | +| `Illuminate\Database\Events\MigrationsStarted` | A batch of migrations is about to be executed. | +| `Illuminate\Database\Events\MigrationsEnded` | A batch of migrations has finished executing. | +| `Illuminate\Database\Events\MigrationStarted` | A single migration is about to be executed. | +| `Illuminate\Database\Events\MigrationEnded` | A single migration has finished executing. | | `Illuminate\Database\Events\NoPendingMigrations` | A migration command found no pending migrations. | -| `Illuminate\Database\Events\SchemaDumped` | A database schema dump has completed. | -| `Illuminate\Database\Events\SchemaLoaded` | An existing database schema dump has loaded. | +| `Illuminate\Database\Events\SchemaDumped` | A database schema dump has completed. | +| `Illuminate\Database\Events\SchemaLoaded` | An existing database schema dump has loaded. | + +
diff --git a/notifications.md b/notifications.md index e6676d8d99b..c195e8b6827 100644 --- a/notifications.md +++ b/notifications.md @@ -780,10 +780,10 @@ The table component allows you to transform a Markdown table into an HTML table. ```blade -| Laravel | Table | Example | -| ------------- |:-------------:| --------:| -| Col 2 is | Centered | $10 | -| Col 3 is | Right-Aligned | $20 | +| Laravel | Table | Example | +| ------------- | :-----------: | ------------: | +| Col 2 is | Centered | $10 | +| Col 3 is | Right-Aligned | $20 | ``` diff --git a/pagination.md b/pagination.md index d55a67fa6c2..91ba4af9141 100644 --- a/pagination.md +++ b/pagination.md @@ -332,48 +332,56 @@ Laravel includes pagination views built using [Bootstrap CSS](https://getbootstr Each paginator instance provides additional pagination information via the following methods: -Method | Description -------- | ----------- -`$paginator->count()` | Get the number of items for the current page. -`$paginator->currentPage()` | Get the current page number. -`$paginator->firstItem()` | Get the result number of the first item in the results. -`$paginator->getOptions()` | Get the paginator options. -`$paginator->getUrlRange($start, $end)` | Create a range of pagination URLs. -`$paginator->hasPages()` | Determine if there are enough items to split into multiple pages. -`$paginator->hasMorePages()` | Determine if there are more items in the data store. -`$paginator->items()` | Get the items for the current page. -`$paginator->lastItem()` | Get the result number of the last item in the results. -`$paginator->lastPage()` | Get the page number of the last available page. (Not available when using `simplePaginate`). -`$paginator->nextPageUrl()` | Get the URL for the next page. -`$paginator->onFirstPage()` | Determine if the paginator is on the first page. -`$paginator->perPage()` | The number of items to be shown per page. -`$paginator->previousPageUrl()` | Get the URL for the previous page. -`$paginator->total()` | Determine the total number of matching items in the data store. (Not available when using `simplePaginate`). -`$paginator->url($page)` | Get the URL for a given page number. -`$paginator->getPageName()` | Get the query string variable used to store the page. -`$paginator->setPageName($name)` | Set the query string variable used to store the page. -`$paginator->through($callback)` | Transform each item using a callback. +
+ +| Method | Description | +| --- | --- | +| `$paginator->count()` | Get the number of items for the current page. | +| `$paginator->currentPage()` | Get the current page number. | +| `$paginator->firstItem()` | Get the result number of the first item in the results. | +| `$paginator->getOptions()` | Get the paginator options. | +| `$paginator->getUrlRange($start, $end)` | Create a range of pagination URLs. | +| `$paginator->hasPages()` | Determine if there are enough items to split into multiple pages. | +| `$paginator->hasMorePages()` | Determine if there are more items in the data store. | +| `$paginator->items()` | Get the items for the current page. | +| `$paginator->lastItem()` | Get the result number of the last item in the results. | +| `$paginator->lastPage()` | Get the page number of the last available page. (Not available when using `simplePaginate`). | +| `$paginator->nextPageUrl()` | Get the URL for the next page. | +| `$paginator->onFirstPage()` | Determine if the paginator is on the first page. | +| `$paginator->perPage()` | The number of items to be shown per page. | +| `$paginator->previousPageUrl()` | Get the URL for the previous page. | +| `$paginator->total()` | Determine the total number of matching items in the data store. (Not available when using `simplePaginate`). | +| `$paginator->url($page)` | Get the URL for a given page number. | +| `$paginator->getPageName()` | Get the query string variable used to store the page. | +| `$paginator->setPageName($name)` | Set the query string variable used to store the page. | +| `$paginator->through($callback)` | Transform each item using a callback. | + +
## Cursor Paginator Instance Methods Each cursor paginator instance provides additional pagination information via the following methods: -Method | Description -------- | ----------- -`$paginator->count()` | Get the number of items for the current page. -`$paginator->cursor()` | Get the current cursor instance. -`$paginator->getOptions()` | Get the paginator options. -`$paginator->hasPages()` | Determine if there are enough items to split into multiple pages. -`$paginator->hasMorePages()` | Determine if there are more items in the data store. -`$paginator->getCursorName()` | Get the query string variable used to store the cursor. -`$paginator->items()` | Get the items for the current page. -`$paginator->nextCursor()` | Get the cursor instance for the next set of items. -`$paginator->nextPageUrl()` | Get the URL for the next page. -`$paginator->onFirstPage()` | Determine if the paginator is on the first page. -`$paginator->onLastPage()` | Determine if the paginator is on the last page. -`$paginator->perPage()` | The number of items to be shown per page. -`$paginator->previousCursor()` | Get the cursor instance for the previous set of items. -`$paginator->previousPageUrl()` | Get the URL for the previous page. -`$paginator->setCursorName()` | Set the query string variable used to store the cursor. -`$paginator->url($cursor)` | Get the URL for a given cursor instance. +
+ +| Method | Description | +| ------------------------------- | ----------------------------------------------------------------- | +| `$paginator->count()` | Get the number of items for the current page. | +| `$paginator->cursor()` | Get the current cursor instance. | +| `$paginator->getOptions()` | Get the paginator options. | +| `$paginator->hasPages()` | Determine if there are enough items to split into multiple pages. | +| `$paginator->hasMorePages()` | Determine if there are more items in the data store. | +| `$paginator->getCursorName()` | Get the query string variable used to store the cursor. | +| `$paginator->items()` | Get the items for the current page. | +| `$paginator->nextCursor()` | Get the cursor instance for the next set of items. | +| `$paginator->nextPageUrl()` | Get the URL for the next page. | +| `$paginator->onFirstPage()` | Determine if the paginator is on the first page. | +| `$paginator->onLastPage()` | Determine if the paginator is on the last page. | +| `$paginator->perPage()` | The number of items to be shown per page. | +| `$paginator->previousCursor()` | Get the cursor instance for the previous set of items. | +| `$paginator->previousPageUrl()` | Get the URL for the previous page. | +| `$paginator->setCursorName()` | Set the query string variable used to store the cursor. | +| `$paginator->url($cursor)` | Get the URL for a given cursor instance. | + +
diff --git a/passport.md b/passport.md index 315d906bbbf..c3b5cc4308c 100644 --- a/passport.md +++ b/passport.md @@ -1162,10 +1162,10 @@ When using this method of authentication, you will need to ensure a valid CSRF t Passport raises events when issuing access tokens and refresh tokens. You may [listen for these events](/docs/{{version}}/events) to prune or revoke other access tokens in your database: -Event Name | -------------- | -`Laravel\Passport\Events\AccessTokenCreated` | -`Laravel\Passport\Events\RefreshTokenCreated` | +| Event Name | +| --- | +| `Laravel\Passport\Events\AccessTokenCreated` | +| `Laravel\Passport\Events\RefreshTokenCreated` | ## Testing diff --git a/requests.md b/requests.md index aef7f57ae4c..65871c45a82 100644 --- a/requests.md +++ b/requests.md @@ -649,4 +649,3 @@ By default, requests coming from subdomains of the application's URL are also au ->withMiddleware(function (Middleware $middleware) { $middleware->trustHosts(at: ['laravel.test'], subdomains: false); }) - diff --git a/scheduling.md b/scheduling.md index 9afd97f8ca0..3c472d87ffc 100644 --- a/scheduling.md +++ b/scheduling.md @@ -120,46 +120,46 @@ We've already seen a few examples of how you may configure a task to run at spec
-Method | Description -------------- | ------------- -`->cron('* * * * *');` | Run the task on a custom cron schedule -`->everySecond();` | Run the task every second -`->everyTwoSeconds();` | Run the task every two seconds -`->everyFiveSeconds();` | Run the task every five seconds -`->everyTenSeconds();` | Run the task every ten seconds -`->everyFifteenSeconds();` | Run the task every fifteen seconds -`->everyTwentySeconds();` | Run the task every twenty seconds -`->everyThirtySeconds();` | Run the task every thirty seconds -`->everyMinute();` | Run the task every minute -`->everyTwoMinutes();` | Run the task every two minutes -`->everyThreeMinutes();` | Run the task every three minutes -`->everyFourMinutes();` | Run the task every four minutes -`->everyFiveMinutes();` | Run the task every five minutes -`->everyTenMinutes();` | Run the task every ten minutes -`->everyFifteenMinutes();` | Run the task every fifteen minutes -`->everyThirtyMinutes();` | Run the task every thirty minutes -`->hourly();` | Run the task every hour -`->hourlyAt(17);` | Run the task every hour at 17 minutes past the hour -`->everyOddHour($minutes = 0);` | Run the task every odd hour -`->everyTwoHours($minutes = 0);` | Run the task every two hours -`->everyThreeHours($minutes = 0);` | Run the task every three hours -`->everyFourHours($minutes = 0);` | Run the task every four hours -`->everySixHours($minutes = 0);` | Run the task every six hours -`->daily();` | Run the task every day at midnight -`->dailyAt('13:00');` | Run the task every day at 13:00 -`->twiceDaily(1, 13);` | Run the task daily at 1:00 & 13:00 -`->twiceDailyAt(1, 13, 15);` | Run the task daily at 1:15 & 13:15 -`->weekly();` | Run the task every Sunday at 00:00 -`->weeklyOn(1, '8:00');` | Run the task every week on Monday at 8:00 -`->monthly();` | Run the task on the first day of every month at 00:00 -`->monthlyOn(4, '15:00');` | Run the task every month on the 4th at 15:00 -`->twiceMonthly(1, 16, '13:00');` | Run the task monthly on the 1st and 16th at 13:00 -`->lastDayOfMonth('15:00');` | Run the task on the last day of the month at 15:00 -`->quarterly();` | Run the task on the first day of every quarter at 00:00 -`->quarterlyOn(4, '14:00');` | Run the task every quarter on the 4th at 14:00 -`->yearly();` | Run the task on the first day of every year at 00:00 -`->yearlyOn(6, 1, '17:00');` | Run the task every year on June 1st at 17:00 -`->timezone('America/New_York');` | Set the timezone for the task +| Method | Description | +| ---------------------------------- | -------------------------------------------------------- | +| `->cron('* * * * *');` | Run the task on a custom cron schedule. | +| `->everySecond();` | Run the task every second. | +| `->everyTwoSeconds();` | Run the task every two seconds. | +| `->everyFiveSeconds();` | Run the task every five seconds. | +| `->everyTenSeconds();` | Run the task every ten seconds. | +| `->everyFifteenSeconds();` | Run the task every fifteen seconds. | +| `->everyTwentySeconds();` | Run the task every twenty seconds. | +| `->everyThirtySeconds();` | Run the task every thirty seconds. | +| `->everyMinute();` | Run the task every minute. | +| `->everyTwoMinutes();` | Run the task every two minutes. | +| `->everyThreeMinutes();` | Run the task every three minutes. | +| `->everyFourMinutes();` | Run the task every four minutes. | +| `->everyFiveMinutes();` | Run the task every five minutes. | +| `->everyTenMinutes();` | Run the task every ten minutes. | +| `->everyFifteenMinutes();` | Run the task every fifteen minutes. | +| `->everyThirtyMinutes();` | Run the task every thirty minutes. | +| `->hourly();` | Run the task every hour. | +| `->hourlyAt(17);` | Run the task every hour at 17 minutes past the hour. | +| `->everyOddHour($minutes = 0);` | Run the task every odd hour. | +| `->everyTwoHours($minutes = 0);` | Run the task every two hours. | +| `->everyThreeHours($minutes = 0);` | Run the task every three hours. | +| `->everyFourHours($minutes = 0);` | Run the task every four hours. | +| `->everySixHours($minutes = 0);` | Run the task every six hours. | +| `->daily();` | Run the task every day at midnight. | +| `->dailyAt('13:00');` | Run the task every day at 13:00. | +| `->twiceDaily(1, 13);` | Run the task daily at 1:00 & 13:00. | +| `->twiceDailyAt(1, 13, 15);` | Run the task daily at 1:15 & 13:15. | +| `->weekly();` | Run the task every Sunday at 00:00. | +| `->weeklyOn(1, '8:00');` | Run the task every week on Monday at 8:00. | +| `->monthly();` | Run the task on the first day of every month at 00:00. | +| `->monthlyOn(4, '15:00');` | Run the task every month on the 4th at 15:00. | +| `->twiceMonthly(1, 16, '13:00');` | Run the task monthly on the 1st and 16th at 13:00. | +| `->lastDayOfMonth('15:00');` | Run the task on the last day of the month at 15:00. | +| `->quarterly();` | Run the task on the first day of every quarter at 00:00. | +| `->quarterlyOn(4, '14:00');` | Run the task every quarter on the 4th at 14:00. | +| `->yearly();` | Run the task on the first day of every year at 00:00. | +| `->yearlyOn(6, 1, '17:00');` | Run the task every year on June 1st at 17:00. | +| `->timezone('America/New_York');` | Set the timezone for the task. |
@@ -183,22 +183,22 @@ A list of additional schedule constraints may be found below:
-Method | Description -------------- | ------------- -`->weekdays();` | Limit the task to weekdays -`->weekends();` | Limit the task to weekends -`->sundays();` | Limit the task to Sunday -`->mondays();` | Limit the task to Monday -`->tuesdays();` | Limit the task to Tuesday -`->wednesdays();` | Limit the task to Wednesday -`->thursdays();` | Limit the task to Thursday -`->fridays();` | Limit the task to Friday -`->saturdays();` | Limit the task to Saturday -`->days(array\|mixed);` | Limit the task to specific days -`->between($startTime, $endTime);` | Limit the task to run between start and end times -`->unlessBetween($startTime, $endTime);` | Limit the task to not run between start and end times -`->when(Closure);` | Limit the task based on a truth test -`->environments($env);` | Limit the task to specific environments +| Method | Description | +| ---------------------------------------- | ------------------------------------------------------ | +| `->weekdays();` | Limit the task to weekdays. | +| `->weekends();` | Limit the task to weekends. | +| `->sundays();` | Limit the task to Sunday. | +| `->mondays();` | Limit the task to Monday. | +| `->tuesdays();` | Limit the task to Tuesday. | +| `->wednesdays();` | Limit the task to Wednesday. | +| `->thursdays();` | Limit the task to Thursday. | +| `->fridays();` | Limit the task to Friday. | +| `->saturdays();` | Limit the task to Saturday. | +| `->days(array\|mixed);` | Limit the task to specific days. | +| `->between($startTime, $endTime);` | Limit the task to run between start and end times. | +| `->unlessBetween($startTime, $endTime);` | Limit the task to not run between start and end times. | +| `->when(Closure);` | Limit the task based on a truth test. | +| `->environments($env);` | Limit the task to specific environments. |
@@ -519,10 +519,14 @@ The `pingOnSuccess` and `pingOnFailure` methods may be used to ping a given URL Laravel dispatches a variety of [events](/docs/{{version}}/events) during the scheduling process. You may [define listeners](/docs/{{version}}/events) for any of the following events: -Event Name | -------------- | -`Illuminate\Console\Events\ScheduledTaskStarting` | -`Illuminate\Console\Events\ScheduledTaskFinished` | -`Illuminate\Console\Events\ScheduledBackgroundTaskFinished` | -`Illuminate\Console\Events\ScheduledTaskSkipped` | -`Illuminate\Console\Events\ScheduledTaskFailed` | +
+ +| Event Name | +| --- | +| `Illuminate\Console\Events\ScheduledTaskStarting` | +| `Illuminate\Console\Events\ScheduledTaskFinished` | +| `Illuminate\Console\Events\ScheduledBackgroundTaskFinished` | +| `Illuminate\Console\Events\ScheduledTaskSkipped` | +| `Illuminate\Console\Events\ScheduledTaskFailed` | + +
diff --git a/valet.md b/valet.md index 1676404a460..0a324237735 100644 --- a/valet.md +++ b/valet.md @@ -465,19 +465,19 @@ If you would like to define a custom Valet driver for a single application, crea
-Command | Description -------------- | ------------- -`valet list` | Display a list of all Valet commands. -`valet diagnose` | Output diagnostics to aid in debugging Valet. -`valet directory-listing` | Determine directory-listing behavior. Default is "off", which renders a 404 page for directories. -`valet forget` | Run this command from a "parked" directory to remove it from the parked directory list. -`valet log` | View a list of logs which are written by Valet's services. -`valet paths` | View all of your "parked" paths. -`valet restart` | Restart the Valet daemons. -`valet start` | Start the Valet daemons. -`valet stop` | Stop the Valet daemons. -`valet trust` | Add sudoers files for Brew and Valet to allow Valet commands to be run without prompting for your password. -`valet uninstall` | Uninstall Valet: shows instructions for manual uninstall. Pass the `--force` option to aggressively delete all of Valet's resources. +| Command | Description | +| --- | --- | +| `valet list` | Display a list of all Valet commands. | +| `valet diagnose` | Output diagnostics to aid in debugging Valet. | +| `valet directory-listing` | Determine directory-listing behavior. Default is "off", which renders a 404 page for directories. | +| `valet forget` | Run this command from a "parked" directory to remove it from the parked directory list. | +| `valet log` | View a list of logs which are written by Valet's services. | +| `valet paths` | View all of your "parked" paths. | +| `valet restart` | Restart the Valet daemons. | +| `valet start` | Start the Valet daemons. | +| `valet stop` | Stop the Valet daemons. | +| `valet trust` | Add sudoers files for Brew and Valet to allow Valet commands to be run without prompting for your password. | +| `valet uninstall` | Uninstall Valet: shows instructions for manual uninstall. Pass the `--force` option to aggressively delete all of Valet's resources. |
From 9f36b02f2c2968ad2c6945df79d9eaf31dfdd224 Mon Sep 17 00:00:00 2001 From: TENIOS <40282681+TENIOS@users.noreply.github.com> Date: Fri, 19 Jul 2024 21:09:56 +0700 Subject: [PATCH 110/325] Fix whitespaces (#9780) --- artisan.md | 2 +- authentication.md | 4 ++-- billing.md | 10 +++++----- cashier-paddle.md | 6 +++--- collections.md | 40 +++++++++++++++++++-------------------- configuration.md | 2 +- container.md | 2 +- context.md | 4 ++-- controllers.md | 2 +- database-testing.md | 2 +- database.md | 2 +- dusk.md | 22 ++++++++++----------- eloquent-collections.md | 6 +++--- eloquent-relationships.md | 2 +- eloquent-resources.md | 2 +- eloquent.md | 4 ++-- errors.md | 2 +- events.md | 6 +++--- helpers.md | 4 ++-- http-tests.md | 6 +++--- installation.md | 8 ++++---- localization.md | 4 ++-- logging.md | 2 +- migrations.md | 2 +- mocking.md | 2 +- notifications.md | 2 +- octane.md | 2 +- pagination.md | 2 +- pennant.md | 9 ++++++--- precognition.md | 4 ++-- pulse.md | 14 +++++++------- routing.md | 2 +- scout.md | 2 +- seeding.md | 2 +- strings.md | 6 +++--- testing.md | 4 ++-- upgrade.md | 2 +- vite.md | 2 +- 38 files changed, 102 insertions(+), 99 deletions(-) diff --git a/artisan.md b/artisan.md index 1681994dd65..ae3d061a6ff 100644 --- a/artisan.md +++ b/artisan.md @@ -649,7 +649,7 @@ Sometimes, you may need more manual control over how a progress bar is advanced. $bar->finish(); -> [!NOTE] +> [!NOTE] > For more advanced options, check out the [Symfony Progress Bar component documentation](https://symfony.com/doc/7.0/components/console/helpers/progressbar.html). diff --git a/authentication.md b/authentication.md index 32248ef9c3a..ffad7e5445a 100644 --- a/authentication.md +++ b/authentication.md @@ -280,8 +280,8 @@ For complex query conditions, you may provide a closure in your array of credent use Illuminate\Database\Eloquent\Builder; if (Auth::attempt([ - 'email' => $email, - 'password' => $password, + 'email' => $email, + 'password' => $password, fn (Builder $query) => $query->has('activeSubscription'), ])) { // Authentication was successful... diff --git a/billing.md b/billing.md index 6a03e8ec69a..782851c54d5 100644 --- a/billing.md +++ b/billing.md @@ -251,7 +251,7 @@ Offering product and subscription billing via your application can be intimidati To charge customers for non-recurring, single-charge products, we'll utilize Cashier to direct customers to Stripe Checkout, where they will provide their payment details and confirm their purchase. Once the payment has been made via Checkout, the customer will be redirected to a success URL of your choosing within your application: use Illuminate\Http\Request; - + Route::get('/checkout', function (Request $request) { $stripePriceId = 'price_deluxe_album'; @@ -276,11 +276,11 @@ If necessary, the `checkout` method will automatically create a customer in Stri When selling products, it's common to keep track of completed orders and purchased products via `Cart` and `Order` models defined by your own application. When redirecting customers to Stripe Checkout to complete a purchase, you may need to provide an existing order identifier so that you can associate the completed purchase with the corresponding order when the customer is redirected back to your application. To accomplish this, you may provide an array of `metadata` to the `checkout` method. Let's imagine that a pending `Order` is created within our application when a user begins the checkout process. Remember, the `Cart` and `Order` models in this example are illustrative and not provided by Cashier. You are free to implement these concepts based on the needs of your own application: - + use App\Models\Cart; use App\Models\Order; use Illuminate\Http\Request; - + Route::get('/cart/{cart}/checkout', function (Request $request, Cart $cart) { $order = Order::create([ 'cart_id' => $cart->id, @@ -340,7 +340,7 @@ To learn how to sell subscriptions using Cashier and Stripe Checkout, let's cons First, let's discover how a customer can subscribe to our services. Of course, you can imagine the customer might click a "subscribe" button for the Basic plan on our application's pricing page. This button or link should direct the user to a Laravel route which creates the Stripe Checkout session for their chosen plan: use Illuminate\Http\Request; - + Route::get('/subscription-checkout', function (Request $request) { return $request->user() ->newSubscription('default', 'price_basic_monthly') @@ -2215,7 +2215,7 @@ Some payment methods require additional data in order to confirm payments. For e $subscription->withPaymentConfirmationOptions([ 'mandate_data' => '...', ])->swap('price_xxx'); - + You may consult the [Stripe API documentation](https://stripe.com/docs/api/payment_intents/confirm) to review all of the options accepted when confirming payments. diff --git a/cashier-paddle.md b/cashier-paddle.md index 7e7e96bcdf7..dc89180111b 100644 --- a/cashier-paddle.md +++ b/cashier-paddle.md @@ -201,7 +201,7 @@ After defining your model, you may instruct Cashier to use your custom model via ### Selling Products -> [!NOTE] +> [!NOTE] > Before utilizing Paddle Checkout, you should define Products with fixed prices in your Paddle dashboard. In addition, you should [configure Paddle's webhook handling](#handling-paddle-webhooks). Offering product and subscription billing via your application can be intimidating. However, thanks to Cashier and [Paddle's Checkout Overlay](https://www.paddle.com/billing/checkout), you can easily build modern, robust payment integrations. @@ -235,11 +235,11 @@ In the `buy` view, we will include a button to display the Checkout Overlay. The When selling products, it's common to keep track of completed orders and purchased products via `Cart` and `Order` models defined by your own application. When redirecting customers to Paddle's Checkout Overlay to complete a purchase, you may need to provide an existing order identifier so that you can associate the completed purchase with the corresponding order when the customer is redirected back to your application. To accomplish this, you may provide an array of custom data to the `checkout` method. Let's imagine that a pending `Order` is created within our application when a user begins the checkout process. Remember, the `Cart` and `Order` models in this example are illustrative and not provided by Cashier. You are free to implement these concepts based on the needs of your own application: - + use App\Models\Cart; use App\Models\Order; use Illuminate\Http\Request; - + Route::get('/cart/{cart}/checkout', function (Request $request, Cart $cart) { $order = Order::create([ 'cart_id' => $cart->id, diff --git a/collections.md b/collections.md index c4cfff89371..17641933a6f 100644 --- a/collections.md +++ b/collections.md @@ -31,7 +31,7 @@ As mentioned above, the `collect` helper returns a new `Illuminate\Support\Colle $collection = collect([1, 2, 3]); -> [!NOTE] +> [!NOTE] > The results of [Eloquent](/docs/{{version}}/eloquent) queries are always returned as `Collection` instances. @@ -432,7 +432,7 @@ The `collect` method is primarily useful for converting [lazy collections](#lazy // [1, 2, 3] -> [!NOTE] +> [!NOTE] > The `collect` method is especially useful when you have an instance of `Enumerable` and need a non-lazy collection instance. Since `collect()` is part of the `Enumerable` contract, you can safely use it to get a `Collection` instance. @@ -525,7 +525,7 @@ The `containsOneItem` method determines whether the collection contains a single This method has the same signature as the [`contains`](#method-contains) method; however, all values are compared using "strict" comparisons. -> [!NOTE] +> [!NOTE] > This method's behavior is modified when using [Eloquent Collections](/docs/{{version}}/eloquent-collections#method-contains). @@ -636,7 +636,7 @@ The `diff` method compares the collection against another collection or a plain // [1, 3, 5] -> [!NOTE] +> [!NOTE] > This method's behavior is modified when using [Eloquent Collections](/docs/{{version}}/eloquent-collections#method-diff). @@ -856,7 +856,7 @@ Primitive types such as `string`, `int`, `float`, `bool`, and `array` may also b return $collection->ensure('int'); -> [!WARNING] +> [!WARNING] > The `ensure` method does not guarantee that elements of different types will not be added to the collection at a later time. @@ -895,7 +895,7 @@ The `except` method returns all items in the collection except for those with th For the inverse of `except`, see the [only](#method-only) method. -> [!NOTE] +> [!NOTE] > This method's behavior is modified when using [Eloquent Collections](/docs/{{version}}/eloquent-collections#method-except). @@ -1078,7 +1078,7 @@ The `forget` method removes an item from the collection by its key: // ['framework' => 'laravel'] -> [!WARNING] +> [!WARNING] > Unlike most other collection methods, `forget` does not return a new modified collection; it modifies the collection it is called on. @@ -1281,7 +1281,7 @@ The `intersect` method removes any values from the original collection that are // [0 => 'Desk', 2 => 'Chair'] -> [!NOTE] +> [!NOTE] > This method's behavior is modified when using [Eloquent Collections](/docs/{{version}}/eloquent-collections#method-intersect). @@ -1470,7 +1470,7 @@ The `map` method iterates through the collection and passes each value to the gi // [2, 4, 6, 8, 10] -> [!WARNING] +> [!WARNING] > Like most other collection methods, `map` returns a new collection instance; it does not modify the collection it is called on. If you want to transform the original collection, use the [`transform`](#method-transform) method. @@ -1750,7 +1750,7 @@ The `only` method returns the items in the collection with the specified keys: For the inverse of `only`, see the [except](#method-except) method. -> [!NOTE] +> [!NOTE] > This method's behavior is modified when using [Eloquent Collections](/docs/{{version}}/eloquent-collections#method-only). @@ -2322,7 +2322,7 @@ You may also pass a simple value to the `skipUntil` method to skip all items unt // [3, 4] -> [!WARNING] +> [!WARNING] > If the given value is not found or the callback never returns `true`, the `skipUntil` method will return an empty collection. @@ -2340,7 +2340,7 @@ The `skipWhile` method skips over items from the collection while the given call // [4] -> [!WARNING] +> [!WARNING] > If the callback never returns `false`, the `skipWhile` method will return an empty collection. @@ -2449,7 +2449,7 @@ The `sort` method sorts the collection. The sorted collection keeps the original If your sorting needs are more advanced, you may pass a callback to `sort` with your own algorithm. Refer to the PHP documentation on [`uasort`](https://secure.php.net/manual/en/function.uasort.php#refsect1-function.uasort-parameters), which is what the collection's `sort` method calls utilizes internally. -> [!NOTE] +> [!NOTE] > If you need to sort a collection of nested arrays or objects, see the [`sortBy`](#method-sortby) and [`sortByDesc`](#method-sortbydesc) methods. @@ -2793,7 +2793,7 @@ You may also pass a simple value to the `takeUntil` method to get the items unti // [1, 2] -> [!WARNING] +> [!WARNING] > If the given value is not found or the callback never returns `true`, the `takeUntil` method will return all items in the collection. @@ -2811,7 +2811,7 @@ The `takeWhile` method returns items in the collection until the given callback // [1, 2] -> [!WARNING] +> [!WARNING] > If the callback never returns `false`, the `takeWhile` method will return all items in the collection. @@ -2856,7 +2856,7 @@ The `toArray` method converts the collection into a plain PHP `array`. If the co ] */ -> [!WARNING] +> [!WARNING] > `toArray` also converts all of the collection's nested objects that are an instance of `Arrayable` to an array. If you want to get the raw array underlying the collection, use the [`all`](#method-all) method instead. @@ -2885,7 +2885,7 @@ The `transform` method iterates over the collection and calls the given callback // [2, 4, 6, 8, 10] -> [!WARNING] +> [!WARNING] > Unlike most other collection methods, `transform` modifies the collection itself. If you wish to create a new collection instead, use the [`map`](#method-map) method. @@ -2989,7 +2989,7 @@ Finally, you may also pass your own closure to the `unique` method to specify wh The `unique` method uses "loose" comparisons when checking item values, meaning a string with an integer value will be considered equal to an integer of the same value. Use the [`uniqueStrict`](#method-uniquestrict) method to filter using "strict" comparisons. -> [!NOTE] +> [!NOTE] > This method's behavior is modified when using [Eloquent Collections](/docs/{{version}}/eloquent-collections#method-unique). @@ -3498,7 +3498,7 @@ Likewise, we can use the `sum` higher order message to gather the total number o ### Introduction -> [!WARNING] +> [!WARNING] > Before learning more about Laravel's lazy collections, take some time to familiarize yourself with [PHP generators](https://www.php.net/manual/en/language.generators.overview.php). To supplement the already powerful `Collection` class, the `LazyCollection` class leverages PHP's [generators](https://www.php.net/manual/en/language.generators.overview.php) to allow you to work with very large datasets while keeping memory usage low. @@ -3689,7 +3689,7 @@ Almost all methods available on the `Collection` class are also available on the -> [!WARNING] +> [!WARNING] > Methods that mutate the collection (such as `shift`, `pop`, `prepend` etc.) are **not** available on the `LazyCollection` class. diff --git a/configuration.md b/configuration.md index ad3ed6a3a43..93306a3e2a9 100644 --- a/configuration.md +++ b/configuration.md @@ -51,7 +51,7 @@ Laravel's default `.env` file contains some common configuration values that may If you are developing with a team, you may wish to continue including and updating the `.env.example` file with your application. By putting placeholder values in the example configuration file, other developers on your team can clearly see which environment variables are needed to run your application. -> [!NOTE] +> [!NOTE] > Any variable in your `.env` file can be overridden by external environment variables such as server-level or system-level environment variables. diff --git a/container.md b/container.md index dc804e9ba04..7a1709cad4f 100644 --- a/container.md +++ b/container.md @@ -231,7 +231,7 @@ Sometimes you may have two classes that utilize the same interface, but you wish Sometimes you may have a class that receives some injected classes, but also needs an injected primitive value such as an integer. You may easily use contextual binding to inject any value your class may need: use App\Http\Controllers\UserController; - + $this->app->when(UserController::class) ->needs('$variableName') ->give($value); diff --git a/context.md b/context.md index 1ef39c20f83..43b91b00387 100644 --- a/context.md +++ b/context.md @@ -318,7 +318,7 @@ public function boot(): void } ``` -> [!NOTE] +> [!NOTE] > You should not use the `Context` facade within the `dehydrating` callback, as that will change the context of the current process. Ensure you only make changes to the repository passed to the callback. @@ -346,5 +346,5 @@ public function boot(): void } ``` -> [!NOTE] +> [!NOTE] > You should not use the `Context` facade within the `hydrated` callback and instead ensure you only make changes to the repository passed to the callback. diff --git a/controllers.md b/controllers.md index 54fc36bde6a..8bd7b1b1fff 100644 --- a/controllers.md +++ b/controllers.md @@ -38,7 +38,7 @@ Let's take a look at an example of a basic controller. A controller may have any assertSoftDeleted($user); - + #### assertNotSoftDeleted diff --git a/database.md b/database.md index dd528b6546b..ffa38b9d1b7 100644 --- a/database.md +++ b/database.md @@ -50,7 +50,7 @@ By default, foreign key constraints are enabled for SQLite connections. If you w DB_FOREIGN_KEYS=false ``` -> [!NOTE] +> [!NOTE] > If you use the [Laravel installer](/docs/{{version}}/installation#creating-a-laravel-project) to create your Laravel application and select SQLite as your database, Laravel will automatically create a `database/database.sqlite` file and run the default [database migrations](/docs/{{version}}/migrations) for you. diff --git a/dusk.md b/dusk.md index 22acb86dccc..dc4d1d7d9b1 100644 --- a/dusk.md +++ b/dusk.md @@ -64,7 +64,7 @@ To get started, you should install [Google Chrome](https://www.google.com/chrome composer require laravel/dusk --dev ``` -> [!WARNING] +> [!WARNING] > If you are manually registering Dusk's service provider, you should **never** register it in your production environment, as doing so could lead to arbitrary users being able to authenticate with your application. After installing the Dusk package, execute the `dusk:install` Artisan command. The `dusk:install` command will create a `tests/Browser` directory, an example Dusk test, and install the Chrome Driver binary for your operating system: @@ -75,7 +75,7 @@ php artisan dusk:install Next, set the `APP_URL` environment variable in your application's `.env` file. This value should match the URL you use to access your application in a browser. -> [!NOTE] +> [!NOTE] > If you are using [Laravel Sail](/docs/{{version}}/sail) to manage your local development environment, please also consult the Sail documentation on [configuring and running Dusk tests](/docs/{{version}}/sail#laravel-dusk). @@ -97,7 +97,7 @@ php artisan dusk:chrome-driver --all php artisan dusk:chrome-driver --detect ``` -> [!WARNING] +> [!WARNING] > Dusk requires the `chromedriver` binaries to be executable. If you're having problems running Dusk, you should ensure the binaries are executable using the following command: `chmod -R 0755 vendor/laravel/dusk/bin/`. @@ -181,7 +181,7 @@ class ExampleTest extends DuskTestCase } ``` -> [!WARNING] +> [!WARNING] > SQLite in-memory databases may not be used when executing Dusk tests. Since the browser executes within its own process, it will not be able to access the in-memory databases of other processes. @@ -220,7 +220,7 @@ class ExampleTest extends DuskTestCase By default, this trait will truncate all tables except the `migrations` table. If you would like to customize the tables that should be truncated, you may define a `$tablesToTruncate` property on your test class: -> [!NOTE] +> [!NOTE] > If you are using Pest, you should define properties or methods on the base `DuskTestCase` class or on any class your test file extends. /** @@ -287,7 +287,7 @@ The `dusk` command accepts any argument that is normally accepted by the Pest / php artisan dusk --group=foo ``` -> [!NOTE] +> [!NOTE] > If you are using [Laravel Sail](/docs/{{version}}/sail) to manage your local development environment, please consult the Sail documentation on [configuring and running Dusk tests](/docs/{{version}}/sail#laravel-dusk). @@ -506,7 +506,7 @@ Often, you will be testing pages that require authentication. You can use Dusk's ->visit('/home'); }); -> [!WARNING] +> [!WARNING] > After using the `loginAs` method, the user session will be maintained for all tests within the file. @@ -707,7 +707,7 @@ The `attach` method may be used to attach a file to a `file` input element. Like $browser->attach('photo', __DIR__.'/photos/mountains.png'); -> [!WARNING] +> [!WARNING] > The attach function requires the `Zip` PHP extension to be installed and enabled on your server. @@ -738,7 +738,7 @@ You may use the `seeLink` method to determine if a link with the given display t // ... } -> [!WARNING] +> [!WARNING] > These methods interact with jQuery. If jQuery is not available on the page, Dusk will automatically inject it into the page so it is available for the test's duration. @@ -752,7 +752,7 @@ Another valuable use case for the `keys` method is sending a "keyboard shortcut" $browser->keys('.app', ['{command}', 'j']); -> [!NOTE] +> [!NOTE] > All modifier keys such as `{command}` are wrapped in `{}` characters, and match the constants defined in the `Facebook\WebDriver\WebDriverKeys` class, which can be [found on GitHub](https://github.com/php-webdriver/php-webdriver/blob/master/lib/WebDriverKeys.php). @@ -2108,7 +2108,7 @@ class ExampleTest extends DuskTestCase ## Continuous Integration -> [!WARNING] +> [!WARNING] > Most Dusk continuous integration configurations expect your Laravel application to be served using the built-in PHP development server on port 8000. Therefore, before continuing, you should ensure that your continuous integration environment has an `APP_URL` environment variable value of `http://127.0.0.1:8000`. diff --git a/eloquent-collections.md b/eloquent-collections.md index 10f2192e1c5..5808b9c5868 100644 --- a/eloquent-collections.md +++ b/eloquent-collections.md @@ -88,7 +88,7 @@ In addition, the `Illuminate\Database\Eloquent\Collection` class provides a supe The `append` method may be used to indicate that an attribute should be [appended](/docs/{{version}}/eloquent-serialization#appending-values-to-json) for every model in the collection. This method accepts an array of attributes or a single attribute: $users->append('team'); - + $users->append(['team', 'is_admin']); @@ -151,7 +151,7 @@ The `load` method eager loads the given relationships for all models in the coll $users->load(['comments', 'posts']); $users->load('comments.author'); - + $users->load(['comments', 'posts' => fn ($query) => $query->where('active', 1)]); @@ -162,7 +162,7 @@ The `loadMissing` method eager loads the given relationships for all models in t $users->loadMissing(['comments', 'posts']); $users->loadMissing('comments.author'); - + $users->loadMissing(['comments', 'posts' => fn ($query) => $query->where('active', 1)]); diff --git a/eloquent-relationships.md b/eloquent-relationships.md index 088dc480544..0c64bac641a 100644 --- a/eloquent-relationships.md +++ b/eloquent-relationships.md @@ -1941,7 +1941,7 @@ The `createQuietly` and `createManyQuietly` methods may be used to create a mode $user->posts()->createQuietly([ 'title' => 'Post title.', ]); - + $user->posts()->createManyQuietly([ ['title' => 'First post.'], ['title' => 'Second post.'], diff --git a/eloquent-resources.md b/eloquent-resources.md index 2623c7412b5..20e0122c2bd 100644 --- a/eloquent-resources.md +++ b/eloquent-resources.md @@ -493,7 +493,7 @@ If you would like to customize the information included in the `links` or `meta` return $default; } - + ### Conditional Attributes diff --git a/eloquent.md b/eloquent.md index c31d51832bd..46d75a76917 100644 --- a/eloquent.md +++ b/eloquent.md @@ -895,7 +895,7 @@ Eloquent's `upsert` method may be used to update or create records in a single, ['departure' => 'Oakland', 'destination' => 'San Diego', 'price' => 99], ['departure' => 'Chicago', 'destination' => 'New York', 'price' => 150] ], uniqueBy: ['departure', 'destination'], update: ['price']); - + > [!WARNING] > All databases except SQL Server require the columns in the second argument of the `upsert` method to have a "primary" or "unique" index. In addition, the MariaDB and MySQL database drivers ignore the second argument of the `upsert` method and always use the "primary" and "unique" indexes of the table to detect existing records. @@ -1510,7 +1510,7 @@ This command will place the new observer in your `app/Observers` directory. If t { // ... } - + /** * Handle the User "restored" event. */ diff --git a/errors.md b/errors.md index 1562d825a85..b87b4f1ef44 100644 --- a/errors.md +++ b/errors.md @@ -410,6 +410,6 @@ php artisan vendor:publish --tag=laravel-errors #### Fallback HTTP Error Pages -You may also define a "fallback" error page for a given series of HTTP status codes. This page will be rendered if there is not a corresponding page for the specific HTTP status code that occurred. To accomplish this, define a `4xx.blade.php` template and a `5xx.blade.php` template in your application's `resources/views/errors` directory. +You may also define a "fallback" error page for a given series of HTTP status codes. This page will be rendered if there is not a corresponding page for the specific HTTP status code that occurred. To accomplish this, define a `4xx.blade.php` template and a `5xx.blade.php` template in your application's `resources/views/errors` directory. When defining fallback error pages, the fallback pages will not affect `404`, `500`, and `503` error responses since Laravel has internal, dedicated pages for these status codes. To customize the pages rendered for these status codes, you should define a custom error page for each of them individually. diff --git a/events.md b/events.md index 916aad6b623..a5e21f2dde1 100644 --- a/events.md +++ b/events.md @@ -234,7 +234,7 @@ Next, let's take a look at the listener for our example event. Event listeners r } } -> [!NOTE] +> [!NOTE] > Your event listeners may also type-hint any dependencies they need on their constructors. All event listeners are resolved via the Laravel [service container](/docs/{{version}}/container), so dependencies will be injected automatically. @@ -404,7 +404,7 @@ If your queue connection's `after_commit` configuration option is set to `false` use InteractsWithQueue; } -> [!NOTE] +> [!NOTE] > To learn more about working around these issues, please review the documentation regarding [queued jobs and database transactions](/docs/{{version}}/queues#jobs-and-database-transactions). @@ -519,7 +519,7 @@ If you would like to conditionally dispatch an event, you may use the `dispatchI OrderShipped::dispatchUnless($condition, $order); -> [!NOTE] +> [!NOTE] > When testing, it can be helpful to assert that certain events were dispatched without actually triggering their listeners. Laravel's [built-in testing helpers](#testing) make it a cinch. diff --git a/helpers.md b/helpers.md index 3baf5b3fa19..72724035102 100644 --- a/helpers.md +++ b/helpers.md @@ -1322,7 +1322,7 @@ $result = Number::pairs(25, 10); // [[1, 10], [11, 20], [21, 25]] $result = Number::pairs(25, 10, offset: 0); - + // [[0, 10], [10, 20], [20, 25]] ``` @@ -2260,7 +2260,7 @@ Additional arguments may be passed to the `value` function. If the first argumen $result = value(function (string $name) { return $name; }, 'Taylor'); - + // 'Taylor' diff --git a/http-tests.md b/http-tests.md index 13e2e095c06..73f6faeafef 100644 --- a/http-tests.md +++ b/http-tests.md @@ -95,7 +95,7 @@ class ExampleTest extends TestCase In general, each of your tests should only make one request to your application. Unexpected behavior may occur if multiple requests are executed within a single test method. -> [!NOTE] +> [!NOTE] > For convenience, the CSRF middleware is automatically disabled when running tests. @@ -480,7 +480,7 @@ expect($response['created'])->toBeTrue(); $this->assertTrue($response['created']); ``` -> [!NOTE] +> [!NOTE] > The `assertJson` method converts the response to an array and utilizes `PHPUnit::assertArraySubset` to verify that the given array exists within the JSON response returned by the application. So, if there are other properties in the JSON response, this test will still pass as long as the given fragment is present. @@ -1312,7 +1312,7 @@ Assert that the response has a moved permanently (301) HTTP status code: Assert that the response has the given URI value in the `Location` header: $response->assertLocation($uri); - + #### assertContent diff --git a/installation.md b/installation.md index 43c643a3038..227e2ee1c99 100644 --- a/installation.md +++ b/installation.md @@ -82,7 +82,7 @@ php artisan serve Once you have started the Artisan development server, your application will be accessible in your web browser at [http://localhost:8000](http://localhost:8000). Next, you're ready to [start taking your next steps into the Laravel ecosystem](#next-steps). Of course, you may also want to [configure a database](#databases-and-migrations). -> [!NOTE] +> [!NOTE] > If you would like a head start when developing your Laravel application, consider using one of our [starter kits](/docs/{{version}}/starter-kits). Laravel's starter kits provide backend and frontend authentication scaffolding for your new Laravel application. @@ -99,7 +99,7 @@ Since many of Laravel's configuration option values may vary depending on whethe Your `.env` file should not be committed to your application's source control, since each developer / server using your application could require a different environment configuration. Furthermore, this would be a security risk in the event an intruder gains access to your source control repository, since any sensitive credentials would be exposed. -> [!NOTE] +> [!NOTE] > For more information about the `.env` file and environment based configuration, check out the full [configuration documentation](/docs/{{version}}/configuration#environment-configuration). @@ -126,7 +126,7 @@ If you choose to use a database other than SQLite, you will need to create the d php artisan migrate ``` -> [!NOTE] +> [!NOTE] > If you are developing on macOS or Windows and need to install MySQL, PostgreSQL, or Redis locally, consider using [Herd Pro](https://herd.laravel.com/#plans). @@ -141,7 +141,7 @@ Laravel should always be served out of the root of the "web directory" configure Once you install Herd, you're ready to start developing with Laravel. Herd includes command line tools for `php`, `composer`, `laravel`, `expose`, `node`, `npm`, and `nvm`. -> [!NOTE] +> [!NOTE] > [Herd Pro](https://herd.laravel.com/#plans) augments Herd with additional powerful features, such as the ability to create and manage local MySQL, Postgres, and Redis databases, as well as local mail viewing and log monitoring. diff --git a/localization.md b/localization.md index ea12a85f5f1..c5e0313db6b 100644 --- a/localization.md +++ b/localization.md @@ -91,9 +91,9 @@ You may instruct Laravel's "pluralizer", which is used by Eloquent and other por */ public function boot(): void { - Pluralizer::useLanguage('spanish'); + Pluralizer::useLanguage('spanish'); - // ... + // ... } > [!WARNING] diff --git a/logging.md b/logging.md index 01a203e8690..a289763ff95 100644 --- a/logging.md +++ b/logging.md @@ -295,7 +295,7 @@ If you would like to share contextual information across _all_ logging channels, } } -> [!NOTE] +> [!NOTE] > If you need to share log context while processing queued jobs, you may utilize [job middleware](/docs/{{version}}/queues#job-middleware). diff --git a/migrations.md b/migrations.md index 7f8dcb89817..1b9b47e2f87 100644 --- a/migrations.md +++ b/migrations.md @@ -627,7 +627,7 @@ The `integer` method creates an `INTEGER` equivalent column: The `ipAddress` method creates a `VARCHAR` equivalent column: $table->ipAddress('visitor'); - + When using PostgreSQL, an `INET` column will be created. diff --git a/mocking.md b/mocking.md index 550da118b19..186e29f6bdf 100644 --- a/mocking.md +++ b/mocking.md @@ -240,7 +240,7 @@ You may also provide a closure to the various time travel methods. The closure w $this->travel(5)->days(function () { // Test something five days into the future... }); - + $this->travelTo(now()->subDays(10), function () { // Test something during a given moment... }); diff --git a/notifications.md b/notifications.md index c195e8b6827..995d404cb2f 100644 --- a/notifications.md +++ b/notifications.md @@ -1267,7 +1267,7 @@ To direct Slack notifications to the appropriate Slack team and channel, define - A `SlackRoute` instance, which allows you to specify an OAuth token and channel name, e.g. `SlackRoute::make($this->slack_channel, $this->slack_token)`. This method should be used to send notifications to external workspaces. For instance, returning `#support-channel` from the `routeNotificationForSlack` method will send the notification to the `#support-channel` channel in the workspace associated with the Bot User OAuth token located in your application's `services.php` configuration file: - + diff --git a/pennant.md b/pennant.md index 8ed326d05ad..2b7682c75f3 100644 --- a/pennant.md +++ b/pennant.md @@ -143,7 +143,8 @@ class NewApi } ``` -> [!NOTE] Feature classes are resolved via the [container](/docs/{{version}}/container), so you may inject dependencies into the feature class's constructor when needed. +> [!NOTE] +> Feature classes are resolved via the [container](/docs/{{version}}/container), so you may inject dependencies into the feature class's constructor when needed. #### Customizing the Stored Feature Name @@ -679,7 +680,8 @@ Pennant's included Blade directive also makes it easy to conditionally render co @endfeature ``` -> [!NOTE] When using rich values, it is important to know that a feature is considered "active" when it has any value other than `false`. +> [!NOTE] +> When using rich values, it is important to know that a feature is considered "active" when it has any value other than `false`. When calling the [conditional `when`](#conditional-execution) method, the feature's rich value will be provided to the first closure: @@ -847,7 +849,8 @@ Alternatively, you may deactivate the feature for all users: Feature::deactivateForEveryone('new-api'); ``` -> [!NOTE] This will only update the resolved feature values that have been stored by Pennant's storage driver. You will also need to update the feature definition in your application. +> [!NOTE] +> This will only update the resolved feature values that have been stored by Pennant's storage driver. You will also need to update the feature definition in your application. ### Purging Features diff --git a/precognition.md b/precognition.md index 600c96ae9b2..158409a74c2 100644 --- a/precognition.md +++ b/precognition.md @@ -314,7 +314,7 @@ If you are validating a subset of a form's inputs with Precognition, it can be u + onChange={(e) => form.setData('avatar', e.target.value); form.forgetError('avatar'); @@ -526,7 +526,7 @@ In the user creation example discussed above, we are using Precognition to perfo Alternatively, if you would like to submit the form via XHR you may use the form's `submit` function, which returns an Axios request promise: ```html - @@ -190,7 +190,7 @@ If you wish to view all usage metrics on screen at the same time, you may includ To learn how to customize how Pulse retrieves and displays user information, consult our documentation on [resolving users](#dashboard-resolving-users). -> [!NOTE] +> [!NOTE] > If your application receives a lot of requests or dispatches a lot of jobs, you may wish to enable [sampling](#sampling). See the [user requests recorder](#user-requests-recorder), [user jobs recorder](#user-jobs-recorder), and [slow jobs recorder](#slow-jobs-recorder) documentation for more information. @@ -251,7 +251,7 @@ Most Pulse recorders will automatically capture entries based on framework event php artisan pulse:check ``` -> [!NOTE] +> [!NOTE] > To keep the `pulse:check` process running permanently in the background, you should use a process monitor such as Supervisor to ensure that the command does not stop running. As the `pulse:check` command is a long-lived process, it will not see changes to your codebase without being restarted. You should gracefully restart the command by calling the `pulse:restart` command during your application's deployment process: @@ -471,7 +471,7 @@ PULSE_DB_CONNECTION=pulse ### Redis Ingest -> [!WARNING] +> [!WARNING] > The Redis Ingest requires Redis 6.2 or greater and `phpredis` or `predis` as the application's configured Redis client driver. By default, Pulse will store entries directly to the [configured database connection](#using-a-different-database) after the HTTP response has been sent to the client or a job has been processed; however, you may use Pulse's Redis ingest driver to send entries to a Redis stream instead. This can be enabled by configuring the `PULSE_INGEST_DRIVER` environment variable: @@ -492,7 +492,7 @@ When using the Redis ingest, you will need to run the `pulse:work` command to mo php artisan pulse:work ``` -> [!NOTE] +> [!NOTE] > To keep the `pulse:work` process running permanently in the background, you should use a process monitor such as Supervisor to ensure that the Pulse worker does not stop running. As the `pulse:work` command is a long-lived process, it will not see changes to your codebase without being restarted. You should gracefully restart the command by calling the `pulse:restart` command during your application's deployment process: @@ -593,7 +593,7 @@ Once you have defined your Livewire component and template, the card may be incl ``` -> [!NOTE] +> [!NOTE] > If your card is included in a package, you will need to register the component with Livewire using the `Livewire::component` method. @@ -707,7 +707,7 @@ The available aggregation methods are: * `min` * `sum` -> [!NOTE] +> [!NOTE] > When building a card package that captures the currently authenticated user ID, you should use the `Pulse::resolveAuthenticatedUserId()` method, which respects any [user resolver customizations](#dashboard-resolving-users) made to the application. diff --git a/routing.md b/routing.md index 57169b48c1c..12e4d050166 100644 --- a/routing.md +++ b/routing.md @@ -323,7 +323,7 @@ For convenience, some commonly used regular expression patterns have helper meth Route::get('/category/{category}', function (string $category) { // ... })->whereIn('category', ['movie', 'song', 'painting']); - + Route::get('/category/{category}', function (string $category) { // ... })->whereIn('category', CategoryEnum::cases()); diff --git a/scout.md b/scout.md index 2a2c28246bb..ba64255c8aa 100644 --- a/scout.md +++ b/scout.md @@ -177,7 +177,7 @@ public function toSearchableArray() } ``` -You should also define your Typesense collection schemas in your application's `config/scout.php` file. A collection schema describes the data types of each field that is searchable via Typesense. For more information on all available schema options, please consult the [Typesense documentation](https://typesense.org/docs/latest/api/collections.html#schema-parameters). +You should also define your Typesense collection schemas in your application's `config/scout.php` file. A collection schema describes the data types of each field that is searchable via Typesense. For more information on all available schema options, please consult the [Typesense documentation](https://typesense.org/docs/latest/api/collections.html#schema-parameters). If you need to change your Typesense collection's schema after it has been defined, you may either run `scout:flush` and `scout:import`, which will delete all existing indexed data and recreate the schema. Or, you may use Typesense's API to modify the collection's schema without removing any indexed data. diff --git a/seeding.md b/seeding.md index 4dd70fab4f2..400bbcb308d 100644 --- a/seeding.md +++ b/seeding.md @@ -135,7 +135,7 @@ You may also seed your database using the `migrate:fresh` command in combination ```shell php artisan migrate:fresh --seed -php artisan migrate:fresh --seed --seeder=UserSeeder +php artisan migrate:fresh --seed --seeder=UserSeeder ``` diff --git a/strings.md b/strings.md index ff3566a28ce..4be9d5b2ea9 100644 --- a/strings.md +++ b/strings.md @@ -545,12 +545,12 @@ The `Str::inlineMarkdown` method converts GitHub flavored Markdown into inline H By default, Markdown supports raw HTML, which will expose Cross-Site Scripting (XSS) vulnerabilities when used with raw user input. As per the [CommonMark Security documentation](https://commonmark.thephpleague.com/security/), you may use the `html_input` option to either escape or strip raw HTML, and the `allow_unsafe_links` option to specify whether to allow unsafe links. If you need to allow some raw HTML, you should pass your compiled Markdown through an HTML Purifier: use Illuminate\Support\Str; - + Str::inlineMarkdown('Inject: ', [ 'html_input' => 'strip', 'allow_unsafe_links' => false, ]); - + // Inject: alert("Hello XSS!"); @@ -1326,7 +1326,7 @@ The `Str::ulid` method generates a ULID, which is a compact, time-ordered unique use Illuminate\Support\Str; return (string) Str::ulid(); - + // 01gd6r360bp37zj17nxb55yv40 If you would like to retrieve a `Illuminate\Support\Carbon` date instance representing the date and time that a given ULID was created, you may use the `createFromId` method provided by Laravel's Carbon integration: diff --git a/testing.md b/testing.md index 15a918a735d..84c7e216418 100644 --- a/testing.md +++ b/testing.md @@ -46,7 +46,7 @@ If you would like to create a test within the `tests/Unit` directory, you may us php artisan make:test UserTest --unit ``` -> [!NOTE] +> [!NOTE] > Test stubs may be customized using [stub publishing](/docs/{{version}}/artisan#stub-customization). Once the test has been generated, you may define test as you normally would using Pest or PHPUnit. To run your tests, execute the `vendor/bin/pest`, `vendor/bin/phpunit`, or `php artisan test` command from your terminal: @@ -78,7 +78,7 @@ class ExampleTest extends TestCase } ``` -> [!WARNING] +> [!WARNING] > If you define your own `setUp` / `tearDown` methods within a test class, be sure to call the respective `parent::setUp()` / `parent::tearDown()` methods on the parent class. Typically, you should invoke `parent::setUp()` at the start of your own `setUp` method, and `parent::tearDown()` at the end of your `tearDown` method. diff --git a/upgrade.md b/upgrade.md index c8eea49b09b..3aaaa06cf1a 100644 --- a/upgrade.md +++ b/upgrade.md @@ -48,7 +48,7 @@ #### Estimated Upgrade Time: 15 Minutes -> [!NOTE] +> [!NOTE] > We attempt to document every possible breaking change. Since some of these breaking changes are in obscure parts of the framework only a portion of these changes may actually affect your application. Want to save time? You can use [Laravel Shift](https://laravelshift.com/) to help automate your application upgrades. diff --git a/vite.md b/vite.md index 0b8d56c4489..559549289b5 100644 --- a/vite.md +++ b/vite.md @@ -866,7 +866,7 @@ For example, the `vite-imagetools` plugin outputs URLs like the following while ``` -The `vite-imagetools` plugin is expecting that the output URL will be intercepted by Vite and the plugin may then handle all URLs that start with `/@imagetools`. If you are using plugins that are expecting this behaviour, you will need to manually correct the URLs. You can do this in your `vite.config.js` file by using the `transformOnServe` option. +The `vite-imagetools` plugin is expecting that the output URL will be intercepted by Vite and the plugin may then handle all URLs that start with `/@imagetools`. If you are using plugins that are expecting this behaviour, you will need to manually correct the URLs. You can do this in your `vite.config.js` file by using the `transformOnServe` option. In this particular example, we will prepend the dev server URL to all occurrences of `/@imagetools` within the generated code: From 46ad3e9ec7fd3c083dd3a997d158f89e1254e81c Mon Sep 17 00:00:00 2001 From: Yusuf Bouzekri Date: Mon, 22 Jul 2024 15:21:16 +0100 Subject: [PATCH 111/325] Update strings.md (#9782) --- strings.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/strings.md b/strings.md index 4be9d5b2ea9..462b7aeec2d 100644 --- a/strings.md +++ b/strings.md @@ -1655,17 +1655,17 @@ The `chopEnd` method removes the last occurrence of the given value only if the use Illuminate\Support\Str; - $url = Str::of('https://laravel.com')->chopEnd('https://'); + $url = Str::of('https://laravel.com')->chopEnd('.com'); - // 'laravel.com' + // 'https://laravel' You may also pass an array. If the string ends with any of the values in the array then that value will be removed from string: use Illuminate\Support\Str; - $url = Str::of('http://laravel.com')->chopEnd(['https://', 'http://']); + $url = Str::of('http://laravel.com')->chopEnd(['.com', '.io']); - // 'laravel.com' + // 'http://laravel' #### `contains` {.collection-method} From fa659e6bd8f4a82fb0dd7e611886f084efcd61a2 Mon Sep 17 00:00:00 2001 From: Hafez Divandari Date: Tue, 23 Jul 2024 17:37:05 +0330 Subject: [PATCH 112/325] extend SQLite support (#9768) --- database.md | 2 +- upgrade.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/database.md b/database.md index ffa38b9d1b7..2f1e189a40a 100644 --- a/database.md +++ b/database.md @@ -22,7 +22,7 @@ Almost every modern web application interacts with a database. Laravel makes int - MariaDB 10.3+ ([Version Policy](https://mariadb.org/about/#maintenance-policy)) - MySQL 5.7+ ([Version Policy](https://en.wikipedia.org/wiki/MySQL#Release_history)) - PostgreSQL 10.0+ ([Version Policy](https://www.postgresql.org/support/versioning/)) -- SQLite 3.35.0+ +- SQLite 3.26.0+ - SQL Server 2017+ ([Version Policy](https://docs.microsoft.com/en-us/lifecycle/products/?products=sql-server)) diff --git a/upgrade.md b/upgrade.md index 3aaaa06cf1a..d76be13755d 100644 --- a/upgrade.md +++ b/upgrade.md @@ -205,11 +205,11 @@ public function dump(...$args); ### Database -#### SQLite 3.35.0+ +#### SQLite 3.26.0+ **Likelihood Of Impact: High** -If your application is utilizing an SQLite database, SQLite 3.35.0 or greater is required. +If your application is utilizing an SQLite database, SQLite 3.26.0 or greater is required. #### Eloquent Model `casts` Method From 2e3c39607018927090fd2cdcf62980ae332f4039 Mon Sep 17 00:00:00 2001 From: Volodya Kurshudyan <70023120+xurshudyan@users.noreply.github.com> Date: Tue, 23 Jul 2024 18:33:39 +0400 Subject: [PATCH 113/325] rename to for clarity (#9783) Co-authored-by: Xurshudyan --- validation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validation.md b/validation.md index 664ba79390c..c73f5079073 100644 --- a/validation.md +++ b/validation.md @@ -1934,7 +1934,7 @@ Alternatively, you may use the `exclude_unless` rule to not validate a given fie In some situations, you may wish to run validation checks against a field **only** if that field is present in the data being validated. To quickly accomplish this, add the `sometimes` rule to your rule list: - $v = Validator::make($data, [ + $validator = Validator::make($data, [ 'email' => 'sometimes|required|email', ]); From dbd430b52d06a095691c1d37a43cedb6480bcb41 Mon Sep 17 00:00:00 2001 From: Einar Hansen <49709354+einar-hansen@users.noreply.github.com> Date: Tue, 23 Jul 2024 23:05:32 +0200 Subject: [PATCH 114/325] Update docs with information about the whereLike query (#9765) * Update docs with information about the whereLike query * Update queries.md * Update queries.md --------- Co-authored-by: Taylor Otwell --- queries.md | 69 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 16 deletions(-) diff --git a/queries.md b/queries.md index 334d2ed1283..27eaea884bf 100644 --- a/queries.md +++ b/queries.md @@ -583,35 +583,42 @@ You may use `whereJsonLength` method to query JSON arrays by their length: ### Additional Where Clauses -**whereBetween / orWhereBetween** +**whereLike / orWhereLike / whereNotLike / orWhereNotLike** -The `whereBetween` method verifies that a column's value is between two values: +The `whereLike` method allows you to add "LIKE" clauses to your query for pattern matching. These methods provide a database-agnostic way of performing string matching queries, with the ability to toggle case-sensitivity. By default, string matching is case-insensitive: $users = DB::table('users') - ->whereBetween('votes', [1, 100]) + ->whereLike('name', '%John%') ->get(); -**whereNotBetween / orWhereNotBetween** +You can enable a case-sensitive search via the `caseSensitive` argument: -The `whereNotBetween` method verifies that a column's value lies outside of two values: + $users = DB::table('users') + ->whereLike('name', '%John%', caseSensitive: true) + ->get(); + +The `orWhereLike` method allows you to add an "or" clause with a LIKE condition: $users = DB::table('users') - ->whereNotBetween('votes', [1, 100]) - ->get(); + ->where('votes', '>', 100) + ->orWhereLike('name', '%John%') + ->get(); -**whereBetweenColumns / whereNotBetweenColumns / orWhereBetweenColumns / orWhereNotBetweenColumns** +The `whereNotLike` method allows you to add "NOT LIKE" clauses to your query: -The `whereBetweenColumns` method verifies that a column's value is between the two values of two columns in the same table row: + $users = DB::table('users') + ->whereNotLike('name', '%John%') + ->get(); - $patients = DB::table('patients') - ->whereBetweenColumns('weight', ['minimum_allowed_weight', 'maximum_allowed_weight']) - ->get(); +Similarly, you can use `orWhereNotLike` to add an "or" clause with a NOT LIKE condition: -The `whereNotBetweenColumns` method verifies that a column's value lies outside the two values of two columns in the same table row: + $users = DB::table('users') + ->where('votes', '>', 100) + ->orWhereNotLike('name', '%John%') + ->get(); - $patients = DB::table('patients') - ->whereNotBetweenColumns('weight', ['minimum_allowed_weight', 'maximum_allowed_weight']) - ->get(); +> [!WARNING] +> The `whereLike` case-sensitive search option is currently not supported on SQL Server. **whereIn / whereNotIn / orWhereIn / orWhereNotIn** @@ -648,6 +655,36 @@ select * from comments where user_id in ( > [!WARNING] > If you are adding a large array of integer bindings to your query, the `whereIntegerInRaw` or `whereIntegerNotInRaw` methods may be used to greatly reduce your memory usage. +**whereBetween / orWhereBetween** + +The `whereBetween` method verifies that a column's value is between two values: + + $users = DB::table('users') + ->whereBetween('votes', [1, 100]) + ->get(); + +**whereNotBetween / orWhereNotBetween** + +The `whereNotBetween` method verifies that a column's value lies outside of two values: + + $users = DB::table('users') + ->whereNotBetween('votes', [1, 100]) + ->get(); + +**whereBetweenColumns / whereNotBetweenColumns / orWhereBetweenColumns / orWhereNotBetweenColumns** + +The `whereBetweenColumns` method verifies that a column's value is between the two values of two columns in the same table row: + + $patients = DB::table('patients') + ->whereBetweenColumns('weight', ['minimum_allowed_weight', 'maximum_allowed_weight']) + ->get(); + +The `whereNotBetweenColumns` method verifies that a column's value lies outside the two values of two columns in the same table row: + + $patients = DB::table('patients') + ->whereNotBetweenColumns('weight', ['minimum_allowed_weight', 'maximum_allowed_weight']) + ->get(); + **whereNull / whereNotNull / orWhereNull / orWhereNotNull** The `whereNull` method verifies that the value of the given column is `NULL`: From c3bd12850534ea3a92e70bf9f3a68cc093a0a704 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 23 Jul 2024 16:07:45 -0500 Subject: [PATCH 115/325] wip --- pennant.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pennant.md b/pennant.md index 2b7682c75f3..71da2a38e88 100644 --- a/pennant.md +++ b/pennant.md @@ -799,6 +799,12 @@ Feature::for($users)->loadMissing([ ]); ``` +You may load all defined features using the `loadAll` method: + +```php +Feature::for($user)->loadAll(); +``` + ## Updating Values From f08454501ad9e80affb6591190e183c541e1fed6 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 23 Jul 2024 16:09:24 -0500 Subject: [PATCH 116/325] wip --- http-tests.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/http-tests.md b/http-tests.md index 73f6faeafef..bf2cc4f0a93 100644 --- a/http-tests.md +++ b/http-tests.md @@ -426,6 +426,15 @@ $this->assertThrows( ); ``` +If you would like to inspect and make assertions against the exception that is thrown, you may provide a closure as the second argument to the `assertThrows` method: + +```php +$this->assertThrows( + fn () => (new ProcessOrder)->execute(), + fn (OrderInvalid $e) => $e->orderId() === 123; +); +``` + ## Testing JSON APIs From ff7f8ac6f249f521a4e4702351254172e722c215 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 23 Jul 2024 16:13:31 -0500 Subject: [PATCH 117/325] wip --- strings.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/strings.md b/strings.md index 462b7aeec2d..d6b8e715a13 100644 --- a/strings.md +++ b/strings.md @@ -695,9 +695,13 @@ The `Str::limit` method truncates the given string to the specified length: // The quick brown fox... -You may pass a third argument to the method to change the string that will be appended to the end of the truncated string: +If you would like to preserve complete words when truncating the string, you may utilize the `preserveWords` argument. When this argument is `true`, the string will be truncated to the nearest complete word boundary: - use Illuminate\Support\Str; + $truncated = Str::limit('The quick brown fox', 12, preserveWords: true); + + // The quick... + +You may pass a third argument to the method to change the string that will be appended to the end of the truncated string: $truncated = Str::limit('The quick brown fox jumps over the lazy dog', 20, ' (...)'); From f78985d7ffab32b5dbb0dfffbced88f693ec058d Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 23 Jul 2024 16:14:39 -0500 Subject: [PATCH 118/325] wip --- strings.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/strings.md b/strings.md index d6b8e715a13..3ba90b62e65 100644 --- a/strings.md +++ b/strings.md @@ -695,18 +695,18 @@ The `Str::limit` method truncates the given string to the specified length: // The quick brown fox... -If you would like to preserve complete words when truncating the string, you may utilize the `preserveWords` argument. When this argument is `true`, the string will be truncated to the nearest complete word boundary: - - $truncated = Str::limit('The quick brown fox', 12, preserveWords: true); - - // The quick... - You may pass a third argument to the method to change the string that will be appended to the end of the truncated string: $truncated = Str::limit('The quick brown fox jumps over the lazy dog', 20, ' (...)'); // The quick brown fox (...) +If you would like to preserve complete words when truncating the string, you may utilize the `preserveWords` argument. When this argument is `true`, the string will be truncated to the nearest complete word boundary: + + $truncated = Str::limit('The quick brown fox', 12, preserveWords: true); + + // The quick... + #### `Str::lower()` {.collection-method} @@ -2021,12 +2021,16 @@ The `limit` method truncates the given string to the specified length: You may also pass a second argument to change the string that will be appended to the end of the truncated string: - use Illuminate\Support\Str; - $truncated = Str::of('The quick brown fox jumps over the lazy dog')->limit(20, ' (...)'); // The quick brown fox (...) +If you would like to preserve complete words when truncating the string, you may utilize the `preserveWords` argument. When this argument is `true`, the string will be truncated to the nearest complete word boundary: + + $truncated = Str::of('The quick brown fox')->limit(12, preserveWords: true); + + // The quick... + #### `lower` {.collection-method} From 9c9e90ae3c73d0a3becd33a10a3086b663a8ec77 Mon Sep 17 00:00:00 2001 From: Sergey Pashkevich Date: Wed, 24 Jul 2024 18:49:49 +0300 Subject: [PATCH 119/325] Update queries.md (#9784) All documentation uses lowercase for `like` operator: https://laravel.com/docs/11.x/queries https://laravel.com/docs/11.x/eloquent-relationships --- queries.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/queries.md b/queries.md index 27eaea884bf..402cb651a8d 100644 --- a/queries.md +++ b/queries.md @@ -513,7 +513,7 @@ Sometimes you may need to apply the same query constraints to multiple columns. 'name', 'email', 'phone', - ], 'LIKE', 'Example%') + ], 'like', 'Example%') ->get(); The query above will result in the following SQL: @@ -535,7 +535,7 @@ Similarly, the `whereAll` method may be used to retrieve records where all of th ->whereAll([ 'title', 'content', - ], 'LIKE', '%Laravel%') + ], 'like', '%Laravel%') ->get(); The query above will result in the following SQL: From 0672b9354731561a93107f3ece894804fbd9dcc1 Mon Sep 17 00:00:00 2001 From: Sergey Pashkevich Date: Wed, 24 Jul 2024 18:50:50 +0300 Subject: [PATCH 120/325] Update database.md (#9785) * Update database.md * Update database.md --------- Co-authored-by: Taylor Otwell --- database.md | 1 + 1 file changed, 1 insertion(+) diff --git a/database.md b/database.md index 2f1e189a40a..1e2cf203759 100644 --- a/database.md +++ b/database.md @@ -291,6 +291,7 @@ If you would like to specify a closure that is invoked for each SQL query execut // $query->sql; // $query->bindings; // $query->time; + // $query->toRawSql(); }); } } From 7e041c42a2518b7c55bcbed429bee933b5574ce1 Mon Sep 17 00:00:00 2001 From: PrinsFrank <25006490+PrinsFrank@users.noreply.github.com> Date: Fri, 26 Jul 2024 07:34:07 +0200 Subject: [PATCH 121/325] Document process count configuration for Horizon (#9790) * Document process count configuration for Horizon * Update horizon.md --------- Co-authored-by: Taylor Otwell --- horizon.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/horizon.md b/horizon.md index 3e34b47cf28..08319cd5c74 100644 --- a/horizon.md +++ b/horizon.md @@ -126,7 +126,7 @@ Unlike Laravel's default queue system, Horizon allows you to choose from three w The `auto` strategy, which is the configuration file's default, adjusts the number of worker processes per queue based on the current workload of the queue. For example, if your `notifications` queue has 1,000 pending jobs while your `render` queue is empty, Horizon will allocate more workers to your `notifications` queue until the queue is empty. -When using the `auto` strategy, you may define the `minProcesses` and `maxProcesses` configuration options to control the minimum and the maximum number of worker processes Horizon should scale up and down to: +When using the `auto` strategy, you may define the `minProcesses` and `maxProcesses` configuration options to control the minimum number of processes per queue and the maximum number of worker processes in total Horizon should scale up and down to: 'environments' => [ 'production' => [ From b0ac2130ee3ba124f6f7141e63584599946a45c2 Mon Sep 17 00:00:00 2001 From: James <16080646+James-buzz@users.noreply.github.com> Date: Fri, 26 Jul 2024 06:35:15 +0100 Subject: [PATCH 122/325] Fix typo on queues.md (#9788) --- queues.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queues.md b/queues.md index 617156d21f7..af2aa0b86c1 100644 --- a/queues.md +++ b/queues.md @@ -1583,7 +1583,7 @@ Then, set the `queue.batching.driver` configuration option's value to `dynamodb` ```php 'batching' => [ - 'driver' => env('QUEUE_FAILED_DRIVER', 'dynamodb'), + 'driver' => env('QUEUE_BATCHING_DRIVER', 'dynamodb'), 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), From e1f9a340efffc94646db3d4b70925bbbb8458f12 Mon Sep 17 00:00:00 2001 From: Bart Stavenuiter Date: Fri, 26 Jul 2024 07:43:52 +0200 Subject: [PATCH 123/325] change default collation to match default config in framework (#9787) --- database.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database.md b/database.md index 1e2cf203759..0390f489696 100644 --- a/database.md +++ b/database.md @@ -103,7 +103,7 @@ To see how read / write connections should be configured, let's look at this exa 'password' => env('DB_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => env('DB_CHARSET', 'utf8mb4'), - 'collation' => env('DB_COLLATION', 'utf8mb4_0900_ai_ci'), + 'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'), 'prefix' => '', 'prefix_indexes' => true, 'strict' => true, From 973948223359c5c918a939a71ce00531b75ce761 Mon Sep 17 00:00:00 2001 From: TENIOS <40282681+TENIOS@users.noreply.github.com> Date: Mon, 29 Jul 2024 13:54:05 +0700 Subject: [PATCH 124/325] Update prompts.md (#9793) --- prompts.md | 100 ++++++++++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 48 deletions(-) diff --git a/prompts.md b/prompts.md index fb7d19eab18..dabba4d6bea 100644 --- a/prompts.md +++ b/prompts.md @@ -113,7 +113,7 @@ Alternatively, you may leverage the power of Laravel's [validator](/docs/{{versi ```php $name = text( label: 'What is your name?', - validate: ['name' => 'required|max:255|unique:users,name'] + validate: ['name' => 'required|max:255|unique:users'] ); ``` @@ -307,8 +307,8 @@ If you need the user to select from a predefined set of choices, you may use the use function Laravel\Prompts\select; $role = select( - 'What role should the user have?', - ['Member', 'Contributor', 'Owner'], + label: 'What role should the user have?', + options: ['Member', 'Contributor', 'Owner'] ); ``` @@ -331,7 +331,7 @@ $role = select( options: [ 'member' => 'Member', 'contributor' => 'Contributor', - 'owner' => 'Owner' + 'owner' => 'Owner', ], default: 'owner' ); @@ -348,7 +348,7 @@ $role = select( ``` -#### Validation +#### Additional Validation Unlike other prompt functions, the `select` function doesn't accept the `required` argument because it is not possible to select nothing. However, you may pass a closure to the `validate` argument if you need to present an option but prevent it from being selected: @@ -358,7 +358,7 @@ $role = select( options: [ 'member' => 'Member', 'contributor' => 'Contributor', - 'owner' => 'Owner' + 'owner' => 'Owner', ], validate: fn (string $value) => $value === 'owner' && User::where('role', 'owner')->exists() @@ -378,8 +378,8 @@ If you need the user to be able to select multiple options, you may use the `mul use function Laravel\Prompts\multiselect; $permissions = multiselect( - 'What permissions should be assigned?', - ['Read', 'Create', 'Update', 'Delete'] + label: 'What permissions should be assigned?', + options: ['Read', 'Create', 'Update', 'Delete'] ); ``` @@ -398,14 +398,14 @@ $permissions = multiselect( You may also pass an associative array to the `options` argument to return the selected options' keys instead of their values: -``` +```php $permissions = multiselect( label: 'What permissions should be assigned?', options: [ 'read' => 'Read', 'create' => 'Create', 'update' => 'Update', - 'delete' => 'Delete' + 'delete' => 'Delete', ], default: ['read', 'create'] ); @@ -423,11 +423,13 @@ $categories = multiselect( You may allow the user to easily select all options via the `canSelectAll` argument: +```php $categories = multiselect( label: 'What categories should be assigned?', options: Category::pluck('name', 'id'), canSelectAll: true ); +``` #### Requiring a Value @@ -438,7 +440,7 @@ By default, the user may select zero or more options. You may pass the `required $categories = multiselect( label: 'What categories should be assigned?', options: Category::pluck('name', 'id'), - required: true, + required: true ); ``` @@ -448,23 +450,23 @@ If you would like to customize the validation message, you may provide a string $categories = multiselect( label: 'What categories should be assigned?', options: Category::pluck('name', 'id'), - required: 'You must select at least one category', + required: 'You must select at least one category' ); ``` -#### Validation +#### Additional Validation You may pass a closure to the `validate` argument if you need to present an option but prevent it from being selected: -``` +```php $permissions = multiselect( label: 'What permissions should the user have?', options: [ 'read' => 'Read', 'create' => 'Create', 'update' => 'Update', - 'delete' => 'Delete' + 'delete' => 'Delete', ], validate: fn (array $values) => ! in_array('read', $values) ? 'All users require the read permission.' @@ -489,8 +491,8 @@ Alternatively, you may pass a closure as the second argument to the `suggest` fu ```php $name = suggest( - 'What is your name?', - fn ($value) => collect(['Taylor', 'Dayle']) + label: 'What is your name?', + options: fn ($value) => collect(['Taylor', 'Dayle']) ->filter(fn ($name) => Str::contains($name, $value, ignoreCase: true)) ) ``` @@ -568,9 +570,9 @@ If you have a lot of options for the user to select from, the `search` function use function Laravel\Prompts\search; $id = search( - 'Search for the user that should receive the mail', - fn (string $value) => strlen($value) > 0 - ? User::where('name', 'like', "%{$value}%")->pluck('name', 'id')->all() + label: 'Search for the user that should receive the mail', + options: fn (string $value) => strlen($value) > 0 + ? User::whereLike('name', "%{$value}%")->pluck('name', 'id')->all() : [] ); ``` @@ -584,7 +586,7 @@ $id = search( label: 'Search for the user that should receive the mail', placeholder: 'E.g. Taylor Otwell', options: fn (string $value) => strlen($value) > 0 - ? User::where('name', 'like', "%{$value}%")->pluck('name', 'id')->all() + ? User::whereLike('name', "%{$value}%")->pluck('name', 'id')->all() : [], hint: 'The user will receive an email immediately.' ); @@ -596,14 +598,14 @@ Up to five options will be displayed before the list begins to scroll. You may c $id = search( label: 'Search for the user that should receive the mail', options: fn (string $value) => strlen($value) > 0 - ? User::where('name', 'like', "%{$value}%")->pluck('name', 'id')->all() + ? User::whereLike('name', "%{$value}%")->pluck('name', 'id')->all() : [], scroll: 10 ); ``` -#### Validation +#### Additional Validation If you would like to perform additional validation logic, you may pass a closure to the `validate` argument: @@ -611,7 +613,7 @@ If you would like to perform additional validation logic, you may pass a closure $id = search( label: 'Search for the user that should receive the mail', options: fn (string $value) => strlen($value) > 0 - ? User::where('name', 'like', "%{$value}%")->pluck('name', 'id')->all() + ? User::whereLike('name', "%{$value}%")->pluck('name', 'id')->all() : [], validate: function (int|string $value) { $user = User::findOrFail($value); @@ -636,7 +638,7 @@ use function Laravel\Prompts\multisearch; $ids = multisearch( 'Search for the users that should receive the mail', fn (string $value) => strlen($value) > 0 - ? User::where('name', 'like', "%{$value}%")->pluck('name', 'id')->all() + ? User::whereLike('name', "%{$value}%")->pluck('name', 'id')->all() : [] ); ``` @@ -650,7 +652,7 @@ $ids = multisearch( label: 'Search for the users that should receive the mail', placeholder: 'E.g. Taylor Otwell', options: fn (string $value) => strlen($value) > 0 - ? User::where('name', 'like', "%{$value}%")->pluck('name', 'id')->all() + ? User::whereLike('name', "%{$value}%")->pluck('name', 'id')->all() : [], hint: 'The user will receive an email immediately.' ); @@ -662,7 +664,7 @@ Up to five options will be displayed before the list begins to scroll. You may c $ids = multisearch( label: 'Search for the users that should receive the mail', options: fn (string $value) => strlen($value) > 0 - ? User::where('name', 'like', "%{$value}%")->pluck('name', 'id')->all() + ? User::whereLike('name', "%{$value}%")->pluck('name', 'id')->all() : [], scroll: 10 ); @@ -675,11 +677,11 @@ By default, the user may select zero or more options. You may pass the `required ```php $ids = multisearch( - 'Search for the users that should receive the mail', - fn (string $value) => strlen($value) > 0 - ? User::where('name', 'like', "%{$value}%")->pluck('name', 'id')->all() + label: 'Search for the users that should receive the mail', + options: fn (string $value) => strlen($value) > 0 + ? User::whereLike('name', "%{$value}%")->pluck('name', 'id')->all() : [], - required: true, + required: true ); ``` @@ -687,16 +689,16 @@ If you would like to customize the validation message, you may also provide a st ```php $ids = multisearch( - 'Search for the users that should receive the mail', - fn (string $value) => strlen($value) > 0 - ? User::where('name', 'like', "%{$value}%")->pluck('name', 'id')->all() + label: 'Search for the users that should receive the mail', + options: fn (string $value) => strlen($value) > 0 + ? User::whereLike('name', "%{$value}%")->pluck('name', 'id')->all() : [], required: 'You must select at least one user.' ); ``` -#### Validation +#### Additional Validation If you would like to perform additional validation logic, you may pass a closure to the `validate` argument: @@ -704,10 +706,10 @@ If you would like to perform additional validation logic, you may pass a closure $ids = multisearch( label: 'Search for the users that should receive the mail', options: fn (string $value) => strlen($value) > 0 - ? User::where('name', 'like', "%{$value}%")->pluck('name', 'id')->all() + ? User::whereLike('name', "%{$value}%")->pluck('name', 'id')->all() : [], validate: function (array $values) { - $optedOut = User::where('name', 'like', '%a%')->findMany($values); + $optedOut = User::whereLike('name', '%a%')->findMany($values); if ($optedOut->isNotEmpty()) { return $optedOut->pluck('name')->join(', ', ', and ').' have opted out.'; @@ -753,16 +755,16 @@ use function Laravel\Prompts\form; $responses = form() ->text('What is your name?', required: true, name: 'name') ->password( - 'What is your password?', + label: 'What is your password?', validate: ['password' => 'min:8'], - name: 'password', + name: 'password' ) ->confirm('Do you accept the terms?') ->submit(); User::create([ 'name' => $responses['name'], - 'password' => $responses['password'] + 'password' => $responses['password'], ]); ``` @@ -804,8 +806,8 @@ The `table` function makes it easy to display multiple rows and columns of data. use function Laravel\Prompts\table; table( - ['Name', 'Email'], - User::all(['name', 'email'])->toArray() + headers: ['Name', 'Email'], + rows: User::all(['name', 'email'])->toArray() ); ``` @@ -818,8 +820,8 @@ The `spin` function displays a spinner along with an optional message while exec use function Laravel\Prompts\spin; $response = spin( - fn () => Http::get('http://example.com'), - 'Fetching response...' + message: 'Fetching response...', + callback: fn () => Http::get('http://example.com') ); ``` @@ -837,13 +839,13 @@ use function Laravel\Prompts\progress; $users = progress( label: 'Updating users', steps: User::all(), - callback: fn ($user) => $this->performTask($user), + callback: fn ($user) => $this->performTask($user) ); ``` The `progress` function acts like a map function and will return an array containing the return value of each iteration of your callback. -The callback may also accept the `\Laravel\Prompts\Progress` instance, allowing you to modify the label and hint on each iteration: +The callback may also accept the `Laravel\Prompts\Progress` instance, allowing you to modify the label and hint on each iteration: ```php $users = progress( @@ -856,7 +858,7 @@ $users = progress( return $this->performTask($user); }, - hint: 'This may take some time.', + hint: 'This may take some time.' ); ``` @@ -928,7 +930,9 @@ TextPrompt::fallbackUsing(function (TextPrompt $prompt) use ($input, $output) { $question = (new Question($prompt->label, $prompt->default ?: null)) ->setValidator(function ($answer) use ($prompt) { if ($prompt->required && $answer === null) { - throw new \RuntimeException(is_string($prompt->required) ? $prompt->required : 'Required.'); + throw new \RuntimeException( + is_string($prompt->required) ? $prompt->required : 'Required.' + ); } if ($prompt->validate) { From 1b69438a67473dc3a9c7f351b3fa742460d11054 Mon Sep 17 00:00:00 2001 From: TENIOS <40282681+TENIOS@users.noreply.github.com> Date: Mon, 29 Jul 2024 13:54:18 +0700 Subject: [PATCH 125/325] Fix double newline typos (#9795) --- collections.md | 1 - errors.md | 1 - helpers.md | 3 --- horizon.md | 1 - logging.md | 6 ++---- middleware.md | 1 - queues.md | 2 -- releases.md | 1 - scheduling.md | 1 - strings.md | 3 --- validation.md | 16 ++++++++-------- 11 files changed, 10 insertions(+), 26 deletions(-) diff --git a/collections.md b/collections.md index 17641933a6f..e5794876299 100644 --- a/collections.md +++ b/collections.md @@ -3434,7 +3434,6 @@ The `whereNull` method returns items from the collection where the given key is ] */ - #### `wrap()` {.collection-method} diff --git a/errors.md b/errors.md index b87b4f1ef44..3d5fbf1f92f 100644 --- a/errors.md +++ b/errors.md @@ -368,7 +368,6 @@ By default, limits will use the exception's class as the rate limit key. You can }); }) - Of course, you may return a mixture of `Lottery` and `Limit` instances for different exceptions: use App\Exceptions\ApiMonitoringException; diff --git a/helpers.md b/helpers.md index 72724035102..7ba4e6b1a38 100644 --- a/helpers.md +++ b/helpers.md @@ -105,7 +105,6 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct - ### Paths @@ -244,7 +243,6 @@ The `Arr::add` method adds a given key / value pair to an array if the given key // ['name' => 'Desk', 'price' => 100] - #### `Arr::collapse()` {.collection-method} @@ -1364,7 +1362,6 @@ The `Number::spell` method transforms the given number into a string of words: // quatre-vingt-huit - The `after` argument allows you to specify a value after which all numbers should be spelled out: $number = Number::spell(10, after: 10); diff --git a/horizon.md b/horizon.md index 08319cd5c74..5ad26553a37 100644 --- a/horizon.md +++ b/horizon.md @@ -375,7 +375,6 @@ When retrieving the tags for a queued event listener, Horizon will automatically } } - ## Notifications diff --git a/logging.md b/logging.md index a289763ff95..3d33582d290 100644 --- a/logging.md +++ b/logging.md @@ -417,9 +417,8 @@ If you are using a Monolog handler that is capable of providing its own formatte 'formatter' => 'default', ], - - - #### Monolog Processors + +#### Monolog Processors Monolog can also process messages before logging them. You can create your own processors or use the [existing processors offered by Monolog](https://github.com/Seldaek/monolog/tree/main/src/Monolog/Processor). @@ -443,7 +442,6 @@ If you would like to customize the processors for a `monolog` driver, add a `pro ], ], - ### Creating Custom Channels via Factories diff --git a/middleware.md b/middleware.md index b56ca30820a..5268ebd3428 100644 --- a/middleware.md +++ b/middleware.md @@ -140,7 +140,6 @@ If you would like to manage Laravel's global middleware stack manually, you may ]); }) - ### Assigning Middleware to Routes diff --git a/queues.md b/queues.md index af2aa0b86c1..baf03958e00 100644 --- a/queues.md +++ b/queues.md @@ -572,7 +572,6 @@ class ProviderIsDown { // ... - public function middleware(): array { return [ @@ -585,7 +584,6 @@ class ProviderIsUp { // ... - public function middleware(): array { return [ diff --git a/releases.md b/releases.md index 6a3663c05ed..692cbfb16f3 100644 --- a/releases.md +++ b/releases.md @@ -21,7 +21,6 @@ When referencing the Laravel framework or its components from your application o For all Laravel releases, bug fixes are provided for 18 months and security fixes are provided for 2 years. For all additional libraries, including Lumen, only the latest major release receives bug fixes. In addition, please review the database versions [supported by Laravel](/docs/{{version}}/database#introduction). -
| Version | PHP (*) | Release | Bug Fixes Until | Security Fixes Until | diff --git a/scheduling.md b/scheduling.md index 3c472d87ffc..5ef90e01c73 100644 --- a/scheduling.md +++ b/scheduling.md @@ -343,7 +343,6 @@ Schedule::call(fn () => User::resetApiRequestCount()) ->onOneServer(); ``` - ### Background Tasks diff --git a/strings.md b/strings.md index 3ba90b62e65..661faf47915 100644 --- a/strings.md +++ b/strings.md @@ -460,7 +460,6 @@ The `Str::endsWith` method determines if the given string ends with the given va // true - You may also pass an array of values to determine if the given string ends with any of the values in the array: use Illuminate\Support\Str; @@ -1895,7 +1894,6 @@ The `isEmpty` method determines if the given string is empty: The `isNotEmpty` method determines if the given string is not empty: - use Illuminate\Support\Str; $result = Str::of(' ')->trim()->isNotEmpty(); @@ -1996,7 +1994,6 @@ The `lcfirst` method returns the given string with the first character lowercase // foo Bar - #### `length` {.collection-method} diff --git a/validation.md b/validation.md index c73f5079073..b77486a7bdf 100644 --- a/validation.md +++ b/validation.md @@ -1544,23 +1544,23 @@ The field under validation must be a multiple of _value_. The field under validation must not be present in the input data. - - #### missing_if:_anotherfield_,_value_,... + +#### missing_if:_anotherfield_,_value_,... The field under validation must not be present if the _anotherfield_ field is equal to any _value_. - - #### missing_unless:_anotherfield_,_value_ + +#### missing_unless:_anotherfield_,_value_ The field under validation must not be present unless the _anotherfield_ field is equal to any _value_. - - #### missing_with:_foo_,_bar_,... + +#### missing_with:_foo_,_bar_,... The field under validation must not be present _only if_ any of the other specified fields are present. - - #### missing_with_all:_foo_,_bar_,... + +#### missing_with_all:_foo_,_bar_,... The field under validation must not be present _only if_ all of the other specified fields are present. From 75690b5d23e2b7a30f31ea3ec244ca3f53829c5f Mon Sep 17 00:00:00 2001 From: Joel Bladt Date: Mon, 29 Jul 2024 08:54:52 +0200 Subject: [PATCH 126/325] Update dusk.md (#9792) --- dusk.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dusk.md b/dusk.md index dc4d1d7d9b1..36d74238380 100644 --- a/dusk.md +++ b/dusk.md @@ -2140,7 +2140,7 @@ To run your Dusk tests on [Travis CI](https://travis-ci.org), use the following language: php php: - - 7.3 + - 8.2 addons: chrome: stable From 524f3893f21821a5334d048c0eaadd66ffa12537 Mon Sep 17 00:00:00 2001 From: Robin Straub Date: Mon, 29 Jul 2024 09:20:52 +0200 Subject: [PATCH 127/325] doc: bump actions/upload-artifact github action to v4 (#9791) Co-authored-by: Robin Straub --- dusk.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dusk.md b/dusk.md index 36d74238380..f17e268e9c3 100644 --- a/dusk.md +++ b/dusk.md @@ -2198,13 +2198,13 @@ jobs: run: php artisan dusk - name: Upload Screenshots if: failure() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: screenshots path: tests/Browser/screenshots - name: Upload Console Logs if: failure() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: console path: tests/Browser/console From 6d7a00b539d8281cc8d7037e82b978fec3c00866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20H=2E?= <36476318+Tamas-hi@users.noreply.github.com> Date: Thu, 1 Aug 2024 14:38:36 +0200 Subject: [PATCH 128/325] Update sanctum.md (#9804) * Update sanctum.md Vue CLI is in maintenance mode for quite a while now (https://cli.vuejs.org/) so we should refer to the preferred-way as well. (https://github.com/vuejs/create-vue) * Update sanctum.md --------- Co-authored-by: Taylor Otwell --- sanctum.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sanctum.md b/sanctum.md index 8830c7d5b9f..c1fd78ab487 100644 --- a/sanctum.md +++ b/sanctum.md @@ -42,7 +42,7 @@ Laravel Sanctum offers this feature by storing user API tokens in a single datab #### SPA Authentication -Second, Sanctum exists to offer a simple way to authenticate single page applications (SPAs) that need to communicate with a Laravel powered API. These SPAs might exist in the same repository as your Laravel application or might be an entirely separate repository, such as an SPA created using Vue CLI or a Next.js application. +Second, Sanctum exists to offer a simple way to authenticate single page applications (SPAs) that need to communicate with a Laravel powered API. These SPAs might exist in the same repository as your Laravel application or might be an entirely separate repository, such as an SPA created using Next.js or Nuxt. For this feature, Sanctum does not use tokens of any kind. Instead, Sanctum uses Laravel's built-in cookie based session authentication services. Typically, Sanctum utilizes Laravel's `web` authentication guard to accomplish this. This provides the benefits of CSRF protection, session authentication, as well as protects against leakage of the authentication credentials via XSS. From 31699722eb75b0ec71d199a8a7d6a8335787cdee Mon Sep 17 00:00:00 2001 From: Hafez Divandari Date: Thu, 1 Aug 2024 16:09:28 +0330 Subject: [PATCH 129/325] support SQLite foreign keys (#9803) --- migrations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations.md b/migrations.md index 1b9b47e2f87..f86f2cab482 100644 --- a/migrations.md +++ b/migrations.md @@ -1228,7 +1228,7 @@ You may enable or disable foreign key constraints within your migrations by usin }); > [!WARNING] -> SQLite disables foreign key constraints by default. When using SQLite, make sure to [enable foreign key support](/docs/{{version}}/database#configuration) in your database configuration before attempting to create them in your migrations. In addition, SQLite only supports foreign keys upon creation of the table and [not when tables are altered](https://www.sqlite.org/omitted.html). +> SQLite disables foreign key constraints by default. When using SQLite, make sure to [enable foreign key support](/docs/{{version}}/database#configuration) in your database configuration before attempting to create them in your migrations. ## Events From 8575d328c680b6d77ec194894f2a57db9c7e7a01 Mon Sep 17 00:00:00 2001 From: Noboru Shiroiwa <14008307+nshiro@users.noreply.github.com> Date: Thu, 1 Aug 2024 22:11:52 +0900 Subject: [PATCH 130/325] Remove the `assertArraySubset' part (#9802) --- http-tests.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/http-tests.md b/http-tests.md index bf2cc4f0a93..2f1b5d15ce3 100644 --- a/http-tests.md +++ b/http-tests.md @@ -490,7 +490,7 @@ $this->assertTrue($response['created']); ``` > [!NOTE] -> The `assertJson` method converts the response to an array and utilizes `PHPUnit::assertArraySubset` to verify that the given array exists within the JSON response returned by the application. So, if there are other properties in the JSON response, this test will still pass as long as the given fragment is present. +> The `assertJson` method converts the response to an array to verify that the given array exists within the JSON response returned by the application. So, if there are other properties in the JSON response, this test will still pass as long as the given fragment is present. #### Asserting Exact JSON Matches @@ -1122,7 +1122,7 @@ Assert that the response contains the given JSON data: $response->assertJson(array $data, $strict = false); -The `assertJson` method converts the response to an array and utilizes `PHPUnit::assertArraySubset` to verify that the given array exists within the JSON response returned by the application. So, if there are other properties in the JSON response, this test will still pass as long as the given fragment is present. +The `assertJson` method converts the response to an array to verify that the given array exists within the JSON response returned by the application. So, if there are other properties in the JSON response, this test will still pass as long as the given fragment is present. #### assertJsonCount From 0be3a636f7198068f9836474e96f3d13f58c172c Mon Sep 17 00:00:00 2001 From: AJ <60591772+devajmeireles@users.noreply.github.com> Date: Thu, 1 Aug 2024 11:08:05 -0300 Subject: [PATCH 131/325] removing semicolon from view example of Pulse page (#9801) --- pulse.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pulse.md b/pulse.md index 99a0c72f59e..4020822192b 100644 --- a/pulse.md +++ b/pulse.md @@ -721,7 +721,7 @@ class TopSellers extends Card public function render() { return view('livewire.pulse.top-sellers', [ - 'topSellers' => $this->aggregate('user_sale', ['sum', 'count']); + 'topSellers' => $this->aggregate('user_sale', ['sum', 'count']) ]); } } From 8b5efa9f8eeeff062961b2791179b6bb55666728 Mon Sep 17 00:00:00 2001 From: ChrissBott Date: Thu, 1 Aug 2024 16:08:21 +0200 Subject: [PATCH 132/325] Fix grammatical error in middleware.md (#9800) Use "allow" instead of "allows" because the subject "aliases" is plural. --- middleware.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleware.md b/middleware.md index 5268ebd3428..3d245a89313 100644 --- a/middleware.md +++ b/middleware.md @@ -301,7 +301,7 @@ If you would like to manually manage all of the middleware within Laravel's defa ### Middleware Aliases -You may assign aliases to middleware in your application's `bootstrap/app.php` file. Middleware aliases allows you to define a short alias for a given middleware class, which can be especially useful for middleware with long class names: +You may assign aliases to middleware in your application's `bootstrap/app.php` file. Middleware aliases allow you to define a short alias for a given middleware class, which can be especially useful for middleware with long class names: use App\Http\Middleware\EnsureUserIsSubscribed; From b874bc07a34f0a9c960f3e1b7ced2370724abcf9 Mon Sep 17 00:00:00 2001 From: Milwad Khosravi <98118400+milwad-dev@users.noreply.github.com> Date: Thu, 1 Aug 2024 18:14:55 +0330 Subject: [PATCH 133/325] [11.x] Add `assertExactJsonStructure` to http-tests (#9799) * add `assertExactJsonStructure` to http-tests * formatting --------- Co-authored-by: Taylor Otwell --- http-tests.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/http-tests.md b/http-tests.md index 2f1b5d15ce3..4bb481f31e8 100644 --- a/http-tests.md +++ b/http-tests.md @@ -922,6 +922,7 @@ Laravel's `Illuminate\Testing\TestResponse` class provides a variety of custom a [assertDontSeeText](#assert-dont-see-text) [assertDownload](#assert-download) [assertExactJson](#assert-exact-json) +[assertExactJsonStructure](#assert-exact-json-structure) [assertForbidden](#assert-forbidden) [assertFound](#assert-found) [assertGone](#assert-gone) @@ -1073,6 +1074,15 @@ Assert that the response contains an exact match of the given JSON data: $response->assertExactJson(array $data); + +#### assertExactJsonStructure + +Assert that the response contains an exact match of the given JSON structure: + + $response->assertExactJsonStructure(array $data); + +This method is a more strict variant of [assertJsonStructure](#assert-json-structure). In contrast with `assertJsonStructure`, this method will fail if the response contains any keys that aren't explicitly included in the expected JSON structure. + #### assertForbidden From c9dfe787f83a020b09562c1e19bf46e9d9942bc7 Mon Sep 17 00:00:00 2001 From: Einar Hansen <49709354+einar-hansen@users.noreply.github.com> Date: Thu, 1 Aug 2024 22:48:34 +0200 Subject: [PATCH 134/325] Add documentation for the `whereNone` method (#9786) --- queries.md | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/queries.md b/queries.md index 402cb651a8d..1d47735cb48 100644 --- a/queries.md +++ b/queries.md @@ -13,7 +13,7 @@ - [Where Clauses](#where-clauses) - [Or Where Clauses](#or-where-clauses) - [Where Not Clauses](#where-not-clauses) - - [Where Any / All Clauses](#where-any-all-clauses) + - [Where Any / All / None Clauses](#where-any-all-none-clauses) - [JSON Where Clauses](#json-where-clauses) - [Additional Where Clauses](#additional-where-clauses) - [Logical Grouping](#logical-grouping) @@ -502,8 +502,8 @@ The `whereNot` and `orWhereNot` methods may be used to negate a given group of q }) ->get(); - -### Where Any / All Clauses + +### Where Any / All / None Clauses Sometimes you may need to apply the same query constraints to multiple columns. For example, you may want to retrieve all records where any columns in a given list are `LIKE` a given value. You may accomplish this using the `whereAny` method: @@ -549,6 +549,29 @@ WHERE published = true AND ( ) ``` +The `whereNone` method may be used to retrieve records where none of the given columns match a given constraint: + + $posts = DB::table('albums') + ->where('published', true) + ->whereNone([ + 'title', + 'lyrics', + 'tags', + ], 'like', '%explicit%') + ->get(); + +The query above will result in the following SQL: + +```sql +SELECT * +FROM albums +WHERE published = true AND NOT ( + title LIKE '%explicit%' OR + lyrics LIKE '%explicit%' OR + tags LIKE '%explicit%' +) +``` + ### JSON Where Clauses From 7c37dcbd8b069397002fcb852dcf2a96ff22abe2 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 1 Aug 2024 15:50:33 -0500 Subject: [PATCH 135/325] wip --- helpers.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/helpers.md b/helpers.md index 7ba4e6b1a38..e9fe2b66f96 100644 --- a/helpers.md +++ b/helpers.md @@ -100,6 +100,7 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct [Number::pairs](#method-number-pairs) [Number::percentage](#method-number-percentage) [Number::spell](#method-number-spell) +[Number::trim](#method-number-trim) [Number::useLocale](#method-number-use-locale) [Number::withLocale](#method-number-with-locale) @@ -1382,6 +1383,21 @@ The `until` argument allows you to specify a value before which all numbers shou // 10 + +#### `Number::trim()` {.collection-method} + +The `Number::trim` method removes any trailing zero digits after the decimal point of the given number: + + use Illuminate\Support\Number; + + $number = Number::trim(12.0); + + // 12 + + $number = Number::trim(12.30); + + // 12.3 + #### `Number::useLocale()` {.collection-method} From 19515e2285039cea35cd111047d6540b23641e21 Mon Sep 17 00:00:00 2001 From: Billy <44404782+dev-billy@users.noreply.github.com> Date: Mon, 5 Aug 2024 16:37:38 +0300 Subject: [PATCH 136/325] update: heroku CI chrome buildpack (#9807) --- dusk.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dusk.md b/dusk.md index f17e268e9c3..382867eba1e 100644 --- a/dusk.md +++ b/dusk.md @@ -2121,7 +2121,7 @@ To run Dusk tests on [Heroku CI](https://www.heroku.com/continuous-integration), "test": { "buildpacks": [ { "url": "heroku/php" }, - { "url": "https://github.com/heroku/heroku-buildpack-google-chrome" } + { "url": "https://github.com/heroku/heroku-buildpack-chrome-for-testing" } ], "scripts": { "test-setup": "cp .env.testing .env", From 696cad17f80605f1cf2ff68c97f60873500c55ca Mon Sep 17 00:00:00 2001 From: Jamie Wood Date: Mon, 5 Aug 2024 14:40:17 +0100 Subject: [PATCH 137/325] Correct import statement for Laravel Cashier Paddle (#9806) --- cashier-paddle.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cashier-paddle.md b/cashier-paddle.md index dc89180111b..0894f29b7b6 100644 --- a/cashier-paddle.md +++ b/cashier-paddle.md @@ -276,8 +276,8 @@ In this example, the `CompleteOrder` listener might look like the following: namespace App\Listeners; use App\Models\Order; - use Laravel\Cashier\Cashier; - use Laravel\Cashier\Events\TransactionCompleted; + use Laravel\Paddle\Cashier; + use Laravel\Paddle\Events\TransactionCompleted; class CompleteOrder { @@ -669,7 +669,7 @@ These defaults will be used for every action in Cashier that generates a [checko You can retrieve a customer by their Paddle Customer ID using the `Cashier::findBillable` method. This method will return an instance of the billable model: - use Laravel\Cashier\Cashier; + use Laravel\Paddle\Cashier; $user = Cashier::findBillable($customerId); @@ -1372,7 +1372,7 @@ When listing the transactions for a customer, you may use the transaction instan The `download-invoice` route may look like the following: use Illuminate\Http\Request; - use Laravel\Cashier\Transaction; + use Laravel\Paddle\Transaction; Route::get('/download-invoice/{transaction}', function (Request $request, Transaction $transaction) { return $transaction->redirectToInvoicePdf(); From 0d2416ba760b34f142688b853c9b6b7817de12da Mon Sep 17 00:00:00 2001 From: Jonathan Goode Date: Tue, 6 Aug 2024 14:50:13 +0100 Subject: [PATCH 138/325] Expand `forget()` example to include removing multiple keys at once (#9809) * Expand `forget()` example to include removing multiple keys at once * Update collections.md --------- Co-authored-by: Taylor Otwell --- collections.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/collections.md b/collections.md index e5794876299..c8c9198a7dc 100644 --- a/collections.md +++ b/collections.md @@ -1072,12 +1072,16 @@ The `forget` method removes an item from the collection by its key: $collection = collect(['name' => 'taylor', 'framework' => 'laravel']); + // Forget a single key... $collection->forget('name'); - $collection->all(); - // ['framework' => 'laravel'] + // Forget multiple keys... + $collection->forget(['name', 'framework']); + + // [] + > [!WARNING] > Unlike most other collection methods, `forget` does not return a new modified collection; it modifies the collection it is called on. From f3ddbdea6c9b79bcf096bee439ce202763d1447a Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 6 Aug 2024 09:04:10 -0500 Subject: [PATCH 139/325] wip --- queues.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/queues.md b/queues.md index baf03958e00..b54d1a90689 100644 --- a/queues.md +++ b/queues.md @@ -2395,7 +2395,7 @@ In addition, you may occasionally need to test an individual job's interaction w Sometimes, you may need to test that a queued job [releases itself back onto the queue](#manually-releasing-a-job). Or, you may need to test that the job deleted itself. You may test these queue interactions by instantiating the job and invoking the `withFakeQueueInteractions` method. -Once the job's queue interactions have been faked, you may invoke the `handle` method on the job. After invoking the job, the `assertReleased`, `assertDeleted`, and `assertFailed` methods may be used to make assertions against the job's queue interactions: +Once the job's queue interactions have been faked, you may invoke the `handle` method on the job. After invoking the job, the `assertReleased`, `assertDeleted`, `assertNotDeleted`, `assertFailed`, and `assertNotFailed` methods may be used to make assertions against the job's queue interactions: ```php use App\Jobs\ProcessPodcast; @@ -2406,7 +2406,9 @@ $job->handle(); $job->assertReleased(delay: 30); $job->assertDeleted(); +$job->assertNotDeleted(); $job->assertFailed(); +$job->assertNotFailed(); ``` From 37a8b499fc099ea49dd232d64c6cc4fd3f7ad7f7 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 6 Aug 2024 09:08:24 -0500 Subject: [PATCH 140/325] wip --- errors.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/errors.md b/errors.md index 3d5fbf1f92f..15c743d1fc6 100644 --- a/errors.md +++ b/errors.md @@ -167,6 +167,22 @@ When building your application, there will be some types of exceptions you never ]); }) +Alternatively, you may simply "mark" an exception class with the `Illuminate\Contracts\Debug\ShouldntReport` interface. When an exception is marked with this interface, it will never be reported by Laravel's exception handler: + +```php + Date: Tue, 6 Aug 2024 09:17:21 -0500 Subject: [PATCH 141/325] wip --- context.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/context.md b/context.md index 43b91b00387..a524d47508b 100644 --- a/context.md +++ b/context.md @@ -183,6 +183,29 @@ DB::listen(function ($event) { }); ``` +You may determine if a value is in a stack using the `stackContains` and `hiddenStackContains` methods: + +```php +if (Context::stackContains('breadcrumbs', 'first_value')) { + // +} + +if (Context::hiddenStackContains('secrets', 'first_value')) { + // +} +``` + +The `stackContains` and `hiddenStackContains` methods also accept a closure as their second argument, allowing more control over the value comparison operation: + +```php +use Illuminate\Support\Facades\Context; +use Illuminate\Support\Str; + +return Context::stackContains('breadcrumbs', function ($value) { + return Str::startsWith($value, 'query_'); +}); +``` + ## Retrieving Context From 31e0ff9637c196639731f4aae69eb718f5ed31ed Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 7 Aug 2024 13:25:42 -0500 Subject: [PATCH 142/325] wip --- blade.md | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/blade.md b/blade.md index 9a99018e9bd..1a414a60322 100644 --- a/blade.md +++ b/blade.md @@ -869,7 +869,7 @@ You may execute this method from your component template by invoking the variabl #### Accessing Attributes and Slots Within Component Classes -Blade components also allow you to access the component name, attributes, and slot inside the class's render method. However, in order to access this data, you should return a closure from your component's `render` method. The closure will receive a `$data` array as its only argument. This array will contain several elements that provide information about the component: +Blade components also allow you to access the component name, attributes, and slot inside the class's render method. However, in order to access this data, you should return a closure from your component's `render` method: use Closure; @@ -878,15 +878,24 @@ Blade components also allow you to access the component name, attributes, and sl */ public function render(): Closure { - return function (array $data) { - // $data['componentName']; - // $data['attributes']; - // $data['slot']; - - return '
Components content
'; + return function () { + return '
Components content
'; }; } +The closure returned by your component's `render` method may also receive a `$data` array as its only argument. This array will contain several elements that provide information about the component: + + return function (array $data) { + // $data['componentName']; + // $data['attributes']; + // $data['slot']; + + return '
Components content
'; + } + +> [!WARNING] +> The elements in the `$data` array should never be directly embedded into the Blade string returned by your `render` method, as doing so could allow remote code execution via malicious attribute content. + The `componentName` is equal to the name used in the HTML tag after the `x-` prefix. So ``'s `componentName` will be `alert`. The `attributes` element will contain all of the attributes that were present on the HTML tag. The `slot` element is an `Illuminate\Support\HtmlString` instance with the contents of the component's slot. The closure should return a string. If the returned string corresponds to an existing view, that view will be rendered; otherwise, the returned string will be evaluated as an inline Blade view. From e0d1667c25ab949e0a7c60c3e940f22f745a4e17 Mon Sep 17 00:00:00 2001 From: Samuel Date: Thu, 8 Aug 2024 15:31:33 +0200 Subject: [PATCH 143/325] Include Str::transliterate method (#9810) * Include Str::transliterate method * Methods in alphabetical order --- strings.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/strings.md b/strings.md index 661faf47915..fc2881bb116 100644 --- a/strings.md +++ b/strings.md @@ -99,6 +99,7 @@ Laravel includes a variety of functions for manipulating string values. Many of [Str::title](#method-title-case) [Str::toBase64](#method-str-to-base64) [Str::toHtmlString](#method-str-to-html-string) +[Str::transliterate](#method-str-transliterate) [Str::trim](#method-str-trim) [Str::ltrim](#method-str-ltrim) [Str::rtrim](#method-str-rtrim) @@ -201,6 +202,7 @@ Laravel includes a variety of functions for manipulating string values. Many of [test](#method-fluent-str-test) [title](#method-fluent-str-title) [toBase64](#method-fluent-str-to-base64) +[transliterate](#method-fluent-str-transliterate) [trim](#method-fluent-str-trim) [ltrim](#method-fluent-str-ltrim) [rtrim](#method-fluent-str-rtrim) @@ -1255,6 +1257,17 @@ The `Str::toHtmlString` method converts the string instance to an instance of `I $htmlString = Str::of('Nuno Maduro')->toHtmlString(); + +#### `Str::transliterate()` {.collection-method} + +The `Str::transliterate` method will attempt to convert a given string into its closest ASCII representation: + + use Illuminate\Support\Str; + + $email = Str::transliterate('ⓣⓔⓢⓣ@ⓛⓐⓡⓐⓥⓔⓛ.ⓒⓞⓜ'); + + // 'test@laravel.com' + #### `Str::trim()` {.collection-method} @@ -2626,6 +2639,17 @@ The `toBase64` method converts the given string to Base64: // TGFyYXZlbA== + +#### `transliterate` {.collection-method} + +The `transliterate` method will attempt to convert a given string into its closest ASCII representation: + + use Illuminate\Support\Str; + + $email = Str::of('ⓣⓔⓢⓣ@ⓛⓐⓡⓐⓥⓔⓛ.ⓒⓞⓜ')->transliterate() + + // 'test@laravel.com' + #### `trim` {.collection-method} From 2eca63c072ec744450de8d45383a3e209205c51d Mon Sep 17 00:00:00 2001 From: "Devon S." <20716219+NintenZone@users.noreply.github.com> Date: Mon, 12 Aug 2024 16:02:20 -0600 Subject: [PATCH 144/325] Feat: Add Warning to Clarify optimize:clear Command Behavior (#9817) * Feat: Add Warning to Clarify optimize:clear Command Behavior * Update deployment.md --------- Co-authored-by: Taylor Otwell --- deployment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment.md b/deployment.md index 1cc4a57297f..ccf8ee042b9 100644 --- a/deployment.md +++ b/deployment.md @@ -115,7 +115,7 @@ When deploying your application to production, there are a variety of files that php artisan optimize ``` -The `optimize:clear` method may be used to remove all of the cache files generated by the `optimize` command: +The `optimize:clear` method may be used to remove all of the cache files generated by the `optimize` command as well as all keys in the default cache driver: ```shell php artisan optimize:clear From de9fad85c69806902a3b809731229513142a66f3 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 12 Aug 2024 17:08:54 -0500 Subject: [PATCH 145/325] [11.x] add clarification on component slot escaping (#9813) * add clarification on component slot escaping this was a little confusing to me when I first saw it, so wanted to add some clarification. it is likely, especially when using a component for your layout, that the `$slot` variable will contain HTML. however, the docs show the `{{ $slot }}` escaped version. although I'm not exactly sure where this happens in the code, it seems that a slot is treated specially, and does not escape content. All code inside the slot appears to respect any escaped or unescaped content. I've also added a wrapping `
` around each task to more closely reflect a real world use, and to further drive home the `$slot` will handle any HTML content it is provided. * Update blade.md --------- Co-authored-by: Taylor Otwell --- blade.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blade.md b/blade.md index 1a414a60322..d1a15aab66b 100644 --- a/blade.md +++ b/blade.md @@ -1506,7 +1506,7 @@ Once the `layout` component has been defined, we may create a Blade view that ut @foreach ($tasks as $task) - {{ $task }} +
{{ $task }}
@endforeach
``` @@ -1522,7 +1522,7 @@ Remember, content that is injected into a component will be supplied to the defa @foreach ($tasks as $task) - {{ $task }} +
{{ $task }}
@endforeach ``` From 40205ebb0d28371a20c2dc5b0b035f74e3056ae7 Mon Sep 17 00:00:00 2001 From: Brandon Surowiec Date: Mon, 12 Aug 2024 18:09:43 -0400 Subject: [PATCH 146/325] Bring Fortify::authenticateThrough() default pipeline definition up to date (#9816) * Update fortify.md Bring Fortify default pipeline definition up to date. * Update fortify.md Add missing Laravel\Fortify\Features import. --- fortify.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fortify.md b/fortify.md index 4e6c83dbbf4..28d5b6e1ff5 100644 --- a/fortify.md +++ b/fortify.md @@ -189,15 +189,18 @@ The example below contains the default pipeline definition that you may use as a ```php use Laravel\Fortify\Actions\AttemptToAuthenticate; +use Laravel\Fortify\Actions\CanonicalizeUsername; use Laravel\Fortify\Actions\EnsureLoginIsNotThrottled; use Laravel\Fortify\Actions\PrepareAuthenticatedSession; use Laravel\Fortify\Actions\RedirectIfTwoFactorAuthenticatable; +use Laravel\Fortify\Features; use Laravel\Fortify\Fortify; use Illuminate\Http\Request; Fortify::authenticateThrough(function (Request $request) { return array_filter([ config('fortify.limiters.login') ? null : EnsureLoginIsNotThrottled::class, + config('fortify.lowercase_usernames') ? CanonicalizeUsername::class : null, Features::enabled(Features::twoFactorAuthentication()) ? RedirectIfTwoFactorAuthenticatable::class : null, AttemptToAuthenticate::class, PrepareAuthenticatedSession::class, From c6bcf0c0842a910b2118791a10ab57e624009576 Mon Sep 17 00:00:00 2001 From: LiveSource Date: Wed, 14 Aug 2024 05:18:46 +1200 Subject: [PATCH 147/325] Document the ability to forget all horizon failed jobs (#9818) * Document the ability to forget all horizon failed jobs * Update horizon.md --------- Co-authored-by: Taylor Otwell --- horizon.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/horizon.md b/horizon.md index 5ad26553a37..1124a947ebf 100644 --- a/horizon.md +++ b/horizon.md @@ -424,6 +424,12 @@ If you would like to delete a failed job, you may use the `horizon:forget` comma php artisan horizon:forget 5 ``` +If you would like to delete all failed jobs, you may provide the `--all` option to the `horizon:forget` command: + +```shell +php artisan horizon:forget --all +``` + ## Clearing Jobs From Queues From fe1d4567fe5402750c54d3f6277f9b84c8b441a1 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 13 Aug 2024 08:16:00 -1000 Subject: [PATCH 148/325] update potentially incorrect interface --- events.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/events.md b/events.md index a5e21f2dde1..dc14cabc4f1 100644 --- a/events.md +++ b/events.md @@ -389,17 +389,16 @@ If you need to manually access the listener's underlying queue job's `delete` an When queued listeners are dispatched within database transactions, they may be processed by the queue before the database transaction has committed. When this happens, any updates you have made to models or database records during the database transaction may not yet be reflected in the database. In addition, any models or database records created within the transaction may not exist in the database. If your listener depends on these models, unexpected errors can occur when the job that dispatches the queued listener is processed. -If your queue connection's `after_commit` configuration option is set to `false`, you may still indicate that a particular queued listener should be dispatched after all open database transactions have been committed by implementing the `ShouldHandleEventsAfterCommit` interface on the listener class: +If your queue connection's `after_commit` configuration option is set to `false`, you may still indicate that a particular queued listener should be dispatched after all open database transactions have been committed by implementing the `ShouldQueueAfterCommit` interface on the listener class: Date: Wed, 14 Aug 2024 22:57:29 +0100 Subject: [PATCH 149/325] fix: avoid page overflow with long table rows (#9820) --- authentication.md | 4 ++++ cache.md | 4 ++++ configuration.md | 4 ++++ passport.md | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/authentication.md b/authentication.md index ffad7e5445a..aea40410552 100644 --- a/authentication.md +++ b/authentication.md @@ -741,6 +741,8 @@ Once the configuration file has been published, you may set the `rehash_on_login Laravel dispatches a variety of [events](/docs/{{version}}/events) during the authentication process. You may [define listeners](/docs/{{version}}/events) for any of the following events: +
+ | Event Name | | --- | | `Illuminate\Auth\Events\Registered` | @@ -755,3 +757,5 @@ Laravel dispatches a variety of [events](/docs/{{version}}/events) during the au | `Illuminate\Auth\Events\OtherDeviceLogout` | | `Illuminate\Auth\Events\Lockout` | | `Illuminate\Auth\Events\PasswordReset` | + +
diff --git a/cache.md b/cache.md index c7d4757ed0d..e4df87a66b0 100644 --- a/cache.md +++ b/cache.md @@ -440,6 +440,8 @@ Once your extension is registered, update the `CACHE_STORE` environment variable To execute code on every cache operation, you may listen for various [events](/docs/{{version}}/events) dispatched by the cache: +
+ | Event Name | | --- | | `Illuminate\Cache\Events\CacheHit` | @@ -447,6 +449,8 @@ To execute code on every cache operation, you may listen for various [events](/d | `Illuminate\Cache\Events\KeyForgotten` | | `Illuminate\Cache\Events\KeyWritten` | +
+ To increase performance, you may disable cache events by setting the `events` configuration option to `false` for a given cache store in your application's `config/cache.php` configuration file: ```php diff --git a/configuration.md b/configuration.md index 93306a3e2a9..eed3d3cf03e 100644 --- a/configuration.md +++ b/configuration.md @@ -71,6 +71,8 @@ Before loading your application's environment variables, Laravel determines if a All variables in your `.env` files are typically parsed as strings, so some reserved values have been created to allow you to return a wider range of types from the `env()` function: +
+ | `.env` Value | `env()` Value | | ------------ | ------------- | | true | (bool) true | @@ -82,6 +84,8 @@ All variables in your `.env` files are typically parsed as strings, so some rese | null | (null) null | | (null) | (null) null | +
+ If you need to define an environment variable with a value that contains spaces, you may do so by enclosing the value in double quotes: ```ini diff --git a/passport.md b/passport.md index c3b5cc4308c..8e06f93ff57 100644 --- a/passport.md +++ b/passport.md @@ -1162,11 +1162,15 @@ When using this method of authentication, you will need to ensure a valid CSRF t Passport raises events when issuing access tokens and refresh tokens. You may [listen for these events](/docs/{{version}}/events) to prune or revoke other access tokens in your database: +
+ | Event Name | | --- | | `Laravel\Passport\Events\AccessTokenCreated` | | `Laravel\Passport\Events\RefreshTokenCreated` | +
+ ## Testing From 527e6a3ba876a0b249dfe25de0582d5b1cd9907f Mon Sep 17 00:00:00 2001 From: Adam <56907039+adamjsturge@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:09:25 -0700 Subject: [PATCH 150/325] Added subnet to trustedProxies example to show it's supported (#9821) --- requests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requests.md b/requests.md index 65871c45a82..1911bc51ae4 100644 --- a/requests.md +++ b/requests.md @@ -604,7 +604,7 @@ To solve this, you may enable the `Illuminate\Http\Middleware\TrustProxies` midd ->withMiddleware(function (Middleware $middleware) { $middleware->trustProxies(at: [ '192.168.1.1', - '192.168.1.2', + '10.0.0.0/8', ]); }) From cd97d3e2b5871b662ed4c2cdfbc104473f13d207 Mon Sep 17 00:00:00 2001 From: Francisco Amaral Date: Thu, 15 Aug 2024 19:15:06 +0100 Subject: [PATCH 151/325] Update trustHosts() documentation to reflect fix (#9822) * Add trustHosts() documentation when hosts are fetched from configuration file Document the fix from https://github.com/laravel/framework/pull/50877, triggered by issue https://github.com/laravel/framework/issues/50845 * Update requests.md --------- Co-authored-by: Taylor Otwell --- requests.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/requests.md b/requests.md index 1911bc51ae4..673bc7c83c2 100644 --- a/requests.md +++ b/requests.md @@ -649,3 +649,9 @@ By default, requests coming from subdomains of the application's URL are also au ->withMiddleware(function (Middleware $middleware) { $middleware->trustHosts(at: ['laravel.test'], subdomains: false); }) + +If you need to access your application's configuration files or database to determine your trusted hosts, you may provide a closure to the `at` argument: + + ->withMiddleware(function (Middleware $middleware) { + $middleware->trustHosts(at: fn () => config('app.trusted_hosts')); + }) From 736c61401b4dbcdad73362c66a906aaef4c0c158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Baconnier?= Date: Fri, 16 Aug 2024 20:01:33 +0200 Subject: [PATCH 152/325] Fix trustProxies (#9825) --- sail.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sail.md b/sail.md index 3811046a3d6..bd20494facb 100644 --- a/sail.md +++ b/sail.md @@ -460,9 +460,7 @@ sail share When sharing your site via the `share` command, you should configure your application's trusted proxies using the `trustProxies` middleware method in your application's `bootstrap/app.php` file. Otherwise, URL generation helpers such as `url` and `route` will be unable to determine the correct HTTP host that should be used during URL generation: ->withMiddleware(function (Middleware $middleware) { - $middleware->trustProxies(at: [ - '*', - ]); + $middleware->trustProxies(at: '*'); }) If you would like to choose the subdomain for your shared site, you may provide the `subdomain` option when executing the `share` command: From 35e8bf2eb40a1e871501dad494ede4fd31aef157 Mon Sep 17 00:00:00 2001 From: Jess Archer Date: Sat, 17 Aug 2024 04:05:17 +1000 Subject: [PATCH 153/325] [11.x] Update caveat for Vite URL processing with absolute paths and dedicated CSS entrypoints. (#9824) * Improve caveat on Vite URL processing with absolute paths * Update vite.md --------- Co-authored-by: Taylor Otwell --- vite.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vite.md b/vite.md index 559549289b5..e04548df157 100644 --- a/vite.md +++ b/vite.md @@ -411,7 +411,7 @@ createInertiaApp({ ### URL Processing -When using Vite and referencing assets in your application's HTML, CSS, or JS, there are a couple of caveats to consider. First, if you reference assets with an absolute path, Vite will not include the asset in the build; therefore, you should ensure that the asset is available in your public directory. +When using Vite and referencing assets in your application's HTML, CSS, or JS, there are a couple of caveats to consider. First, if you reference assets with an absolute path, Vite will not include the asset in the build; therefore, you should ensure that the asset is available in your public directory. You should avoid using absolute paths when using a [dedicated CSS entrypoint](#configuring-vite) because, during development, browsers will try to load these paths from the Vite development server, where the CSS is hosted, rather than from your public directory. When referencing relative asset paths, you should remember that the paths are relative to the file where they are referenced. Any assets referenced via a relative path will be re-written, versioned, and bundled by Vite. From a87913b96b32f8e31022388626a9b008b7f17b9b Mon Sep 17 00:00:00 2001 From: Andrew Jorgenson Date: Fri, 16 Aug 2024 20:32:51 -0400 Subject: [PATCH 154/325] Update PHPunit test reference to match Pest (#9828) --- helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers.md b/helpers.md index e9fe2b66f96..6b24ab85eeb 100644 --- a/helpers.md +++ b/helpers.md @@ -2530,7 +2530,7 @@ it('checks if ready three times', function () { ``` ```php tab=PHPUnit -public function test_it_checks_if_ready_four_times() +public function test_it_checks_if_ready_three_times() { Sleep::fake(); From 6e5d9d7ce2304218bc19aca7d77b6e4327688ab2 Mon Sep 17 00:00:00 2001 From: "Axel C. Lopez" Date: Sun, 18 Aug 2024 23:04:13 -0300 Subject: [PATCH 155/325] Fix broken links to #middleware-aliases (#9829) --- authentication.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/authentication.md b/authentication.md index aea40410552..0935e54aca8 100644 --- a/authentication.md +++ b/authentication.md @@ -182,7 +182,7 @@ To determine if the user making the incoming HTTP request is authenticated, you ### Protecting Routes -[Route middleware](/docs/{{version}}/middleware) can be used to only allow authenticated users to access a given route. Laravel ships with an `auth` middleware, which is a [middleware alias](/docs/{{version}}/middleware#middleware-alias) for the `Illuminate\Auth\Middleware\Authenticate` class. Since this middleware is already aliased internally by Laravel, all you need to do is attach the middleware to a route definition: +[Route middleware](/docs/{{version}}/middleware) can be used to only allow authenticated users to access a given route. Laravel ships with an `auth` middleware, which is a [middleware alias](/docs/{{version}}/middleware#middleware-aliases) for the `Illuminate\Auth\Middleware\Authenticate` class. Since this middleware is already aliased internally by Laravel, all you need to do is attach the middleware to a route definition: Route::get('/flights', function () { // Only authenticated users may access this route... @@ -458,7 +458,7 @@ In addition to calling the `logout` method, it is recommended that you invalidat Laravel also provides a mechanism for invalidating and "logging out" a user's sessions that are active on other devices without invalidating the session on their current device. This feature is typically utilized when a user is changing or updating their password and you would like to invalidate sessions on other devices while keeping the current device authenticated. -Before getting started, you should make sure that the `Illuminate\Session\Middleware\AuthenticateSession` middleware is included on the routes that should receive session authentication. Typically, you should place this middleware on a route group definition so that it can be applied to the majority of your application's routes. By default, the `AuthenticateSession` middleware may be attached to a route using the `auth.session` [middleware alias](/docs/{{version}}/middleware#middleware-alias): +Before getting started, you should make sure that the `Illuminate\Session\Middleware\AuthenticateSession` middleware is included on the routes that should receive session authentication. Typically, you should place this middleware on a route group definition so that it can be applied to the majority of your application's routes. By default, the `AuthenticateSession` middleware may be attached to a route using the `auth.session` [middleware alias](/docs/{{version}}/middleware#middleware-aliases): Route::middleware(['auth', 'auth.session'])->group(function () { Route::get('/', function () { From 8a54e92ce9007cc47b505a52fa97c1ad9b2555b4 Mon Sep 17 00:00:00 2001 From: adhham Date: Mon, 19 Aug 2024 07:10:14 +0500 Subject: [PATCH 156/325] Added info on ignoring case for "contains" and "containsAll" methods (#9811) * Add info on ignoring the case for "contains" and "containsAll" methods Added information on how to ignore the case when using "contains" and "containsAll" methods. * Use named arguments * Update strings.md * Update strings.md --------- Co-authored-by: Taylor Otwell --- strings.md | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/strings.md b/strings.md index fc2881bb116..ed7382cd60f 100644 --- a/strings.md +++ b/strings.md @@ -424,7 +424,7 @@ You may also pass an array as the second argument. If the string ends with any o #### `Str::contains()` {.collection-method} -The `Str::contains` method determines if the given string contains the given value. This method is case sensitive: +The `Str::contains` method determines if the given string contains the given value. By default this method is case sensitive: use Illuminate\Support\Str; @@ -440,6 +440,14 @@ You may also pass an array of values to determine if the given string contains a // true +You may disable case sensitivity by setting the `ignoreCase` argument to `true`: + + use Illuminate\Support\Str; + + $contains = Str::contains('This is my name', 'MY', ignoreCase: true); + + // true + #### `Str::containsAll()` {.collection-method} @@ -451,6 +459,14 @@ The `Str::containsAll` method determines if the given string contains all of the // true +You may disable case sensitivity by setting the `ignoreCase` argument to `true`: + + use Illuminate\Support\Str; + + $containsAll = Str::containsAll('This is my name', ['MY', 'NAME'], ignoreCase: true); + + // true + #### `Str::endsWith()` {.collection-method} @@ -1686,7 +1702,7 @@ You may also pass an array. If the string ends with any of the values in the arr #### `contains` {.collection-method} -The `contains` method determines if the given string contains the given value. This method is case sensitive: +The `contains` method determines if the given string contains the given value. By default this method is case sensitive: use Illuminate\Support\Str; @@ -1702,6 +1718,14 @@ You may also pass an array of values to determine if the given string contains a // true +You can disable case sensitivity by setting the `ignoreCase` argument to `true`: + + use Illuminate\Support\Str; + + $contains = Str::of('This is my name')->contains('MY', ignoreCase: true); + + // true + #### `containsAll` {.collection-method} @@ -1713,6 +1737,14 @@ The `containsAll` method determines if the given string contains all of the valu // true +You can disable case sensitivity by setting the `ignoreCase` argument to `true`: + + use Illuminate\Support\Str; + + $containsAll = Str::of('This is my name')->containsAll(['MY', 'NAME'], ignoreCase: true); + + // true + #### `dirname` {.collection-method} From 08f56047b25bb3e7ed46da76883238e8b0fc13d4 Mon Sep 17 00:00:00 2001 From: tadhgboyle Date: Tue, 20 Aug 2024 07:48:55 -0700 Subject: [PATCH 157/325] Fix remember named param syntax (#9832) --- authentication.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/authentication.md b/authentication.md index 0935e54aca8..586f2f29033 100644 --- a/authentication.md +++ b/authentication.md @@ -362,7 +362,7 @@ To authenticate a user using their database record's primary key, you may use th You may pass a boolean value as the second argument to the `loginUsingId` method. This value indicates if "remember me" functionality is desired for the authenticated session. Remember, this means that the session will be authenticated indefinitely or until the user manually logs out of the application: - Auth::loginUsingId(1, $remember = true); + Auth::loginUsingId(1, remember: true); #### Authenticate a User Once From 03cecc6287a59cfed872ee77de67e61ac1706e25 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 20 Aug 2024 09:49:30 -0500 Subject: [PATCH 158/325] wip --- authentication.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/authentication.md b/authentication.md index 586f2f29033..8a56d1a435c 100644 --- a/authentication.md +++ b/authentication.md @@ -360,7 +360,7 @@ To authenticate a user using their database record's primary key, you may use th Auth::loginUsingId(1); -You may pass a boolean value as the second argument to the `loginUsingId` method. This value indicates if "remember me" functionality is desired for the authenticated session. Remember, this means that the session will be authenticated indefinitely or until the user manually logs out of the application: +You may pass a boolean value to the `remember` argument of the `loginUsingId` method. This value indicates if "remember me" functionality is desired for the authenticated session. Remember, this means that the session will be authenticated indefinitely or until the user manually logs out of the application: Auth::loginUsingId(1, remember: true); From 3a2fa3ea59532f3239ae737ae78d0ffd1922c4c8 Mon Sep 17 00:00:00 2001 From: Noboru Shiroiwa <14008307+nshiro@users.noreply.github.com> Date: Tue, 20 Aug 2024 23:50:54 +0900 Subject: [PATCH 159/325] Rename `link` to `links` (#9831) --- eloquent-resources.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eloquent-resources.md b/eloquent-resources.md index 20e0122c2bd..ea01e2d81bf 100644 --- a/eloquent-resources.md +++ b/eloquent-resources.md @@ -675,7 +675,7 @@ If your intermediate table is using an accessor other than `pivot`, you may use ### Adding Meta Data -Some JSON API standards require the addition of meta data to your resource and resource collections responses. This often includes things like `links` to the resource or related resources, or meta data about the resource itself. If you need to return additional meta data about a resource, include it in your `toArray` method. For example, you might include `link` information when transforming a resource collection: +Some JSON API standards require the addition of meta data to your resource and resource collections responses. This often includes things like `links` to the resource or related resources, or meta data about the resource itself. If you need to return additional meta data about a resource, include it in your `toArray` method. For example, you might include `links` information when transforming a resource collection: /** * Transform the resource into an array. From 24a9f991e9a7aa18f32e4ed48a5b2abd6ab0b99d Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 20 Aug 2024 16:32:10 -0500 Subject: [PATCH 160/325] expectsSearch --- console-tests.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/console-tests.md b/console-tests.md index 9b8c8d991fe..826a7a9f938 100644 --- a/console-tests.md +++ b/console-tests.md @@ -86,6 +86,36 @@ public function test_console_command(): void } ``` +If you are utilizing the `search` or `multisearch` functions provided by [Laravel Prompts](/docs/{{version}}/prompts), you may use the `expectsSearch` assertion to mock the user's input, search results, and selection: + +```php tab=Pest +test('console command', function () { + $this->artisan('example') + ->expectsSearch('What is your name?', search: 'Tay', answers: [ + 'Taylor Otwell', + 'Taylor Swift', + 'Darian Taylor' + ], answer: 'Taylor Otwell') + ->assertExitCode(0); +}); +``` + +```php tab=PHPUnit +/** + * Test a console command. + */ +public function test_console_command(): void +{ + $this->artisan('example') + ->expectsSearch('What is your name?', search: 'Tay', answers: [ + 'Taylor Otwell', + 'Taylor Swift', + 'Darian Taylor' + ], answer: 'Taylor Otwell') + ->assertExitCode(0); +} +``` + You may also assert that a console command does not generate any output using the `doesntExpectOutput` method: ```php tab=Pest From 05a382c6e7721b9a243773f3e86114bf001280f4 Mon Sep 17 00:00:00 2001 From: Peter Elmered Date: Wed, 21 Aug 2024 18:01:43 +0200 Subject: [PATCH 161/325] Remove canSelectAll example (#9834) It looks like this parameter was reverted and replaced with a keyboard shortcut. See the PR here: https://github.com/laravel/prompts/pull/147 --- prompts.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/prompts.md b/prompts.md index dabba4d6bea..3b088a2c46c 100644 --- a/prompts.md +++ b/prompts.md @@ -421,16 +421,6 @@ $categories = multiselect( ); ``` -You may allow the user to easily select all options via the `canSelectAll` argument: - -```php -$categories = multiselect( - label: 'What categories should be assigned?', - options: Category::pluck('name', 'id'), - canSelectAll: true -); -``` - #### Requiring a Value From 8bc2cdb5a19e7e757da97a6b4572dedb230f25b1 Mon Sep 17 00:00:00 2001 From: iainco <84080628+iainco@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:01:58 +0100 Subject: [PATCH 162/325] Update horizon.md (typo) (#9833) --- horizon.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/horizon.md b/horizon.md index 1124a947ebf..d1d8405e339 100644 --- a/horizon.md +++ b/horizon.md @@ -230,7 +230,7 @@ You may check the current status of the Horizon process using the `horizon:statu php artisan horizon:status ``` -You may gracefully terminate the Horizon process using the `horizon:terminate` Artisan command. Any jobs that are currently being processed by will be completed and then Horizon will stop executing: +You may gracefully terminate the Horizon process using the `horizon:terminate` Artisan command. Any jobs that are currently being processed will be completed and then Horizon will stop executing: ```shell php artisan horizon:terminate From af8926466f6afe7dd8415d751c9c95cda7aa1965 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Aug 2024 14:48:53 -0500 Subject: [PATCH 163/325] feature instances --- pennant.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pennant.md b/pennant.md index 71da2a38e88..1d8e04a2411 100644 --- a/pennant.md +++ b/pennant.md @@ -143,6 +143,14 @@ class NewApi } ``` +If you would like to manually resolve an instance of a class based feature, you may invoke the `instance` method on the `Feature` facade: + +```php +use Illuminate\Support\Facades\Feature; + +$instance = Feature::instance(NewApi::class); +``` + > [!NOTE] > Feature classes are resolved via the [container](/docs/{{version}}/container), so you may inject dependencies into the feature class's constructor when needed. From 9bbce539dc2e2ca0efe0b035bf87db8e3b2ec0e4 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Aug 2024 16:24:34 -0500 Subject: [PATCH 164/325] force destroy --- eloquent.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eloquent.md b/eloquent.md index 46d75a76917..514a2d535a4 100644 --- a/eloquent.md +++ b/eloquent.md @@ -927,6 +927,10 @@ In the example above, we are retrieving the model from the database before calli Flight::destroy(collect([1, 2, 3])); +If you are utilizing [soft deleting models](#soft-deleting), you may permanently delete models via the `forceDestroy` method: + + Flight::forceDestroy(1); + > [!WARNING] > The `destroy` method loads each model individually and calls the `delete` method so that the `deleting` and `deleted` events are properly dispatched for each model. From 6441ead7d4b19a8c39576b9f8e52452f7b075b64 Mon Sep 17 00:00:00 2001 From: Einar Hansen <49709354+einar-hansen@users.noreply.github.com> Date: Wed, 21 Aug 2024 23:25:06 +0200 Subject: [PATCH 165/325] Add the resource method to the http client docs (#9812) --- http-client.md | 1 + 1 file changed, 1 insertion(+) diff --git a/http-client.md b/http-client.md index ca74f4d5fa9..2e49325fe7b 100644 --- a/http-client.md +++ b/http-client.md @@ -38,6 +38,7 @@ The `get` method returns an instance of `Illuminate\Http\Client\Response`, which $response->json($key = null, $default = null) : mixed; $response->object() : object; $response->collect($key = null) : Illuminate\Support\Collection; + $response->resource() : resource; $response->status() : int; $response->successful() : bool; $response->redirect(): bool; From de98ca780d45beb9772ba7febf85e6de6531b06a Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Aug 2024 16:35:39 -0500 Subject: [PATCH 166/325] transform --- prompts.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/prompts.md b/prompts.md index 3b088a2c46c..7ac4de4b0fa 100644 --- a/prompts.md +++ b/prompts.md @@ -13,6 +13,7 @@ - [Search](#search) - [Multi-search](#multisearch) - [Pause](#pause) +- [Transforming Input Before Validation](#transforming-input-before-validation) - [Forms](#forms) - [Informational Messages](#informational-messages) - [Tables](#tables) @@ -721,6 +722,23 @@ use function Laravel\Prompts\pause; pause('Press ENTER to continue.'); ``` + +## Transforming Input Before Validation + +Sometimes you may want to transform the prompt input before validation takes place. For example, you may wish to remove white space from any provided strings. To accomplish this, many of the prompt functions provide a `transform` argument, which accepts a closure: + +```php +$name = text( + label: 'What is your name?', + transform: fn (string $value) => trim($value), + validate: fn (string $value) => match (true) { + strlen($value) < 3 => 'The name must be at least 3 characters.', + strlen($value) > 255 => 'The name must not exceed 255 characters.', + default => null + } +); +``` + ## Forms From a6124510a5db5a83e9268fafdb48b6cc8e1ebbb1 Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Thu, 22 Aug 2024 12:35:52 +1000 Subject: [PATCH 167/325] Header fixes (#9836) --- middleware.md | 1 - routing.md | 1 - session.md | 2 +- strings.md | 1 - upgrade.md | 1 - 5 files changed, 1 insertion(+), 5 deletions(-) diff --git a/middleware.md b/middleware.md index 3d245a89313..9938bfe0aac 100644 --- a/middleware.md +++ b/middleware.md @@ -61,7 +61,6 @@ It's best to envision middleware as a series of "layers" HTTP requests must pass > [!NOTE] > All middleware are resolved via the [service container](/docs/{{version}}/container), so you may type-hint any dependencies you need within a middleware's constructor. - #### Middleware and Responses diff --git a/routing.md b/routing.md index 12e4d050166..0821accd1f2 100644 --- a/routing.md +++ b/routing.md @@ -552,7 +552,6 @@ Typically, implicit model binding will not retrieve models that have been [soft return $user->email; })->withTrashed(); - #### Customizing the Key diff --git a/session.md b/session.md index c01fddf0b7a..e7ef049a5a6 100644 --- a/session.md +++ b/session.md @@ -185,7 +185,7 @@ The `pull` method will retrieve and delete an item from the session in a single $value = $request->session()->pull('key', 'default'); - + #### Incrementing and Decrementing Session Values If your session data contains an integer you wish to increment or decrement, you may use the `increment` and `decrement` methods: diff --git a/strings.md b/strings.md index ed7382cd60f..9408404fb6d 100644 --- a/strings.md +++ b/strings.md @@ -372,7 +372,6 @@ The `Str::camel` method converts the given string to `camelCase`: // 'fooBar' - #### `Str::charAt()` {.collection-method} The `Str::charAt` method returns the character at the specified index. If the index is out of bounds, `false` is returned: diff --git a/upgrade.md b/upgrade.md index d76be13755d..381f486024c 100644 --- a/upgrade.md +++ b/upgrade.md @@ -164,7 +164,6 @@ public function getAuthPasswordName() The default `User` model included with Laravel receives this method automatically since the method is included within the `Illuminate\Auth\Authenticatable` trait. - #### The `AuthenticationException` Class **Likelihood Of Impact: Very Low** From 8758bd2c244370939f1246f1d32138ec478c01e1 Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Thu, 22 Aug 2024 12:40:40 +1000 Subject: [PATCH 168/325] [11.x] document async validate (#9835) * document async validate * Fix syntax * formatting --------- Co-authored-by: Taylor Otwell --- precognition.md | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/precognition.md b/precognition.md index 158409a74c2..a3942e15135 100644 --- a/precognition.md +++ b/precognition.md @@ -150,6 +150,20 @@ If you are validating a subset of a form's inputs with Precognition, it can be u > ``` +As we have seen, you can hook into an input's `change` event and validate individual inputs as the user interacts with them; however, you may need to validate inputs that the user has not yet interacted with. This is common when building a "wizard", where you want to validate all visible inputs, whether the user has interacted with them or not, before moving to the next step. + +To do this with Precognition, you should mark the fields you wish to validate as "touched" by passing their names to the `touch` method. Then, call the `validate` method with `onSuccess` or `onValidationError` callbacks: + +```html + +``` + Of course, you may also execute code in reaction to the response to the form submission. The form's `submit` function returns an Axios request promise. This provides a convenient way to access the response payload, reset the form inputs on successful submission, or handle a failed request: ```js @@ -314,14 +328,28 @@ If you are validating a subset of a form's inputs with Precognition, it can be u + onChange={(e) => { form.setData('avatar', e.target.value); form.forgetError('avatar'); - } + }} > ``` +As we have seen, you can hook into an input's `blur` event and validate individual inputs as the user interacts with them; however, you may need to validate inputs that the user has not yet interacted with. This is common when building a "wizard", where you want to validate all visible inputs, whether the user has interacted with them or not, before moving to the next step. + +To do this with Precognition, you should mark the fields you wish to validate as "touched" by passing their names to the `touch` method. Then, call the `validate` method with `onSuccess` or `onValidationError` callbacks: + +```jsx + +``` + Of course, you may also execute code in reaction to the response to the form submission. The form's `submit` function returns an Axios request promise. This provides a convenient way to access the response payload, reset the form's inputs on a successful form submission, or handle a failed request: ```js @@ -501,6 +529,20 @@ You may also determine if an input has passed or failed validation by passing th > [!WARNING] > A form input will only appear as valid or invalid once it has changed and a validation response has been received. +As we have seen, you can hook into an input's `change` event and validate individual inputs as the user interacts with them; however, you may need to validate inputs that the user has not yet interacted with. This is common when building a "wizard", where you want to validate all visible inputs, whether the user has interacted with them or not, before moving to the next step. + +To do this with Precognition, you should mark the fields you wish to validate as "touched" by passing their names to the `touch` method. Then, call the `validate` method with `onSuccess` or `onValidationError` callbacks: + +```html + +``` + You may determine if a form submission request is in-flight by inspecting the form's `processing` property: ```html From 1a3d112255c8d0da2cbc10ebe581deebdd172ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20M=C3=BCller?= Date: Thu, 22 Aug 2024 14:47:18 +0200 Subject: [PATCH 169/325] Add Context to the facade class reference (#9837) --- facades.md | 1 + 1 file changed, 1 insertion(+) diff --git a/facades.md b/facades.md index 1c8fcbb0bd9..175c50ea358 100644 --- a/facades.md +++ b/facades.md @@ -297,6 +297,7 @@ Below you will find every facade and its underlying class. This is a useful tool | Cache (Instance) | [Illuminate\Cache\Repository](https://laravel.com/api/{{version}}/Illuminate/Cache/Repository.html) | `cache.store` | | Cache | [Illuminate\Cache\CacheManager](https://laravel.com/api/{{version}}/Illuminate/Cache/CacheManager.html) | `cache` | | Config | [Illuminate\Config\Repository](https://laravel.com/api/{{version}}/Illuminate/Config/Repository.html) | `config` | +| Context | [Illuminate\Log\Context\Repository](https://laravel.com/api/{{version}}/Illuminate/Log/Context/Repository.html) |   | | Cookie | [Illuminate\Cookie\CookieJar](https://laravel.com/api/{{version}}/Illuminate/Cookie/CookieJar.html) | `cookie` | | Crypt | [Illuminate\Encryption\Encrypter](https://laravel.com/api/{{version}}/Illuminate/Encryption/Encrypter.html) | `encrypter` | | Date | [Illuminate\Support\DateFactory](https://laravel.com/api/{{version}}/Illuminate/Support/DateFactory.html) | `date` | From b2830447ba2c1edca5dceffbbe740ec7dd3a5c3a Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Sat, 24 Aug 2024 02:22:19 +1000 Subject: [PATCH 170/325] Fix example (#9839) --- queries.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queries.md b/queries.md index 1d47735cb48..401b8a63c29 100644 --- a/queries.md +++ b/queries.md @@ -979,7 +979,7 @@ Alternatively, you may use the `limit` and `offset` methods. These methods are f Sometimes you may want certain query clauses to apply to a query based on another condition. For instance, you may only want to apply a `where` statement if a given input value is present on the incoming HTTP request. You may accomplish this using the `when` method: - $role = $request->string('role'); + $role = $request->input('role'); $users = DB::table('users') ->when($role, function (Builder $query, string $role) { From b9fa924860cb30ba5be04d6dddb62f4b6ce17d19 Mon Sep 17 00:00:00 2001 From: Faraz Samapoor Date: Sat, 24 Aug 2024 15:26:56 +0330 Subject: [PATCH 171/325] [11.x] Updates Artisan Docs (#9840) * Adds "migrate:install" to the Tinker Command Allow List. References: https://github.com/laravel/tinker/commit/8531d0f0e0285783f420bdd743c37f99c0f394d1 * Update artisan.md --------- Co-authored-by: Faraz Samapoor Co-authored-by: Taylor Otwell --- artisan.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/artisan.md b/artisan.md index ae3d061a6ff..794326a4d6a 100644 --- a/artisan.md +++ b/artisan.md @@ -86,7 +86,7 @@ php artisan vendor:publish --provider="Laravel\Tinker\TinkerServiceProvider" #### Command Allow List -Tinker utilizes an "allow" list to determine which Artisan commands are allowed to be run within its shell. By default, you may run the `clear-compiled`, `down`, `env`, `inspire`, `migrate`, `optimize`, and `up` commands. If you would like to allow more commands you may add them to the `commands` array in your `tinker.php` configuration file: +Tinker utilizes an "allow" list to determine which Artisan commands are allowed to be run within its shell. By default, you may run the `clear-compiled`, `down`, `env`, `inspire`, `migrate`, `migrate:install`, `up`, and `optimize` commands. If you would like to allow more commands you may add them to the `commands` array in your `tinker.php` configuration file: 'commands' => [ // App\Console\Commands\ExampleCommand::class, From b63370cb54fd7158d004dfae2b647de937c80355 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 26 Aug 2024 20:39:05 +0800 Subject: [PATCH 172/325] Explicitly include `--port=9515` when running `chromedriver` on CI (#9841) --- dusk.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dusk.md b/dusk.md index 382867eba1e..0f49217b95a 100644 --- a/dusk.md +++ b/dusk.md @@ -2125,7 +2125,7 @@ To run Dusk tests on [Heroku CI](https://www.heroku.com/continuous-integration), ], "scripts": { "test-setup": "cp .env.testing .env", - "test": "nohup bash -c './vendor/laravel/dusk/bin/chromedriver-linux > /dev/null 2>&1 &' && nohup bash -c 'php artisan serve --no-reload > /dev/null 2>&1 &' && php artisan dusk" + "test": "nohup bash -c './vendor/laravel/dusk/bin/chromedriver-linux --port=9515 > /dev/null 2>&1 &' && nohup bash -c 'php artisan serve --no-reload > /dev/null 2>&1 &' && php artisan dusk" } } } @@ -2191,7 +2191,7 @@ jobs: - name: Upgrade Chrome Driver run: php artisan dusk:chrome-driver --detect - name: Start Chrome Driver - run: ./vendor/laravel/dusk/bin/chromedriver-linux & + run: ./vendor/laravel/dusk/bin/chromedriver-linux --port=9515 & - name: Run Laravel Server run: php artisan serve --no-reload & - name: Run Dusk Tests From d0aaa1b62ab0304f0a7eb3d881eee9a01c44ea99 Mon Sep 17 00:00:00 2001 From: Greg Brock Date: Tue, 27 Aug 2024 09:01:29 -0400 Subject: [PATCH 173/325] Add corrected middleware class (#9851) The `ValidateSignature` middleware is actually for validating signed routes --- fortify.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortify.md b/fortify.md index 28d5b6e1ff5..d6e271a0c72 100644 --- a/fortify.md +++ b/fortify.md @@ -536,7 +536,7 @@ If the request to resend the verification link email was successful, Fortify wil ### Protecting Routes -To specify that a route or group of routes requires that the user has verified their email address, you should attach Laravel's built-in `verified` middleware to the route. The `verified` middleware alias is automatically registered by Laravel and serves as an alias for the `Illuminate\Routing\Middleware\ValidateSignature` middleware: +To specify that a route or group of routes requires that the user has verified their email address, you should attach Laravel's built-in `verified` middleware to the route. The `verified` middleware alias is automatically registered by Laravel and serves as an alias for the `Illuminate\Auth\Middleware\EnsureEmailIsVerified` middleware: ```php Route::get('/dashboard', function () { From 7b696f268160e61c19eeed2a9c49191ae89f6bf1 Mon Sep 17 00:00:00 2001 From: Noboru Shiroiwa <14008307+nshiro@users.noreply.github.com> Date: Tue, 27 Aug 2024 22:02:57 +0900 Subject: [PATCH 174/325] Add Livewire directory to full page refresh on file save (#9866) --- vite.md | 1 + 1 file changed, 1 insertion(+) diff --git a/vite.md b/vite.md index e04548df157..640558bbac8 100644 --- a/vite.md +++ b/vite.md @@ -499,6 +499,7 @@ export default defineConfig({ When the `refresh` option is `true`, saving files in the following directories will trigger the browser to perform a full page refresh while you are running `npm run dev`: +- `app/Livewire/**` - `app/View/Components/**` - `lang/**` - `resources/lang/**` From bb4650831ec4567c07d72f7a9949a95f90c04035 Mon Sep 17 00:00:00 2001 From: Joe Koop Date: Wed, 28 Aug 2024 11:04:39 -0500 Subject: [PATCH 175/325] (attempted to) fix/remove dead internal links (#9867) --- authorization.md | 2 +- controllers.md | 2 +- eloquent.md | 2 +- helpers.md | 13 ++++++------- requests.md | 2 +- verification.md | 2 +- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/authorization.md b/authorization.md index d795ac76c09..ca5b4c8f470 100644 --- a/authorization.md +++ b/authorization.md @@ -607,7 +607,7 @@ As previously discussed, some policy methods like `create` do not require a mode ### Via Middleware -Laravel includes a middleware that can authorize actions before the incoming request even reaches your routes or controllers. By default, the `Illuminate\Auth\Middleware\Authorize` middleware may be attached to a route using the `can` [middleware alias](/docs/{{version}}/middleware#middleware-alias), which is automatically registered by Laravel. Let's explore an example of using the `can` middleware to authorize that a user can update a post: +Laravel includes a middleware that can authorize actions before the incoming request even reaches your routes or controllers. By default, the `Illuminate\Auth\Middleware\Authorize` middleware may be attached to a route using the `can` [middleware alias](/docs/{{version}}/middleware#middleware-aliases), which is automatically registered by Laravel. Let's explore an example of using the `can` middleware to authorize that a user can update a post: use App\Models\Post; diff --git a/controllers.md b/controllers.md index 8bd7b1b1fff..30ad8127d72 100644 --- a/controllers.md +++ b/controllers.md @@ -431,7 +431,7 @@ Singleton resources may also be nested within a standard resource: Route::singleton('photos.thumbnail', ThumbnailController::class); ``` -In this example, the `photos` resource would receive all of the [standard resource routes](#actions-handled-by-resource-controller); however, the `thumbnail` resource would be a singleton resource with the following routes: +In this example, the `photos` resource would receive all of the [standard resource routes](#actions-handled-by-resource-controllers); however, the `thumbnail` resource would be a singleton resource with the following routes:
diff --git a/eloquent.md b/eloquent.md index 514a2d535a4..14383122503 100644 --- a/eloquent.md +++ b/eloquent.md @@ -388,7 +388,7 @@ Model::preventSilentlyDiscardingAttributes(! $this->app->isProduction()); ## Retrieving Models -Once you have created a model and [its associated database table](/docs/{{version}}/migrations#writing-migrations), you are ready to start retrieving data from your database. You can think of each Eloquent model as a powerful [query builder](/docs/{{version}}/queries) allowing you to fluently query the database table associated with the model. The model's `all` method will retrieve all of the records from the model's associated database table: +Once you have created a model and [its associated database table](/docs/{{version}}/migrations#generating-migrations), you are ready to start retrieving data from your database. You can think of each Eloquent model as a powerful [query builder](/docs/{{version}}/queries) allowing you to fluently query the database table associated with the model. The model's `all` method will retrieve all of the records from the model's associated database table: use App\Models\Flight; diff --git a/helpers.md b/helpers.md index 6b24ab85eeb..382255b5899 100644 --- a/helpers.md +++ b/helpers.md @@ -69,7 +69,6 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct [Arr::sort](#method-array-sort) [Arr::sortDesc](#method-array-sort-desc) [Arr::sortRecursive](#method-array-sort-recursive) -[Arr::sortRecursiveDesc](#method-array-sort-recursive-desc) [Arr::take](#method-array-take) [Arr::toCssClasses](#method-array-to-css-classes) [Arr::toCssStyles](#method-array-to-css-styles) @@ -1603,7 +1602,7 @@ If no path is provided, an `Illuminate\Routing\UrlGenerator` instance is returne #### `abort()` {.collection-method} -The `abort` function throws [an HTTP exception](/docs/{{version}}/errors#http-exceptions) which will be rendered by the [exception handler](/docs/{{version}}/errors#the-exception-handler): +The `abort` function throws [an HTTP exception](/docs/{{version}}/errors#http-exceptions) which will be rendered by the [exception handler](/docs/{{version}}/errors#handling-exceptions): abort(403); @@ -1919,7 +1918,7 @@ An array of contextual data may also be passed to the function: logger('User has logged in.', ['id' => $user->id]); -A [logger](/docs/{{version}}/errors#logging) instance will be returned if no value is passed to the function: +A [logger](/docs/{{version}}/logging) instance will be returned if no value is passed to the function: logger()->error('You are not allowed here.'); @@ -2031,7 +2030,7 @@ The `redirect` function returns a [redirect HTTP response](/docs/{{version}}/res #### `report()` {.collection-method} -The `report` function will report an exception using your [exception handler](/docs/{{version}}/errors#the-exception-handler): +The `report` function will report an exception using your [exception handler](/docs/{{version}}/errors#handling-exceptions): report($e); @@ -2042,7 +2041,7 @@ The `report` function also accepts a string as an argument. When a string is giv #### `report_if()` {.collection-method} -The `report_if` function will report an exception using your [exception handler](/docs/{{version}}/errors#the-exception-handler) if the given condition is `true`: +The `report_if` function will report an exception using your [exception handler](/docs/{{version}}/errors#handling-exceptions) if the given condition is `true`: report_if($shouldReport, $e); @@ -2051,7 +2050,7 @@ The `report_if` function will report an exception using your [exception handler] #### `report_unless()` {.collection-method} -The `report_unless` function will report an exception using your [exception handler](/docs/{{version}}/errors#the-exception-handler) if the given condition is `false`: +The `report_unless` function will report an exception using your [exception handler](/docs/{{version}}/errors#handling-exceptions) if the given condition is `false`: report_unless($reportingDisabled, $e); @@ -2069,7 +2068,7 @@ The `request` function returns the current [request](/docs/{{version}}/requests) #### `rescue()` {.collection-method} -The `rescue` function executes the given closure and catches any exceptions that occur during its execution. All exceptions that are caught will be sent to your [exception handler](/docs/{{version}}/errors#the-exception-handler); however, the request will continue processing: +The `rescue` function executes the given closure and catches any exceptions that occur during its execution. All exceptions that are caught will be sent to your [exception handler](/docs/{{version}}/errors#handling-exceptions); however, the request will continue processing: return rescue(function () { return $this->method(); diff --git a/requests.md b/requests.md index 673bc7c83c2..103f92df37d 100644 --- a/requests.md +++ b/requests.md @@ -306,7 +306,7 @@ When sending JSON requests to your application, you may access the JSON data via #### Retrieving Stringable Input Values -Instead of retrieving the request's input data as a primitive `string`, you may use the `string` method to retrieve the request data as an instance of [`Illuminate\Support\Stringable`](/docs/{{version}}/helpers#fluent-strings): +Instead of retrieving the request's input data as a primitive `string`, you may use the `string` method to retrieve the request data as an instance of [`Illuminate\Support\Stringable`](/docs/{{version}}/strings): $name = $request->string('name')->trim(); diff --git a/verification.md b/verification.md index d8c2cca2c8d..d6c0a752499 100644 --- a/verification.md +++ b/verification.md @@ -108,7 +108,7 @@ Sometimes a user may misplace or accidentally delete the email address verificat ### Protecting Routes -[Route middleware](/docs/{{version}}/middleware) may be used to only allow verified users to access a given route. Laravel includes a `verified` [middleware alias](/docs/{{version}}/middleware#middleware-alias), which is an alias for the `Illuminate\Auth\Middleware\EnsureEmailIsVerified` middleware class. Since this alias is already automatically registered by Laravel, all you need to do is attach the `verified` middleware to a route definition. Typically, this middleware is paired with the `auth` middleware: +[Route middleware](/docs/{{version}}/middleware) may be used to only allow verified users to access a given route. Laravel includes a `verified` [middleware alias](/docs/{{version}}/middleware#middleware-aliases), which is an alias for the `Illuminate\Auth\Middleware\EnsureEmailIsVerified` middleware class. Since this alias is already automatically registered by Laravel, all you need to do is attach the `verified` middleware to a route definition. Typically, this middleware is paired with the `auth` middleware: Route::get('/profile', function () { // Only verified users may access this route... From 1c647219738642c4b667c5ed7bac880e18ab67d9 Mon Sep 17 00:00:00 2001 From: Sergio Peris Date: Sun, 1 Sep 2024 01:31:21 +0200 Subject: [PATCH 176/325] Update filesystem.md (#9869) --- filesystem.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filesystem.md b/filesystem.md index 659db7882a7..6a4e839cd67 100644 --- a/filesystem.md +++ b/filesystem.md @@ -219,7 +219,7 @@ AWS_URL=http://localhost:9000/local ``` > [!WARNING] -> Generating temporary storage URLs via the `temporaryUrl` method is not supported when using MinIO. +> Generating temporary storage URLs via the `temporaryUrl` method may not work when using MinIO if the `endpoint` is not accessible by the client. ## Obtaining Disk Instances From eeb8b2839390f6e5c317978cdea3c5056681ebf3 Mon Sep 17 00:00:00 2001 From: Amir Date: Mon, 2 Sep 2024 18:26:47 +0330 Subject: [PATCH 177/325] queue: change ThrottlesExceptions decay from minutes to seconds (#9872) --- queues.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/queues.md b/queues.md index b54d1a90689..080b54adedb 100644 --- a/queues.md +++ b/queues.md @@ -610,7 +610,7 @@ For example, let's imagine a queued job that interacts with a third-party API th */ public function middleware(): array { - return [new ThrottlesExceptions(10, 5)]; + return [new ThrottlesExceptions(10, 5 * 60)]; } /** @@ -621,7 +621,7 @@ For example, let's imagine a queued job that interacts with a third-party API th return now()->addMinutes(5); } -The first constructor argument accepted by the middleware is the number of exceptions the job can throw before being throttled, while the second constructor argument is the number of minutes that should elapse before the job is attempted again once it has been throttled. In the code example above, if the job throws 10 exceptions within 5 minutes, we will wait 5 minutes before attempting the job again. +The first constructor argument accepted by the middleware is the number of exceptions the job can throw before being throttled, while the second constructor argument is the number of seconds that should elapse before the job is attempted again once it has been throttled. In the code example above, if the job throws 10 exceptions within 5 minutes, we will wait 5 minutes before attempting the job again. When a job throws an exception but the exception threshold has not yet been reached, the job will typically be retried immediately. However, you may specify the number of minutes such a job should be delayed by calling the `backoff` method when attaching the middleware to the job: @@ -634,7 +634,7 @@ When a job throws an exception but the exception threshold has not yet been reac */ public function middleware(): array { - return [(new ThrottlesExceptions(10, 5))->backoff(5)]; + return [(new ThrottlesExceptions(10, 5 * 60))->backoff(5)]; } Internally, this middleware uses Laravel's cache system to implement rate limiting, and the job's class name is utilized as the cache "key". You may override this key by calling the `by` method when attaching the middleware to your job. This may be useful if you have multiple jobs interacting with the same third-party service and you would like them to share a common throttling "bucket": @@ -648,7 +648,7 @@ Internally, this middleware uses Laravel's cache system to implement rate limiti */ public function middleware(): array { - return [(new ThrottlesExceptions(10, 10))->by('key')]; + return [(new ThrottlesExceptions(10, 10 * 60))->by('key')]; } By default, this middleware will throttle every exception. You can modify this behaviour by invoking the `when` method when attaching the middleware to your job. The exception will then only be throttled if closure provided to the `when` method returns `true`: @@ -663,7 +663,7 @@ By default, this middleware will throttle every exception. You can modify this b */ public function middleware(): array { - return [(new ThrottlesExceptions(10, 10))->when( + return [(new ThrottlesExceptions(10, 10 * 60))->when( fn (Throwable $throwable) => $throwable instanceof HttpClientException )]; } @@ -680,7 +680,7 @@ If you would like to have the throttled exceptions reported to your application' */ public function middleware(): array { - return [(new ThrottlesExceptions(10, 10))->report( + return [(new ThrottlesExceptions(10, 10 * 60))->report( fn (Throwable $throwable) => $throwable instanceof HttpClientException )]; } From c92f80d37444c1574ec525db8830bff189087fe0 Mon Sep 17 00:00:00 2001 From: Naoki Haba <59875779+NaokiHaba@users.noreply.github.com> Date: Mon, 2 Sep 2024 23:57:29 +0900 Subject: [PATCH 178/325] chore: Update Pint CLI commands to use vendor/bin directory (#9873) --- pint.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pint.md b/pint.md index f7da25d53d4..5de25ca04ba 100644 --- a/pint.md +++ b/pint.md @@ -81,7 +81,7 @@ As previously mentioned, Pint does not require any configuration. However, if yo In addition, if you wish to use a `pint.json` from a specific directory, you may provide the `--config` option when invoking Pint: ```shell -pint --config vendor/my-company/coding-style/pint.json +./vendor/bin/pint --config vendor/my-company/coding-style/pint.json ``` @@ -90,7 +90,7 @@ pint --config vendor/my-company/coding-style/pint.json Presets define a set of rules that can be used to fix code style issues in your code. By default, Pint uses the `laravel` preset, which fixes issues by following the opinionated coding style of Laravel. However, you may specify a different preset by providing the `--preset` option to Pint: ```shell -pint --preset psr12 +./vendor/bin/pint --preset psr12 ``` If you wish, you may also set the preset in your project's `pint.json` file: From e1b400d993364b991891bbcaa380bd1979bc741d Mon Sep 17 00:00:00 2001 From: Tobias Grasse <834914+tobias-grasse@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:25:38 +0200 Subject: [PATCH 179/325] Update sail.md (#9875) The seleniarm/standalone-chromium fork was merged back into the official Selenium project and is only maintained there. The last seleniarm/standalone-chromium release is Chromium v124.0.6367.78. --- sail.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sail.md b/sail.md index bd20494facb..f14030178d8 100644 --- a/sail.md +++ b/sail.md @@ -352,11 +352,11 @@ sail dusk #### Selenium on Apple Silicon -If your local machine contains an Apple Silicon chip, your `selenium` service must use the `seleniarm/standalone-chromium` image: +If your local machine contains an Apple Silicon chip, your `selenium` service must use the `selenium/standalone-chromium` image: ```yaml selenium: - image: 'seleniarm/standalone-chromium' + image: 'selenium/standalone-chromium' extra_hosts: - 'host.docker.internal:host-gateway' volumes: From 20492202acc86e4f234fa2320cb126f19493cbc6 Mon Sep 17 00:00:00 2001 From: ytoda Date: Tue, 3 Sep 2024 22:39:47 +0900 Subject: [PATCH 180/325] Update eloquent-mutators.md (#9865) * Update eloquent-mutators.md Clarify UTC formatting for timestamp columns in date/datetime casting * Update eloquent-mutators.md --------- Co-authored-by: Taylor Otwell --- eloquent-mutators.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eloquent-mutators.md b/eloquent-mutators.md index 3aeaeca0981..34a5ba2e7a6 100644 --- a/eloquent-mutators.md +++ b/eloquent-mutators.md @@ -443,7 +443,7 @@ To specify the format that should be used when actually storing a model's dates By default, the `date` and `datetime` casts will serialize dates to a UTC ISO-8601 date string (`YYYY-MM-DDTHH:MM:SS.uuuuuuZ`), regardless of the timezone specified in your application's `timezone` configuration option. You are strongly encouraged to always use this serialization format, as well as to store your application's dates in the UTC timezone by not changing your application's `timezone` configuration option from its default `UTC` value. Consistently using the UTC timezone throughout your application will provide the maximum level of interoperability with other date manipulation libraries written in PHP and JavaScript. -If a custom format is applied to the `date` or `datetime` cast, such as `datetime:Y-m-d H:i:s`, the inner timezone of the Carbon instance will be used during date serialization. Typically, this will be the timezone specified in your application's `timezone` configuration option. +If a custom format is applied to the `date` or `datetime` cast, such as `datetime:Y-m-d H:i:s`, the inner timezone of the Carbon instance will be used during date serialization. Typically, this will be the timezone specified in your application's `timezone` configuration option. However, it's important to note that `timestamp` columns such as `created_at` and `updated_at` are exempt from this behavior and are always formatted in UTC, regardless of the application's timezone setting. ### Enum Casting From 040ab151f8350470f8df5d00bfba05f56c155d12 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 3 Sep 2024 09:34:44 -0500 Subject: [PATCH 181/325] wip --- socialite.md | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/socialite.md b/socialite.md index 54a27175346..e4689ceab92 100644 --- a/socialite.md +++ b/socialite.md @@ -15,7 +15,7 @@ ## Introduction -In addition to typical, form based authentication, Laravel also provides a simple, convenient way to authenticate with OAuth providers using [Laravel Socialite](https://github.com/laravel/socialite). Socialite currently supports authentication via Facebook, Twitter, LinkedIn, Google, GitHub, GitLab, Bitbucket, and Slack. +In addition to typical, form based authentication, Laravel also provides a simple, convenient way to authenticate with OAuth providers using [Laravel Socialite](https://github.com/laravel/socialite). Socialite currently supports authentication via Facebook, X, LinkedIn, Google, GitHub, GitLab, Bitbucket, and Slack. > [!NOTE] > Adapters for other platforms are available via the community driven [Socialite Providers](https://socialiteproviders.com/) website. @@ -39,7 +39,7 @@ When upgrading to a new major version of Socialite, it's important that you care Before using Socialite, you will need to add credentials for the OAuth providers your application utilizes. Typically, these credentials may be retrieved by creating a "developer application" within the dashboard of the service you will be authenticating with. -These credentials should be placed in your application's `config/services.php` configuration file, and should use the key `facebook`, `twitter` (OAuth 1.0), `twitter-oauth-2` (OAuth 2.0), `linkedin-openid`, `google`, `github`, `gitlab`, `bitbucket`, `slack`, or `slack-openid`, depending on the providers your application requires: +These credentials should be placed in your application's `config/services.php` configuration file, and should use the key `facebook`, `x`, `linkedin-openid`, `google`, `github`, `gitlab`, `bitbucket`, `slack`, or `slack-openid`, depending on the providers your application requires: 'github' => [ 'client_id' => env('GITHUB_CLIENT_ID'), @@ -189,7 +189,7 @@ Differing properties and methods may be available on this object depending on wh }); -#### Retrieving User Details From a Token (OAuth2) +#### Retrieving User Details From a Token If you already have a valid access token for a user, you can retrieve their user details using Socialite's `userFromToken` method: @@ -199,15 +199,6 @@ If you already have a valid access token for a user, you can retrieve their user If you are using Facebook Limited Login via an iOS application, Facebook will return an OIDC token instead of an access token. Like an access token, the OIDC token can be provided to the `userFromToken` method in order to retrieve user details. - -#### Retrieving User Details From a Token and Secret (OAuth1) - -If you already have a valid token and secret for a user, you can retrieve their user details using Socialite's `userFromTokenAndSecret` method: - - use Laravel\Socialite\Facades\Socialite; - - $user = Socialite::driver('twitter')->userFromTokenAndSecret($token, $secret); - #### Stateless Authentication @@ -216,6 +207,3 @@ The `stateless` method may be used to disable session state verification. This i use Laravel\Socialite\Facades\Socialite; return Socialite::driver('google')->stateless()->user(); - -> [!WARNING] -> Stateless authentication is not available for the Twitter OAuth 1.0 driver. From 06c3df075e79917d1a6afbbb587a17545f2ac7c9 Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Fri, 6 Sep 2024 07:04:00 +1000 Subject: [PATCH 182/325] [11.x] Asset Prefetching (#9838) * Asset Prefetching (vite) * Add event docs * typo * Use initialism * formatting --------- Co-authored-by: Taylor Otwell --- vite.md | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/vite.md b/vite.md index 640558bbac8..16d69524989 100644 --- a/vite.md +++ b/vite.md @@ -18,6 +18,7 @@ - [Processing Static Assets With Vite](#blade-processing-static-assets) - [Refreshing on Save](#blade-refreshing-on-save) - [Aliases](#blade-aliases) +- [Asset Prefetching](#asset-prefetching) - [Custom Base URLs](#custom-base-urls) - [Environment Variables](#environment-variables) - [Disabling Vite in Tests](#disabling-vite-in-tests) @@ -405,6 +406,8 @@ createInertiaApp({ }); ``` +If you are using Vite's code splitting feature with Inertia, we recommend configuring [asset prefetching](#asset-prefetching). + > [!NOTE] > Laravel's [starter kits](/docs/{{version}}/starter-kits) already include the proper Laravel, Inertia, and Vite configuration. Check out [Laravel Breeze](/docs/{{version}}/starter-kits#breeze-and-inertia) for the fastest way to get started with Laravel, Inertia, and Vite. @@ -562,6 +565,75 @@ Once a macro has been defined, it can be invoked within your templates. For exam Laravel Logo ``` + +## Asset Prefetching + +When building an SPA using Vite's code splitting feature, required assets are fetched on each page navigation. This behavior can lead to delayed UI rendering. If this is a problem for your frontend framework of choice, Laravel offers the ability to eagerly prefetch your application's JavaScript and CSS assets on initial page load. + +You can instruct Laravel to eagerly prefetch your assets by invoking the `Vite::prefetch` method in the `boot` method of a [service provider](/docs/{{version}}/providers): + +```php + + addEventListener('load', () => setTimeout(() => { + dispatchEvent(new Event('vite:prefetch')) + }, 3000)) + +``` + ## Custom Base URLs From 62eb15f6637ea5810edf8a9aeae0e621003cff0f Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 6 Sep 2024 08:38:07 -0500 Subject: [PATCH 183/325] standardize constructor examples (#9879) - always use trailing commas in signature - always use multiline arguments - correct indentation - remove empty bodies --- broadcasting.md | 5 +---- collections.md | 4 ++-- container.md | 4 ++-- events.md | 5 +---- queues.md | 10 +++++----- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/broadcasting.md b/broadcasting.md index 6fb7ebad010..7c42269e48a 100644 --- a/broadcasting.md +++ b/broadcasting.md @@ -672,10 +672,7 @@ Finally, you may place the authorization logic for your channel in the channel c /** * Create a new channel instance. */ - public function __construct() - { - // ... - } + public function __construct() {} /** * Authenticate the user's access to the channel. diff --git a/collections.md b/collections.md index c8c9198a7dc..58a05007a4e 100644 --- a/collections.md +++ b/collections.md @@ -1488,7 +1488,7 @@ The `mapInto()` method iterates over the collection, creating a new instance of * Create a new currency instance. */ function __construct( - public string $code + public string $code, ) {} } @@ -1842,7 +1842,7 @@ The `pipeInto` method creates a new instance of the given class and passes the c * Create a new ResourceCollection instance. */ public function __construct( - public Collection $collection, + public Collection $collection, ) {} } diff --git a/container.md b/container.md index 7a1709cad4f..89db5d5c617 100644 --- a/container.md +++ b/container.md @@ -199,7 +199,7 @@ This statement tells the container that it should inject the `RedisEventPusher` * Create a new class instance. */ public function __construct( - protected EventPusher $pusher + protected EventPusher $pusher, ) {} @@ -380,7 +380,7 @@ If you would like to have the Laravel container instance itself injected into a * Create a new class instance. */ public function __construct( - protected Container $container + protected Container $container, ) {} diff --git a/events.md b/events.md index dc14cabc4f1..ebe2934bddb 100644 --- a/events.md +++ b/events.md @@ -220,10 +220,7 @@ Next, let's take a look at the listener for our example event. Event listeners r /** * Create the event listener. */ - public function __construct() - { - // ... - } + public function __construct() {} /** * Handle the event. diff --git a/queues.md b/queues.md index 080b54adedb..a324913faf4 100644 --- a/queues.md +++ b/queues.md @@ -236,8 +236,9 @@ Or, to prevent relations from being serialized, you can call the `withoutRelatio /** * Create a new job instance. */ - public function __construct(Podcast $podcast) - { + public function __construct( + Podcast $podcast, + ) { $this->podcast = $podcast->withoutRelations(); } @@ -250,9 +251,8 @@ If you are using PHP constructor property promotion and would like to indicate t */ public function __construct( #[WithoutRelations] - public Podcast $podcast - ) { - } + public Podcast $podcast, + ) {} If a job receives a collection or array of Eloquent models instead of a single model, the models within that collection will not have their relationships restored when the job is deserialized and executed. This is to prevent excessive resource usage on jobs that deal with large numbers of models. From 0f44074a2b2d10fe6ccc0f72d57574c7c8a360f5 Mon Sep 17 00:00:00 2001 From: Pedro Borges Date: Fri, 6 Sep 2024 17:37:10 -0300 Subject: [PATCH 184/325] Document `Response` "stream" and "streamJson" methods (#9881) * Document response "stream" and "streamJson" methods * formatting * formatting --------- Co-authored-by: Taylor Otwell --- responses.md | 56 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/responses.md b/responses.md index 1653629ed5c..559ed9f3fab 100644 --- a/responses.md +++ b/responses.md @@ -14,6 +14,7 @@ - [JSON Responses](#json-responses) - [File Downloads](#file-downloads) - [File Responses](#file-responses) + - [Streamed Responses](#streamed-responses) - [Response Macros](#response-macros) @@ -287,6 +288,52 @@ The `download` method may be used to generate a response that forces the user's > [!WARNING] > Symfony HttpFoundation, which manages file downloads, requires the file being downloaded to have an ASCII filename. + +### File Responses + +The `file` method may be used to display a file, such as an image or PDF, directly in the user's browser instead of initiating a download. This method accepts the absolute path to the file as its first argument and an array of headers as its second argument: + + return response()->file($pathToFile); + + return response()->file($pathToFile, $headers); + + +### Streamed Responses + +By streaming data to the client as it is generated, you can significantly reduce memory usage and improve performance, especially for very large responses. Streamed responses allow the client to begin processing data before the server has finished sending it: + + function streamedContent(): Generator { + yield 'Hello, '; + yield 'World!'; + } + + Route::get('/stream', function () { + return response()->stream(function (): void { + foreach (streamedContent() as $chunk) { + echo $chunk; + ob_flush(); + flush(); + sleep(2); // Simulate delay between chunks... + } + }, 200, ['X-Accel-Buffering' => 'no']); + }); + +> [!NOTE] +> Internally, Laravel utilizes PHP's output buffering functionality. As you can see in the example above, you should use the `ob_flush` and `flush` functions to push buffered content to the client. + + +#### Streamed JSON Responses + +If you need to stream JSON data incrementally, you may utilize the `streamJson` method. This method is especially useful for large datasets that need to be sent progressively to the browser in a format that can be easily parsed by JavaScript: + + use App\Models\User; + + Route::get('/users.json', function () { + return response()->streamJson([ + 'users' => User::cursor(), + ]); + }); + #### Streamed Downloads @@ -300,15 +347,6 @@ Sometimes you may wish to turn the string response of a given operation into a d ->readme('laravel', 'laravel')['contents']; }, 'laravel-readme.md'); - -### File Responses - -The `file` method may be used to display a file, such as an image or PDF, directly in the user's browser instead of initiating a download. This method accepts the absolute path to the file as its first argument and an array of headers as its second argument: - - return response()->file($pathToFile); - - return response()->file($pathToFile, $headers); - ## Response Macros From f1c0e59dc78917eef5d5adfadc4d89448fed38f3 Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Mon, 9 Sep 2024 10:58:04 -0300 Subject: [PATCH 185/325] Add docs for `isNotFilled()` method on Request docs (#9884) --- requests.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/requests.md b/requests.md index 103f92df37d..dd35ff68f84 100644 --- a/requests.md +++ b/requests.md @@ -405,6 +405,18 @@ If you would like to determine if a value is present on the request and is not a // ... } +If you would like to determine if a value is missing from the request or is an empty string, you may use the `isNotFilled` method: + + if ($request->isNotFilled('name')) { + // ... + } + +When given an array, the `isNotFilled` method will determine if all of the specified values are missing or empty: + + if ($request->isNotFilled(['name', 'email'])) { + // ... + } + The `anyFilled` method returns `true` if any of the specified values is not an empty string: if ($request->anyFilled(['name', 'email'])) { From 9ad603d85e801497147758044a45a63117133e50 Mon Sep 17 00:00:00 2001 From: "Dr. Adam Nielsen" <1765602+iwasherefirst2@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:16:07 +0200 Subject: [PATCH 186/325] Update Xdebug docs: Static IP for Linux pre-Docker 20.10 (#9887) Clarified Linux Xdebug setup. For Docker 20.10+, host.docker.internal works without manual config. For older versions, added instructions to set a static IP in docker-compose.yml. --- sail.md | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/sail.md b/sail.md index f14030178d8..0d9541b3107 100644 --- a/sail.md +++ b/sail.md @@ -483,18 +483,28 @@ SAIL_XDEBUG_MODE=develop,debug,coverage #### Linux Host IP Configuration -Internally, the `XDEBUG_CONFIG` environment variable is defined as `client_host=host.docker.internal` so that Xdebug will be properly configured for Mac and Windows (WSL2). If your local machine is running Linux, you should ensure that you are running Docker Engine 17.06.0+ and Compose 1.16.0+. Otherwise, you will need to manually define this environment variable as shown below. +Internally, the `XDEBUG_CONFIG` environment variable is defined as `client_host=host.docker.internal` so that Xdebug will be properly configured for Mac and Windows (WSL2). If your local machine is running Linux and you're using **Docker 20.10+**, `host.docker.internal` is available, and no manual configuration is required. -First, you should determine the correct host IP address to add to the environment variable by running the following command. Typically, the `` should be the name of the container that serves your application and often ends with `_laravel.test_1`: +For **Docker versions older than 20.10**, `host.docker.internal` is not supported on Linux, and you will need to manually define the host IP. To do this, configure a static IP for your container by defining a custom network in your `docker-compose.yml` file: -```shell -docker inspect -f {{range.NetworkSettings.Networks}}{{.Gateway}}{{end}} +```yaml +networks: + custom_network: + ipam: + config: + - subnet: 172.20.0.0/16 + +services: + laravel.test: + networks: + custom_network: + ipv4_address: 172.20.0.2 ``` -Once you have obtained the correct host IP address, you should define the `SAIL_XDEBUG_CONFIG` variable within your application's `.env` file: +Once you have set the static IP, define the SAIL_XDEBUG_CONFIG variable within your application's .env file: ```ini -SAIL_XDEBUG_CONFIG="client_host=" +SAIL_XDEBUG_CONFIG="client_host=172.20.0.2" ``` From 3a8bc7fa4eaf942a9e1793e12db1b7b530c1b063 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 10 Sep 2024 08:17:02 -0500 Subject: [PATCH 187/325] wip --- sail.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sail.md b/sail.md index 0d9541b3107..7226abe3d78 100644 --- a/sail.md +++ b/sail.md @@ -483,9 +483,9 @@ SAIL_XDEBUG_MODE=develop,debug,coverage #### Linux Host IP Configuration -Internally, the `XDEBUG_CONFIG` environment variable is defined as `client_host=host.docker.internal` so that Xdebug will be properly configured for Mac and Windows (WSL2). If your local machine is running Linux and you're using **Docker 20.10+**, `host.docker.internal` is available, and no manual configuration is required. +Internally, the `XDEBUG_CONFIG` environment variable is defined as `client_host=host.docker.internal` so that Xdebug will be properly configured for Mac and Windows (WSL2). If your local machine is running Linux and you're using Docker 20.10+, `host.docker.internal` is available, and no manual configuration is required. -For **Docker versions older than 20.10**, `host.docker.internal` is not supported on Linux, and you will need to manually define the host IP. To do this, configure a static IP for your container by defining a custom network in your `docker-compose.yml` file: +For Docker versions older than 20.10, `host.docker.internal` is not supported on Linux, and you will need to manually define the host IP. To do this, configure a static IP for your container by defining a custom network in your `docker-compose.yml` file: ```yaml networks: From 681e1f1beea1aae88c75d5a6b10df2b8fc4bce8c Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 11 Sep 2024 17:00:56 -0500 Subject: [PATCH 188/325] Laracon 2024 (#9885) * concurrency * deferred functions * chaperone * chaperone polymorphic * attributes * custom attributes * cache flexible docs --- cache.md | 13 +++++ concurrency.md | 50 ++++++++++++++++++ container.md | 104 ++++++++++++++++++++++++++++++++++++++ documentation.md | 1 + eloquent-relationships.md | 87 +++++++++++++++++++++++++++++++ helpers.md | 37 ++++++++++++++ 6 files changed, 292 insertions(+) create mode 100644 concurrency.md diff --git a/cache.md b/cache.md index e4df87a66b0..0eced2f74d1 100644 --- a/cache.md +++ b/cache.md @@ -202,6 +202,19 @@ You may use the `rememberForever` method to retrieve an item from the cache or s return DB::table('users')->get(); }); + +#### Stale While Revalidate + +When using the `Cache::remember` method, some users may experience slow response times if the cached value has expired. For certain types of data, it can be useful to allow partially stale data to be served while the cached value is recalculated in the background, preventing some users from experiencing slow response times while cached values are calculated. This is often referred to as the "stale-while-revalidate" pattern, and the `Cache::flexible` method provides an implementation of this pattern. + +The flexible method accepts an array that specifies how long the cached value is considered “fresh” and when it becomes “stale.” The first value in the array represents the number of seconds the cache is considered fresh, while the second value defines how long it can be served as stale data before recalculation is necessary. + +If a request is made within the fresh period (before the first value), the cache is returned immediately without recalculation. If a request is made during the stale period (between the two values), the stale value is served to the user, and a [deferred function](/docs/{{version}}/helpers#deferred-functions) is registered to refresh the cached value after the response is sent to the user. If a request is made after the second value, the cache is considered expired, and the value is recalculated immediately, which may result in a slower response for the user: + + $value = Cache::flexible('users', [5, 10], function () { + return DB::table('users')->get(); + }); + #### Retrieve and Delete diff --git a/concurrency.md b/concurrency.md new file mode 100644 index 00000000000..114950d9f38 --- /dev/null +++ b/concurrency.md @@ -0,0 +1,50 @@ +# Concurrency + +- [Introduction](#introduction) +- [Running Concurrent Tasks](#running-concurrent-tasks) +- [Deferring Concurrent Tasks](#deferring-concurrent-tasks) + + +## Introduction + +> [!WARNING] +> Laravel's `Concurrency` facade is currently in beta while we gather community feedback. + +Sometimes you may need to execute several slow tasks which do not depend on one another. In many cases, significant performance improvements can be realized by executing the tasks concurrently. Laravel's `Concurrency` facade provides a simple, convenient API for executing closures concurrently. + + +#### How it Works + +Laravel achieves concurrency by serializing the given closures and dispatching them to a hidden Artisan CLI command, which unserializes the closures and invokes it within its own PHP process. After the closure has been invoked, the resulting value is serialized back to the parent process. + +The `Concurrency` facade supports three drivers: `process` (the default), `fork`, and `sync`. The `fork` driver offers improved performance compared to the default `process` driver, but it may only be used within PHP's CLI context, as PHP does not support forking during web requests. The `sync` driver is primarily useful during testing when you want to disable all concurrency and simple execute the given closure in sequence within the parent process. + + +## Running Concurrent Tasks + +To run concurrent tasks, you may invoke the `Concurrency` facade's `run` method. The `run` method accepts an array of closures which should be executed simultaneously in child PHP processes: + +```php +use Illuminate\Support\Facades\Concurrency; +use Illuminate\Support\Facades\DB; + +[$userCount, $orderCount] = Concurrency::run([ + fn () => DB::table('users')->count(), + fn () => DB::table('orders')->count(), +]); +``` + + +## Deferring Concurrent Tasks + +If you would like to execute an array of closures concurrently, but are not interested in the results returned by those closures, you should consider using the `defer` method. When the `defer` method is invoked, the given closures are not executed immediately. Instead, Laravel will execute the closures concurrently after the HTTP response has been sent to the user: + +```php +use App\Services\Metrics; +use Illuminate\Support\Facades\Concurrency; + +Concurrency::defer([ + fn () => Metrics::report('users'), + fn () => Metrics::report('orders'), +]); +``` diff --git a/container.md b/container.md index 89db5d5c617..39155e8ea0f 100644 --- a/container.md +++ b/container.md @@ -7,6 +7,7 @@ - [Binding Basics](#binding-basics) - [Binding Interfaces to Implementations](#binding-interfaces-to-implementations) - [Contextual Binding](#contextual-binding) + - [Contextual Attributes](#contextual-attributes) - [Binding Primitives](#binding-primitives) - [Binding Typed Variadics](#binding-typed-variadics) - [Tagging](#tagging) @@ -225,6 +226,109 @@ Sometimes you may have two classes that utilize the same interface, but you wish return Storage::disk('s3'); }); + +### Contextual Attributes + +Since contextual binding is often used to inject implementations of drivers or configuration values, Laravel offers a variety of contextual binding attributes that allow to inject these types of values without manually defining the contextual bindings in your service providers. + +For example, the `Storage` attribute may be used to inject a specific [storage disk](/docs/{{version}}/filesystem): + +```php +middleware('auth'); +``` + + +#### Defining Custom Attributes + +You can create your own contextual attributes by implementing the `Illuminate\Contracts\Container\ContextualAttribute` contract. The container will call your attribute's `resolve` method, which should resolve the value that should be injected into the class utilizing the attribute. In the example below, we will re-implement Laravel's built-in `Config` attribute: + + make('config')->get($attribute->key, $attribute->default); + } + } + ### Binding Primitives diff --git a/documentation.md b/documentation.md index 2ea03e6a683..b4e36d8c503 100644 --- a/documentation.md +++ b/documentation.md @@ -34,6 +34,7 @@ - [Broadcasting](/docs/{{version}}/broadcasting) - [Cache](/docs/{{version}}/cache) - [Collections](/docs/{{version}}/collections) + - [Concurrency](/docs/{{version}}/concurrency) - [Context](/docs/{{version}}/context) - [Contracts](/docs/{{version}}/contracts) - [Events](/docs/{{version}}/events) diff --git a/eloquent-relationships.md b/eloquent-relationships.md index 0c64bac641a..33692568ec3 100644 --- a/eloquent-relationships.md +++ b/eloquent-relationships.md @@ -194,6 +194,53 @@ Like the `hasOne` method, you may also override the foreign and local keys by pa return $this->hasMany(Comment::class, 'foreign_key', 'local_key'); + +#### Automatically Hydrating Parent Models on Children + +Even when utilizing Eloquent eager loading, "N + 1" query problems can arise if you try to access the parent model from a child model while looping through the child models: + +```php +$posts = Post::with('comments')->get(); + +foreach ($posts as $post) { + foreach ($post->comments as $comment) { + echo $comment->post->title; + } +} +``` + +In the example above, an "N + 1" query problem has been introduced because, even though comments were eager loaded for every `Post` model, Eloquent does not automatically hydrate the parent `Post` on each child `Comment` model. + +If you would like Eloquent to automatically hydrate parent models onto their children, you may invoke the `chaperone` method when defining a `hasMany` relationship: + + hasMany(Comment::class)->chaperone(); + } + } + +Or, if you would like to opt-in to automatic parent hydration at run time, you may invoke the `chaperone` model when eager loading the relationship: + +```php +use App\Models\Post; + +$posts = Post::with([ + 'comments' => fn ($comments) => $comments->chaperone(), +])->get(); +``` + ### One to Many (Inverse) / Belongs To @@ -1008,6 +1055,46 @@ You may also retrieve the parent of a polymorphic child model by accessing the n The `commentable` relation on the `Comment` model will return either a `Post` or `Video` instance, depending on which type of model is the comment's parent. + +#### Automatically Hydrating Parent Models on Children + +Even when utilizing Eloquent eager loading, "N + 1" query problems can arise if you try to access the parent model from a child model while looping through the child models: + +```php +$posts = Post::with('comments')->get(); + +foreach ($posts as $post) { + foreach ($post->comments as $comment) { + echo $comment->commentable->title; + } +} +``` + +In the example above, an "N + 1" query problem has been introduced because, even though comments were eager loaded for every `Post` model, Eloquent does not automatically hydrate the parent `Post` on each child `Comment` model. + +If you would like Eloquent to automatically hydrate parent models onto their children, you may invoke the `chaperone` method when defining a `hasMany` relationship: + + class Post extends Model + { + /** + * Get all of the post's comments. + */ + public function comments(): MorphMany + { + return $this->morphMany(Comment::class, 'commentable')->chaperone(); + } + } + +Or, if you would like to opt-in to automatic parent hydration at run time, you may invoke the `chaperone` model when eager loading the relationship: + +```php +use App\Models\Post; + +$posts = Post::with([ + 'comments' => fn ($comments) => $comments->chaperone(), +])->get(); +``` + ### One of Many (Polymorphic) diff --git a/helpers.md b/helpers.md index 382255b5899..fe06ecdfd46 100644 --- a/helpers.md +++ b/helpers.md @@ -5,6 +5,7 @@ - [Other Utilities](#other-utilities) - [Benchmarking](#benchmarking) - [Dates](#dates) + - [Deferred Functions](#deferred-functions) - [Lottery](#lottery) - [Pipeline](#pipeline) - [Sleep](#sleep) @@ -2352,6 +2353,36 @@ $now = Carbon::now(); For a thorough discussion of Carbon and its features, please consult the [official Carbon documentation](https://carbon.nesbot.com/docs/). + +### Deferred Functions + +> [!WARNING] +> Deferred functions are currently in beta while we gather community feedback. + +While Laravel's [queued jobs](/docs/{{version}}/queues) allow you to queue tasks for background processing, sometimes you may have simple tasks you would like to defer without configuring or maintaining a long-running queue worker. + +Deferred functions allow you to defer the execution of a closure until after the HTTP response has been sent to the user, keeping your application feeling fast and responsive. To defer the execution of a closure, simply pass the closure to the `defer` function: + +```php +use App\Services\Metrics; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Route; + +Route::post('/orders', function (Request $request) { + // Create order... + + defer(fn () => Metrics::reportOrder($order)); + + return $order; +}); +``` + +By default, deferred functions will only be executed if the HTTP response, Artisan command, or queued job from which `defer` is invoked completes successfully. This means that deferred functions will not be executed if a request results in a `4xx` or `5xx` HTTP response. If you would like a deferred function to always execute, you may chain the `always` method onto your deferred function: + +```php +defer(fn () => Metrics::reportOrder($order))->always(); +``` + ### Lottery @@ -2451,6 +2482,12 @@ Laravel's `Sleep` class is a light-weight wrapper around PHP's native `sleep` an The `Sleep` class offers a variety of methods that allow you to work with different units of time: + // Return a value after sleeping... + $result = Sleep::for(1)->second()->then(fn () => 1 + 1); + + // Sleep while a given value is true... + Sleep::for(1)->second()->while(fn () => shouldKeepSleeping()); + // Pause execution for 90 seconds... Sleep::for(1.5)->minutes(); From c394da46ffa88cd14e25ece6d374ce3057b457a9 Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Wed, 11 Sep 2024 19:07:41 -0300 Subject: [PATCH 189/325] [11.x] Add Skipping Jobs section (#9883) * [11.x] Add Skipping Jobs section * formatting --------- Co-authored-by: Taylor Otwell --- queues.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/queues.md b/queues.md index a324913faf4..ea99a89c0f8 100644 --- a/queues.md +++ b/queues.md @@ -12,6 +12,7 @@ - [Rate Limiting](#rate-limiting) - [Preventing Job Overlaps](#preventing-job-overlaps) - [Throttling Exceptions](#throttling-exceptions) + - [Skipping Jobs](#skipping-jobs) - [Dispatching Jobs](#dispatching-jobs) - [Delayed Dispatching](#delayed-dispatching) - [Synchronous Dispatching](#synchronous-dispatching) @@ -688,6 +689,39 @@ If you would like to have the throttled exceptions reported to your application' > [!NOTE] > If you are using Redis, you may use the `Illuminate\Queue\Middleware\ThrottlesExceptionsWithRedis` middleware, which is fine-tuned for Redis and more efficient than the basic exception throttling middleware. + +### Skipping Jobs + +The `Skip` middleware allows you to specify that a job should be skipped / deleted without needing to modify the job's logic. The `Skip::when` method will delete the job if the given condition evaluates to `true`, while the `Skip::unless` method will delete the job if the condition evaluates to `false`: + + use Illuminate\Queue\Middleware\Skip; + + /** + * Get the middleware the job should pass through. + */ + public function middleware(): array + { + return [ + Skip::when($someCondition), + ]; + } + +You can also pass a `Closure` to the `when` and `unless` methods for more complex conditional evaluation: + + use Illuminate\Queue\Middleware\Skip; + + /** + * Get the middleware the job should pass through. + */ + public function middleware(): array + { + return [ + Skip::when(function (): bool { + return $this->shouldSkip(); + }), + ]; + } + ## Dispatching Jobs From 4ee51634d1f738b7f3ebffa4955bdae40b0f2470 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 11 Sep 2024 17:11:03 -0500 Subject: [PATCH 190/325] wip --- eloquent-collections.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/eloquent-collections.md b/eloquent-collections.md index 5808b9c5868..bd1080352c1 100644 --- a/eloquent-collections.md +++ b/eloquent-collections.md @@ -67,6 +67,7 @@ In addition, the `Illuminate\Database\Eloquent\Collection` class provides a supe [diff](#method-diff) [except](#method-except) [find](#method-find) +[findOrFail](#method-find-or-fail) [fresh](#method-fresh) [intersect](#method-intersect) [load](#method-load) @@ -125,6 +126,15 @@ The `find` method returns the model that has a primary key matching the given ke $user = $users->find(1); + +#### `findOrFail($key)` {.collection-method} + +The `findOrFail` method returns the model that has a primary key matching the given key or throws an `Illuminate\Database\Eloquent\ModelNotFoundException` exception if no matching model can be found in the collection: + + $users = User::all(); + + $user = $users->findOrFail(1); + #### `fresh($with = [])` {.collection-method} From 0a27093a90b0db8cb6ef00ff576b7f8af786326f Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 11 Sep 2024 17:12:46 -0500 Subject: [PATCH 191/325] wip --- prompts.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/prompts.md b/prompts.md index 7ac4de4b0fa..5f8f49aeb1f 100644 --- a/prompts.md +++ b/prompts.md @@ -19,6 +19,7 @@ - [Tables](#tables) - [Spin](#spin) - [Progress Bar](#progress) +- [Clearing the Terminal](#clear) - [Terminal Considerations](#terminal-considerations) - [Unsupported Environments and Fallbacks](#fallbacks) @@ -888,6 +889,17 @@ foreach ($users as $user) { $progress->finish(); ``` + +## Clearing the Terminal + +The `clear` function may be used to clear the user's terminal: + +``` +use function Laravel\Prompts\clear; + +clear(); +``` + ## Terminal Considerations From 57ac7ac1a316e7c6c6efed4c4894921a65f406e6 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 11 Sep 2024 17:13:48 -0500 Subject: [PATCH 192/325] wip --- container.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/container.md b/container.md index 39155e8ea0f..575bd93461a 100644 --- a/container.md +++ b/container.md @@ -252,7 +252,7 @@ class PhotoController extends Controller } ``` -In addition to the `Storage` attribute, Laravel offers `Auth`, `Cache`, `Config`, `DB`, and `Log` attributes: +In addition to the `Storage` attribute, Laravel offers `Auth`, `Cache`, `Config`, `DB`, `Log`, and [`Tag`](#tagging) attributes: ```php Date: Wed, 11 Sep 2024 17:17:29 -0500 Subject: [PATCH 193/325] wip --- helpers.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/helpers.md b/helpers.md index fe06ecdfd46..8a7dc84a67e 100644 --- a/helpers.md +++ b/helpers.md @@ -199,6 +199,7 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct [value](#method-value) [view](#method-view) [with](#method-with) +[when](#method-when)
@@ -2304,6 +2305,23 @@ The `with` function returns the value it is given. If a closure is passed as the // 5 + +#### `when()` {.collection-method} + +The `when` function returns the value it is given if the given condition evaluates to `true`. Otherwise, `null` is returned. If a closure is passed as the second argument to the function, the closure will be executed and its returned value will be returned: + + $value = when(true, 'Hello World'); + + $value = when(true, fn () => 'Hello World'); + +The `when` function is primarily useful for conditionally rendering HTML attributes: + +```blade +
+ ... +
+``` + ## Other Utilities From 1dd01f3e13d27a8669a1b8832b86427d8e649c06 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 11 Sep 2024 17:17:47 -0500 Subject: [PATCH 194/325] wip --- helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers.md b/helpers.md index 8a7dc84a67e..f293cd61e54 100644 --- a/helpers.md +++ b/helpers.md @@ -2308,7 +2308,7 @@ The `with` function returns the value it is given. If a closure is passed as the #### `when()` {.collection-method} -The `when` function returns the value it is given if the given condition evaluates to `true`. Otherwise, `null` is returned. If a closure is passed as the second argument to the function, the closure will be executed and its returned value will be returned: +The `when` function returns the value it is given if a given condition evaluates to `true`. Otherwise, `null` is returned. If a closure is passed as the second argument to the function, the closure will be executed and its returned value will be returned: $value = when(true, 'Hello World'); From cfa4896d43b4fa1730d58e9e87d78c9adba046e4 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 11 Sep 2024 17:26:42 -0500 Subject: [PATCH 195/325] wip --- queries.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/queries.md b/queries.md index 401b8a63c29..369cd83d647 100644 --- a/queries.md +++ b/queries.md @@ -95,6 +95,10 @@ If you just need to retrieve a single row from a database table, you may use the return $user->email; +If you would like to retrieve a single row from the database table, but throw a `Illuminate\Database\RecordNotFoundException` is no matching row is found, you may use the `firstOrFail` method. If the `RecordNotFoundException` is not caught, a 404 HTTP response is automatically sent back to the client: + + $user = DB::table('users')->where('name', 'John')->firstOrFail(); + If you don't need an entire row, you may extract a single value from a record using the `value` method. This method will return the value of the column directly: $email = DB::table('users')->where('name', 'John')->value('email'); From 02dc4b6b61bc8ad607cc9b4ee9d4469f25fd8d00 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 11 Sep 2024 17:27:00 -0500 Subject: [PATCH 196/325] wip --- queries.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queries.md b/queries.md index 369cd83d647..4c01fe44a19 100644 --- a/queries.md +++ b/queries.md @@ -95,7 +95,7 @@ If you just need to retrieve a single row from a database table, you may use the return $user->email; -If you would like to retrieve a single row from the database table, but throw a `Illuminate\Database\RecordNotFoundException` is no matching row is found, you may use the `firstOrFail` method. If the `RecordNotFoundException` is not caught, a 404 HTTP response is automatically sent back to the client: +If you would like to retrieve a single row from a database table, but throw an `Illuminate\Database\RecordNotFoundException` if no matching row is found, you may use the `firstOrFail` method. If the `RecordNotFoundException` is not caught, a 404 HTTP response is automatically sent back to the client: $user = DB::table('users')->where('name', 'John')->firstOrFail(); From 510dd2ef02a1efee44174d64c97ea79cf4532d49 Mon Sep 17 00:00:00 2001 From: Ronald Beilsma Date: Thu, 12 Sep 2024 17:36:39 +0300 Subject: [PATCH 197/325] [11.x] Fix fluent methods order (alphabetical) (#9891) * [11.x] Fix fluent methods order (alphabetical) * Also fix order in method list --- strings.md | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/strings.md b/strings.md index 9408404fb6d..e81aa12ba24 100644 --- a/strings.md +++ b/strings.md @@ -143,8 +143,8 @@ Laravel includes a variety of functions for manipulating string values. Many of [containsAll](#method-fluent-str-contains-all) [dirname](#method-fluent-str-dirname) [endsWith](#method-fluent-str-ends-with) -[excerpt](#method-fluent-str-excerpt) [exactly](#method-fluent-str-exactly) +[excerpt](#method-fluent-str-excerpt) [explode](#method-fluent-str-explode) [finish](#method-fluent-str-finish) [headline](#method-fluent-str-headline) @@ -1763,32 +1763,6 @@ If necessary, you may specify how many directory levels you wish to trim from th // '/foo' - -#### `excerpt` {.collection-method} - -The `excerpt` method extracts an excerpt from the string that matches the first instance of a phrase within that string: - - use Illuminate\Support\Str; - - $excerpt = Str::of('This is my name')->excerpt('my', [ - 'radius' => 3 - ]); - - // '...is my na...' - -The `radius` option, which defaults to `100`, allows you to define the number of characters that should appear on each side of the truncated string. - -In addition, you may use the `omission` option to change the string that will be prepended and appended to the truncated string: - - use Illuminate\Support\Str; - - $excerpt = Str::of('This is my name')->excerpt('name', [ - 'radius' => 3, - 'omission' => '(...) ' - ]); - - // '(...) my name' - #### `endsWith` {.collection-method} @@ -1823,6 +1797,32 @@ The `exactly` method determines if the given string is an exact match with anoth // true + +#### `excerpt` {.collection-method} + +The `excerpt` method extracts an excerpt from the string that matches the first instance of a phrase within that string: + + use Illuminate\Support\Str; + + $excerpt = Str::of('This is my name')->excerpt('my', [ + 'radius' => 3 + ]); + + // '...is my na...' + +The `radius` option, which defaults to `100`, allows you to define the number of characters that should appear on each side of the truncated string. + +In addition, you may use the `omission` option to change the string that will be prepended and appended to the truncated string: + + use Illuminate\Support\Str; + + $excerpt = Str::of('This is my name')->excerpt('name', [ + 'radius' => 3, + 'omission' => '(...) ' + ]); + + // '(...) my name' + #### `explode` {.collection-method} From d62fe02f06606bc5696999e03f42008ce950801c Mon Sep 17 00:00:00 2001 From: Ronald Beilsma Date: Thu, 12 Sep 2024 17:41:25 +0300 Subject: [PATCH 198/325] [11.x] Document Str::deduplicate method (#9890) * [11.x] Document Str::deduplicate method * Fix order (alphabetical) * formatting --------- Co-authored-by: Taylor Otwell --- strings.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/strings.md b/strings.md index e81aa12ba24..e56975e3fe6 100644 --- a/strings.md +++ b/strings.md @@ -47,6 +47,7 @@ Laravel includes a variety of functions for manipulating string values. Many of [Str::chopEnd](#method-str-chop-end) [Str::contains](#method-str-contains) [Str::containsAll](#method-str-contains-all) +[Str::deduplicate](#method-deduplicate) [Str::endsWith](#method-ends-with) [Str::excerpt](#method-excerpt) [Str::finish](#method-str-finish) @@ -141,6 +142,7 @@ Laravel includes a variety of functions for manipulating string values. Many of [chopEnd](#method-fluent-str-chop-end) [contains](#method-fluent-str-contains) [containsAll](#method-fluent-str-contains-all) +[deduplicate](#method-fluent-str-deduplicate) [dirname](#method-fluent-str-dirname) [endsWith](#method-fluent-str-ends-with) [exactly](#method-fluent-str-exactly) @@ -466,6 +468,25 @@ You may disable case sensitivity by setting the `ignoreCase` argument to `true`: // true + +#### `Str::deduplicate()` {.collection-method} + +The `Str::deduplicate` method replaces consecutive instances of a character with a single instance of that character in the given string. By default, the method deduplicates spaces: + + use Illuminate\Support\Str; + + $result = Str::deduplicate('The Laravel Framework'); + + // The Laravel Framework + +You may specify a different character to deduplicate by passing it in as the second argument to the method: + + use Illuminate\Support\Str; + + $result = Str::deduplicate('The---Laravel---Framework', '-'); + + // The-Laravel-Framework + #### `Str::endsWith()` {.collection-method} @@ -1744,6 +1765,25 @@ You can disable case sensitivity by setting the `ignoreCase` argument to `true`: // true + +#### `deduplicate` {.collection-method} + +The `deduplicate` method replaces consecutive instances of a character with a single instance of that character in the given string. By default, the method deduplicates spaces: + + use Illuminate\Support\Str; + + $result = Str::of('The Laravel Framework')->deduplicate(); + + // The Laravel Framework + +You may specify a different character to deduplicate by passing it in as the second argument to the method: + + use Illuminate\Support\Str; + + $result = Str::of('The---Laravel---Framework')->deduplicate('-'); + + // The-Laravel-Framework + #### `dirname` {.collection-method} From ce6cf0e289dff0b42a9c2a1e2206200498d50018 Mon Sep 17 00:00:00 2001 From: Braunson Yager Date: Thu, 12 Sep 2024 14:19:11 -0400 Subject: [PATCH 199/325] [11.x] Update scout.md about connecting to Typesense in Laravel Sail (#9889) * Update scout.md Added note under Typesense section about setting the TYPESENSE_HOST to match the Docker container for Typesense allowing Scout to properly connect. * Update scout.md --------- Co-authored-by: Taylor Otwell --- scout.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scout.md b/scout.md index ba64255c8aa..65af70930a7 100644 --- a/scout.md +++ b/scout.md @@ -147,7 +147,7 @@ TYPESENSE_API_KEY=masterKey TYPESENSE_HOST=localhost ``` -If needed, you may also specify your installation's port, path, and protocol: +If you are using [Laravel Sail](/docs/{{version}}/sail), you may need to adjust the `TYPESENSE_HOST` environment variable to match the Docker container name. You may also optionally specify your installation's port, path, and protocol: ```env TYPESENSE_PORT=8108 From 4fb89ead0f2fb36c7deda672befa00d4be008c44 Mon Sep 17 00:00:00 2001 From: Benji Bilheimer Date: Fri, 13 Sep 2024 18:02:09 +0200 Subject: [PATCH 200/325] Add documentation for retrieving input values as integers to requests.md (#9894) * Add documentation for retrieving input values as integers to requests.md * Update requests.md --------- Co-authored-by: Taylor Otwell --- requests.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/requests.md b/requests.md index dd35ff68f84..bfcc95d2467 100644 --- a/requests.md +++ b/requests.md @@ -310,6 +310,13 @@ Instead of retrieving the request's input data as a primitive `string`, you may $name = $request->string('name')->trim(); + +#### Retrieving Integer Input Values + +To retrieve input values as integers, you may use the `integer` method. This method will attempt to cast the input value to an integer. If the input is not present or the cast fails, it will return the default value you specify. This is particularly useful for pagination or other numeric inputs: + + $perPage = $request->integer('per_page'); + #### Retrieving Boolean Input Values From ce657e91c960ef28cfa9da317021c9d4650e945c Mon Sep 17 00:00:00 2001 From: Giancarlo Di Massa Date: Fri, 13 Sep 2024 18:06:21 +0200 Subject: [PATCH 201/325] Update concurrency.md (#9893) * Update concurrency.md - Add requirements of spatie/fork - Show example on how to switch drivers - Explain that the defer method will never run the tasks in the PHP CLI's context * Update concurrency.md --------- Co-authored-by: Taylor Otwell --- concurrency.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/concurrency.md b/concurrency.md index 114950d9f38..d849f6049a1 100644 --- a/concurrency.md +++ b/concurrency.md @@ -17,7 +17,15 @@ Sometimes you may need to execute several slow tasks which do not depend on one Laravel achieves concurrency by serializing the given closures and dispatching them to a hidden Artisan CLI command, which unserializes the closures and invokes it within its own PHP process. After the closure has been invoked, the resulting value is serialized back to the parent process. -The `Concurrency` facade supports three drivers: `process` (the default), `fork`, and `sync`. The `fork` driver offers improved performance compared to the default `process` driver, but it may only be used within PHP's CLI context, as PHP does not support forking during web requests. The `sync` driver is primarily useful during testing when you want to disable all concurrency and simple execute the given closure in sequence within the parent process. +The `Concurrency` facade supports three drivers: `process` (the default), `fork`, and `sync`. + +The `fork` driver offers improved performance compared to the default `process` driver, but it may only be used within PHP's CLI context, as PHP does not support forking during web requests. Before using the `fork` driver, you need to install the `spatie/fork` package: + +```bash +composer require spatie/fork +``` + +The `sync` driver is primarily useful during testing when you want to disable all concurrency and simply execute the given closures in sequence within the parent process. ## Running Concurrent Tasks @@ -34,6 +42,18 @@ use Illuminate\Support\Facades\DB; ]); ``` +To use a specific driver, you may use the `driver` method: + +```php +$results = Concurrency::driver('fork')->run(...); +``` + +Or, to change the default concurrency driver, you should publish the `concurrency` configuration file via the `config:publish` Artisan command and update the `default` option within the file: + +```bash +php artisan config:publish concurrency +``` + ## Deferring Concurrent Tasks From afbf2ca8be70031941591131a9a56571a5a5a8a4 Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Fri, 13 Sep 2024 13:15:57 -0300 Subject: [PATCH 202/325] [11.x] Add dispatching without delay section (#9888) * [11.x] Add dispatching without delay section * formatting * word * formatting --------- Co-authored-by: Taylor Otwell --- queues.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/queues.md b/queues.md index ea99a89c0f8..4c4926add0c 100644 --- a/queues.md +++ b/queues.md @@ -795,6 +795,10 @@ If you would like to specify that a job should not be immediately available for } } +In some cases, jobs may have a default delay configured. If you need to bypass this delay and dispatch a job for immediate processing, you may use the `withoutDelay` method: + + ProcessPodcast::dispatch($podcast)->withoutDelay(); + > [!WARNING] > The Amazon SQS queue service has a maximum delay time of 15 minutes. From 821326045cb8527b3aa79dddbd31eceeebcf8bd6 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sun, 15 Sep 2024 15:51:45 -0500 Subject: [PATCH 203/325] wip --- helpers.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/helpers.md b/helpers.md index f293cd61e54..0bbc8f7e8c2 100644 --- a/helpers.md +++ b/helpers.md @@ -2401,6 +2401,19 @@ By default, deferred functions will only be executed if the HTTP response, Artis defer(fn () => Metrics::reportOrder($order))->always(); ``` + +#### Deferred Function Compatibility + +If you upgraded to Laravel 11.x from a Laravel 10.x application and your application's skeleton still contains an `app/Http/Kernel.php` file, you should add the `InvokeDeferredCallbacks` middleware to the beginning of the kernel's `$middleware` property: + +```php +protected $middleware = [ + \Illuminate\Foundation\Http\Middleware\InvokeDeferredCallbacks::class, + \App\Http\Middleware\TrustProxies::class, + // ... +]; +``` + ### Lottery From 0a357c22b2c218b70d281caa8e912af17edc630d Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sun, 15 Sep 2024 15:52:42 -0500 Subject: [PATCH 204/325] wip --- helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers.md b/helpers.md index 0bbc8f7e8c2..b3c9a604b6d 100644 --- a/helpers.md +++ b/helpers.md @@ -2408,7 +2408,7 @@ If you upgraded to Laravel 11.x from a Laravel 10.x application and your applica ```php protected $middleware = [ - \Illuminate\Foundation\Http\Middleware\InvokeDeferredCallbacks::class, + \Illuminate\Foundation\Http\Middleware\InvokeDeferredCallbacks::class, // [tl! add] \App\Http\Middleware\TrustProxies::class, // ... ]; From 81330e871dd01be123c39846b8f4a46c023c4476 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sun, 15 Sep 2024 15:58:01 -0500 Subject: [PATCH 205/325] wip --- filesystem.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/filesystem.md b/filesystem.md index 6a4e839cd67..0f3c04f78e7 100644 --- a/filesystem.md +++ b/filesystem.md @@ -312,7 +312,7 @@ If you would like to modify the host for URLs generated using the `Storage` faca ### Temporary URLs -Using the `temporaryUrl` method, you may create temporary URLs to files stored using the `s3` driver. This method accepts a path and a `DateTime` instance specifying when the URL should expire: +Using the `temporaryUrl` method, you may create temporary URLs to files stored using the `local` and `s3` drivers. This method accepts a path and a `DateTime` instance specifying when the URL should expire: use Illuminate\Support\Facades\Storage; @@ -320,6 +320,23 @@ Using the `temporaryUrl` method, you may create temporary URLs to files stored u 'file.jpg', now()->addMinutes(5) ); + +#### Enabling Local Temporary URLs + +If you started developing your application before support for temporary URLs was introduced to the `local` driver, you may need to enable local temporary URLs. To do so, add the `serve` option to your `local` disk's configuration array within the `config/filesystems.php` configuration file: + +```php +'local' => [ + 'driver' => 'local', + 'root' => storage_path('app/private'), + 'serve' => true, // [tl! add] + 'throw' => false, +], +``` + + +#### S3 Request Parameters + If you need to specify additional [S3 request parameters](https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGET.html#RESTObjectGET-requests), you may pass the array of request parameters as the third argument to the `temporaryUrl` method: $url = Storage::temporaryUrl( @@ -331,6 +348,9 @@ If you need to specify additional [S3 request parameters](https://docs.aws.amazo ] ); + +#### Customizing Temporary URLs + If you need to customize how temporary URLs are created for a specific storage disk, you can use the `buildTemporaryUrlsUsing` method. For example, this can be useful if you have a controller that allows you to download files stored via a disk that doesn't typically support temporary URLs. Usually, this method should be called from the `boot` method of a service provider: Date: Mon, 16 Sep 2024 15:12:38 +0100 Subject: [PATCH 206/325] Update when helper example for rendering HTML attributes. (#9898) Josh Cirre DM'd me that he was having an issue with using when() with livewire, and noted that the docs example shows it using `{{` blade tags, where it should be using `{!!` to prevent output escaping. quick fix! --- helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers.md b/helpers.md index b3c9a604b6d..884d9f9ccdb 100644 --- a/helpers.md +++ b/helpers.md @@ -2317,7 +2317,7 @@ The `when` function returns the value it is given if a given condition evaluates The `when` function is primarily useful for conditionally rendering HTML attributes: ```blade -
+
...
``` From 45c8abc0c7f914cbd223f207ee44ab417deb8065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rodr=C3=ADguez?= Date: Mon, 16 Sep 2024 16:17:37 +0200 Subject: [PATCH 207/325] [11.x] Fix `ThrottlesExceptions` description and adjust `retryUntil()` time limit (#9899) * Fixes incorrect behavior description of the Limiter and adjusts the time limit value to reduce confusion * Improoved redaction for the 30-minute time limit --------- Co-authored-by: Jose Rodriguez --- queues.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/queues.md b/queues.md index 4c4926add0c..cda1ccedfe8 100644 --- a/queues.md +++ b/queues.md @@ -619,10 +619,10 @@ For example, let's imagine a queued job that interacts with a third-party API th */ public function retryUntil(): DateTime { - return now()->addMinutes(5); + return now()->addMinutes(30); } -The first constructor argument accepted by the middleware is the number of exceptions the job can throw before being throttled, while the second constructor argument is the number of seconds that should elapse before the job is attempted again once it has been throttled. In the code example above, if the job throws 10 exceptions within 5 minutes, we will wait 5 minutes before attempting the job again. +The first constructor argument accepted by the middleware is the number of exceptions the job can throw before being throttled, while the second constructor argument is the number of seconds that should elapse before the job is attempted again once it has been throttled. In the code example above, if the job throws 10 consecutive exceptions, we will wait 5 minutes before attempting the job again, constrained by the 30-minute time limit. When a job throws an exception but the exception threshold has not yet been reached, the job will typically be retried immediately. However, you may specify the number of minutes such a job should be delayed by calling the `backoff` method when attaching the middleware to the job: From aac0a3fa319d0ac84d546957c4ca30ca0ec4c2df Mon Sep 17 00:00:00 2001 From: Hasan Can Boga Date: Mon, 16 Sep 2024 17:30:26 +0300 Subject: [PATCH 208/325] Add hint about ConcurrencyServiceProvider for old Laravel structure (#9897) * Add hint about ConcurrencyServiceProvider for older Laravel versions * wip --------- Co-authored-by: Hasancan Boga Co-authored-by: Taylor Otwell --- concurrency.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/concurrency.md b/concurrency.md index d849f6049a1..a5f93276548 100644 --- a/concurrency.md +++ b/concurrency.md @@ -12,6 +12,29 @@ Sometimes you may need to execute several slow tasks which do not depend on one another. In many cases, significant performance improvements can be realized by executing the tasks concurrently. Laravel's `Concurrency` facade provides a simple, convenient API for executing closures concurrently. + +#### Concurrency Compatibility + +If you upgraded to Laravel 11.x from a Laravel 10.x application, you may need to add the `ConcurrencyServiceProvider` to the `providers` array in your application's `config/app.php` configuration file: + +```php +'providers' => ServiceProvider::defaultProviders()->merge([ + /* + * Package Service Providers... + */ + Illuminate\Concurrency\ConcurrencyServiceProvider::class, // [tl! add] + + /* + * Application Service Providers... + */ + App\Providers\AppServiceProvider::class, + App\Providers\AuthServiceProvider::class, + // App\Providers\BroadcastServiceProvider::class, + App\Providers\EventServiceProvider::class, + App\Providers\RouteServiceProvider::class, +])->toArray(), +``` + #### How it Works From 6e7ec33a34c32dd3416823e5960e2c339320c074 Mon Sep 17 00:00:00 2001 From: Peter C <63091190+petoc@users.noreply.github.com> Date: Tue, 17 Sep 2024 16:16:29 +0200 Subject: [PATCH 209/325] passport.md - Purging Tokens, updated namespace (#9900) --- passport.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/passport.md b/passport.md index 8e06f93ff57..96738eae41b 100644 --- a/passport.md +++ b/passport.md @@ -518,7 +518,7 @@ php artisan passport:purge --expired You may also configure a [scheduled job](/docs/{{version}}/scheduling) in your application's `routes/console.php` file to automatically prune your tokens on a schedule: - use Laravel\Support\Facades\Schedule; + use Illuminate\Support\Facades\Schedule; Schedule::command('passport:purge')->hourly(); From ebbf48e1899a68df4f067292a0e7b0ea2ffba143 Mon Sep 17 00:00:00 2001 From: Wes Hooper Date: Wed, 18 Sep 2024 15:23:10 +0100 Subject: [PATCH 210/325] Document fluent string wrap() (#9904) --- strings.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/strings.md b/strings.md index e56975e3fe6..396f45c4c57 100644 --- a/strings.md +++ b/strings.md @@ -228,6 +228,7 @@ Laravel includes a variety of functions for manipulating string values. Many of [whenTest](#method-fluent-str-when-test) [wordCount](#method-fluent-str-word-count) [words](#method-fluent-str-words) +[wrap](#method-fluent-str-wrap)
@@ -3051,3 +3052,18 @@ The `words` method limits the number of words in a string. If necessary, you may $string = Str::of('Perfectly balanced, as all things should be.')->words(3, ' >>>'); // Perfectly balanced, as >>> + + +#### `wrap` {.collection-method} + +The `wrap` method wraps the given string with an additional string or pair of strings: + + use Illuminate\Support\Str; + + Str::of('Laravel')->wrap('"'); + + // "Laravel" + + Str::is('is')->wrap(before: 'This ', after: ' Laravel!'); + + // This is Laravel! From 358fd26b3a81359b6e5f54d263f50083e82f525b Mon Sep 17 00:00:00 2001 From: Ronny Badilla Date: Wed, 18 Sep 2024 08:41:12 -0600 Subject: [PATCH 211/325] [11.x] `helpers.md` - Cancelling deferred functions (#9902) * mention defer forget method * formatting * remove word * wording --------- Co-authored-by: Taylor Otwell --- helpers.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/helpers.md b/helpers.md index 884d9f9ccdb..9a75390696e 100644 --- a/helpers.md +++ b/helpers.md @@ -2401,6 +2401,17 @@ By default, deferred functions will only be executed if the HTTP response, Artis defer(fn () => Metrics::reportOrder($order))->always(); ``` + +#### Cancelling Deferred Functions + +If you need to cancel a deferred function before it is executed, you can use the `forget` method to cancel the function by its name. To name a deferred function, provide a second argument to the `defer` function: + +```php +defer(fn () => Metrics::report(), 'reportMetrics'); + +defer()->forget('reportMetrics'); +``` + #### Deferred Function Compatibility From a71a1ac32316192e8c489268c2fbc61f6bc6f3e7 Mon Sep 17 00:00:00 2001 From: Renato Cardoso Date: Thu, 19 Sep 2024 08:19:06 -0300 Subject: [PATCH 212/325] [11.x] Add middleware alias registration example for EnsureUserHasRole middleware (#9906) * [11.x] Add middleware alias registration example for EnsureUserHasRole middleware This commit adds information about registering a middleware alias for the `EnsureUserHasRole` middleware example in the "Middleware Parameters" section of the documentation. The current documentation provides an example of the `EnsureUserHasRole` middleware and how to use it with parameters, but it doesn't mention the necessary step of registering the middleware alias. This addition will help users avoid confusion when implementing the middleware in their applications. Changes made: 1. Added a code snippet demonstrating how to register the `EnsureUserHasRole` middleware alias in the `bootstrap/app.php` file. 2. Placed the new information immediately after the middleware class example and before the route definition examples. * Update middleware.md * Update middleware.md --------- Co-authored-by: Taylor Otwell --- middleware.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/middleware.md b/middleware.md index 9938bfe0aac..b9e3d03b21f 100644 --- a/middleware.md +++ b/middleware.md @@ -394,15 +394,17 @@ Additional middleware parameters will be passed to the middleware after the `$ne Middleware parameters may be specified when defining the route by separating the middleware name and parameters with a `:`: + use App\Http\Middleware\EnsureUserHasRole; + Route::put('/post/{id}', function (string $id) { // ... - })->middleware('role:editor'); + })->middleware(EnsureUserHasRole::class.':editor'); Multiple parameters may be delimited by commas: Route::put('/post/{id}', function (string $id) { // ... - })->middleware('role:editor,publisher'); + })->middleware(EnsureUserHasRole::class.':editor,publisher'); ## Terminable Middleware From 05e97a83ed36b745afd6abd7c307d6689143a580 Mon Sep 17 00:00:00 2001 From: Sarah Gilberg Date: Thu, 19 Sep 2024 07:31:03 -0400 Subject: [PATCH 213/325] Document breaking change in password rehashing if custom password field (#9901) * Document breaking change in password rehashing if custom password field Also added missing likelihood-of-impact, which I'm calling "low" since most folks probably use the default 'password' field name. * Update upgrade.md --------- Co-authored-by: Taylor Otwell --- upgrade.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/upgrade.md b/upgrade.md index 381f486024c..209df7bd94c 100644 --- a/upgrade.md +++ b/upgrade.md @@ -126,9 +126,15 @@ However, we do **not recommend** that Laravel 10 applications upgrading to Larav #### Password Rehashing -Laravel 11 will automatically rehash your user's passwords during authentication if your hashing algorithm's "work factor" has been updated since the password was last hashed. +**Likelihood Of Impact: Low** + +Laravel 11 will automatically rehash your user's passwords during authentication if your hashing algorithm's "work factor" has been updated since the password was last hashed. + +Typically, this should not disrupt your application; however, if your `User` model's "password" field has a name other than `password`, you should specify the field's name via the model's `authPasswordName` property: + + protected $authPasswordName = 'custom_password_field'; -Typically, this should not disrupt your application; however, you may disable this behavior by adding the `rehash_on_login` option to your application's `config/hashing.php` configuration file: +Alternatively, you may disable password rehashing by adding the `rehash_on_login` option to your application's `config/hashing.php` configuration file: 'rehash_on_login' => false, From ab75377e9b8fff24a3f4715895a82087513c5fcf Mon Sep 17 00:00:00 2001 From: "Pankaj M. Aagjal" Date: Fri, 20 Sep 2024 14:51:35 +0200 Subject: [PATCH 214/325] fix: active version mentioned in contributions.md (#9907) --- contributions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributions.md b/contributions.md index e390461c54d..5e96e643fb8 100644 --- a/contributions.md +++ b/contributions.md @@ -80,7 +80,7 @@ Informal discussion regarding bugs, new features, and implementation of existing ## Which Branch? -**All** bug fixes should be sent to the latest version that supports bug fixes (currently `10.x`). Bug fixes should **never** be sent to the `master` branch unless they fix features that exist only in the upcoming release. +**All** bug fixes should be sent to the latest version that supports bug fixes (currently `11.x`). Bug fixes should **never** be sent to the `master` branch unless they fix features that exist only in the upcoming release. **Minor** features that are **fully backward compatible** with the current release may be sent to the latest stable branch (currently `11.x`). From 38fa9c370f19c1bfad16eb1b9e83884f94cf526a Mon Sep 17 00:00:00 2001 From: Seweryn Czabanowski <68080844+PaperTurtle@users.noreply.github.com> Date: Sun, 22 Sep 2024 17:03:09 +0200 Subject: [PATCH 215/325] Add Laravel Breeze link (#9912) --- contributions.md | 1 + 1 file changed, 1 insertion(+) diff --git a/contributions.md b/contributions.md index 5e96e643fb8..ce9668a2c47 100644 --- a/contributions.md +++ b/contributions.md @@ -28,6 +28,7 @@ The Laravel source code is managed on GitHub, and there are repositories for eac - [Laravel Application](https://github.com/laravel/laravel) - [Laravel Art](https://github.com/laravel/art) +- [Laravel Breeze](https://github.com/laravel/breeze) - [Laravel Documentation](https://github.com/laravel/docs) - [Laravel Dusk](https://github.com/laravel/dusk) - [Laravel Cashier Stripe](https://github.com/laravel/cashier) From b744d060e795703c95a56576c63011f68101020e Mon Sep 17 00:00:00 2001 From: Sajad Torkamani Date: Sun, 22 Sep 2024 16:05:29 +0100 Subject: [PATCH 216/325] fix links to Mailgun docs (#9910) --- mail.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mail.md b/mail.md index df469d22326..2798dad7bfc 100644 --- a/mail.md +++ b/mail.md @@ -689,7 +689,7 @@ Some third-party email providers such as Mailgun and Postmark support message "t ); } -If your application is using the Mailgun driver, you may consult Mailgun's documentation for more information on [tags](https://documentation.mailgun.com/en/latest/user_manual.html#tagging-1) and [metadata](https://documentation.mailgun.com/en/latest/user_manual.html#attaching-data-to-messages). Likewise, the Postmark documentation may also be consulted for more information on their support for [tags](https://postmarkapp.com/blog/tags-support-for-smtp) and [metadata](https://postmarkapp.com/support/article/1125-custom-metadata-faq). +If your application is using the Mailgun driver, you may consult Mailgun's documentation for more information on [tags](https://documentation.mailgun.com/docs/mailgun/user-manual/tracking-messages/#tagging) and [metadata](https://documentation.mailgun.com/docs/mailgun/user-manual/tracking-messages/#attaching-data-to-messages). Likewise, the Postmark documentation may also be consulted for more information on their support for [tags](https://postmarkapp.com/blog/tags-support-for-smtp) and [metadata](https://postmarkapp.com/support/article/1125-custom-metadata-faq). If your application is using Amazon SES to send emails, you should use the `metadata` method to attach [SES "tags"](https://docs.aws.amazon.com/ses/latest/APIReference/API_MessageTag.html) to the message. From d41ad218afaa2cf009e8c47411f3405ef208fe42 Mon Sep 17 00:00:00 2001 From: gisu nasrollahi <113020788+gisuNasr@users.noreply.github.com> Date: Sun, 22 Sep 2024 18:43:04 +0330 Subject: [PATCH 217/325] noActionOnDelete() added to migrations.md (#9908) * add noActionOnDelete() to migrations.md * Update migrations.md --------- Co-authored-by: Taylor Otwell --- migrations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/migrations.md b/migrations.md index f86f2cab482..a22bc3e5c25 100644 --- a/migrations.md +++ b/migrations.md @@ -1194,6 +1194,7 @@ An alternative, expressive syntax is also provided for these actions: | `$table->cascadeOnDelete();` | Deletes should cascade. | | `$table->restrictOnDelete();` | Deletes should be restricted. | | `$table->nullOnDelete();` | Deletes should set the foreign key value to null. | +| `$table->noActionOnDelete();` | Prevents deletes if child records exist. |
From dc8015a44281e30a45bd98de4a5830b56d002392 Mon Sep 17 00:00:00 2001 From: inmanturbo <47095624+inmanturbo@users.noreply.github.com> Date: Mon, 23 Sep 2024 09:33:53 -0400 Subject: [PATCH 218/325] fix incompatible return type (#9909) * fix incompatible return type * Include full doc block like in the factory example * Update eloquent-factories.md * Update eloquent-factories.md --------- Co-authored-by: Taylor Otwell --- eloquent-factories.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/eloquent-factories.md b/eloquent-factories.md index 2c852a7f7ba..9baefc19b37 100644 --- a/eloquent-factories.md +++ b/eloquent-factories.md @@ -95,13 +95,12 @@ Once you have defined your factories, you may use the static `factory` method pr The `HasFactory` trait's `factory` method will use conventions to determine the proper factory for the model the trait is assigned to. Specifically, the method will look for a factory in the `Database\Factories` namespace that has a class name matching the model name and is suffixed with `Factory`. If these conventions do not apply to your particular application or factory, you may overwrite the `newFactory` method on your model to return an instance of the model's corresponding factory directly: - use Illuminate\Database\Eloquent\Factories\Factory; use Database\Factories\Administration\FlightFactory; /** * Create a new factory instance for the model. */ - protected static function newFactory(): Factory + protected static function newFactory() { return FlightFactory::new(); } From f54c269ce77ea3fff2f36f325a8d82b3a42bc23c Mon Sep 17 00:00:00 2001 From: Mohammed Omer Date: Tue, 24 Sep 2024 18:41:26 +0400 Subject: [PATCH 219/325] [11.x] Clarify event subscriber registration (#9913) * Clarify event subscriber registration * Update events.md * Update events.md --------- Co-authored-by: Taylor Otwell --- events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/events.md b/events.md index ebe2934bddb..93c7b8cd69d 100644 --- a/events.md +++ b/events.md @@ -631,7 +631,7 @@ If your event listener methods are defined within the subscriber itself, you may ### Registering Event Subscribers -After writing the subscriber, you are ready to register it with the event dispatcher. You may register subscribers using the `subscribe` method of the `Event` facade. Typically, this should be done within the `boot` method of your application's `AppServiceProvider`: +After writing the subscriber, Laravel will automatically register handler methods within the subscriber if they follow Laravel's [event discovery conventions](#event-discovery). Otherwise, you may manually register your subscriber using the `subscribe` method of the `Event` facade. Typically, this should be done within the `boot` method of your application's `AppServiceProvider`: Date: Wed, 25 Sep 2024 12:02:32 -0400 Subject: [PATCH 220/325] DynamoDB Cache TTL (#9916) * DynamoDB Cache TTL * formatting --------- Co-authored-by: Taylor Otwell --- cache.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cache.md b/cache.md index 0eced2f74d1..56bc99d5a10 100644 --- a/cache.md +++ b/cache.md @@ -90,6 +90,8 @@ Before using the [DynamoDB](https://aws.amazon.com/dynamodb) cache driver, you m This table should also have a string partition key with a name that corresponds to the value of the `stores.dynamodb.attributes.key` configuration item within your application's `cache` configuration file. By default, the partition key should be named `key`. +Typically, DynamoDB will not proactively remove expired items from a table. Therefore, you should [enable Time to Live (TTL)](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TTL.html) on the table. When configuring the table's TTL settings, you should set the TTL attribute name to `expires_at`. + Next, install the AWS SDK so that your Laravel application can communicate with DynamoDB: ```shell From 1ba0d0395b54440fb2d706b676aeb1828d4731fc Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Thu, 26 Sep 2024 21:56:27 +1000 Subject: [PATCH 221/325] [11.x] Document namespaced function (#9915) * Document namespaced function * reference namespaced function in prose --- helpers.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/helpers.md b/helpers.md index 9a75390696e..097f1ff83ea 100644 --- a/helpers.md +++ b/helpers.md @@ -2379,12 +2379,13 @@ For a thorough discussion of Carbon and its features, please consult the [offici While Laravel's [queued jobs](/docs/{{version}}/queues) allow you to queue tasks for background processing, sometimes you may have simple tasks you would like to defer without configuring or maintaining a long-running queue worker. -Deferred functions allow you to defer the execution of a closure until after the HTTP response has been sent to the user, keeping your application feeling fast and responsive. To defer the execution of a closure, simply pass the closure to the `defer` function: +Deferred functions allow you to defer the execution of a closure until after the HTTP response has been sent to the user, keeping your application feeling fast and responsive. To defer the execution of a closure, simply pass the closure to the `Illuminate\Support\defer` function: ```php use App\Services\Metrics; use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; +use function Illuminate\Support\defer; Route::post('/orders', function (Request $request) { // Create order... @@ -2395,7 +2396,7 @@ Route::post('/orders', function (Request $request) { }); ``` -By default, deferred functions will only be executed if the HTTP response, Artisan command, or queued job from which `defer` is invoked completes successfully. This means that deferred functions will not be executed if a request results in a `4xx` or `5xx` HTTP response. If you would like a deferred function to always execute, you may chain the `always` method onto your deferred function: +By default, deferred functions will only be executed if the HTTP response, Artisan command, or queued job from which `Illuminate\Support\defer` is invoked completes successfully. This means that deferred functions will not be executed if a request results in a `4xx` or `5xx` HTTP response. If you would like a deferred function to always execute, you may chain the `always` method onto your deferred function: ```php defer(fn () => Metrics::reportOrder($order))->always(); @@ -2404,7 +2405,7 @@ defer(fn () => Metrics::reportOrder($order))->always(); #### Cancelling Deferred Functions -If you need to cancel a deferred function before it is executed, you can use the `forget` method to cancel the function by its name. To name a deferred function, provide a second argument to the `defer` function: +If you need to cancel a deferred function before it is executed, you can use the `forget` method to cancel the function by its name. To name a deferred function, provide a second argument to the `Illuminate\Support\defer` function: ```php defer(fn () => Metrics::report(), 'reportMetrics'); From 2d2cfae706c9367ebf19e13175dc1de2711cad7a Mon Sep 17 00:00:00 2001 From: Arco Voets <142106975+ArcoVoets@users.noreply.github.com> Date: Sat, 28 Sep 2024 16:24:05 +0200 Subject: [PATCH 222/325] Update pulse.md (#9919) Fix: User requests are about URLs, so ignore ignores URLs and not jobs --- pulse.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pulse.md b/pulse.md index 4020822192b..4cabaa86b5a 100644 --- a/pulse.md +++ b/pulse.md @@ -426,7 +426,7 @@ You may optionally adjust the [sample rate](#sampling) and ignored job patterns. The `UserRequests` recorder captures information about the users making requests to your application for display on the [Application Usage](#application-usage-card) card. -You may optionally adjust the [sample rate](#sampling) and ignored job patterns. +You may optionally adjust the [sample rate](#sampling) and ignored URL patterns. ### Filtering From f04003eccc61f9f05e291305d66f73cd10dbb1da Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 1 Oct 2024 16:06:44 -0500 Subject: [PATCH 223/325] wip --- pennant.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pennant.md b/pennant.md index 1d8e04a2411..c0783ae1b3f 100644 --- a/pennant.md +++ b/pennant.md @@ -364,7 +364,7 @@ $user->features()->unless('new-api', ### Blade Directive -To make checking features in Blade a seamless experience, Pennant offers a `@feature` directive: +To make checking features in Blade a seamless experience, Pennant offers the `@feature` and `@featureany` directive: ```blade @feature('site-redesign') @@ -372,6 +372,10 @@ To make checking features in Blade a seamless experience, Pennant offers a `@fea @else @endfeature + +@featureany(['site-redesign', 'beta']) + +@endfeatureany ``` From f891b178c8ceb9b7aa6771785a9805adac1e7e51 Mon Sep 17 00:00:00 2001 From: KentarouTakeda Date: Wed, 2 Oct 2024 23:40:05 +0900 Subject: [PATCH 224/325] fix: releases.md -Unify presence/absence of comma (#9924) * fix: releases.md -Unify presence/absence of comma * Update releases.md --------- Co-authored-by: Taylor Otwell --- releases.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releases.md b/releases.md index 692cbfb16f3..894f97c5123 100644 --- a/releases.md +++ b/releases.md @@ -28,7 +28,7 @@ For all Laravel releases, bug fixes are provided for 18 months and security fixe | 9 | 8.0 - 8.2 | February 8th, 2022 | August 8th, 2023 | February 6th, 2024 | | 10 | 8.1 - 8.3 | February 14th, 2023 | August 6th, 2024 | February 4th, 2025 | | 11 | 8.2 - 8.3 | March 12th, 2024 | September 3rd, 2025 | March 12th, 2026 | -| 12 | 8.2 - 8.3 | Q1 2025 | Q3, 2026 | Q1, 2027 | +| 12 | 8.2 - 8.3 | Q1 2025 | Q3 2026 | Q1 2027 |
From 70abbf2ea5625c6f6d6aab6c88d2dd19d6b0c623 Mon Sep 17 00:00:00 2001 From: Lijahide <49410375+Lijahide@users.noreply.github.com> Date: Wed, 2 Oct 2024 10:43:17 -0400 Subject: [PATCH 225/325] changed "one-to-many" header (#9922) added " / Has Many" to the "One to Many" header and corresponding TOC line. --- eloquent-relationships.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eloquent-relationships.md b/eloquent-relationships.md index 33692568ec3..cbaf8bbfbb0 100644 --- a/eloquent-relationships.md +++ b/eloquent-relationships.md @@ -3,7 +3,7 @@ - [Introduction](#introduction) - [Defining Relationships](#defining-relationships) - [One to One](#one-to-one) - - [One to Many](#one-to-many) + - [One to Many / Has Many](#one-to-many) - [One to Many (Inverse) / Belongs To](#one-to-many-inverse) - [Has One of Many](#has-one-of-many) - [Has One Through](#has-one-through) @@ -148,7 +148,7 @@ If the parent model does not use `id` as its primary key, or you wish to find th } -### One to Many +### One to Many / Has Many A one-to-many relationship is used to define relationships where a single model is the parent to one or more child models. For example, a blog post may have an infinite number of comments. Like all other Eloquent relationships, one-to-many relationships are defined by defining a method on your Eloquent model: From b967f72817e992d526405d0712b606aa164b9efb Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 2 Oct 2024 09:43:45 -0500 Subject: [PATCH 226/325] wip --- eloquent-relationships.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eloquent-relationships.md b/eloquent-relationships.md index cbaf8bbfbb0..37f88cbf926 100644 --- a/eloquent-relationships.md +++ b/eloquent-relationships.md @@ -2,7 +2,7 @@ - [Introduction](#introduction) - [Defining Relationships](#defining-relationships) - - [One to One](#one-to-one) + - [One to One / Has One](#one-to-one) - [One to Many / Has Many](#one-to-many) - [One to Many (Inverse) / Belongs To](#one-to-many-inverse) - [Has One of Many](#has-one-of-many) @@ -68,7 +68,7 @@ Eloquent relationships are defined as methods on your Eloquent model classes. Si But, before diving too deep into using relationships, let's learn how to define each type of relationship supported by Eloquent. -### One to One +### One to One / Has One A one-to-one relationship is a very basic type of database relationship. For example, a `User` model might be associated with one `Phone` model. To define this relationship, we will place a `phone` method on the `User` model. The `phone` method should call the `hasOne` method and return its result. The `hasOne` method is available to your model via the model's `Illuminate\Database\Eloquent\Model` base class: From 935b090bdbe1b8616240382087ac19f49bd8b95f Mon Sep 17 00:00:00 2001 From: andzandz Date: Wed, 2 Oct 2024 15:55:39 +0100 Subject: [PATCH 227/325] Add note about logically grouping "or" queries for chunkById and lazyById (#9921) * Update queries.md * Update eloquent.md * Update eloquent.md * Update queries.md --------- Co-authored-by: Taylor Otwell --- eloquent.md | 13 +++++++++++++ queries.md | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/eloquent.md b/eloquent.md index 14383122503..5739d808792 100644 --- a/eloquent.md +++ b/eloquent.md @@ -482,6 +482,19 @@ Flight::where('departed', true) }, $column = 'id'); ``` +Since the `chunkById` and `lazyById` methods add their own "where" conditions to the query being executed, you should typically [logically group](/docs/{{version}}/queries#logical-grouping) your own conditions within a closure: + +```php +Flight::where(function ($query) { + $query->where('delayed', true)->orWhere('cancelled', true); +})->chunkById(200, function (Collection $flights) { + $flights->each->update([ + 'departed' => false, + 'cancelled' => true + ]); +}, column: 'id'); +``` + ### Chunking Using Lazy Collections diff --git a/queries.md b/queries.md index 4c01fe44a19..a77466e732a 100644 --- a/queries.md +++ b/queries.md @@ -161,6 +161,20 @@ If you are updating database records while chunking results, your chunk results } }); +Since the `chunkById` and `lazyById` methods add their own "where" conditions to the query being executed, you should typically [logically group](#logical-grouping) your own conditions within a closure: + +```php +DB::table('users')->where(function ($query) { + $query->where('credits', 1)->orWhere('credits', 2); +})->chunkById(100, function (Collection $users) { + foreach ($users as $user) { + DB::table('users') + ->where('id', $user->id) + ->update(['credits' => 3]); + } +}); +``` + > [!WARNING] > When updating or deleting records inside the chunk callback, any changes to the primary key or foreign keys could affect the chunk query. This could potentially result in records not being included in the chunked results. From 45969e396c5ec52aca9a558a43e9f902759e3d41 Mon Sep 17 00:00:00 2001 From: Matthew Frieswyk Date: Wed, 2 Oct 2024 12:37:16 -0400 Subject: [PATCH 228/325] Document horizon:supervisor-status (#9926) * Document horizon:supervisor-status * Update horizon.md --------- Co-authored-by: Taylor Otwell --- horizon.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/horizon.md b/horizon.md index d1d8405e339..fc2a090c627 100644 --- a/horizon.md +++ b/horizon.md @@ -230,6 +230,12 @@ You may check the current status of the Horizon process using the `horizon:statu php artisan horizon:status ``` +You may check the current status of a specific Horizon [supervisor](#supervisors) using the `horizon:supervisor-status` Artisan command: + +```shell +php artisan horizon:supervisor-status supervisor-1 +``` + You may gracefully terminate the Horizon process using the `horizon:terminate` Artisan command. Any jobs that are currently being processed will be completed and then Horizon will stop executing: ```shell From ead3a5b4b11c267f20ee1065eb3f9aa98fc986e1 Mon Sep 17 00:00:00 2001 From: Jonathan Goode Date: Thu, 3 Oct 2024 18:30:47 +0100 Subject: [PATCH 229/325] Wording (#9929) --- blade.md | 2 +- cache.md | 2 +- controllers.md | 2 +- eloquent.md | 2 +- encryption.md | 4 ++-- packages.md | 2 +- queries.md | 4 ++-- queues.md | 2 +- routing.md | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/blade.md b/blade.md index d1a15aab66b..fb9193d6250 100644 --- a/blade.md +++ b/blade.md @@ -1435,7 +1435,7 @@ Because the `color` prop was only passed into the parent (``), it won't ``` > [!WARNING] -> The `@aware` directive can not access parent data that is not explicitly passed to the parent component via HTML attributes. Default `@props` values that are not explicitly passed to the parent component can not be accessed by the `@aware` directive. +> The `@aware` directive cannot access parent data that is not explicitly passed to the parent component via HTML attributes. Default `@props` values that are not explicitly passed to the parent component cannot be accessed by the `@aware` directive. ### Anonymous Component Paths diff --git a/cache.md b/cache.md index 56bc99d5a10..e80e3a0a0f7 100644 --- a/cache.md +++ b/cache.md @@ -327,7 +327,7 @@ The `get` method also accepts a closure. After the closure is executed, Laravel // Lock acquired for 10 seconds and automatically released... }); -If the lock is not available at the moment you request it, you may instruct Laravel to wait for a specified number of seconds. If the lock can not be acquired within the specified time limit, an `Illuminate\Contracts\Cache\LockTimeoutException` will be thrown: +If the lock is not available at the moment you request it, you may instruct Laravel to wait for a specified number of seconds. If the lock cannot be acquired within the specified time limit, an `Illuminate\Contracts\Cache\LockTimeoutException` will be thrown: use Illuminate\Contracts\Cache\LockTimeoutException; diff --git a/controllers.md b/controllers.md index 30ad8127d72..c2c22c7bffa 100644 --- a/controllers.md +++ b/controllers.md @@ -198,7 +198,7 @@ You may even register many resource controllers at once by passing an array to t #### Customizing Missing Model Behavior -Typically, a 404 HTTP response will be generated if an implicitly bound resource model is not found. However, you may customize this behavior by calling the `missing` method when defining your resource route. The `missing` method accepts a closure that will be invoked if an implicitly bound model can not be found for any of the resource's routes: +Typically, a 404 HTTP response will be generated if an implicitly bound resource model is not found. However, you may customize this behavior by calling the `missing` method when defining your resource route. The `missing` method accepts a closure that will be invoked if an implicitly bound model cannot be found for any of the resource's routes: use App\Http\Controllers\PhotoController; use Illuminate\Http\Request; diff --git a/eloquent.md b/eloquent.md index 5739d808792..776029bc98b 100644 --- a/eloquent.md +++ b/eloquent.md @@ -631,7 +631,7 @@ If the `ModelNotFoundException` is not caught, a 404 HTTP response is automatica ### Retrieving or Creating Models -The `firstOrCreate` method will attempt to locate a database record using the given column / value pairs. If the model can not be found in the database, a record will be inserted with the attributes resulting from merging the first array argument with the optional second array argument: +The `firstOrCreate` method will attempt to locate a database record using the given column / value pairs. If the model cannot be found in the database, a record will be inserted with the attributes resulting from merging the first array argument with the optional second array argument: The `firstOrNew` method, like `firstOrCreate`, will attempt to locate a record in the database matching the given attributes. However, if a model is not found, a new model instance will be returned. Note that the model returned by `firstOrNew` has not yet been persisted to the database. You will need to manually call the `save` method to persist it: diff --git a/encryption.md b/encryption.md index 02a07927207..49beb8cd179 100644 --- a/encryption.md +++ b/encryption.md @@ -8,7 +8,7 @@ ## Introduction -Laravel's encryption services provide a simple, convenient interface for encrypting and decrypting text via OpenSSL using AES-256 and AES-128 encryption. All of Laravel's encrypted values are signed using a message authentication code (MAC) so that their underlying value can not be modified or tampered with once encrypted. +Laravel's encryption services provide a simple, convenient interface for encrypting and decrypting text via OpenSSL using AES-256 and AES-128 encryption. All of Laravel's encrypted values are signed using a message authentication code (MAC) so that their underlying value cannot be modified or tampered with once encrypted. ## Configuration @@ -65,7 +65,7 @@ You may encrypt a value using the `encryptString` method provided by the `Crypt` #### Decrypting a Value -You may decrypt values using the `decryptString` method provided by the `Crypt` facade. If the value can not be properly decrypted, such as when the message authentication code is invalid, an `Illuminate\Contracts\Encryption\DecryptException` will be thrown: +You may decrypt values using the `decryptString` method provided by the `Crypt` facade. If the value cannot be properly decrypted, such as when the message authentication code is invalid, an `Illuminate\Contracts\Encryption\DecryptException` will be thrown: use Illuminate\Contracts\Encryption\DecryptException; use Illuminate\Support\Facades\Crypt; diff --git a/packages.md b/packages.md index 4999c4e343d..e43ef7a0bde 100644 --- a/packages.md +++ b/packages.md @@ -107,7 +107,7 @@ Now, when users of your package execute Laravel's `vendor:publish` command, your $value = config('courier.option'); > [!WARNING] -> You should not define closures in your configuration files. They can not be serialized correctly when users execute the `config:cache` Artisan command. +> You should not define closures in your configuration files. They cannot be serialized correctly when users execute the `config:cache` Artisan command. #### Default Package Configuration diff --git a/queries.md b/queries.md index a77466e732a..d437ab81f40 100644 --- a/queries.md +++ b/queries.md @@ -276,7 +276,7 @@ Sometimes you may need to insert an arbitrary string into a query. To create a r ### Raw Methods -Instead of using the `DB::raw` method, you may also use the following methods to insert a raw expression into various parts of your query. **Remember, Laravel can not guarantee that any query using raw expressions is protected against SQL injection vulnerabilities.** +Instead of using the `DB::raw` method, you may also use the following methods to insert a raw expression into various parts of your query. **Remember, Laravel cannot guarantee that any query using raw expressions is protected against SQL injection vulnerabilities.** #### `selectRaw` @@ -1096,7 +1096,7 @@ In addition to inserting records into the database, the query builder can also u Sometimes you may want to update an existing record in the database or create it if no matching record exists. In this scenario, the `updateOrInsert` method may be used. The `updateOrInsert` method accepts two arguments: an array of conditions by which to find the record, and an array of column and value pairs indicating the columns to be updated. -The `updateOrInsert` method will attempt to locate a matching database record using the first argument's column and value pairs. If the record exists, it will be updated with the values in the second argument. If the record can not be found, a new record will be inserted with the merged attributes of both arguments: +The `updateOrInsert` method will attempt to locate a matching database record using the first argument's column and value pairs. If the record exists, it will be updated with the values in the second argument. If the record cannot be found, a new record will be inserted with the merged attributes of both arguments: DB::table('users') ->updateOrInsert( diff --git a/queues.md b/queues.md index cda1ccedfe8..b6dfffd8c1c 100644 --- a/queues.md +++ b/queues.md @@ -1649,7 +1649,7 @@ If you defined your DynamoDB table with a `ttl` attribute, you may define config ## Queueing Closures -Instead of dispatching a job class to the queue, you may also dispatch a closure. This is great for quick, simple tasks that need to be executed outside of the current request cycle. When dispatching closures to the queue, the closure's code content is cryptographically signed so that it can not be modified in transit: +Instead of dispatching a job class to the queue, you may also dispatch a closure. This is great for quick, simple tasks that need to be executed outside of the current request cycle. When dispatching closures to the queue, the closure's code content is cryptographically signed so that it cannot be modified in transit: $podcast = App\Podcast::find(1); diff --git a/routing.md b/routing.md index 0821accd1f2..b77e6f67fd0 100644 --- a/routing.md +++ b/routing.md @@ -613,7 +613,7 @@ Similarly, you may explicitly instruct Laravel to not scope bindings by invoking #### Customizing Missing Model Behavior -Typically, a 404 HTTP response will be generated if an implicitly bound model is not found. However, you may customize this behavior by calling the `missing` method when defining your route. The `missing` method accepts a closure that will be invoked if an implicitly bound model can not be found: +Typically, a 404 HTTP response will be generated if an implicitly bound model is not found. However, you may customize this behavior by calling the `missing` method when defining your route. The `missing` method accepts a closure that will be invoked if an implicitly bound model cannot be found: use App\Http\Controllers\LocationsController; use Illuminate\Http\Request; From 77db50ec005aa0e6391511eb81ff3a0e21d7e504 Mon Sep 17 00:00:00 2001 From: Jess Archer Date: Fri, 4 Oct 2024 03:33:25 +1000 Subject: [PATCH 230/325] [11.x] Prompts: Warn about inadvertently returning associative arrays after filtering (#9928) * Prompts: Warn about inadvertently returning associative arrays after filtering * Update prompts.md --------- Co-authored-by: Taylor Otwell --- prompts.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/prompts.md b/prompts.md index 5f8f49aeb1f..441f5c6a1b6 100644 --- a/prompts.md +++ b/prompts.md @@ -571,6 +571,20 @@ $id = search( The closure will receive the text that has been typed by the user so far and must return an array of options. If you return an associative array then the selected option's key will be returned, otherwise its value will be returned instead. +When filtering an array where you intend to return the value, you should use the `array_values` function or the `values` Collection method to ensure the array doesn't become associative: + +```php +$names = collect(['Taylor', 'Abigail']); + +$selected = search( + label: 'Search for the user that should receive the mail', + options: fn (string $value) => $names + ->filter(fn ($name) => Str::contains($name, $value, ignoreCase: true)) + ->values() + ->all(), +); +``` + You may also include placeholder text and an informational hint: ```php @@ -637,6 +651,20 @@ $ids = multisearch( The closure will receive the text that has been typed by the user so far and must return an array of options. If you return an associative array then the selected options' keys will be returned; otherwise, their values will be returned instead. +When filtering an array where you intend to return the value, you should use the `array_values` function or the `values` Collection method to ensure the array doesn't become associative: + +```php +$names = collect(['Taylor', 'Abigail']); + +$selected = multisearch( + label: 'Search for the users that should receive the mail', + options: fn (string $value) => $names + ->filter(fn ($name) => Str::contains($name, $value, ignoreCase: true)) + ->values() + ->all(), +); +``` + You may also include placeholder text and an informational hint: ```php From 5f7df11b007c4c775ca1870a1008b47b1cfc9494 Mon Sep 17 00:00:00 2001 From: Michael Stephen Date: Mon, 7 Oct 2024 21:02:47 +0700 Subject: [PATCH 231/325] added missing "whereMorphedTo" on Eloquent relationship page (#9931) * added missing "whereMorphedTo" on Eloquent relationship page from [\#53041](https://github.com/laravel/framework/pull/53041), it turns out there's Polymorphic equivalent to `whereBelongsTo()` that is not mentioned anywhere in the docs. * Updated description Changed the wording to follow general Laravel documentation wording and updated the example to match. * Update eloquent-relationships.md --------- Co-authored-by: Taylor Otwell --- eloquent-relationships.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/eloquent-relationships.md b/eloquent-relationships.md index 37f88cbf926..caea2bb0645 100644 --- a/eloquent-relationships.md +++ b/eloquent-relationships.md @@ -1502,6 +1502,12 @@ You may occasionally need to add query constraints based on the "type" of the re } )->get(); +Sometimes you may want to query for the children of a "morph to" relationship's parent. You may accomplish this using the `whereMorphedTo` and `whereNotMorphedTo` methods, which will automatically determine the proper morph type mapping for the given model. These methods accept the name of the `morphTo` relationship as their first argument and the related parent model as their second argument: + + $comments = Comment::whereMorphedTo('commentable', $post) + ->orWhereMorphedTo('commentable', $video) + ->get(); + #### Querying All Related Models From 44f2375021852c0b1f0c9b6d3316436d3fc590d3 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 8 Oct 2024 11:34:08 -0500 Subject: [PATCH 232/325] document php nwe --- installation.md | 60 +++++++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/installation.md b/installation.md index 227e2ee1c99..6009d6b1ac4 100644 --- a/installation.md +++ b/installation.md @@ -2,7 +2,9 @@ - [Meet Laravel](#meet-laravel) - [Why Laravel?](#why-laravel) -- [Creating a Laravel Project](#creating-a-laravel-project) +- [Creating a Laravel Application](#creating-a-laravel-project) + - [Installing PHP and the Laravel Installer](#installing-php) + - [Creating an Application](#creating-an-application) - [Initial Configuration](#initial-configuration) - [Environment Based Configuration](#environment-based-configuration) - [Databases and Migrations](#databases-and-migrations) @@ -54,25 +56,39 @@ Need extreme scaling? Platforms like [Laravel Vapor](https://vapor.laravel.com) Laravel combines the best packages in the PHP ecosystem to offer the most robust and developer friendly framework available. In addition, thousands of talented developers from around the world have [contributed to the framework](https://github.com/laravel/framework). Who knows, maybe you'll even become a Laravel contributor. -## Creating a Laravel Project +## Creating a Laravel Application -Before creating your first Laravel project, make sure that your local machine has PHP and [Composer](https://getcomposer.org) installed. If you are developing on macOS or Windows, PHP, Composer, Node and NPM can be installed in minutes via [Laravel Herd](#local-installation-using-herd). + +### Installing PHP and the Laravel Installer -After you have installed PHP and Composer, you may create a new Laravel project via Composer's `create-project` command: +Before creating your first Laravel application, make sure that your local machine has [PHP](https://php.net) and [Composer](https://getcomposer.org) installed. In addition, you should install [Node and NPM](https://nodejs.org). -```nothing -composer create-project laravel/laravel example-app +If you don't have PHP and Composer installed on your local machine, the following commands will install PHP, Composer, and the Laravel installer on macOS, Windows, or Linux: + +```shell tab=macOS +/bin/bash -c "$(curl -fsSL https://php.new/install/mac)" ``` -Or, you may create new Laravel projects by globally installing [the Laravel installer](https://github.com/laravel/installer) via Composer. The Laravel installer allows you to select your preferred testing framework, database, and starter kit when creating new applications: +```shell tab=Windows Powershell +Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://php.new/install/windows')) +``` -```nothing -composer global require laravel/installer +```shell tab=Linux +/bin/bash -c "$(curl -fsSL https://php.new/install/linux)" +``` +After running one of the commands above, you should restart your terminal session. To update PHP, Composer, and the Laravel installer after installing them via `php.new`, you can re-run the command in your terminal. + + +### Creating an Application + +After you have installed PHP, Composer, and the Laravel installer, you may create a new Laravel application. The Laravel installer allows you to select your preferred testing framework, database, and starter kit when creating new applications: + +```nothing laravel new example-app ``` -Once the project has been created, start Laravel's local development server using Laravel Artisan's `serve` command: +Once the application has been created, start Laravel's local development server using Laravel Artisan's `serve` command: ```nothing cd example-app @@ -107,7 +123,7 @@ Your `.env` file should not be committed to your application's source control, s Now that you have created your Laravel application, you probably want to store some data in a database. By default, your application's `.env` configuration file specifies that Laravel will be interacting with a SQLite database. -During the creation of the project, Laravel created a `database/database.sqlite` file for you, and ran the necessary migrations to create the application's database tables. +During the creation of the application, Laravel created a `database/database.sqlite` file for you, and ran the necessary migrations to create the application's database tables. If you prefer to use another database driver such as MySQL or PostgreSQL, you can update your `.env` configuration file to use the appropriate database. For example, if you wish to use MySQL, update your `.env` configuration file's `DB_*` variables like so: @@ -151,7 +167,7 @@ If you develop on macOS, you can download the Herd installer from the [Herd webs Herd for macOS uses [dnsmasq](https://en.wikipedia.org/wiki/Dnsmasq) to support "parked" directories. Any Laravel application in a parked directory will automatically be served by Herd. By default, Herd creates a parked directory at `~/Herd` and you can access any Laravel application in this directory on the `.test` domain using its directory name. -After installing Herd, the fastest way to create a new Laravel project is using the Laravel CLI, which is bundled with Herd: +After installing Herd, the fastest way to create a new Laravel application is using the Laravel CLI, which is bundled with Herd: ```nothing cd ~/Herd @@ -173,7 +189,7 @@ The Herd UI is accessible by left-clicking on Herd's system tray icon. A right-c During installation, Herd creates a "parked" directory in your home directory at `%USERPROFILE%\Herd`. Any Laravel application in a parked directory will automatically be served by Herd, and you can access any Laravel application in this directory on the `.test` domain using its directory name. -After installing Herd, the fastest way to create a new Laravel project is using the Laravel CLI, which is bundled with Herd. To get started, open Powershell and run the following commands: +After installing Herd, the fastest way to create a new Laravel application is using the Laravel CLI, which is bundled with Herd. To get started, open Powershell and run the following commands: ```nothing cd ~\Herd @@ -187,7 +203,7 @@ You can learn more about Herd by checking out the [Herd documentation for Window ## Docker Installation Using Sail -We want it to be as easy as possible to get started with Laravel regardless of your preferred operating system. So, there are a variety of options for developing and running a Laravel project on your local machine. While you may wish to explore these options at a later time, Laravel provides [Sail](/docs/{{version}}/sail), a built-in solution for running your Laravel project using [Docker](https://www.docker.com). +We want it to be as easy as possible to get started with Laravel regardless of your preferred operating system. So, there are a variety of options for developing and running a Laravel application on your local machine. While you may wish to explore these options at a later time, Laravel provides [Sail](/docs/{{version}}/sail), a built-in solution for running your Laravel application using [Docker](https://www.docker.com). Docker is a tool for running applications and services in small, light-weight "containers" which do not interfere with your local machine's installed software or configuration. This means you don't have to worry about configuring or setting up complicated development tools such as web servers and databases on your local machine. To get started, you only need to install [Docker Desktop](https://www.docker.com/products/docker-desktop). @@ -199,7 +215,7 @@ Laravel Sail is a light-weight command-line interface for interacting with Larav ### Sail on macOS -If you're developing on a Mac and [Docker Desktop](https://www.docker.com/products/docker-desktop) is already installed, you can use a simple terminal command to create a new Laravel project. For example, to create a new Laravel application in a directory named "example-app", you may run the following command in your terminal: +If you're developing on a Mac and [Docker Desktop](https://www.docker.com/products/docker-desktop) is already installed, you can use a simple terminal command to create a new Laravel application. For example, to create a new Laravel application in a directory named "example-app", you may run the following command in your terminal: ```shell curl -s "https://laravel.build/example-app" | bash @@ -209,7 +225,7 @@ Of course, you can change "example-app" in this URL to anything you like - just Sail installation may take several minutes while Sail's application containers are built on your local machine. -After the project has been created, you can navigate to the application directory and start Laravel Sail. Laravel Sail provides a simple command-line interface for interacting with Laravel's default Docker configuration: +After the application has been created, you can navigate to the application directory and start Laravel Sail. Laravel Sail provides a simple command-line interface for interacting with Laravel's default Docker configuration: ```shell cd example-app @@ -236,7 +252,7 @@ Before we create a new Laravel application on your Windows machine, make sure to > [!NOTE] > After installing and enabling WSL2, you should ensure that Docker Desktop is [configured to use the WSL2 backend](https://docs.docker.com/docker-for-windows/wsl/). -Next, you are ready to create your first Laravel project. Launch [Windows Terminal](https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701?rtc=1&activetab=pivot:overviewtab) and begin a new terminal session for your WSL2 Linux operating system. Next, you can use a simple terminal command to create a new Laravel project. For example, to create a new Laravel application in a directory named "example-app", you may run the following command in your terminal: +Next, you are ready to create your first Laravel application. Launch [Windows Terminal](https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701?rtc=1&activetab=pivot:overviewtab) and begin a new terminal session for your WSL2 Linux operating system. Next, you can use a simple terminal command to create a new Laravel application. For example, to create a new Laravel application in a directory named "example-app", you may run the following command in your terminal: ```shell curl -s https://laravel.build/example-app | bash @@ -246,7 +262,7 @@ Of course, you can change "example-app" in this URL to anything you like - just Sail installation may take several minutes while Sail's application containers are built on your local machine. -After the project has been created, you can navigate to the application directory and start Laravel Sail. Laravel Sail provides a simple command-line interface for interacting with Laravel's default Docker configuration: +After the application has been created, you can navigate to the application directory and start Laravel Sail. Laravel Sail provides a simple command-line interface for interacting with Laravel's default Docker configuration: ```shell cd example-app @@ -269,12 +285,12 @@ Finally, you can access the application in your web browser at: http://localhost Of course, you will need to be able to modify the Laravel application files that were created within your WSL2 installation. To accomplish this, we recommend using Microsoft's [Visual Studio Code](https://code.visualstudio.com) editor and their first-party extension for [Remote Development](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack). -Once these tools are installed, you may open any Laravel project by executing the `code .` command from your application's root directory using Windows Terminal. +Once these tools are installed, you may open any Laravel application by executing the `code .` command from your application's root directory using Windows Terminal. ### Sail on Linux -If you're developing on Linux and [Docker Compose](https://docs.docker.com/compose/install/) is already installed, you can use a simple terminal command to create a new Laravel project. +If you're developing on Linux and [Docker Compose](https://docs.docker.com/compose/install/) is already installed, you can use a simple terminal command to create a new Laravel application. First, if you are using Docker Desktop for Linux, you should execute the following command. If you are not using Docker Desktop for Linux, you may skip this step: @@ -292,7 +308,7 @@ Of course, you can change "example-app" in this URL to anything you like - just Sail installation may take several minutes while Sail's application containers are built on your local machine. -After the project has been created, you can navigate to the application directory and start Laravel Sail. Laravel Sail provides a simple command-line interface for interacting with Laravel's default Docker configuration: +After the application has been created, you can navigate to the application directory and start Laravel Sail. Laravel Sail provides a simple command-line interface for interacting with Laravel's default Docker configuration: ```shell cd example-app @@ -338,7 +354,7 @@ In addition, the community maintained [Laravel Idea](https://laravel-idea.com/) ## Next Steps -Now that you have created your Laravel project, you may be wondering what to learn next. First, we strongly recommend becoming familiar with how Laravel works by reading the following documentation: +Now that you have created your Laravel application, you may be wondering what to learn next. First, we strongly recommend becoming familiar with how Laravel works by reading the following documentation:
From 0a9edb1107b6110c9aa109f8d5b3104ea4ea3a91 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 8 Oct 2024 11:37:10 -0500 Subject: [PATCH 233/325] wip --- installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation.md b/installation.md index 6009d6b1ac4..eed208cb75d 100644 --- a/installation.md +++ b/installation.md @@ -82,7 +82,7 @@ After running one of the commands above, you should restart your terminal sessio ### Creating an Application -After you have installed PHP, Composer, and the Laravel installer, you may create a new Laravel application. The Laravel installer allows you to select your preferred testing framework, database, and starter kit when creating new applications: +After you have installed PHP, Composer, and the Laravel installer, you're ready to create a new Laravel application. The Laravel installer will prompt you to select your preferred testing framework, database, and starter kit: ```nothing laravel new example-app From 8e3d7df4f888db955cb6409758433d90fa595c4b Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 8 Oct 2024 11:37:31 -0500 Subject: [PATCH 234/325] wip --- installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation.md b/installation.md index eed208cb75d..617378affb0 100644 --- a/installation.md +++ b/installation.md @@ -88,7 +88,7 @@ After you have installed PHP, Composer, and the Laravel installer, you're ready laravel new example-app ``` -Once the application has been created, start Laravel's local development server using Laravel Artisan's `serve` command: +Once the application has been created, start Laravel's local development server using the `serve` command: ```nothing cd example-app From 49c9b6b7207485055c5236935423fc1b6d7e07eb Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 8 Oct 2024 11:39:18 -0500 Subject: [PATCH 235/325] wip --- installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation.md b/installation.md index 617378affb0..223da81060c 100644 --- a/installation.md +++ b/installation.md @@ -61,7 +61,7 @@ Laravel combines the best packages in the PHP ecosystem to offer the most robust ### Installing PHP and the Laravel Installer -Before creating your first Laravel application, make sure that your local machine has [PHP](https://php.net) and [Composer](https://getcomposer.org) installed. In addition, you should install [Node and NPM](https://nodejs.org). +Before creating your first Laravel application, make sure that your local machine has [PHP](https://php.net) and [Composer](https://getcomposer.org) installed. In addition, you should install [Node and NPM](https://nodejs.org) so that you can compile your application's frontend assets. If you don't have PHP and Composer installed on your local machine, the following commands will install PHP, Composer, and the Laravel installer on macOS, Windows, or Linux: From 49e3020bb599d19eba0f9583c0d4da2b2bceca4d Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 8 Oct 2024 12:05:47 -0500 Subject: [PATCH 236/325] wip --- installation.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/installation.md b/installation.md index 223da81060c..ab6508af262 100644 --- a/installation.md +++ b/installation.md @@ -69,7 +69,7 @@ If you don't have PHP and Composer installed on your local machine, the followin /bin/bash -c "$(curl -fsSL https://php.new/install/mac)" ``` -```shell tab=Windows Powershell +```shell tab=Windows PowerShell Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://php.new/install/windows')) ``` @@ -79,6 +79,9 @@ Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManage After running one of the commands above, you should restart your terminal session. To update PHP, Composer, and the Laravel installer after installing them via `php.new`, you can re-run the command in your terminal. +> [!NOTE] +> For a fully-featured, graphical PHP installation and management experience, check out [Laravel Herd](#local-installation-using-herd). + ### Creating an Application From f6318a64440b85473c46b2b4789412f7a5202564 Mon Sep 17 00:00:00 2001 From: Sarah Gilberg Date: Tue, 8 Oct 2024 14:35:23 -0400 Subject: [PATCH 237/325] Document solution for multiple rate limits on same segment (#9933) * Document solution for multiple rate limits on same segment * formatting --------- Co-authored-by: Taylor Otwell --- routing.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/routing.md b/routing.md index b77e6f67fd0..f0fdbdd1900 100644 --- a/routing.md +++ b/routing.md @@ -829,6 +829,15 @@ If needed, you may return an array of rate limits for a given rate limiter confi ]; }); +If you're assigning multiple rate limits segmented by identical `by` values, you should ensure that each `by` value is unique. The easiest way to achieve this is to prefix the values given to the `by` method: + + RateLimiter::for('uploads', function (Request $request) { + return [ + Limit::perMinute(10)->by('minute:'.$request->user()->id), + Limit::perDay(1000)->by('day:'.$request->user()->id), + ]; + }); + ### Attaching Rate Limiters to Routes From 08fbb4d3aa9a28ea0aaf294bbb1a465046067286 Mon Sep 17 00:00:00 2001 From: Noboru Shiroiwa <14008307+nshiro@users.noreply.github.com> Date: Wed, 9 Oct 2024 23:26:38 +0900 Subject: [PATCH 238/325] Add link to Carbon 3.x official migration guide (#9934) * Add link to Carbon 3.x official migration guide * Update upgrade.md --------- Co-authored-by: Taylor Otwell --- upgrade.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upgrade.md b/upgrade.md index 209df7bd94c..0c1008e39db 100644 --- a/upgrade.md +++ b/upgrade.md @@ -421,7 +421,7 @@ public function scalar($query, $bindings = [], $useReadPdo = true); **Likelihood Of Impact: Medium** -Laravel 11 supports both Carbon 2 and Carbon 3. Carbon is a date manipulation library utilized extensively by Laravel and packages throughout the ecosystem. If you upgrade to Carbon 3, be aware that `diffIn*` methods now return floating-point numbers and may return negative values to indicate time direction, which is a significant change from Carbon 2. Review Carbon's [change log](https://github.com/briannesbitt/Carbon/releases/tag/3.0.0) for detailed information on how to handle these and other changes. +Laravel 11 supports both Carbon 2 and Carbon 3. Carbon is a date manipulation library utilized extensively by Laravel and packages throughout the ecosystem. If you upgrade to Carbon 3, be aware that `diffIn*` methods now return floating-point numbers and may return negative values to indicate time direction, which is a significant change from Carbon 2. Review Carbon's [change log](https://github.com/briannesbitt/Carbon/releases/tag/3.0.0) and [documentation](https://carbon.nesbot.com/docs/#api-carbon-3) for detailed information on how to handle these and other changes. ### Mail From 2f56a79462e97db0fa5072c92d0bb1f1197eff2f Mon Sep 17 00:00:00 2001 From: Ryan Holton Date: Wed, 9 Oct 2024 20:35:54 +0100 Subject: [PATCH 239/325] feat: document Str::doesntContain() (#9937) --- strings.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/strings.md b/strings.md index 396f45c4c57..7a75023e369 100644 --- a/strings.md +++ b/strings.md @@ -47,6 +47,7 @@ Laravel includes a variety of functions for manipulating string values. Many of [Str::chopEnd](#method-str-chop-end) [Str::contains](#method-str-contains) [Str::containsAll](#method-str-contains-all) +[Str::doesntContain](#method-str-doesnt-contain) [Str::deduplicate](#method-deduplicate) [Str::endsWith](#method-ends-with) [Str::excerpt](#method-excerpt) @@ -468,6 +469,33 @@ You may disable case sensitivity by setting the `ignoreCase` argument to `true`: $containsAll = Str::containsAll('This is my name', ['MY', 'NAME'], ignoreCase: true); // true + + +#### `Str::doesntContain()` {.collection-method} + +The `Str::doesntContain` method determines if the given string doesn't contain the given value. By default this method is case sensitive: + + use Illuminate\Support\Str; + + $doesntContain = Str::doesntContain('This is name', 'my'); + + // true + +You may also pass an array of values to determine if the given string doesn't contain any of the values in the array: + + use Illuminate\Support\Str; + + $doesntContain = Str::doesntContain('This is name', ['my', 'foo']); + + // true + +You may disable case sensitivity by setting the `ignoreCase` argument to `true`: + + use Illuminate\Support\Str; + + $doesntContain = Str::doesntContain('This is name', 'MY', ignoreCase: true); + + // true #### `Str::deduplicate()` {.collection-method} From f6715ca87507f0e5f8dc2ed862e0d47743359504 Mon Sep 17 00:00:00 2001 From: Giga <36007921+gigabites19@users.noreply.github.com> Date: Wed, 9 Oct 2024 23:37:07 +0400 Subject: [PATCH 240/325] fix inaccurate return type (#9935) --- vite.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vite.md b/vite.md index 16d69524989..69bf5b6f5c4 100644 --- a/vite.md +++ b/vite.md @@ -399,7 +399,7 @@ import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'; createInertiaApp({ resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')), setup({ el, App, props, plugin }) { - return createApp({ render: () => h(App, props) }) + createApp({ render: () => h(App, props) }) .use(plugin) .mount(el) }, From c720e78408598e7534eef4d0bb79ab58922b46bb Mon Sep 17 00:00:00 2001 From: Ryan Holton Date: Wed, 9 Oct 2024 20:38:23 +0100 Subject: [PATCH 241/325] [11.x] feat: document new Number::withCurrency and Number::useCurrency (#9936) * feat: document new currency methods * feat: document new currency methods --- helpers.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/helpers.md b/helpers.md index 097f1ff83ea..ac604263946 100644 --- a/helpers.md +++ b/helpers.md @@ -103,6 +103,8 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct [Number::trim](#method-number-trim) [Number::useLocale](#method-number-use-locale) [Number::withLocale](#method-number-with-locale) +[Number::useCurrency](#method-number-use-currency) +[Number::withCurrency](#method-number-with-currency)
@@ -1425,6 +1427,32 @@ The `Number::withLocale` method executes the given closure using the specified l return Number::format(1500); }); + +#### `Number::useCurrency()` {.collection-method} + +The `Number::useCurrency` method sets the default number currency globally, which affects how the currency is formatted by subsequent invocations to the `Number` class's methods: + + use Illuminate\Support\Number; + + /** + * Bootstrap any application services. + */ + public function boot(): void + { + Number::useCurrency('GBP'); + } + + +#### `Number::withCurrency()` {.collection-method} + +The `Number::withCurrency` method executes the given closure using the specified currency and then restores the original currency after the callback has executed: + + use Illuminate\Support\Number; + + $number = Number::withCurrency('GBP', function () { + // ... + }); + ## Paths From e3cf0747f0c17032d9dcc324ac3bd5b47315e4dd Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 9 Oct 2024 15:00:33 -0500 Subject: [PATCH 242/325] wip --- queries.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/queries.md b/queries.md index d437ab81f40..c5f93a92afa 100644 --- a/queries.md +++ b/queries.md @@ -479,6 +479,9 @@ You may also pass an array of conditions to the `where` function. Each element o > [!WARNING] > PDO does not support binding column names. Therefore, you should never allow user input to dictate the column names referenced by your queries, including "order by" columns. +> [!WARNING] +> MySQL and MariaDB automatically typecast strings to integers in string-number comparisons. In this process, non-numeric strings are converted to `0`, which can lead to unexpected results. For example, if your table has a `secret` column with a value of `aaa` and you run `User::where('secret', 0)`, that row will be returned. To avoid this, ensure all values are typecast to their appropriate types before using them in queries. + ### Or Where Clauses From 687b781084e92ce5ee56197125c071b0d592fda4 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 10 Oct 2024 20:05:42 -0500 Subject: [PATCH 243/325] consistent styling for multi-line attributes (#9941) we had a mix of multiline attribute styling, some with the first attribute on the first line and some on the second line. this converts them all to be the same. --- blade.md | 48 ++++++++++++++++++++++++++++++------------------ validation.md | 6 ++++-- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/blade.md b/blade.md index fb9193d6250..e124c9cfb2a 100644 --- a/blade.md +++ b/blade.md @@ -482,10 +482,12 @@ Likewise, the `@style` directive may be used to conditionally add inline CSS sty For convenience, you may use the `@checked` directive to easily indicate if a given HTML checkbox input is "checked". This directive will echo `checked` if the provided condition evaluates to `true`: ```blade -active)) /> +active)) +/> ``` Likewise, the `@selected` directive may be used to indicate if a given select option should be "selected": @@ -509,19 +511,23 @@ Additionally, the `@disabled` directive may be used to indicate if a given eleme Moreover, the `@readonly` directive may be used to indicate if a given element should be "readonly": ```blade -isNotAdmin()) /> +isNotAdmin()) +/> ``` In addition, the `@required` directive may be used to indicate if a given element should be "required": ```blade -isAdmin()) /> +isAdmin()) +/> ``` @@ -1641,9 +1647,11 @@ The `@error` directive may be used to quickly check if [validation error message - + class="@error('title') is-invalid @enderror" +/> @error('title')
{{ $message }}
@@ -1657,9 +1665,11 @@ Since the `@error` directive compiles to an "if" statement, you may use the `@el - + class="@error('email') is-invalid @else is-valid @enderror" +/> ``` You may pass [the name of a specific error bag](/docs/{{version}}/validation#named-error-bags) as the second parameter to the `@error` directive to retrieve validation error messages on pages containing multiple forms: @@ -1669,9 +1679,11 @@ You may pass [the name of a specific error bag](/docs/{{version}}/validation#nam - + class="@error('email', 'login') is-invalid @enderror" +/> @error('email', 'login')
{{ $message }}
diff --git a/validation.md b/validation.md index b77486a7bdf..011d9f6d98d 100644 --- a/validation.md +++ b/validation.md @@ -220,10 +220,12 @@ You may use the `@error` [Blade](/docs/{{version}}/blade) directive to quickly d - + class="@error('title') is-invalid @enderror" +/> @error('title')
{{ $message }}
From 718322dbbf948e16789b05be3e8580683bdf4f64 Mon Sep 17 00:00:00 2001 From: Alex Miles Date: Fri, 11 Oct 2024 02:07:23 +0100 Subject: [PATCH 244/325] [11.x] Reinstate link to Laravel installer package (#9940) * Reinstate link to Laravel installer package * Update installation.md --------- Co-authored-by: Taylor Otwell --- installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation.md b/installation.md index ab6508af262..eb184447445 100644 --- a/installation.md +++ b/installation.md @@ -61,7 +61,7 @@ Laravel combines the best packages in the PHP ecosystem to offer the most robust ### Installing PHP and the Laravel Installer -Before creating your first Laravel application, make sure that your local machine has [PHP](https://php.net) and [Composer](https://getcomposer.org) installed. In addition, you should install [Node and NPM](https://nodejs.org) so that you can compile your application's frontend assets. +Before creating your first Laravel application, make sure that your local machine has [PHP](https://php.net), [Composer](https://getcomposer.org), and [the Laravel installer](https://github.com/laravel/installer) installed. In addition, you should install [Node and NPM](https://nodejs.org) so that you can compile your application's frontend assets. If you don't have PHP and Composer installed on your local machine, the following commands will install PHP, Composer, and the Laravel installer on macOS, Windows, or Linux: From 413397108dceec51289541a1b899a0783646d84a Mon Sep 17 00:00:00 2001 From: Andy Hinkle Date: Fri, 11 Oct 2024 08:57:40 -0500 Subject: [PATCH 245/325] [11.x] Optional param for Confirmed rule (#9943) * Add documentation for optional param of confirmed rule * wording --- validation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/validation.md b/validation.md index 011d9f6d98d..43d71477dab 100644 --- a/validation.md +++ b/validation.md @@ -1100,6 +1100,8 @@ The field under validation must be able to be cast as a boolean. Accepted input The field under validation must have a matching field of `{field}_confirmation`. For example, if the field under validation is `password`, a matching `password_confirmation` field must be present in the input. +You may also pass a custom confirmation field name. For example, `confirmed:repeat_username` will expect the field `repeat_username` to match the field under validation. + #### contains:_foo_,_bar_,... From 85faadde4f004298773a1e0e8f0d53ae47430c77 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 11 Oct 2024 09:27:58 -0500 Subject: [PATCH 246/325] update the list of global middleware (#9944) document the newly added global middleware https://github.com/laravel/framework/blob/11.x/src/Illuminate/Foundation/Configuration/Middleware.php#L411 --- middleware.md | 1 + 1 file changed, 1 insertion(+) diff --git a/middleware.md b/middleware.md index b9e3d03b21f..95db7bb8b7d 100644 --- a/middleware.md +++ b/middleware.md @@ -129,6 +129,7 @@ If you would like to manage Laravel's global middleware stack manually, you may ->withMiddleware(function (Middleware $middleware) { $middleware->use([ + \Illuminate\Foundation\Http\Middleware\InvokeDeferredCallbacks::class, // \Illuminate\Http\Middleware\TrustHosts::class, \Illuminate\Http\Middleware\TrustProxies::class, \Illuminate\Http\Middleware\HandleCors::class, From 339648899df6c796dc63dd3b614986af451ea493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Tue, 15 Oct 2024 15:41:37 +0200 Subject: [PATCH 247/325] Explain how to get structured logs when using FrankenPHP through Octane (#9953) * Explain how to get structured logs when using FrankenPHP through Octane * Update octane.md --------- Co-authored-by: Taylor Otwell --- octane.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/octane.md b/octane.md index 999360a1ead..8259e9a3985 100644 --- a/octane.md +++ b/octane.md @@ -135,6 +135,8 @@ services: - .:/app ``` +If the `--log-level` option is explicitly passed to the `php artisan octane:start` command, Octane will use FrankenPHP's native logger and, unless configured differently, will produce structured JSON logs. + You may consult [the official FrankenPHP documentation](https://frankenphp.dev/docs/docker/) for more information on running FrankenPHP with Docker. From 2da9260ac1dc62a9c282a075da036ab997f870e2 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 15 Oct 2024 09:32:29 -0500 Subject: [PATCH 248/325] document collected by --- eloquent-collections.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/eloquent-collections.md b/eloquent-collections.md index bd1080352c1..c5b9b5c0b55 100644 --- a/eloquent-collections.md +++ b/eloquent-collections.md @@ -242,7 +242,23 @@ The `unique` method returns all of the unique models in the collection. Any mode ## Custom Collections -If you would like to use a custom `Collection` object when interacting with a given model, you may define a `newCollection` method on your model: +If you would like to use a custom `Collection` object when interacting with a given model, you may add the `CollectedBy` attribute to your model: + + Date: Tue, 15 Oct 2024 09:33:02 -0500 Subject: [PATCH 249/325] wip --- eloquent-collections.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eloquent-collections.md b/eloquent-collections.md index c5b9b5c0b55..860a1f7ea8e 100644 --- a/eloquent-collections.md +++ b/eloquent-collections.md @@ -282,4 +282,6 @@ Alternatively, you may define a `newCollection` method on your model: } } -Once you have defined a `newCollection` method, you will receive an instance of your custom collection anytime Eloquent would normally return an `Illuminate\Database\Eloquent\Collection` instance. If you would like to use a custom collection for every model in your application, you should define the `newCollection` method on a base model class that is extended by all of your application's models. +Once you have defined a `newCollection` method or added the `CollectedBy` attribute to your model, you will receive an instance of your custom collection anytime Eloquent would normally return an `Illuminate\Database\Eloquent\Collection` instance. + +If you would like to use a custom collection for every model in your application, you should define the `newCollection` method on a base model class that is extended by all of your application's models. From 8205b55a6e20c0ceecc9fa606f03b7a58c32095a Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 15 Oct 2024 09:34:04 -0500 Subject: [PATCH 250/325] wip --- container.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container.md b/container.md index 575bd93461a..5fc122ed354 100644 --- a/container.md +++ b/container.md @@ -252,7 +252,7 @@ class PhotoController extends Controller } ``` -In addition to the `Storage` attribute, Laravel offers `Auth`, `Cache`, `Config`, `DB`, `Log`, and [`Tag`](#tagging) attributes: +In addition to the `Storage` attribute, Laravel offers `Auth`, `Cache`, `Config`, `DB`, `Log`, `RouteParameter`, and [`Tag`](#tagging) attributes: ```php Date: Tue, 15 Oct 2024 09:35:35 -0500 Subject: [PATCH 251/325] composer run dev --- installation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/installation.md b/installation.md index eb184447445..ee92d33252f 100644 --- a/installation.md +++ b/installation.md @@ -91,15 +91,15 @@ After you have installed PHP, Composer, and the Laravel installer, you're ready laravel new example-app ``` -Once the application has been created, start Laravel's local development server using the `serve` command: +Once the application has been created, you can start Laravel's local development server, queue worker, and Vite development server using the `dev` Composer script: ```nothing cd example-app -php artisan serve +composer run dev ``` -Once you have started the Artisan development server, your application will be accessible in your web browser at [http://localhost:8000](http://localhost:8000). Next, you're ready to [start taking your next steps into the Laravel ecosystem](#next-steps). Of course, you may also want to [configure a database](#databases-and-migrations). +Once you have started the development server, your application will be accessible in your web browser at [http://localhost:8000](http://localhost:8000). Next, you're ready to [start taking your next steps into the Laravel ecosystem](#next-steps). Of course, you may also want to [configure a database](#databases-and-migrations). > [!NOTE] > If you would like a head start when developing your Laravel application, consider using one of our [starter kits](/docs/{{version}}/starter-kits). Laravel's starter kits provide backend and frontend authentication scaffolding for your new Laravel application. From 6edbc838af936fca1c98832a55e78325d6214097 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 15 Oct 2024 09:39:47 -0500 Subject: [PATCH 252/325] wip --- packages.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages.md b/packages.md index e43ef7a0bde..0ee98e13d8b 100644 --- a/packages.md +++ b/packages.md @@ -13,6 +13,7 @@ - [View Components](#view-components) - ["About" Artisan Command](#about-artisan-command) - [Commands](#commands) + - [Optimize Commands](#optimize-commands) - [Public Assets](#public-assets) - [Publishing File Groups](#publishing-file-groups) @@ -339,6 +340,24 @@ To register your package's Artisan commands with Laravel, you may use the `comma } } + +### Optimize Commands + +Laravel's [`optimize` command](/docs/{{version}}/deployment#optimization) caches the application's configuration, events, routes, and views. Using the `optimizes` method, you may register your package's own Artisan commands that should be invoked when the `optimize` and `optimize:clear` commands are executed: + + /** + * Bootstrap any package services. + */ + public function boot(): void + { + if ($this->app->runningInConsole()) { + $this->optimizes( + optimize: 'package:optimize', + clear: 'package:clear-optimizations', + ); + } + } + ## Public Assets From 3e699863690de91ec3ea7b002cf52f0e80e62442 Mon Sep 17 00:00:00 2001 From: Andy Hinkle Date: Tue, 15 Oct 2024 10:08:32 -0500 Subject: [PATCH 253/325] [11.x] Migration `nullOnUpdate` (#9954) * Add docs for null on update * Update migrations.md --------- Co-authored-by: Taylor Otwell --- migrations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/migrations.md b/migrations.md index a22bc3e5c25..d4613404ade 100644 --- a/migrations.md +++ b/migrations.md @@ -1190,6 +1190,7 @@ An alternative, expressive syntax is also provided for these actions: | ----------------------------- | ------------------------------------------------- | | `$table->cascadeOnUpdate();` | Updates should cascade. | | `$table->restrictOnUpdate();` | Updates should be restricted. | +| `$table->nullOnUpdate();` | Updates should set the foreign key value to null. | | `$table->noActionOnUpdate();` | No action on updates. | | `$table->cascadeOnDelete();` | Deletes should cascade. | | `$table->restrictOnDelete();` | Deletes should be restricted. | From 8f1a3d074d960178fc00bc91760324336e898822 Mon Sep 17 00:00:00 2001 From: Andy Hinkle Date: Tue, 15 Oct 2024 10:24:35 -0500 Subject: [PATCH 254/325] [11.x] Add Number Helpers: `defaultLocale`, `defaultCurrency` (#9955) * Add Number Default Locale * Add docs for default currency * Update helpers.md --------- Co-authored-by: Taylor Otwell --- helpers.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/helpers.md b/helpers.md index ac604263946..6986624beb9 100644 --- a/helpers.md +++ b/helpers.md @@ -93,6 +93,8 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct [Number::abbreviate](#method-number-abbreviate) [Number::clamp](#method-number-clamp) [Number::currency](#method-number-currency) +[Number::defaultCurrency](#method-default-currency) +[Number::defaultLocale](#method-default-locale) [Number::fileSize](#method-number-file-size) [Number::forHumans](#method-number-for-humans) [Number::format](#method-number-format) @@ -1231,6 +1233,28 @@ The `Number::currency` method returns the currency representation of the given v // 1.000,00 € + +#### `Number::defaultCurrency()` {.collection-method} + +The `Number::defaultCurrency` method returns the default currency being used by the `Number` class: + + use Illuminate\Support\Number; + + $currency = Number::defaultCurrency(); + + // USD + + +#### `Number::defaultLocale()` {.collection-method} + +The `Number::defaultLocale` method returns the default locale being used by the `Number` class: + + use Illuminate\Support\Number; + + $locale = Number::defaultLocale(); + + // en + #### `Number::fileSize()` {.collection-method} From d3df0454dd72245b80aa8801a770ceb2146cc2f9 Mon Sep 17 00:00:00 2001 From: Dmytro Morozov Date: Wed, 16 Oct 2024 23:43:33 +0300 Subject: [PATCH 255/325] [11.x] Get back old installation/application creation methods (#9958) * Get back old installation/application creation methods * Update installation.md * Update installation.md --------- Co-authored-by: Taylor Otwell --- installation.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/installation.md b/installation.md index ee92d33252f..1c704185bb4 100644 --- a/installation.md +++ b/installation.md @@ -79,6 +79,12 @@ Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManage After running one of the commands above, you should restart your terminal session. To update PHP, Composer, and the Laravel installer after installing them via `php.new`, you can re-run the command in your terminal. +In you already have PHP and Composer installed, you may install the Laravel installer via Composer: + +```shell +composer global require laravel/installer +``` + > [!NOTE] > For a fully-featured, graphical PHP installation and management experience, check out [Laravel Herd](#local-installation-using-herd). From 49b1b9f790ce1def7b3e94f254d21c0a90dfae98 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 16 Oct 2024 22:50:27 +0200 Subject: [PATCH 256/325] [11.x] Add support for union types in event listeners in Laravel 11 (#9957) * [11.x] Add support for union types in event listeners in Laravel 11 It's something I simply discovered. It simplifies some of my listeners, so I thought it would be helpful for other developers to know that this is possible. By using union types in Laravel event listeners, you can handle multiple related events in a single listener. This reduces redundancy and makes it easier to manage similar events in one place. The example in the documentation shows how to use union types in the `handle` method, leveraging the `instanceof` operator to differentiate and handle each event accordingly. * Update events.md * Update events.md --------- Co-authored-by: Taylor Otwell --- events.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/events.md b/events.md index 93c7b8cd69d..9fffbe352ac 100644 --- a/events.md +++ b/events.md @@ -68,6 +68,16 @@ By default, Laravel will automatically find and register your event listeners by } } +You may listen to multiple events using PHP's union types: + + /** + * Handle the given event. + */ + public function handle(PodcastProcessed|PodcastPublished $event): void + { + // ... + } + If you plan to store your listeners in a different directory or within multiple directories, you may instruct Laravel to scan those directories using the `withEvents` method in your application's `bootstrap/app.php` file: ->withEvents(discover: [ From da497fd5e0d1b0fd9f0715bcc50b7524abaec7bd Mon Sep 17 00:00:00 2001 From: Okorare Tega Date: Fri, 18 Oct 2024 14:50:40 +0100 Subject: [PATCH 257/325] Update typo error in installation.md (#9961) --- installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation.md b/installation.md index 1c704185bb4..eae384c4b8d 100644 --- a/installation.md +++ b/installation.md @@ -79,7 +79,7 @@ Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManage After running one of the commands above, you should restart your terminal session. To update PHP, Composer, and the Laravel installer after installing them via `php.new`, you can re-run the command in your terminal. -In you already have PHP and Composer installed, you may install the Laravel installer via Composer: +If you already have PHP and Composer installed, you may install the Laravel installer via Composer: ```shell composer global require laravel/installer From 34ce2334289e77fb46bbf05f7089852d39217e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:54:10 +0200 Subject: [PATCH 258/325] [11.x] Fix code block language (#9973) * Change code block language from "shell" to "ini" for environment variables * That's obviously a shell command oO * The correct language is "ini", not "env" * Another one --- mail.md | 2 +- sail.md | 2 +- scout.md | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mail.md b/mail.md index 2798dad7bfc..af1fe496b8e 100644 --- a/mail.md +++ b/mail.md @@ -195,7 +195,7 @@ composer require mailersend/laravel-driver Once the package is installed, add the `MAILERSEND_API_KEY` environment variable to your application's `.env` file. In addition, the `MAIL_MAILER` environment variable should be defined as `mailersend`: -```shell +```ini MAIL_MAILER=mailersend MAIL_FROM_ADDRESS=app@yourdomain.com MAIL_FROM_NAME="App Name" diff --git a/sail.md b/sail.md index 7226abe3d78..6ba060a301f 100644 --- a/sail.md +++ b/sail.md @@ -177,7 +177,7 @@ sail php script.php Composer commands may be executed using the `composer` command. Laravel Sail's application container includes a Composer installation: -```nothing +```shell sail composer require laravel/sanctum ``` diff --git a/scout.md b/scout.md index 65af70930a7..4812de51f48 100644 --- a/scout.md +++ b/scout.md @@ -141,7 +141,7 @@ composer require typesense/typesense-php Then, set the `SCOUT_DRIVER` environment variable as well as your Typesense host and API key credentials within your application's .env file: -```env +```ini SCOUT_DRIVER=typesense TYPESENSE_API_KEY=masterKey TYPESENSE_HOST=localhost @@ -149,7 +149,7 @@ TYPESENSE_HOST=localhost If you are using [Laravel Sail](/docs/{{version}}/sail), you may need to adjust the `TYPESENSE_HOST` environment variable to match the Docker container name. You may also optionally specify your installation's port, path, and protocol: -```env +```ini TYPESENSE_PORT=8108 TYPESENSE_PATH= TYPESENSE_PROTOCOL=http From e54ac7fb565a0be4661bf77535d9c52b1f5856e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:57:40 +0200 Subject: [PATCH 259/325] Fix heading levels on structure page (#9969) --- structure.md | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/structure.md b/structure.md index 50c181be912..669241f1fdd 100644 --- a/structure.md +++ b/structure.md @@ -39,37 +39,37 @@ The default Laravel application structure is intended to provide a great startin ## The Root Directory -#### The App Directory +### The App Directory The `app` directory contains the core code of your application. We'll explore this directory in more detail soon; however, almost all of the classes in your application will be in this directory. -#### The Bootstrap Directory +### The Bootstrap Directory The `bootstrap` directory contains the `app.php` file which bootstraps the framework. This directory also houses a `cache` directory which contains framework generated files for performance optimization such as the route and services cache files. -#### The Config Directory +### The Config Directory The `config` directory, as the name implies, contains all of your application's configuration files. It's a great idea to read through all of these files and familiarize yourself with all of the options available to you. -#### The Database Directory +### The Database Directory The `database` directory contains your database migrations, model factories, and seeds. If you wish, you may also use this directory to hold an SQLite database. -#### The Public Directory +### The Public Directory The `public` directory contains the `index.php` file, which is the entry point for all requests entering your application and configures autoloading. This directory also houses your assets such as images, JavaScript, and CSS. -#### The Resources Directory +### The Resources Directory The `resources` directory contains your [views](/docs/{{version}}/views) as well as your raw, un-compiled assets such as CSS or JavaScript. -#### The Routes Directory +### The Routes Directory The `routes` directory contains all of the route definitions for your application. By default, two route files are included with Laravel: `web.php` and `console.php`. @@ -84,19 +84,19 @@ The `api.php` file contains routes that are intended to be stateless, so request The `channels.php` file is where you may register all of the [event broadcasting](/docs/{{version}}/broadcasting) channels that your application supports. -#### The Storage Directory +### The Storage Directory The `storage` directory contains your logs, compiled Blade templates, file based sessions, file caches, and other files generated by the framework. This directory is segregated into `app`, `framework`, and `logs` directories. The `app` directory may be used to store any files generated by your application. The `framework` directory is used to store framework generated files and caches. Finally, the `logs` directory contains your application's log files. The `storage/app/public` directory may be used to store user-generated files, such as profile avatars, that should be publicly accessible. You should create a symbolic link at `public/storage` which points to this directory. You may create the link using the `php artisan storage:link` Artisan command. -#### The Tests Directory +### The Tests Directory The `tests` directory contains your automated tests. Example [Pest](https://pestphp.com) or [PHPUnit](https://phpunit.de/) unit tests and feature tests are provided out of the box. Each test class should be suffixed with the word `Test`. You may run your tests using the `/vendor/bin/pest` or `/vendor/bin/phpunit` commands. Or, if you would like a more detailed and beautiful representation of your test results, you may run your tests using the `php artisan test` Artisan command. -#### The Vendor Directory +### The Vendor Directory The `vendor` directory contains your [Composer](https://getcomposer.org) dependencies. @@ -113,68 +113,68 @@ Both the `Console` and `Http` directories are further explained in their respect > Many of the classes in the `app` directory can be generated by Artisan via commands. To review the available commands, run the `php artisan list make` command in your terminal. -#### The Broadcasting Directory +### The Broadcasting Directory The `Broadcasting` directory contains all of the broadcast channel classes for your application. These classes are generated using the `make:channel` command. This directory does not exist by default, but will be created for you when you create your first channel. To learn more about channels, check out the documentation on [event broadcasting](/docs/{{version}}/broadcasting). -#### The Console Directory +### The Console Directory The `Console` directory contains all of the custom Artisan commands for your application. These commands may be generated using the `make:command` command. -#### The Events Directory +### The Events Directory This directory does not exist by default, but will be created for you by the `event:generate` and `make:event` Artisan commands. The `Events` directory houses [event classes](/docs/{{version}}/events). Events may be used to alert other parts of your application that a given action has occurred, providing a great deal of flexibility and decoupling. -#### The Exceptions Directory +### The Exceptions Directory The `Exceptions` directory contains all of the custom exceptions for your application. These exceptions may be generated using the `make:exception` command. -#### The Http Directory +### The Http Directory The `Http` directory contains your controllers, middleware, and form requests. Almost all of the logic to handle requests entering your application will be placed in this directory. -#### The Jobs Directory +### The Jobs Directory This directory does not exist by default, but will be created for you if you execute the `make:job` Artisan command. The `Jobs` directory houses the [queueable jobs](/docs/{{version}}/queues) for your application. Jobs may be queued by your application or run synchronously within the current request lifecycle. Jobs that run synchronously during the current request are sometimes referred to as "commands" since they are an implementation of the [command pattern](https://en.wikipedia.org/wiki/Command_pattern). -#### The Listeners Directory +### The Listeners Directory This directory does not exist by default, but will be created for you if you execute the `event:generate` or `make:listener` Artisan commands. The `Listeners` directory contains the classes that handle your [events](/docs/{{version}}/events). Event listeners receive an event instance and perform logic in response to the event being fired. For example, a `UserRegistered` event might be handled by a `SendWelcomeEmail` listener. -#### The Mail Directory +### The Mail Directory This directory does not exist by default, but will be created for you if you execute the `make:mail` Artisan command. The `Mail` directory contains all of your [classes that represent emails](/docs/{{version}}/mail) sent by your application. Mail objects allow you to encapsulate all of the logic of building an email in a single, simple class that may be sent using the `Mail::send` method. -#### The Models Directory +### The Models Directory The `Models` directory contains all of your [Eloquent model classes](/docs/{{version}}/eloquent). The Eloquent ORM included with Laravel provides a beautiful, simple ActiveRecord implementation for working with your database. Each database table has a corresponding "Model" which is used to interact with that table. Models allow you to query for data in your tables, as well as insert new records into the table. -#### The Notifications Directory +### The Notifications Directory This directory does not exist by default, but will be created for you if you execute the `make:notification` Artisan command. The `Notifications` directory contains all of the "transactional" [notifications](/docs/{{version}}/notifications) that are sent by your application, such as simple notifications about events that happen within your application. Laravel's notification feature abstracts sending notifications over a variety of drivers such as email, Slack, SMS, or stored in a database. -#### The Policies Directory +### The Policies Directory This directory does not exist by default, but will be created for you if you execute the `make:policy` Artisan command. The `Policies` directory contains the [authorization policy classes](/docs/{{version}}/authorization) for your application. Policies are used to determine if a user can perform a given action against a resource. -#### The Providers Directory +### The Providers Directory The `Providers` directory contains all of the [service providers](/docs/{{version}}/providers) for your application. Service providers bootstrap your application by binding services in the service container, registering events, or performing any other tasks to prepare your application for incoming requests. In a fresh Laravel application, this directory will already contain the `AppServiceProvider`. You are free to add your own providers to this directory as needed. -#### The Rules Directory +### The Rules Directory This directory does not exist by default, but will be created for you if you execute the `make:rule` Artisan command. The `Rules` directory contains the custom validation rule objects for your application. Rules are used to encapsulate complicated validation logic in a simple object. For more information, check out the [validation documentation](/docs/{{version}}/validation). From 77569f35d47752c3ae19c88f8c6cb47366b89905 Mon Sep 17 00:00:00 2001 From: Jorge Lapa <2780099+heyjorgedev@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:00:02 +0100 Subject: [PATCH 260/325] Update typo error in eloquent.md (#9964) --- eloquent.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eloquent.md b/eloquent.md index 776029bc98b..9e7084cc881 100644 --- a/eloquent.md +++ b/eloquent.md @@ -479,7 +479,7 @@ If you are filtering the results of the `chunk` method based on a column that yo Flight::where('departed', true) ->chunkById(200, function (Collection $flights) { $flights->each->update(['departed' => false]); - }, $column = 'id'); + }, column: 'id'); ``` Since the `chunkById` and `lazyById` methods add their own "where" conditions to the query being executed, you should typically [logically group](/docs/{{version}}/queries#logical-grouping) your own conditions within a closure: @@ -512,7 +512,7 @@ If you are filtering the results of the `lazy` method based on a column that you ```php Flight::where('departed', true) - ->lazyById(200, $column = 'id') + ->lazyById(200, column: 'id') ->each->update(['departed' => false]); ``` From 16b8805d9c475af2f01351913316fcd835a81ad3 Mon Sep 17 00:00:00 2001 From: David Gasperoni Date: Mon, 21 Oct 2024 16:00:57 +0200 Subject: [PATCH 261/325] Update Axios's URL (#9963) --- broadcasting.md | 2 +- passport.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/broadcasting.md b/broadcasting.md index 7c42269e48a..1c0ef6aae8d 100644 --- a/broadcasting.md +++ b/broadcasting.md @@ -721,7 +721,7 @@ However, remember that we also broadcast the task's creation. If your JavaScript #### Configuration -When you initialize a Laravel Echo instance, a socket ID is assigned to the connection. If you are using a global [Axios](https://github.com/mzabriskie/axios) instance to make HTTP requests from your JavaScript application, the socket ID will automatically be attached to every outgoing request as an `X-Socket-ID` header. Then, when you call the `toOthers` method, Laravel will extract the socket ID from the header and instruct the broadcaster to not broadcast to any connections with that socket ID. +When you initialize a Laravel Echo instance, a socket ID is assigned to the connection. If you are using a global [Axios](https://github.com/axios/axios) instance to make HTTP requests from your JavaScript application, the socket ID will automatically be attached to every outgoing request as an `X-Socket-ID` header. Then, when you call the `toOthers` method, Laravel will extract the socket ID from the header and instruct the broadcaster to not broadcast to any connections with that socket ID. If you are not using a global Axios instance, you will need to manually configure your JavaScript application to send the `X-Socket-ID` header with all outgoing requests. You may retrieve the socket ID using the `Echo.socketId` method: diff --git a/passport.md b/passport.md index 96738eae41b..9aaa57cb908 100644 --- a/passport.md +++ b/passport.md @@ -438,7 +438,7 @@ This `/oauth/token` route will return a JSON response containing `access_token`, #### JSON API -Passport also includes a JSON API for managing authorized access tokens. You may pair this with your own frontend to offer your users a dashboard for managing access tokens. For convenience, we'll use [Axios](https://github.com/mzabriskie/axios) to demonstrate making HTTP requests to the endpoints. The JSON API is guarded by the `web` and `auth` middleware; therefore, it may only be called from your own application. +Passport also includes a JSON API for managing authorized access tokens. You may pair this with your own frontend to offer your users a dashboard for managing access tokens. For convenience, we'll use [Axios](https://github.com/axios/axios) to demonstrate making HTTP requests to the endpoints. The JSON API is guarded by the `web` and `auth` middleware; therefore, it may only be called from your own application. #### `GET /oauth/tokens` @@ -867,7 +867,7 @@ Once you have created a personal access client, you may issue tokens for a given #### JSON API -Passport also includes a JSON API for managing personal access tokens. You may pair this with your own frontend to offer your users a dashboard for managing personal access tokens. Below, we'll review all of the API endpoints for managing personal access tokens. For convenience, we'll use [Axios](https://github.com/mzabriskie/axios) to demonstrate making HTTP requests to the endpoints. +Passport also includes a JSON API for managing personal access tokens. You may pair this with your own frontend to offer your users a dashboard for managing personal access tokens. Below, we'll review all of the API endpoints for managing personal access tokens. For convenience, we'll use [Axios](https://github.com/axios/axios) to demonstrate making HTTP requests to the endpoints. The JSON API is guarded by the `web` and `auth` middleware; therefore, it may only be called from your own application. It is not able to be called from an external source. From d636b0efcb462b894e8f18dd73f1b72f37a74881 Mon Sep 17 00:00:00 2001 From: Nelson Isioma Date: Mon, 21 Oct 2024 20:43:42 +0100 Subject: [PATCH 262/325] docs: updating authorization.md (#9975) * Update authorization.md * Update authorization.md --------- Co-authored-by: Taylor Otwell --- authorization.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/authorization.md b/authorization.md index ca5b4c8f470..ec79b888e2f 100644 --- a/authorization.md +++ b/authorization.md @@ -241,7 +241,7 @@ You may use the `after` method to define a closure to be executed after all othe } }); -Similar to the `before` method, if the `after` closure returns a non-null result that result will be considered the result of the authorization check. +Values returned by `after` closures will not override the result of the authorization check unless the gate or policy returned `null`. ### Inline Authorization From 4f4c78e4a04ac1c09c8092016ff2434c9c0532a0 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 22 Oct 2024 09:26:06 -0500 Subject: [PATCH 263/325] wip --- processes.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/processes.md b/processes.md index 0ad4de84126..46051b96b84 100644 --- a/processes.md +++ b/processes.md @@ -291,6 +291,16 @@ $process = Process::start('bash import.sh', function (string $type, string $outp $result = $process->wait(); ``` +Instead of waiting until the process has finished, you may use the `waitUntil` method to stop waiting based on the output of the process. Laravel will stop waiting for the process to finish when the closure given to the `waitUntil` method returns `true`: + +```php +$process = Process::start('bash import.sh'); + +$process->waitUntil(function (string $type, string $output) { + return $output === 'Ready...'; +}); +``` + ## Concurrent Processes From 426c6287831d95a7472e085cfd53ea11d93f0a78 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 23 Oct 2024 08:01:55 -0500 Subject: [PATCH 264/325] add clarification about `forget` method return value (#9982) the wording here is just a little unclear. the first sentence seems to suggest that the `forget()` method does not return anything, even though it does. you are free to assign the result to a new variable even though you don't need to. --- collections.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collections.md b/collections.md index 58a05007a4e..a963e8bd22e 100644 --- a/collections.md +++ b/collections.md @@ -1083,7 +1083,7 @@ The `forget` method removes an item from the collection by its key: // [] > [!WARNING] -> Unlike most other collection methods, `forget` does not return a new modified collection; it modifies the collection it is called on. +> Unlike most other collection methods, `forget` does not return a new modified collection; it modifies and returns the collection it is called on. #### `forPage()` {.collection-method} From c155276ccdc164d27663b7a2f210f388531db377 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 24 Oct 2024 09:31:08 -0500 Subject: [PATCH 265/325] [11.x] new allowed filename for anonymous index components (#9984) * new allowed filename for anonymous index components we can now use either `index.blade.php` or `{directory}.blade.php` for our anonymous index components. https://github.com/laravel/framework/pull/52669 * Update blade.md --------- Co-authored-by: Taylor Otwell --- blade.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blade.md b/blade.md index e124c9cfb2a..cbfd7373477 100644 --- a/blade.md +++ b/blade.md @@ -1374,10 +1374,10 @@ This directory structure allows you to render the accordion component and its it However, in order to render the accordion component via `x-accordion`, we were forced to place the "index" accordion component template in the `resources/views/components` directory instead of nesting it within the `accordion` directory with the other accordion related templates. -Thankfully, Blade allows you to place an `index.blade.php` file within a component's template directory. When an `index.blade.php` template exists for the component, it will be rendered as the "root" node of the component. So, we can continue to use the same Blade syntax given in the example above; however, we will adjust our directory structure like so: +Thankfully, Blade allows you to place a file matching the component's directory name within the component's directory itself. When this template exists, it can be rendered as the "root" element of the component even though it is nested within a directory. So, we can continue to use the same Blade syntax given in the example above; however, we will adjust our directory structure like so: ```none -/resources/views/components/accordion/index.blade.php +/resources/views/components/accordion/accordion.blade.php /resources/views/components/accordion/item.blade.php ``` From 724c31ccd3edce6b6dfe5e0dd2a594a47217f078 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 24 Oct 2024 09:38:19 -0500 Subject: [PATCH 266/325] [11.x] document "index" class components (#9985) * document "index" class components https://github.com/laravel/framework/pull/52669 * formatting --------- Co-authored-by: Taylor Otwell --- blade.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/blade.md b/blade.md index cbfd7373477..7b08cc4825c 100644 --- a/blade.md +++ b/blade.md @@ -18,6 +18,7 @@ - [Comments](#comments) - [Components](#components) - [Rendering Components](#rendering-components) + - [Index Components](#index-components) - [Passing Data to Components](#passing-data-to-components) - [Component Attributes](#component-attributes) - [Reserved Keywords](#reserved-keywords) @@ -756,6 +757,26 @@ If you would like to conditionally render your component, you may define a `shou return Str::length($this->message) > 0; } + +### Index Components + +Sometimes components are part of a component group and you may wish to group the related components within a single directory. For example, imagine a "card" component with the following class structure: + +```none +App\Views\Components\Card\Card +App\Views\Components\Card\Header +App\Views\Components\Card\Body +``` + +Since the root `Card` component is nested within a `Card` directory, you might expect that you would need to render the component via ``. However, when a component's file name matches the name of the component's directory, Laravel automatically assumes that component is the "root" component and allows you to render the component without repeating the directory name: + +```blade + + ... + ... + +``` + ### Passing Data to Components From c608c51d885501d71575dd692e33949e0eb7fe47 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 29 Oct 2024 08:56:21 -0500 Subject: [PATCH 267/325] [11.x] consistently use "an" when preceding "SQL" or "SQLite" (#9998) * consistently use "an" when preceding "SQL" or "SQLite" my preference would be to go the other direction, but this at least makes it consistent across the docs * remove "unique" SQL injection warning I don't believe this warning is actually valid anymore. Best I can tell, using the default `DatabasePresenceVerifier`, we are executing an aggregate "count" query, which use Prepared Statements with variable binding. the note was added 5 years ago [here](https://github.com/laravel/docs/commit/8c63ad24fdb6750e0372e4ee9170ac2b119c377f) the query is built [here](https://github.com/laravel/docs/commit/8c63ad24fdb6750e0372e4ee9170ac2b119c377f) for the example of updating a user and ensuring the email remains unique, the generated query is ```sql select count(*) as aggregate from `users` where `email` = ? and `id` <> ? and `users`.`deleted_at` is null ``` we could also go the route of not removing this completely, but softening the language to something like "*may* be vulnerable..." in case we're worried about people using alternate "Presence Verifiers". * oops, revert. wrong branch --- installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation.md b/installation.md index eae384c4b8d..dfff142a526 100644 --- a/installation.md +++ b/installation.md @@ -130,7 +130,7 @@ Your `.env` file should not be committed to your application's source control, s ### Databases and Migrations -Now that you have created your Laravel application, you probably want to store some data in a database. By default, your application's `.env` configuration file specifies that Laravel will be interacting with a SQLite database. +Now that you have created your Laravel application, you probably want to store some data in a database. By default, your application's `.env` configuration file specifies that Laravel will be interacting with an SQLite database. During the creation of the application, Laravel created a `database/database.sqlite` file for you, and ran the necessary migrations to create the application's database tables. From 2a4226eadcd991901858e699f9c0ae62c13f90e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BC=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=BA=D0=BE=D1=88?= =?UTF-8?q?=D0=BA=D0=B8=D0=BD?= <126749386+humblera1@users.noreply.github.com> Date: Tue, 29 Oct 2024 21:21:09 +0700 Subject: [PATCH 268/325] Changed the name of the method in the description to the appropriate one (#9996) --- eloquent-relationships.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eloquent-relationships.md b/eloquent-relationships.md index caea2bb0645..f4ed21b32d8 100644 --- a/eloquent-relationships.md +++ b/eloquent-relationships.md @@ -1072,7 +1072,7 @@ foreach ($posts as $post) { In the example above, an "N + 1" query problem has been introduced because, even though comments were eager loaded for every `Post` model, Eloquent does not automatically hydrate the parent `Post` on each child `Comment` model. -If you would like Eloquent to automatically hydrate parent models onto their children, you may invoke the `chaperone` method when defining a `hasMany` relationship: +If you would like Eloquent to automatically hydrate parent models onto their children, you may invoke the `chaperone` method when defining a `morphMany` relationship: class Post extends Model { From e81073dfdf1af87568007014abe72aaa235c61b1 Mon Sep 17 00:00:00 2001 From: Perry van der Meer <11609290+PerryvanderMeer@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:32:42 +0100 Subject: [PATCH 269/325] Docs for `$this->assertDatabaseEmpty('table')` (#9995) * Update database-testing.md * Update database-testing.md Co-authored-by: Josh Manders --------- Co-authored-by: Josh Manders --- database-testing.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/database-testing.md b/database-testing.md index f4eb1acdba9..4545a81268e 100644 --- a/database-testing.md +++ b/database-testing.md @@ -196,6 +196,13 @@ Assert that a table in the database contains the given number of records: $this->assertDatabaseCount('users', 5); + +#### assertDatabaseEmpty + +Assert that a table in the database contains no records: + + $this->assertDatabaseEmpty('users'); + #### assertDatabaseHas From 47f34bd8ee4cbec55ad5c3b3e2dddb7a3a563628 Mon Sep 17 00:00:00 2001 From: Akhilesh Jha Date: Tue, 29 Oct 2024 20:03:17 +0530 Subject: [PATCH 270/325] Update installation.md (#9994) This got wasted my 10 min as when I ran "composer run dev" as I am new to laravel. this --> "npm install && npm run build" --- installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation.md b/installation.md index dfff142a526..c890af7f45b 100644 --- a/installation.md +++ b/installation.md @@ -101,7 +101,7 @@ Once the application has been created, you can start Laravel's local development ```nothing cd example-app - +npm install && npm run build composer run dev ``` From 0fb74b53ead24933cdc2024aa979675b45e6e821 Mon Sep 17 00:00:00 2001 From: Pushpak Chhajed Date: Tue, 29 Oct 2024 20:08:52 +0530 Subject: [PATCH 271/325] Update Octane configuration to use dynamic port for supervisor PHP command instead of Port 80 (#9993) --- octane.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/octane.md b/octane.md index 8259e9a3985..1a4d891abaf 100644 --- a/octane.md +++ b/octane.md @@ -78,7 +78,7 @@ Finally, add a `SUPERVISOR_PHP_COMMAND` environment variable to the `laravel.tes services: laravel.test: environment: - SUPERVISOR_PHP_COMMAND: "/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan octane:start --server=frankenphp --host=0.0.0.0 --admin-port=2019 --port=80" # [tl! add] + SUPERVISOR_PHP_COMMAND: "/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan octane:start --server=frankenphp --host=0.0.0.0 --admin-port=2019 --port='${APP_PORT:-80}'" # [tl! add] XDG_CONFIG_HOME: /var/www/html/config # [tl! add] XDG_DATA_HOME: /var/www/html/data # [tl! add] ``` @@ -170,7 +170,7 @@ Then, add a `SUPERVISOR_PHP_COMMAND` environment variable to the `laravel.test` services: laravel.test: environment: - SUPERVISOR_PHP_COMMAND: "/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan octane:start --server=roadrunner --host=0.0.0.0 --rpc-port=6001 --port=80" # [tl! add] + SUPERVISOR_PHP_COMMAND: "/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan octane:start --server=roadrunner --host=0.0.0.0 --rpc-port=6001 --port='${APP_PORT:-80}'" # [tl! add] ``` Finally, ensure the `rr` binary is executable and build your Sail images: @@ -215,7 +215,7 @@ To get started, add a `SUPERVISOR_PHP_COMMAND` environment variable to the `lara services: laravel.test: environment: - SUPERVISOR_PHP_COMMAND: "/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan octane:start --server=swoole --host=0.0.0.0 --port=80" # [tl! add] + SUPERVISOR_PHP_COMMAND: "/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan octane:start --server=swoole --host=0.0.0.0 --port='${APP_PORT:-80}'" # [tl! add] ``` Finally, build your Sail images: From 1747ca57ca53190d7266b575c8aba86305ba17f1 Mon Sep 17 00:00:00 2001 From: Ahmadreza Bashari <61243238+ahmadreza1383@users.noreply.github.com> Date: Tue, 29 Oct 2024 18:09:49 +0330 Subject: [PATCH 272/325] Add scopedIf method for container (#9992) * Add scopedIf method for container * Update container.md --------- Co-authored-by: ahmadreza Co-authored-by: Taylor Otwell --- container.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/container.md b/container.md index 5fc122ed354..aafba3e1d65 100644 --- a/container.md +++ b/container.md @@ -170,6 +170,12 @@ The `scoped` method binds a class or interface into the container that should on return new Transistor($app->make(PodcastParser::class)); }); +You may use the `scopedIf` method to register a scoped container binding only if a binding has not already been registered for the given type: + + $this->app->scopedIf(Transistor::class, function (Application $app) { + return new Transistor($app->make(PodcastParser::class)); + }); + #### Binding Instances From 690175ad7106a7b8ce6e6e8420872ca932622e84 Mon Sep 17 00:00:00 2001 From: Ahmadreza Bashari <61243238+ahmadreza1383@users.noreply.github.com> Date: Tue, 29 Oct 2024 18:40:28 +0330 Subject: [PATCH 273/325] Add rebinding method to container docs (#9990) * Add rebinding to Container docs * document rebinding --------- Co-authored-by: ahmadreza Co-authored-by: Taylor Otwell --- container.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/container.md b/container.md index aafba3e1d65..61b90d81f2a 100644 --- a/container.md +++ b/container.md @@ -17,6 +17,7 @@ - [Automatic Injection](#automatic-injection) - [Method Invocation and Injection](#method-invocation-and-injection) - [Container Events](#container-events) + - [Rebinding](#rebinding) - [PSR-11](#psr-11) @@ -584,6 +585,28 @@ The service container fires an event each time it resolves an object. You may li As you can see, the object being resolved will be passed to the callback, allowing you to set any additional properties on the object before it is given to its consumer. + +### Rebinding + +The `rebinding` method allows you to listen for when a service is re-bound to the container, meaning it is registered again or overridden after its initial binding. This can be useful when you need to update dependencies or modify behavior each time a specific binding is updated: + + use App\Contracts\PodcastPublisher; + use App\Services\SpotifyPublisher; + use App\Services\TransistorPublisher; + use Illuminate\Contracts\Foundation\Application; + + $this->app->bind(PodcastPublisher::class, SpotifyPublisher::class); + + $this->app->rebinding( + PodcastPublisher::class, + function (Application $app, PodcastPublisher $newInstance) { + // + }, + ); + + // New binding will trigger rebinding closure... + $this->app->bind(PodcastPublisher::class, TransistorPublisher::class); + ## PSR-11 From 364b634ccee1fff2794ce0e11f8223bd0c10604b Mon Sep 17 00:00:00 2001 From: Pradeep Singh Date: Tue, 29 Oct 2024 20:44:08 +0530 Subject: [PATCH 274/325] Slack notification prerequisites (#9988) * Update notifications.md * Update notifications.md --------- Co-authored-by: Taylor Otwell --- notifications.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifications.md b/notifications.md index 995d404cb2f..a6dea95c10c 100644 --- a/notifications.md +++ b/notifications.md @@ -1126,7 +1126,7 @@ composer require laravel/slack-notification-channel Additionally, you must create a [Slack App](https://api.slack.com/apps?new_app=1) for your Slack workspace. -If you only need to send notifications to the same Slack workspace that the App is created in, you should ensure that your App has the `chat:write`, `chat:write.public`, and `chat:write.customize` scopes. These scopes can be added from the "OAuth & Permissions" App management tab within Slack. +If you only need to send notifications to the same Slack workspace that the App is created in, you should ensure that your App has the `chat:write`, `chat:write.public`, and `chat:write.customize` scopes. If you want to send messages as your Slack App, you should ensure that your App also has the `chat:write:bot` scope. These scopes can be added from the "OAuth & Permissions" App management tab within Slack. Next, copy the App's "Bot User OAuth Token" and place it within a `slack` configuration array in your application's `services.php` configuration file. This token can be found on the "OAuth & Permissions" tab within Slack: From e589c65973ef8668df016fc27f4f37e07d8abf26 Mon Sep 17 00:00:00 2001 From: Prince John Santillan <60916966+princejohnsantillan@users.noreply.github.com> Date: Wed, 30 Oct 2024 01:48:22 +0800 Subject: [PATCH 275/325] Add Using Slack's Block Kit Builder Template section (#9987) * Add Using Slack's Block Kit Builder Template section * formatting --------- Co-authored-by: Taylor Otwell --- notifications.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/notifications.md b/notifications.md index a6dea95c10c..17235144293 100644 --- a/notifications.md +++ b/notifications.md @@ -1174,6 +1174,44 @@ If a notification supports being sent as a Slack message, you should define a `t }); } + +#### Using Slack's Block Kit Builder Template + +Instead of using the fluent message builder methods to construct your Block Kit message, you may provide the raw JSON payload generated by Slack's Block Kit Builder to the `usingBlockKitTemplate` method: + + use Illuminate\Notifications\Slack\SlackMessage; + use Illuminate\Support\Str; + + /** + * Get the Slack representation of the notification. + */ + public function toSlack(object $notifiable): SlackMessage + { + $template = <<usingBlockKitTemplate($template); + } + ### Slack Interactivity From 1f6303f816ef026fb5bed346c7a0952b86160800 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 30 Oct 2024 09:06:16 -0500 Subject: [PATCH 276/325] add suggestion for using Bun (#10005) Bun is a Node/NPM alternative that can handle dependency management and frontent asset compilation, with better performance, and simpler installation/upgrading. --- installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation.md b/installation.md index c890af7f45b..1277baa288a 100644 --- a/installation.md +++ b/installation.md @@ -61,7 +61,7 @@ Laravel combines the best packages in the PHP ecosystem to offer the most robust ### Installing PHP and the Laravel Installer -Before creating your first Laravel application, make sure that your local machine has [PHP](https://php.net), [Composer](https://getcomposer.org), and [the Laravel installer](https://github.com/laravel/installer) installed. In addition, you should install [Node and NPM](https://nodejs.org) so that you can compile your application's frontend assets. +Before creating your first Laravel application, make sure that your local machine has [PHP](https://php.net), [Composer](https://getcomposer.org), and [the Laravel installer](https://github.com/laravel/installer) installed. In addition, you should install either [Node and NPM](https://nodejs.org) or [Bun](https://bun.sh/) so that you can compile your application's frontend assets. If you don't have PHP and Composer installed on your local machine, the following commands will install PHP, Composer, and the Laravel installer on macOS, Windows, or Linux: From 37ccd45736efc6fd562ea40645c9b9580c770181 Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Thu, 31 Oct 2024 02:57:07 +1100 Subject: [PATCH 277/325] [11.x] without defer testing docs (#10006) * without defer * formatting --------- Co-authored-by: Taylor Otwell --- helpers.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/helpers.md b/helpers.md index 6986624beb9..24988b30230 100644 --- a/helpers.md +++ b/helpers.md @@ -2478,6 +2478,53 @@ protected $middleware = [ ]; ``` + +#### Disabling Deferred Functions in Tests + +When writing tests, it may be useful to disable deferred functions. You may call `withoutDefer` in your test to instruct Laravel to invoke all deferred functions immediately: + +```php tab=Pest +test('without defer', function () { + $this->withoutDefer(); + + // ... +}); +``` + +```php tab=PHPUnit +use Tests\TestCase; + +class ExampleTest extends TestCase +{ + public function test_without_defer(): void + { + $this->withoutDefer(); + + // ... + } +} +``` + +If you would like to disable deferred functions for all tests within a test case, you may call the `withoutDefer` method from the `setUp` method on your base `TestCase` class: + +```php +withoutDefer(); + }// [tl! add:end] +} +``` + ### Lottery From 1e8496c232c2e3f17179c7ad8d751f9c795ce16a Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 30 Oct 2024 10:57:33 -0500 Subject: [PATCH 278/325] wip --- helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers.md b/helpers.md index 24988b30230..bde5d85235d 100644 --- a/helpers.md +++ b/helpers.md @@ -2478,7 +2478,7 @@ protected $middleware = [ ]; ``` - + #### Disabling Deferred Functions in Tests When writing tests, it may be useful to disable deferred functions. You may call `withoutDefer` in your test to instruct Laravel to invoke all deferred functions immediately: From dde9f07b782ba5a3ff93e34471bf2b1a581b0a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilsen=20Hern=C3=A1ndez?= <13445515+wilsenhc@users.noreply.github.com> Date: Thu, 31 Oct 2024 13:56:05 -0400 Subject: [PATCH 279/325] Add new vector method to migrations (#10007) add dimensions missing parameter to vector revert whitespace changes --- migrations.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/migrations.md b/migrations.md index d4613404ade..a0be8bed27a 100644 --- a/migrations.md +++ b/migrations.md @@ -458,6 +458,7 @@ The schema builder blueprint offers a variety of methods that correspond to the [uuidMorphs](#column-method-uuidMorphs) [ulid](#column-method-ulid) [uuid](#column-method-uuid) +[vector](#column-method-vector) [year](#column-method-year) @@ -918,6 +919,13 @@ The `uuid` method creates a `UUID` equivalent column: $table->uuid('id'); + +#### `vector()` {.collection-method} + +The `vector` method creates a `vector` equivalent column: + + $table->vector('embedding', dimensions: 100); + #### `year()` {.collection-method} From 88b6f0d99c9f89ca38266d9fa0c3b4ea3df3c85e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Thu, 31 Oct 2024 22:16:33 +0100 Subject: [PATCH 280/325] Add documentation for MongoDB support (#9945) * Add mentions to MongoDB in the docs * formatting * Update session.md --------- Co-authored-by: Taylor Otwell --- authentication.md | 4 +- cache.md | 7 ++++ database.md | 2 + documentation.md | 1 + mongodb.md | 99 +++++++++++++++++++++++++++++++++++++++++++++++ queues.md | 1 + session.md | 7 ++-- 7 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 mongodb.md diff --git a/authentication.md b/authentication.md index 8a56d1a435c..a16e00ac148 100644 --- a/authentication.md +++ b/authentication.md @@ -53,7 +53,9 @@ Want to get started fast? Install a [Laravel application starter kit](/docs/{{ve ### Database Considerations -By default, Laravel includes an `App\Models\User` [Eloquent model](/docs/{{version}}/eloquent) in your `app/Models` directory. This model may be used with the default Eloquent authentication driver. If your application is not using Eloquent, you may use the `database` authentication provider which uses the Laravel query builder. +By default, Laravel includes an `App\Models\User` [Eloquent model](/docs/{{version}}/eloquent) in your `app/Models` directory. This model may be used with the default Eloquent authentication driver. + +If your application is not using Eloquent, you may use the `database` authentication provider which uses the Laravel query builder. If your application is using MongoDB, check out MongoDB's official [Laravel user authentication documentation](https://www.mongodb.com/docs/drivers/php/laravel-mongodb/current/user-authentication/) . When building the database schema for the `App\Models\User` model, make sure the password column is at least 60 characters in length. Of course, the `users` table migration that is included in new Laravel applications already creates a column that exceeds this length. diff --git a/cache.md b/cache.md index e80e3a0a0f7..289641e6cfd 100644 --- a/cache.md +++ b/cache.md @@ -111,6 +111,13 @@ In addition, you should ensure that values are provided for the DynamoDB cache s ], ``` + +#### MongoDB + +If you are using MongoDB, a `mongodb` cache driver is provided by the official `mongodb/laravel-mongodb` package and can be configured using a `mongodb` database connection. MongoDB supports TTL indexes, which can be used to automatically clear expired cache items. + +For more information on configuring MongoDB, please refer to the MongoDB [Cache and Locks documentation](https://www.mongodb.com/docs/drivers/php/laravel-mongodb/current/cache/). + ## Cache Usage diff --git a/database.md b/database.md index 0390f489696..829eca93572 100644 --- a/database.md +++ b/database.md @@ -27,6 +27,8 @@ Almost every modern web application interacts with a database. Laravel makes int +Additionally, MongoDB is supported via the `mongodb/laravel-mongodb` package, which is officially maintained by MongoDB. Check out the [Laravel MongoDB](https://www.mongodb.com/docs/drivers/php/laravel-mongodb/) documentation for more information. + ### Configuration diff --git a/documentation.md b/documentation.md index b4e36d8c503..c0eecca09eb 100644 --- a/documentation.md +++ b/documentation.md @@ -64,6 +64,7 @@ - [Migrations](/docs/{{version}}/migrations) - [Seeding](/docs/{{version}}/seeding) - [Redis](/docs/{{version}}/redis) + - [MongoDB](/docs/{{version}}/mongodb) - ## Eloquent ORM - [Getting Started](/docs/{{version}}/eloquent) - [Relationships](/docs/{{version}}/eloquent-relationships) diff --git a/mongodb.md b/mongodb.md new file mode 100644 index 00000000000..af992cd0d24 --- /dev/null +++ b/mongodb.md @@ -0,0 +1,99 @@ +# MongoDB + +- [Introduction](#introduction) +- [Installation](#installation) + - [MongoDB Driver](#mongodb-driver) + - [Starting a MongoDB Server](#starting-a-mongodb-server) + - [Install the Laravel MongoDB Package](#install-the-laravel-mongodb-package) +- [Configuration](#configuration) +- [Features](#features) + + +## Introduction + +[MongoDB](https://www.mongodb.com/resources/products/fundamentals/why-use-mongodb) is one of the most popular NoSQL document-oriented database, used for its high write load (useful for analytics or IoT) and high availability (easy to set replica sets with automatic failover). It can also shard the database easily for horizontal scalability and has a powerful query language for doing aggregation, text search or geospatial queries. + +Instead of storing data in tables of rows or columns like SQL databases, each record in a MongoDB database is a document described in BSON, a binary representation of the data. Applications can then retrieve this information in a JSON format. It supports a wide variety of data types, including documents, arrays, embedded documents, and binary data. + +Before using MongoDB with Laravel, we recommend installing and using the `mongodb/laravel-mongodb` package via Composer. The `laravel-mongodb` package is officially maintained by MongoDB, and while MongoDB is natively supported by PHP through the MongoDB driver, the [Laravel MongoDB](https://www.mongodb.com/docs/drivers/php/laravel-mongodb/) package provides a richer integration with Eloquent and other Laravel features: + +```shell +composer require mongodb/laravel-mongodb +``` + + +## Installation + + +### MongoDB Driver + +To connect to a MongoDB database, the `mongodb` PHP extension is required. If you are developing locally using [Laravel Herd](https://herd.laravel.com) or installed PHP via `php.new`, you already have this extension installed on your system. However, if you need to install the extension manually, you may do so via PECL: + +```shell +pecl install mongodb +``` + +For more information on installing the MongoDB PHP extension, check out the [MongoDB PHP extension installation instructions](https://www.php.net/manual/en/mongodb.installation.php). + + +### Starting a MongoDB Server + +The MongoDB Community Server can be used to run MongoDB locally and is available for installation on Windows, macOS, Linux, or as a Docker container. To learn how to install MongoDB, please refer to the [official MongoDB Community installation guide](https://docs.mongodb.com/manual/administration/install-community/). + +The connection string for the MongoDB server can be set in your `.env` file: + +```ini +MONGODB_URI="mongodb://localhost:27017" +MONGODB_DATABASE="laravel_app" +``` + +For hosting MongoDB in the cloud, consider using [MongoDB Atlas](https://www.mongodb.com/cloud/atlas). +To access a MongoDB Atlas cluster locally from your application, you will need to [add your own IP address in the cluster's network settings](https://www.mongodb.com/docs/atlas/security/add-ip-address-to-list/) to the project's IP Access List. + +The connection string for MongoDB Atlas can also be set in your `.env` file: + +```ini +MONGODB_URI="mongodb+srv://:@.mongodb.net/?retryWrites=true&w=majority" +MONGODB_DATABASE="laravel_app" +``` + + +### Install the Laravel MongoDB Package + +Finally, use Composer to install the Laravel MongoDB package: + +```shell +composer require mongodb/laravel-mongodb +``` + +> [!NOTE] +> This installation of the package will fail if the `mongodb` PHP extension is not installed. The PHP configuration can differ between the CLI and the web server, so ensure the extension is enabled in both configurations. + + +## Configuration + +You may configure your MongoDB connection via your application's `config/database.php` configuration file. Within this file, add a `mongodb` connection that utilizes the `mongodb` driver: + +```php +'connections' => [ + 'mongodb' => [ + 'driver' => 'mongodb', + 'dsn' => env('MONGODB_URI', 'mongodb://localhost:27017'), + 'database' => env('MONGODB_DATABASE', 'laravel_app'), + ], +], +``` + + +## Features + +Once your configuration is complete, you can use the `mongodb` package and database connection in your application to leverage a variety of powerful features: + +- [Using Eloquent](https://www.mongodb.com/docs/drivers/php/laravel-mongodb/current/eloquent-models/), models can be stored in MongoDB collections. In addition to the standard Eloquent features, the Laravel MongoDB package provides additional features such as embedded relationships. The package also provides direct access to the MongoDB driver, which can be used to execute operations such as raw queries and aggregation pipelines. +- [Write complex queries](https://www.mongodb.com/docs/drivers/php/laravel-mongodb/current/query-builder/) using the query builder. +- The `mongodb` [cache driver](https://www.mongodb.com/docs/drivers/php/laravel-mongodb/current/cache/) is optimized to use MongoDB features such as TTL indexes to automatically clear expired cache entries. +- [Dispatch and process queued jobs](https://www.mongodb.com/docs/drivers/php/laravel-mongodb/current/queues/) with the `mongodb` queue driver. +- [Storing files in GridFS](https://www.mongodb.com/docs/drivers/php/laravel-mongodb/current/gridfs/), via the [GridFS Adapter for Flysystem](https://flysystem.thephpleague.com/docs/adapter/gridfs/). +- Most third party packages using a database connection or Eloquent can be used with MongoDB. + +To continue learning how to use MongoDB and Laravel, refer to MongoDB's [Quick Start guide](https://www.mongodb.com/docs/drivers/php/laravel-mongodb/current/quick-start/). diff --git a/queues.md b/queues.md index b6dfffd8c1c..f90404984b2 100644 --- a/queues.md +++ b/queues.md @@ -151,6 +151,7 @@ The following dependencies are needed for the listed queue drivers. These depend - Amazon SQS: `aws/aws-sdk-php ~3.0` - Beanstalkd: `pda/pheanstalk ~5.0` - Redis: `predis/predis ~2.0` or phpredis PHP extension +- [MongoDB](https://www.mongodb.com/docs/drivers/php/laravel-mongodb/current/queues/): `mongodb/laravel-mongodb` diff --git a/session.md b/session.md index e7ef049a5a6..7daa7d74481 100644 --- a/session.md +++ b/session.md @@ -245,7 +245,7 @@ If you need to regenerate the session ID and remove all data from the session in ## Session Blocking > [!WARNING] -> To utilize session blocking, your application must be using a cache driver that supports [atomic locks](/docs/{{version}}/cache#atomic-locks). Currently, those cache drivers include the `memcached`, `dynamodb`, `redis`, `database`, `file`, and `array` drivers. In addition, you may not use the `cookie` session driver. +> To utilize session blocking, your application must be using a cache driver that supports [atomic locks](/docs/{{version}}/cache#atomic-locks). Currently, those cache drivers include the `memcached`, `dynamodb`, `redis`, `mongodb` (included in the official `mongodb/laravel-mongodb` package), `database`, `file`, and `array` drivers. In addition, you may not use the `cookie` session driver. By default, Laravel allows requests using the same session to execute concurrently. So, for example, if you use a JavaScript HTTP library to make two HTTP requests to your application, they will both execute at the same time. For many applications, this is not a problem; however, session data loss can occur in a small subset of applications that make concurrent requests to two different application endpoints which both write data to the session. @@ -291,10 +291,9 @@ If none of the existing session drivers fit your application's needs, Laravel ma public function gc($lifetime) {} } -> [!NOTE] -> Laravel does not ship with a directory to contain your extensions. You are free to place them anywhere you like. In this example, we have created an `Extensions` directory to house the `MongoSessionHandler`. +Since Laravel does not include a default directory to house your extensions. You are free to place them anywhere you like. In this example, we have created an `Extensions` directory to house the `MongoSessionHandler`. -Since the purpose of these methods is not readily understandable, let's quickly cover what each of the methods do: +Since the purpose of these methods is not readily understandable, here is an overview of the purpose of each method:
From 1ae07b0e1cb7539b7c9c0f4a69eabbb93d50a3a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEuris?= Date: Fri, 1 Nov 2024 15:40:37 +0200 Subject: [PATCH 281/325] Warn about automatically registered event on the upgrade guide (#10009) * Update upgrade.md * Update upgrade.md * Update upgrade.md --------- Co-authored-by: Taylor Otwell --- upgrade.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/upgrade.md b/upgrade.md index 0c1008e39db..85d842ce552 100644 --- a/upgrade.md +++ b/upgrade.md @@ -182,6 +182,20 @@ if ($e instanceof AuthenticationException) { } ``` + +#### Email Verification Notification on Registration + +**Likelihood Of Impact: Very Low** + +The `SendEmailVerificationNotification` listener is now automatically registered for the `Registered` event if it is not already registered by your application's `EventServiceProvider`. If your application's `EventServiceProvider` does not register this listener and you do not want Laravel to automatically register it for you, you should define an empty `configureEmailVerification` method in your application's `EventServiceProvider`: + +```php +protected function configureEmailVerification() +{ + // ... +} +``` + ### Cache From d973103c480300debe835bf11748435e5af58bfb Mon Sep 17 00:00:00 2001 From: Luis De la Cruz <98129640+cruzmediaorg@users.noreply.github.com> Date: Thu, 7 Nov 2024 22:55:58 +0100 Subject: [PATCH 282/325] Adds type hint to array to match trait structure (#10018) --- eloquent.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eloquent.md b/eloquent.md index 9e7084cc881..3cdc7f0b0cd 100644 --- a/eloquent.md +++ b/eloquent.md @@ -843,7 +843,7 @@ So, to get started, you should define which model attributes you want to make ma /** * The attributes that are mass assignable. * - * @var array + * @var array */ protected $fillable = ['name']; } @@ -864,7 +864,7 @@ When assigning JSON columns, each column's mass assignable key must be specified /** * The attributes that are mass assignable. * - * @var array + * @var array */ protected $fillable = [ 'options->enabled', @@ -878,7 +878,7 @@ If you would like to make all of your attributes mass assignable, you may define /** * The attributes that aren't mass assignable. * - * @var array + * @var array|bool */ protected $guarded = []; From 73a37c89e6d04bc6941cd9d623b2150710556b25 Mon Sep 17 00:00:00 2001 From: Simone Folador Date: Mon, 11 Nov 2024 21:33:59 +0100 Subject: [PATCH 283/325] Update installation.md (#10023) * Update installation.md The proposed PowerShell command does not work if the PowerShell is not run as Administrator. If that's the case, the PowerShell just disappears without any error on both Windows 10 and Windows 11. By running the PowerShell as an administrator, the command is executed with success. * Update installation.md --------- Co-authored-by: Taylor Otwell --- installation.md | 1 + 1 file changed, 1 insertion(+) diff --git a/installation.md b/installation.md index 1277baa288a..bf624e5d66f 100644 --- a/installation.md +++ b/installation.md @@ -70,6 +70,7 @@ If you don't have PHP and Composer installed on your local machine, the followin ``` ```shell tab=Windows PowerShell +# Run as administrator... Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://php.new/install/windows')) ``` From 7102a2df101517a6388a4280485eafda00d0f28d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caio=20Galv=C3=A3o?= Date: Tue, 12 Nov 2024 11:59:28 -0300 Subject: [PATCH 284/325] docs(logging): fix default retention days for daily channel to 14 (#10024) --- logging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logging.md b/logging.md index 3d33582d290..251a52d663b 100644 --- a/logging.md +++ b/logging.md @@ -93,7 +93,7 @@ Additionally, the retention policy for the `daily` channel can be configured via | Name | Description | Default | | ------ | ----------------------------------------------------------- | ------- | -| `days` | The number of days that daily log files should be retained. | `7` | +| `days` | The number of days that daily log files should be retained. | `14` |
From f3f131ae61df7679e53454c3647d0fe63bbaeac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Tue, 12 Nov 2024 21:00:07 +0100 Subject: [PATCH 285/325] [11.x] Add MongoDB to Sail doc (#10020) * Add MongoDB to Sail doc * Update sail.md --------- Co-authored-by: Taylor Otwell --- sail.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sail.md b/sail.md index 6ba060a301f..f1bfd8c54b0 100644 --- a/sail.md +++ b/sail.md @@ -13,6 +13,7 @@ - [Executing Node / NPM Commands](#executing-node-npm-commands) - [Interacting With Databases](#interacting-with-sail-databases) - [MySQL](#mysql) + - [MongoDB](#mongodb) - [Redis](#redis) - [Meilisearch](#meilisearch) - [Typesense](#typesense) @@ -239,6 +240,23 @@ Once you have started your containers, you may connect to the MySQL instance wit To connect to your application's MySQL database from your local machine, you may use a graphical database management application such as [TablePlus](https://tableplus.com). By default, the MySQL database is accessible at `localhost` port 3306 and the access credentials correspond to the values of your `DB_USERNAME` and `DB_PASSWORD` environment variables. Or, you may connect as the `root` user, which also utilizes the value of your `DB_PASSWORD` environment variable as its password. + +### MongoDB + +If you chose to install the [MongoDB](https://www.mongodb.com/) service when installing Sail, your application's `docker-compose.yml` file contains an entry for a [MongoDB Atlas Local](https://www.mongodb.com/docs/atlas/cli/current/atlas-cli-local-cloud/) container which provides the MongoDB document database with Atlas features like [Search Indexes](https://www.mongodb.com/docs/atlas/atlas-search/). This container uses a [Docker volume](https://docs.docker.com/storage/volumes/) so that the data stored in your database is persisted even when stopping and restarting your containers. + +Once you have started your containers, you may connect to the MongoDB instance within your application by setting your `MONGODB_URI` environment variable within your application's `.env` file to `mongodb://mongodb:27017`. Authentication is disabled by default, but you can set the `MONGODB_USERNAME` and `MONGODB_PASSWORD` environment variables to enable authentication before starting the `mongodb` container. Then, add the credentials to the connection string: + +```ini +MONGODB_USERNAME=user +MONGODB_PASSWORD=laravel +MONGODB_URI=mongodb://${MONGODB_USERNAME}:${MONGODB_PASSWORD}@mongodb:27017 +``` + +For seamless integration of MongoDB with your application, you can install the [official package maintained by MongoDB](https://www.mongodb.com/docs/drivers/php/laravel-mongodb/). + +To connect to your application's MongoDB database from your local machine, you may use a graphical interface such as [Compass](https://www.mongodb.com/products/tools/compass). By default, the MongoDB database is accessible at `localhost` port `27017`. + ### Redis From 137c84001cb546324e63327cb0c08ca67d3cd5fc Mon Sep 17 00:00:00 2001 From: David Heremans Date: Tue, 12 Nov 2024 21:09:06 +0100 Subject: [PATCH 286/325] Introduction support popping items from stackable context item (#10014) * Introduction support popping items from stackable context item Documentation update for changes introduced in https://github.com/laravel/framework/pull/53403 * Update context.md * Update context.md * Update context.md --------- Co-authored-by: Taylor Otwell --- context.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/context.md b/context.md index a524d47508b..99eeaf19fad 100644 --- a/context.md +++ b/context.md @@ -229,6 +229,18 @@ The `pull` method may be used to retrieve information from the context and immed $value = Context::pull('key'); ``` +If context data is stored in a [stack](#stacks), you may pop items from the stack using the `pop` method: + +```php +Context::push('breadcrumbs', 'first_value', 'second_value'); + +Context::pop('breadcrumbs') +// second_value + +Context::get('breadcrumbs'); +// ['first_value'] +``` + If you would like to retrieve all of the information stored in the context, you may invoke the `all` method: ```php @@ -305,6 +317,7 @@ Context::addHiddenIf(/* ... */); Context::pushHidden(/* ... */); Context::getHidden(/* ... */); Context::pullHidden(/* ... */); +Context::popHidden(/* ... */); Context::onlyHidden(/* ... */); Context::allHidden(/* ... */); Context::hasHidden(/* ... */); From 3ed0888fdb29edbb04d290707a2819f739dc5b7b Mon Sep 17 00:00:00 2001 From: Davey Shafik Date: Thu, 14 Nov 2024 07:30:19 -0800 Subject: [PATCH 287/325] Remove unnecessary warning about Route::fallback() being last (#10026) --- routing.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/routing.md b/routing.md index f0fdbdd1900..3fda01168da 100644 --- a/routing.md +++ b/routing.md @@ -737,9 +737,6 @@ Using the `Route::fallback` method, you may define a route that will be executed // ... }); -> [!WARNING] -> The fallback route should always be the last route registered by your application. - ## Rate Limiting From fe38158e2fe3b32feb9f9ec238d0161373162f9c Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Sat, 16 Nov 2024 01:51:20 +1100 Subject: [PATCH 288/325] [11.x] Document defining Pennant features externally (#10027) * Document defining features externally * Update pennant.md --------- Co-authored-by: Taylor Otwell --- pennant.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/pennant.md b/pennant.md index c0783ae1b3f..fd9c757fc49 100644 --- a/pennant.md +++ b/pennant.md @@ -28,6 +28,7 @@ - [Adding Custom Pennant Drivers](#adding-custom-pennant-drivers) - [Implementing the Driver](#implementing-the-driver) - [Registering the Driver](#registering-the-driver) + - [Defining Features Externally](#defining-features-externally) - [Events](#events) @@ -1022,7 +1023,7 @@ class RedisFeatureDriver implements Driver Now, we just need to implement each of these methods using a Redis connection. For an example of how to implement each of these methods, take a look at the `Laravel\Pennant\Drivers\DatabaseDriver` in the [Pennant source code](https://github.com/laravel/pennant/blob/1.x/src/Drivers/DatabaseDriver.php) -> [!NOTE] +> [!NOTE] > Laravel does not ship with a directory to contain your extensions. You are free to place them anywhere you like. In this example, we have created an `Extensions` directory to house the `RedisFeatureDriver`. @@ -1075,6 +1076,32 @@ Once the driver has been registered, you may use the `redis` driver in your appl ], + +### Defining Features Externally + +If your driver is a wrapper around a third-party feature flag platform, you will likely define features on the platform rather than using Pennant's `Feature::define` method. If that is the case, your custom driver should also implement the `Laravel\Pennant\Contracts\DefinesFeaturesExternally` interface: + +```php + ## Events From 63ffde91d51bd2be64036899966496461423f6b1 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 18 Nov 2024 08:18:01 -0600 Subject: [PATCH 289/325] update docblock for Model `$hidden` (#10030) syncs up both the comment and the var declaration with `laravel/laravel` https://github.com/laravel/laravel/pull/6495 --- eloquent-serialization.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eloquent-serialization.md b/eloquent-serialization.md index 30821074124..45f4df9cce7 100644 --- a/eloquent-serialization.md +++ b/eloquent-serialization.md @@ -84,9 +84,9 @@ Sometimes you may wish to limit the attributes, such as passwords, that are incl class User extends Model { /** - * The attributes that should be hidden for arrays. + * The attributes that should be hidden for serialization. * - * @var array + * @var array */ protected $hidden = ['password']; } From 3dfff31349118d0a1a3e413336baf19b02ced97e Mon Sep 17 00:00:00 2001 From: jordyvanderhaegen Date: Tue, 19 Nov 2024 20:44:21 +0100 Subject: [PATCH 290/325] docs: replace deprecated PHP CS rules (#10033) --- pint.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pint.md b/pint.md index 5de25ca04ba..d4741dc41d3 100644 --- a/pint.md +++ b/pint.md @@ -115,10 +115,10 @@ However, if you wish, you may enable or disable specific rules in your `pint.jso "preset": "laravel", "rules": { "simplified_null_return": true, - "braces": false, - "new_with_braces": { - "anonymous_class": false, - "named_class": false + "array_indentation": false, + "new_with_parentheses": { + "anonymous_class": true, + "named_class": true } } } From 3e3ecda52ed7aac946f9338e9e9a848d58f565a1 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 19 Nov 2024 13:57:35 -0600 Subject: [PATCH 291/325] wip --- requests.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/requests.md b/requests.md index bfcc95d2467..4b4cc9e412d 100644 --- a/requests.md +++ b/requests.md @@ -346,6 +346,12 @@ Input values that correspond to [PHP enums](https://www.php.net/manual/en/langua $status = $request->enum('status', Status::class); +If the input value is an array of values that correspond to a PHP enum, you may use the `enums` method to retrieve the array of values as enum instances: + + use App\Enums\Product; + + $products = $request->enums('products', Product::class); + #### Retrieving Input via Dynamic Properties From c0b77dd72e27ab1f37a4ba9284fffaad1aa999c8 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 19 Nov 2024 14:10:39 -0600 Subject: [PATCH 292/325] wip --- http-client.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/http-client.md b/http-client.md index 2e49325fe7b..f613fe09032 100644 --- a/http-client.md +++ b/http-client.md @@ -530,6 +530,15 @@ If you would like to specify a fallback URL pattern that will stub all unmatched '*' => Http::response('Hello World', 200, ['Headers']), ]); + +#### Faking Connection Exceptions + +Sometimes you may need to test your application's behavior if the HTTP client encounters an `Illuminate\Http\Client\ConnectionException` when attempting to make a request. You can instruct the HTTP client to throw a connection exception using the `failedConnection` method: + + Http::fake([ + 'github.com/*' => Http::failedConnection(), + ]); + #### Faking Response Sequences From de55c9c4a1b77462a4dfd1c40777b55380c16d37 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 19 Nov 2024 14:25:58 -0600 Subject: [PATCH 293/325] wip --- scheduling.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/scheduling.md b/scheduling.md index 5ef90e01c73..39ed28f3c8e 100644 --- a/scheduling.md +++ b/scheduling.md @@ -11,6 +11,7 @@ - [Running Tasks on One Server](#running-tasks-on-one-server) - [Background Tasks](#background-tasks) - [Maintenance Mode](#maintenance-mode) + - [Schedule Groups](#schedule-groups) - [Running the Scheduler](#running-the-scheduler) - [Sub-Minute Scheduled Tasks](#sub-minute-scheduled-tasks) - [Running the Scheduler Locally](#running-the-scheduler-locally) @@ -364,6 +365,25 @@ Your application's scheduled tasks will not run when the application is in [main Schedule::command('emails:send')->evenInMaintenanceMode(); + +### Schedule Groups + +When defining multiple scheduled tasks with similar configurations, you can use Laravel’s task grouping feature to avoid repeating the same settings for each task. Grouping tasks simplifies your code and ensures consistency across related tasks. + +To create a group of scheduled tasks, invoke the desired task configuration methods, followed by the `group` method. The `group` method accepts a closure that is responsible for defining the tasks that share the specified configuration: + +```php +use Illuminate\Support\Facades\Schedule; + +Schedule::daily() + ->onOneServer() + ->timezone('America/New_York') + ->group(function () { + Schedule::command('emails:send --force'); + Schedule::command('emails:prune'); + }); +``` + ## Running the Scheduler From f81965f336cd20e8af9999cde362175547b48f02 Mon Sep 17 00:00:00 2001 From: Julius Kiekbusch Date: Tue, 19 Nov 2024 21:40:09 +0100 Subject: [PATCH 294/325] [11.x] Add PHP 8.4 (#10019) * Add PHP 8.4 * Update PHP 8.4 in Sail --- releases.md | 4 ++-- sail.md | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/releases.md b/releases.md index 894f97c5123..ff5401eae82 100644 --- a/releases.md +++ b/releases.md @@ -27,8 +27,8 @@ For all Laravel releases, bug fixes are provided for 18 months and security fixe | --- | --- | --- | --- | --- | | 9 | 8.0 - 8.2 | February 8th, 2022 | August 8th, 2023 | February 6th, 2024 | | 10 | 8.1 - 8.3 | February 14th, 2023 | August 6th, 2024 | February 4th, 2025 | -| 11 | 8.2 - 8.3 | March 12th, 2024 | September 3rd, 2025 | March 12th, 2026 | -| 12 | 8.2 - 8.3 | Q1 2025 | Q3 2026 | Q1 2027 | +| 11 | 8.2 - 8.4 | March 12th, 2024 | September 3rd, 2025 | March 12th, 2026 | +| 12 | 8.2 - 8.4 | Q1 2025 | Q3 2026 | Q1 2027 | diff --git a/sail.md b/sail.md index f1bfd8c54b0..dcc10298226 100644 --- a/sail.md +++ b/sail.md @@ -416,9 +416,12 @@ sail tinker ## PHP Versions -Sail currently supports serving your application via PHP 8.3, 8.2, 8.1, or PHP 8.0. The default PHP version used by Sail is currently PHP 8.3. To change the PHP version that is used to serve your application, you should update the `build` definition of the `laravel.test` container in your application's `docker-compose.yml` file: +Sail currently supports serving your application via PHP 8.4, 8.3, 8.2, 8.1, or PHP 8.0. The default PHP version used by Sail is currently PHP 8.3. To change the PHP version that is used to serve your application, you should update the `build` definition of the `laravel.test` container in your application's `docker-compose.yml` file: ```yaml +# PHP 8.4 +context: ./vendor/laravel/sail/runtimes/8.4 + # PHP 8.3 context: ./vendor/laravel/sail/runtimes/8.3 From c4151f0848b5fb1188b7d8349196f7817fcc510f Mon Sep 17 00:00:00 2001 From: Noboru Shiroiwa <14008307+nshiro@users.noreply.github.com> Date: Wed, 20 Nov 2024 23:58:38 +0900 Subject: [PATCH 295/325] Remove return keyword from example (#10038) --- validation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validation.md b/validation.md index 43d71477dab..e3841ffc850 100644 --- a/validation.md +++ b/validation.md @@ -1354,7 +1354,7 @@ If you would like to customize the query executed by the validation rule, you ma 'email' => [ 'required', Rule::exists('staff')->where(function (Builder $query) { - return $query->where('account_id', 1); + $query->where('account_id', 1); }), ], ]); From 0db6ab246107750937a39f29489a0af33be7266b Mon Sep 17 00:00:00 2001 From: Noboru Shiroiwa <14008307+nshiro@users.noreply.github.com> Date: Thu, 21 Nov 2024 00:01:02 +0900 Subject: [PATCH 296/325] Update contextual attributes example (#10037) * Update contextual attributes example * Update container.md --------- Co-authored-by: Taylor Otwell --- container.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/container.md b/container.md index 61b90d81f2a..a538174bab5 100644 --- a/container.md +++ b/container.md @@ -266,15 +266,17 @@ In addition to the `Storage` attribute, Laravel offers `Auth`, `Cache`, `Config` namespace App\Http\Controllers; +use App\Models\Photo; use Illuminate\Container\Attributes\Auth; use Illuminate\Container\Attributes\Cache; use Illuminate\Container\Attributes\Config; use Illuminate\Container\Attributes\DB; use Illuminate\Container\Attributes\Log; +use Illuminate\Container\Attributes\RouteParameter; use Illuminate\Container\Attributes\Tag; use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Cache\Repository; -use Illuminate\Contracts\Database\Connection; +use Illuminate\Database\Connection; use Psr\Log\LoggerInterface; class PhotoController extends Controller @@ -285,6 +287,7 @@ class PhotoController extends Controller #[Config('app.timezone')] protected string $timezone, #[DB('mysql')] protected Connection $connection, #[Log('daily')] protected LoggerInterface $log, + #[RouteParameter('photo')] protected Photo $photo, #[Tag('reports')] protected iterable $reports, ) { From ea8c67bb179ffd41616900519f17f2e9c58e5e47 Mon Sep 17 00:00:00 2001 From: Ahmadreza Bashari <61243238+ahmadreza1383@users.noreply.github.com> Date: Fri, 22 Nov 2024 18:53:38 +0330 Subject: [PATCH 297/325] Add assertCount for filesystem doc (#10041) * Add assertCount for filesystem doc * Update filesystem.md --------- Co-authored-by: Taylor Otwell --- filesystem.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/filesystem.md b/filesystem.md index 0f3c04f78e7..5229c37d1cc 100644 --- a/filesystem.md +++ b/filesystem.md @@ -701,6 +701,9 @@ test('albums can be uploaded', function () { Storage::disk('photos')->assertMissing('missing.jpg'); Storage::disk('photos')->assertMissing(['missing.jpg', 'non-existing.jpg']); + // Assert that the number of files in a given directory matches the expected count... + Storage::disk('photos')->assertCount('/wallpapers', 2); + // Assert that a given directory is empty... Storage::disk('photos')->assertDirectoryEmpty('/wallpapers'); }); @@ -734,6 +737,9 @@ class ExampleTest extends TestCase Storage::disk('photos')->assertMissing('missing.jpg'); Storage::disk('photos')->assertMissing(['missing.jpg', 'non-existing.jpg']); + // Assert that the number of files in a given directory matches the expected count... + Storage::disk('photos')->assertCount('/wallpapers', 2); + // Assert that a given directory is empty... Storage::disk('photos')->assertDirectoryEmpty('/wallpapers'); } From bf57399422909dce882226ede0a560d1fe3aa2ee Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 25 Nov 2024 17:47:08 -0600 Subject: [PATCH 298/325] wip --- sail.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sail.md b/sail.md index f1bfd8c54b0..903914475d8 100644 --- a/sail.md +++ b/sail.md @@ -194,11 +194,11 @@ docker run --rm \ -u "$(id -u):$(id -g)" \ -v "$(pwd):/var/www/html" \ -w /var/www/html \ - laravelsail/php83-composer:latest \ + laravelsail/php84-composer:latest \ composer install --ignore-platform-reqs ``` -When using the `laravelsail/phpXX-composer` image, you should use the same version of PHP that you plan to use for your application (`80`, `81`, `82`, or `83`). +When using the `laravelsail/phpXX-composer` image, you should use the same version of PHP that you plan to use for your application (`80`, `81`, `82`, `83`, or `84`). ### Executing Artisan Commands @@ -416,9 +416,12 @@ sail tinker ## PHP Versions -Sail currently supports serving your application via PHP 8.3, 8.2, 8.1, or PHP 8.0. The default PHP version used by Sail is currently PHP 8.3. To change the PHP version that is used to serve your application, you should update the `build` definition of the `laravel.test` container in your application's `docker-compose.yml` file: +Sail currently supports serving your application via PHP 8.4, 8.3, 8.2, 8.1, or PHP 8.0. The default PHP version used by Sail is currently PHP 8.4. To change the PHP version that is used to serve your application, you should update the `build` definition of the `laravel.test` container in your application's `docker-compose.yml` file: ```yaml +# PHP 8.4 +context: ./vendor/laravel/sail/runtimes/8.4 + # PHP 8.3 context: ./vendor/laravel/sail/runtimes/8.3 From f821f3d559de9f57121dc5b6530eb088d988aa00 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 26 Nov 2024 09:35:18 -0600 Subject: [PATCH 299/325] wip --- installation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/installation.md b/installation.md index bf624e5d66f..559595d7c35 100644 --- a/installation.md +++ b/installation.md @@ -66,16 +66,16 @@ Before creating your first Laravel application, make sure that your local machin If you don't have PHP and Composer installed on your local machine, the following commands will install PHP, Composer, and the Laravel installer on macOS, Windows, or Linux: ```shell tab=macOS -/bin/bash -c "$(curl -fsSL https://php.new/install/mac)" +/bin/bash -c "$(curl -fsSL https://php.new/install/mac/8.3)" ``` ```shell tab=Windows PowerShell # Run as administrator... -Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://php.new/install/windows')) +Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://php.new/install/windows/8.3')) ``` ```shell tab=Linux -/bin/bash -c "$(curl -fsSL https://php.new/install/linux)" +/bin/bash -c "$(curl -fsSL https://php.new/install/linux/8.3)" ``` After running one of the commands above, you should restart your terminal session. To update PHP, Composer, and the Laravel installer after installing them via `php.new`, you can re-run the command in your terminal. From 65a9f2e285fad310d2a3de756877b375232ff9fc Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 26 Nov 2024 15:57:30 -0600 Subject: [PATCH 300/325] convenience methods --- http-client.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/http-client.md b/http-client.md index f613fe09032..cd3f01a30c3 100644 --- a/http-client.md +++ b/http-client.md @@ -530,6 +530,14 @@ If you would like to specify a fallback URL pattern that will stub all unmatched '*' => Http::response('Hello World', 200, ['Headers']), ]); +For convenience, simple string, JSON, and empty responses may be generated by providing a string, array, or integer as the response: + + Http::fake([ + 'google.com/*' => 'Hello World', + 'github.com/*' => ['foo' => 'bar'], + 'chatgpt.com/*' => 200, + ]); + #### Faking Connection Exceptions From d468548b1184fc289e09888881de4664f8936ec4 Mon Sep 17 00:00:00 2001 From: Abdel Elrafa Date: Fri, 29 Nov 2024 11:08:17 -0500 Subject: [PATCH 301/325] [11.x] Clarify how schedule:work will handle sub-minute tasks. (#10047) * Clarify how schedule:work will handle sub-minute tasks. * Update scheduling.md --------- Co-authored-by: Taylor Otwell --- scheduling.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scheduling.md b/scheduling.md index 39ed28f3c8e..dcf7f2db019 100644 --- a/scheduling.md +++ b/scheduling.md @@ -430,7 +430,7 @@ php artisan schedule:interrupt ### Running the Scheduler Locally -Typically, you would not add a scheduler cron entry to your local development machine. Instead, you may use the `schedule:work` Artisan command. This command will run in the foreground and invoke the scheduler every minute until you terminate the command: +Typically, you would not add a scheduler cron entry to your local development machine. Instead, you may use the `schedule:work` Artisan command. This command will run in the foreground and invoke the scheduler every minute until you terminate the command. When sub-minute tasks are defined, the scheduler will continue running within each minute to process those tasks: ```shell php artisan schedule:work From 660e0c0b5d1a90c8d7e04b1711032d4499496ee2 Mon Sep 17 00:00:00 2001 From: Owen Andrews Date: Wed, 4 Dec 2024 03:22:19 +1100 Subject: [PATCH 302/325] [11.x] Improve explanation of skipWhile and skipUntil (#10050) * Improve explanation of skipWhile and skipUntil * Fix spelling mistakes --- collections.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/collections.md b/collections.md index a963e8bd22e..836cbe4d89b 100644 --- a/collections.md +++ b/collections.md @@ -2304,7 +2304,7 @@ The `skip` method returns a new collection, with the given number of elements re #### `skipUntil()` {.collection-method} -The `skipUntil` method skips over items from the collection until the given callback returns `true` and then returns the remaining items in the collection as a new collection instance: +The `skipUntil` method skips over items from the collection while the given callback returns `false`. Once the callback returns `true` all of the remaining items in the collection will be returned as a new collection: $collection = collect([1, 2, 3, 4]); @@ -2332,7 +2332,7 @@ You may also pass a simple value to the `skipUntil` method to skip all items unt #### `skipWhile()` {.collection-method} -The `skipWhile` method skips over items from the collection while the given callback returns `true` and then returns the remaining items in the collection as a new collection: +The `skipWhile` method skips over items from the collection while the given callback returns `true`. Once the callback returns `false` all of the remaining items in the collection will be returned as a new collection: $collection = collect([1, 2, 3, 4]); From f23019a2ff3a4d937f4b876190031881a7cca947 Mon Sep 17 00:00:00 2001 From: Artfaith <25136754+serious-angel@users.noreply.github.com> Date: Fri, 6 Dec 2024 20:51:48 +0200 Subject: [PATCH 303/325] Allow only /index.php to be passed to FastCGI. (#10053) --- deployment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment.md b/deployment.md index ccf8ee042b9..fc8b049e1b4 100644 --- a/deployment.md +++ b/deployment.md @@ -77,7 +77,7 @@ server { error_page 404 /index.php; - location ~ \.php$ { + location ~ ^/index\.php(/|$) { { fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; From ad340137755df077c5efe7d0a57e3579aa1e0ca2 Mon Sep 17 00:00:00 2001 From: Steve Bauman Date: Fri, 6 Dec 2024 14:22:30 -0500 Subject: [PATCH 304/325] [11x.] Add queued listener `backoff` docs (#10052) * Add queued listener `backoff` docs * Update events.md * Update events.md --------- Co-authored-by: Taylor Otwell --- events.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/events.md b/events.md index 9fffbe352ac..dcfac0fe8f1 100644 --- a/events.md +++ b/events.md @@ -487,6 +487,40 @@ As an alternative to defining how many times a listener may be attempted before return now()->addMinutes(5); } + +#### Specifying Queued Listener Backoff + +If you would like to configure how many seconds Laravel should wait before retrying a listener that has encountered an exception, you may do so by defining a `backoff` property on your listener class: + + /** + * The number of seconds to wait before retrying the queued listener. + * + * @var int + */ + public $backoff = 3; + +If you require more complex logic for determining the listeners's backoff time, you may define a `backoff` method on your listener class: + + /** + * Calculate the number of seconds to wait before retrying the queued listener. + */ + public function backoff(): int + { + return 3; + } + +You may easily configure "exponential" backoffs by returning an array of backoff values from the `backoff` method. In this example, the retry delay will be 1 second for the first retry, 5 seconds for the second retry, 10 seconds for the third retry, and 10 seconds for every subsequent retry if there are more attempts remaining: + + /** + * Calculate the number of seconds to wait before retrying the queued listener. + * + * @return array + */ + public function backoff(): array + { + return [1, 5, 10]; + } + ## Dispatching Events From f8931dd81ba4d3039c549b787130c1542991681c Mon Sep 17 00:00:00 2001 From: "Md. Rasel" Date: Sun, 8 Dec 2024 21:19:17 +0600 Subject: [PATCH 305/325] Update deployment.md (#10055) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update deployment.md left double curly brace issue. * Update deployment.md Co-authored-by: Señor Henrik Nordquist --------- Co-authored-by: Taylor Otwell Co-authored-by: Señor Henrik Nordquist --- deployment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment.md b/deployment.md index fc8b049e1b4..11ad9a88089 100644 --- a/deployment.md +++ b/deployment.md @@ -77,7 +77,7 @@ server { error_page 404 /index.php; - location ~ ^/index\.php(/|$) { { + location ~ ^/index\.php(/|$) { fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; From 667396a7971720b717079436ff1fe8682168d72e Mon Sep 17 00:00:00 2001 From: Fady Bark <71821989+Bark-fa@users.noreply.github.com> Date: Tue, 10 Dec 2024 21:06:31 +0200 Subject: [PATCH 306/325] Update billing.md to include new billing meters docs (#10045) * Update billing.md to include new billing meters docs * formatting * formatting * Update billing.md * Update billing.md --------- Co-authored-by: Taylor Otwell --- billing.md | 49 ++++++++++++++----------------------------------- 1 file changed, 14 insertions(+), 35 deletions(-) diff --git a/billing.md b/billing.md index 782851c54d5..294f6827856 100644 --- a/billing.md +++ b/billing.md @@ -35,7 +35,7 @@ - [Subscription Quantity](#subscription-quantity) - [Subscriptions With Multiple Products](#subscriptions-with-multiple-products) - [Multiple Subscriptions](#multiple-subscriptions) - - [Metered Billing](#metered-billing) + - [Usage Based Billing](#usage-based-billing) - [Subscription Taxes](#subscription-taxes) - [Subscription Anchor Date](#subscription-anchor-date) - [Canceling Subscriptions](#cancelling-subscriptions) @@ -1309,12 +1309,12 @@ Of course, you may also cancel the subscription entirely: $user->subscription('swimming')->cancel(); - -### Metered Billing + +### Usage Based Billing -[Metered billing](https://stripe.com/docs/billing/subscriptions/metered-billing) allows you to charge customers based on their product usage during a billing cycle. For example, you may charge customers based on the number of text messages or emails they send per month. +[Usage based billing](https://stripe.com/docs/billing/subscriptions/metered-billing) allows you to charge customers based on their product usage during a billing cycle. For example, you may charge customers based on the number of text messages or emails they send per month. -To start using metered billing, you will first need to create a new product in your Stripe dashboard with a metered price. Then, use the `meteredPrice` to add the metered price ID to a customer subscription: +To start using usage billing, you will first need to create a new product in your Stripe dashboard with a [usage based billing model](https://docs.stripe.com/billing/subscriptions/usage-based/implementation-guide) and a [meter](https://docs.stripe.com/billing/subscriptions/usage-based/recording-usage#configure-meter). After creating the meter, store the associated event name and meter ID, which you will need to report and retrieve usage. Then, use the `meteredPrice` method to add the metered price ID to a customer subscription: use Illuminate\Http\Request; @@ -1340,54 +1340,33 @@ You may also start a metered subscription via [Stripe Checkout](#checkout): #### Reporting Usage -As your customer uses your application, you will report their usage to Stripe so that they can be billed accurately. To increment the usage of a metered subscription, you may use the `reportUsage` method: +As your customer uses your application, you will report their usage to Stripe so that they can be billed accurately. To report the usage of a metered event, you may use the `reportMeterEvent` method on your `Billable` model: $user = User::find(1); - $user->subscription('default')->reportUsage(); + $user->reportMeterEvent('emails-sent'); By default, a "usage quantity" of 1 is added to the billing period. Alternatively, you may pass a specific amount of "usage" to add to the customer's usage for the billing period: $user = User::find(1); - $user->subscription('default')->reportUsage(15); + $user->reportMeterEvent('emails-sent', quantity: 15); -If your application offers multiple prices on a single subscription, you will need to use the `reportUsageFor` method to specify the metered price you want to report usage for: +To retrieve a customer's event summary for a meter, you may use a `Billable` instance's `meterEventSummaries` method: $user = User::find(1); - $user->subscription('default')->reportUsageFor('price_metered', 15); + $meterUsage = $user->meterEventSummaries($meterId); -Sometimes, you may need to update usage which you have previously reported. To accomplish this, you may pass a timestamp or a `DateTimeInterface` instance as the second parameter to `reportUsage`. When doing so, Stripe will update the usage that was reported at that given time. You can continue to update previous usage records as the given date and time is still within the current billing period: + $meterUsage->first()->aggregated_value // 10 - $user = User::find(1); - - $user->subscription('default')->reportUsage(5, $timestamp); - - -#### Retrieving Usage Records - -To retrieve a customer's past usage, you may use a subscription instance's `usageRecords` method: - - $user = User::find(1); - - $usageRecords = $user->subscription('default')->usageRecords(); +Please refer to Stripe's [Meter Event Summary object documentation](https://docs.stripe.com/api/billing/meter-event_summary/object) for more information on meter event summaries. -If your application offers multiple prices on a single subscription, you may use the `usageRecordsFor` method to specify the metered price that you wish to retrieve usage records for: +To [list all meters](https://docs.stripe.com/api/billing/meter/list), you may use a `Billable` instance's `meters` method: $user = User::find(1); - $usageRecords = $user->subscription('default')->usageRecordsFor('price_metered'); - -The `usageRecords` and `usageRecordsFor` methods return a Collection instance containing an associative array of usage records. You may iterate over this array to display a customer's total usage: - - @foreach ($usageRecords as $usageRecord) - - Period Starting: {{ $usageRecord['period']['start'] }} - - Period Ending: {{ $usageRecord['period']['end'] }} - - Total Usage: {{ $usageRecord['total_usage'] }} - @endforeach - -For a full reference of all usage data returned and how to use Stripe's cursor based pagination, please consult [the official Stripe API documentation](https://stripe.com/docs/api/usage_records/subscription_item_summary_list). + $user->meters(); ### Subscription Taxes From 519c46b94461471dcb4bf2f4692e4edb481b808c Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 10 Dec 2024 13:19:25 -0600 Subject: [PATCH 307/325] message truncation --- http-client.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/http-client.md b/http-client.md index cd3f01a30c3..34b8396c730 100644 --- a/http-client.md +++ b/http-client.md @@ -337,6 +337,16 @@ If you would like to perform some additional logic before the exception is throw // ... })->json(); +By default, `RequestException` messages are truncated to 120 characters when logged or reported. To customize or disable this behavior, you may utilize the `truncateRequestExceptionsAt` and `dontTruncateRequestExceptions` methods when configuring your application's exception handling behavior in your `bootstrap/app.php` file: + + ->withExceptions(function (Exceptions $exceptions) { + // Truncate request exception messages to 240 characters... + $exceptions->truncateRequestExceptionsAt(240); + + // Disable request exception message truncation... + $exceptions->dontTruncateRequestExceptions(); + }) + ### Guzzle Middleware From ace0221459d884e41a90aa4c3a23cff35248a5d4 Mon Sep 17 00:00:00 2001 From: Zakaria Arrid <35905260+zakariaarrid@users.noreply.github.com> Date: Tue, 10 Dec 2024 20:30:45 +0100 Subject: [PATCH 308/325] [11.x] pingOnSuccessIf and pingOnFailureIf -scheduling.md- PR:#53795 (#10057) * [11.x] pingOnSuccessIf and pingOnFailureIf -scheduling.md- PR:#53795 * Update scheduling.md --------- Co-authored-by: Taylor Otwell --- scheduling.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/scheduling.md b/scheduling.md index dcf7f2db019..0cb90589a6b 100644 --- a/scheduling.md +++ b/scheduling.md @@ -519,19 +519,24 @@ Using the `pingBefore` and `thenPing` methods, the scheduler can automatically p ->pingBefore($url) ->thenPing($url); -The `pingBeforeIf` and `thenPingIf` methods may be used to ping a given URL only if a given condition is `true`: +The `pingOnSuccess` and `pingOnFailure` methods may be used to ping a given URL only if the task succeeds or fails. A failure indicates that the scheduled Artisan or system command terminated with a non-zero exit code: Schedule::command('emails:send') ->daily() - ->pingBeforeIf($condition, $url) - ->thenPingIf($condition, $url); + ->pingOnSuccess($successUrl) + ->pingOnFailure($failureUrl); -The `pingOnSuccess` and `pingOnFailure` methods may be used to ping a given URL only if the task succeeds or fails. A failure indicates that the scheduled Artisan or system command terminated with a non-zero exit code: +The `pingBeforeIf`,`thenPingIf`,`pingOnSuccessIf`, and `pingOnFailureIf` methods may be used to ping a given URL only if a given condition is `true`: Schedule::command('emails:send') ->daily() - ->pingOnSuccess($successUrl) - ->pingOnFailure($failureUrl); + ->pingBeforeIf($condition, $url) + ->thenPingIf($condition, $url); + + Schedule::command('emails:send') + ->daily() + ->pingOnSuccessIf($condition, $successUrl) + ->pingOnFailureIf($condition, $failureUrl); ## Events From cf389d90871ca35d24b1fd1f8d728c3ffe085edd Mon Sep 17 00:00:00 2001 From: Benjamin Crozat Date: Wed, 11 Dec 2024 17:20:24 +0100 Subject: [PATCH 309/325] Updated Telescope setup for local environments (#10064) * Update telescope.md * Update telescope.md * Update telescope.md --------- Co-authored-by: Taylor Otwell --- telescope.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telescope.md b/telescope.md index 38457bf70d0..6e3e24f3b6d 100644 --- a/telescope.md +++ b/telescope.md @@ -78,7 +78,7 @@ After running `telescope:install`, you should remove the `TelescopeServiceProvid */ public function register(): void { - if ($this->app->environment('local')) { + if ($this->app->environment('local') && class_exists(\Laravel\Telescope\TelescopeServiceProvider::class)) { $this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class); $this->app->register(TelescopeServiceProvider::class); } From e49f5b8d02f6c41ee5952e2630043173bd707dae Mon Sep 17 00:00:00 2001 From: Andy Hinkle Date: Wed, 11 Dec 2024 10:34:08 -0600 Subject: [PATCH 310/325] bump installation docs to 8.4 (#10061) --- installation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/installation.md b/installation.md index 559595d7c35..548503f3cf9 100644 --- a/installation.md +++ b/installation.md @@ -66,16 +66,16 @@ Before creating your first Laravel application, make sure that your local machin If you don't have PHP and Composer installed on your local machine, the following commands will install PHP, Composer, and the Laravel installer on macOS, Windows, or Linux: ```shell tab=macOS -/bin/bash -c "$(curl -fsSL https://php.new/install/mac/8.3)" +/bin/bash -c "$(curl -fsSL https://php.new/install/mac/8.4)" ``` ```shell tab=Windows PowerShell # Run as administrator... -Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://php.new/install/windows/8.3')) +Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://php.new/install/windows/8.4')) ``` ```shell tab=Linux -/bin/bash -c "$(curl -fsSL https://php.new/install/linux/8.3)" +/bin/bash -c "$(curl -fsSL https://php.new/install/linux/8.4)" ``` After running one of the commands above, you should restart your terminal session. To update PHP, Composer, and the Laravel installer after installing them via `php.new`, you can re-run the command in your terminal. From 9fdd948a5a10ecef51622b903f66d8f76fc3e85d Mon Sep 17 00:00:00 2001 From: Chetan Patel <87816669+ChetanTechnource@users.noreply.github.com> Date: Wed, 11 Dec 2024 22:13:34 +0530 Subject: [PATCH 311/325] Storage:link source and target directory (#10062) Storage:link source and target directory for beginners --- filesystem.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filesystem.md b/filesystem.md index 5229c37d1cc..79cfa25fb16 100644 --- a/filesystem.md +++ b/filesystem.md @@ -54,7 +54,7 @@ When using the `local` driver, all file operations are relative to the `root` di The `public` disk included in your application's `filesystems` configuration file is intended for files that are going to be publicly accessible. By default, the `public` disk uses the `local` driver and stores its files in `storage/app/public`. -To make these files accessible from the web, you should create a symbolic link from `public/storage` to `storage/app/public`. Utilizing this folder convention will keep your publicly accessible files in one directory that can be easily shared across deployments when using zero down-time deployment systems like [Envoyer](https://envoyer.io). +To make these files accessible from the web, you should create a symbolic link from source directory `storage/app/public` to target directory `public/storage`. Utilizing this folder convention will keep your publicly accessible files in one directory that can be easily shared across deployments when using zero down-time deployment systems like [Envoyer](https://envoyer.io). To create the symbolic link, you may use the `storage:link` Artisan command: From a8861d2e1b82d8d0ef11ef8138af59d718bac386 Mon Sep 17 00:00:00 2001 From: "Dr. Adam Nielsen" <1765602+iwasherefirst2@users.noreply.github.com> Date: Thu, 12 Dec 2024 00:36:01 +0100 Subject: [PATCH 312/325] Add missing steps for enabling Xdebug in Laravel Sail docs (#10067) * Add missing steps for enabling Xdebug in Laravel Sail docs * formatting * formatting --------- Co-authored-by: Taylor Otwell --- sail.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sail.md b/sail.md index 903914475d8..2c0aed7741f 100644 --- a/sail.md +++ b/sail.md @@ -496,12 +496,25 @@ sail share --subdomain=my-sail-site ## Debugging With Xdebug -Laravel Sail's Docker configuration includes support for [Xdebug](https://xdebug.org/), a popular and powerful debugger for PHP. In order to enable Xdebug, you will need to add a few variables to your application's `.env` file to [configure Xdebug](https://xdebug.org/docs/step_debug#mode). To enable Xdebug you must set the appropriate mode(s) before starting Sail: +Laravel Sail's Docker configuration includes support for [Xdebug](https://xdebug.org/), a popular and powerful debugger for PHP. To enable Xdebug, ensure you have [published your Sail configuration](#sail-customization). Then, add the following variables to your application's `.env` file to configure Xdebug: ```ini SAIL_XDEBUG_MODE=develop,debug,coverage ``` +Next, ensure that your published `php.ini` file includes the following configuration so that Xdebug is activated in the specified modes: + +```ini +[xdebug] +xdebug.mode=${XDEBUG_MODE} +``` + +After modifying the `php.ini` file, remember to rebuild your Docker images so that your changes to the `php.ini` file take effect: + +```shell +sail build --no-cache +``` + #### Linux Host IP Configuration Internally, the `XDEBUG_CONFIG` environment variable is defined as `client_host=host.docker.internal` so that Xdebug will be properly configured for Mac and Windows (WSL2). If your local machine is running Linux and you're using Docker 20.10+, `host.docker.internal` is available, and no manual configuration is required. From 7e89b0d5ae05e39854aa7e78c44bdc9ff6de624d Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 12 Dec 2024 13:41:40 -0600 Subject: [PATCH 313/325] wip --- urls.md | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/urls.md b/urls.md index 35a730ae271..5becbe7d49f 100644 --- a/urls.md +++ b/urls.md @@ -238,20 +238,9 @@ Setting URL default values can interfere with Laravel's handling of implicit mod ```php ->withMiddleware(function (Middleware $middleware) { - $middleware->priority([ - \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class, - \Illuminate\Cookie\Middleware\EncryptCookies::class, - \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, - \Illuminate\Session\Middleware\StartSession::class, - \Illuminate\View\Middleware\ShareErrorsFromSession::class, - \Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class, - \Illuminate\Contracts\Auth\Middleware\AuthenticatesRequests::class, - \Illuminate\Routing\Middleware\ThrottleRequests::class, - \Illuminate\Routing\Middleware\ThrottleRequestsWithRedis::class, - \Illuminate\Session\Middleware\AuthenticateSession::class, - \App\Http\Middleware\SetDefaultLocaleForUrls::class, // [tl! add] - \Illuminate\Routing\Middleware\SubstituteBindings::class, - \Illuminate\Auth\Middleware\Authorize::class, - ]); + $middleware->prependToPriorityList( + before: \Illuminate\Routing\Middleware\SubstituteBindings::class, + prepend: \App\Http\Middleware\SetDefaultLocaleForUrls::class, + ); }) ``` From 933bda5f2aa87567d24096f8967a4c287ee6b9f3 Mon Sep 17 00:00:00 2001 From: salah eddine bendyab <64494826+salahhusa9@users.noreply.github.com> Date: Sat, 14 Dec 2024 22:20:24 +0100 Subject: [PATCH 314/325] Update pennant.md (#10070) change `Feature::for($user)->loadAll();` to `Feature::for($users)->loadAll();` --- pennant.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pennant.md b/pennant.md index fd9c757fc49..c6ab436696f 100644 --- a/pennant.md +++ b/pennant.md @@ -815,7 +815,7 @@ Feature::for($users)->loadMissing([ You may load all defined features using the `loadAll` method: ```php -Feature::for($user)->loadAll(); +Feature::for($users)->loadAll(); ``` From e438d061210631c1a8f8a637d9c80b3d5c3a6e87 Mon Sep 17 00:00:00 2001 From: MOHAMED CHARRAFI <130717329+CharrafiMed@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:32:11 +0100 Subject: [PATCH 315/325] fix a wrong props cashier-paddle.md (#10078) The documentation incorrectly suggests using ``:url="$payLink"`` with ````. However, this should be ``:checkout="$checkout"`` as per ```` component code source --- cashier-paddle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cashier-paddle.md b/cashier-paddle.md index 0894f29b7b6..23126a4e7e1 100644 --- a/cashier-paddle.md +++ b/cashier-paddle.md @@ -444,7 +444,7 @@ Cashier includes a `paddle-button` [Blade component](/docs/{{version}}/blade#com By default, this will display the widget using Paddle's default styling. You can customize the widget by adding [Paddle supported attributes](https://developer.paddle.com/paddlejs/html-data-attributes) like the `data-theme='light'` attribute to the component: ```html - + Subscribe ``` From a40f7f46c186fa4ce16c40097e5773aacc9b6949 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 17 Dec 2024 12:20:47 -0600 Subject: [PATCH 316/325] wip --- sanctum.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sanctum.md b/sanctum.md index c1fd78ab487..ee09eaba6d2 100644 --- a/sanctum.md +++ b/sanctum.md @@ -133,12 +133,16 @@ Sanctum allows you to assign "abilities" to tokens. Abilities serve a similar pu return $user->createToken('token-name', ['server:update'])->plainTextToken; -When handling an incoming request authenticated by Sanctum, you may determine if the token has a given ability using the `tokenCan` method: +When handling an incoming request authenticated by Sanctum, you may determine if the token has a given ability using the `tokenCan` or `tokenCant` methods: if ($user->tokenCan('server:update')) { // ... } + if ($user->tokenCant('server:update')) { + // ... + } + #### Token Ability Middleware From 514b4f4783d8b519f51d5ee8083183fc4e1dde21 Mon Sep 17 00:00:00 2001 From: tatata-keshi <73019225+tatata-keshi@users.noreply.github.com> Date: Wed, 18 Dec 2024 06:26:24 +0900 Subject: [PATCH 317/325] Update queries.md (#10079) --- queries.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queries.md b/queries.md index c5f93a92afa..4704519e22a 100644 --- a/queries.md +++ b/queries.md @@ -820,7 +820,7 @@ select * from users where name = 'John' and (votes > 100 or title = 'Admin') > You should always group `orWhere` calls in order to avoid unexpected behavior when global scopes are applied. -### Advanced Where Clauses +## Advanced Where Clauses ### Where Exists Clauses From 8c64a3b84e67f55673ce84024cd87e20335d7c76 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Thu, 19 Dec 2024 18:05:10 +0000 Subject: [PATCH 318/325] update monitoring docs (#10082) --- reverb.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/reverb.md b/reverb.md index ab054f31696..e58460859b3 100644 --- a/reverb.md +++ b/reverb.md @@ -190,6 +190,8 @@ Next, add the Pulse cards for each recorder to your [Pulse dashboard](/docs/{{ve ``` +Connection activity is recorded by polling for new updates on a periodic basis. To ensure this information is rendered correctly on the Pulse dashboard, you must run the `pulse:check` daemon on your Reverb server. If you are running Reverb in a [horizontally scaled](#scaling) configuration, you should only run this daemon on one of your servers. + ## Running Reverb in Production From 09492ea7b419970a560f6b43abbc969b4a07aaa0 Mon Sep 17 00:00:00 2001 From: Cas Ebbers <617080+CasEbb@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:45:29 +0100 Subject: [PATCH 319/325] Move `toHtmlString()` to fluent strings (#10083) * Move `toHtmlString()` to fluent strings * Update strings.md --------- Co-authored-by: Taylor Otwell --- strings.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/strings.md b/strings.md index 7a75023e369..1bac19163a8 100644 --- a/strings.md +++ b/strings.md @@ -100,7 +100,6 @@ Laravel includes a variety of functions for manipulating string values. Many of [Str::take](#method-take) [Str::title](#method-title-case) [Str::toBase64](#method-str-to-base64) -[Str::toHtmlString](#method-str-to-html-string) [Str::transliterate](#method-str-transliterate) [Str::trim](#method-str-trim) [Str::ltrim](#method-str-ltrim) @@ -205,6 +204,7 @@ Laravel includes a variety of functions for manipulating string values. Many of [test](#method-fluent-str-test) [title](#method-fluent-str-title) [toBase64](#method-fluent-str-to-base64) +[toHtmlString](#method-fluent-str-to-html-string) [transliterate](#method-fluent-str-transliterate) [trim](#method-fluent-str-trim) [ltrim](#method-fluent-str-ltrim) @@ -496,7 +496,7 @@ You may disable case sensitivity by setting the `ignoreCase` argument to `true`: $doesntContain = Str::doesntContain('This is name', 'MY', ignoreCase: true); // true - + #### `Str::deduplicate()` {.collection-method} @@ -1313,15 +1313,6 @@ The `Str::toBase64` method converts the given string to Base64: // TGFyYXZlbA== - -#### `Str::toHtmlString()` {.collection-method} - -The `Str::toHtmlString` method converts the string instance to an instance of `Illuminate\Support\HtmlString`, which may be displayed in Blade templates: - - use Illuminate\Support\Str; - - $htmlString = Str::of('Nuno Maduro')->toHtmlString(); - #### `Str::transliterate()` {.collection-method} @@ -1793,7 +1784,7 @@ You can disable case sensitivity by setting the `ignoreCase` argument to `true`: $containsAll = Str::of('This is my name')->containsAll(['MY', 'NAME'], ignoreCase: true); // true - + #### `deduplicate` {.collection-method} @@ -2729,7 +2720,7 @@ The `title` method converts the given string to `Title Case`: // A Nice Title Uses The Correct Case -#### `toBase64()` {.collection-method} +#### `toBase64` {.collection-method} The `toBase64` method converts the given string to Base64: @@ -2739,6 +2730,15 @@ The `toBase64` method converts the given string to Base64: // TGFyYXZlbA== + +#### `toHtmlString` {.collection-method} + +The `toHtmlString` method converts the given string to an instance of `Illuminate\Support\HtmlString`, which will not be escaped when rendered in Blade templates: + + use Illuminate\Support\Str; + + $htmlString = Str::of('Nuno Maduro')->toHtmlString(); + #### `transliterate` {.collection-method} From 06bc7bd2acc706e564254994b1d3ed7baad8f5f2 Mon Sep 17 00:00:00 2001 From: Zakaria Arrid <35905260+zakariaarrid@users.noreply.github.com> Date: Fri, 20 Dec 2024 22:43:03 +0100 Subject: [PATCH 320/325] [11.x] update Str::is() strings.md (#10084) --- strings.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/strings.md b/strings.md index 1bac19163a8..f5b1b957326 100644 --- a/strings.md +++ b/strings.md @@ -634,6 +634,14 @@ The `Str::is` method determines if a given string matches a given pattern. Aster // false +You may disable case sensitivity by setting the `ignoreCase` argument to `true`: + + use Illuminate\Support\Str; + + $matches = Str::is('*.jpg', 'photo.JPG', ignoreCase: true); + + // true + #### `Str::isAscii()` {.collection-method} From ecae9ec0d8b7dd60bae30101d80cb26e21ee94bb Mon Sep 17 00:00:00 2001 From: Andy Hinkle Date: Thu, 26 Dec 2024 15:35:29 -0600 Subject: [PATCH 321/325] bump github actions php to 8.4 (#10087) --- pint.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pint.md b/pint.md index d4741dc41d3..ea7f8132122 100644 --- a/pint.md +++ b/pint.md @@ -178,7 +178,7 @@ jobs: strategy: fail-fast: true matrix: - php: [8.3] + php: [8.4] steps: - name: Checkout code @@ -199,6 +199,4 @@ jobs: - name: Commit linted files uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: "Fixes coding style" ``` From cd9999d15d4f6fcb2e4686bd508a065933955616 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 27 Dec 2024 16:00:49 -0600 Subject: [PATCH 322/325] wip --- validation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validation.md b/validation.md index e3841ffc850..e89a9c934dc 100644 --- a/validation.md +++ b/validation.md @@ -415,7 +415,7 @@ By adding a `stopOnFirstFailure` property to your request class, you may inform #### Customizing the Redirect Location -As previously discussed, a redirect response will be generated to send the user back to their previous location when form request validation fails. However, you are free to customize this behavior. To do so, define a `$redirect` property on your form request: +When form request validation fails, a redirect response will be generated to send the user back to their previous location. However, you are free to customize this behavior. To do so, define a `$redirect` property on your form request: /** * The URI that users should be redirected to if validation fails. From 981c6152c4a49a0910d72577afc43025ca43602b Mon Sep 17 00:00:00 2001 From: AriaieBOY Date: Mon, 30 Dec 2024 19:30:15 +0330 Subject: [PATCH 323/325] Sail valkey (#10090) * update sail to add valkey * add valkey to supported services in installation doc * Update sail.md --------- Co-authored-by: Taylor Otwell --- installation.md | 2 +- sail.md | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/installation.md b/installation.md index 548503f3cf9..ad451b0d5ad 100644 --- a/installation.md +++ b/installation.md @@ -340,7 +340,7 @@ Finally, you can access the application in your web browser at: http://localhost ### Choosing Your Sail Services -When creating a new Laravel application via Sail, you may use the `with` query string variable to choose which services should be configured in your new application's `docker-compose.yml` file. Available services include `mysql`, `pgsql`, `mariadb`, `redis`, `memcached`, `meilisearch`, `typesense`, `minio`, `selenium`, and `mailpit`: +When creating a new Laravel application via Sail, you may use the `with` query string variable to choose which services should be configured in your new application's `docker-compose.yml` file. Available services include `mysql`, `pgsql`, `mariadb`, `redis`, `valkey`, `memcached`, `meilisearch`, `typesense`, `minio`, `selenium`, and `mailpit`: ```shell curl -s "https://laravel.build/example-app?with=mysql,redis" | bash diff --git a/sail.md b/sail.md index 2c0aed7741f..a9932622b25 100644 --- a/sail.md +++ b/sail.md @@ -15,6 +15,7 @@ - [MySQL](#mysql) - [MongoDB](#mongodb) - [Redis](#redis) + - [Valkey](#valkey) - [Meilisearch](#meilisearch) - [Typesense](#typesense) - [File Storage](#file-storage) @@ -260,10 +261,17 @@ To connect to your application's MongoDB database from your local machine, you m ### Redis -Your application's `docker-compose.yml` file also contains an entry for a [Redis](https://redis.io) container. This container uses a [Docker volume](https://docs.docker.com/storage/volumes/) so that the data stored in your Redis data is persisted even when stopping and restarting your containers. Once you have started your containers, you may connect to the Redis instance within your application by setting your `REDIS_HOST` environment variable within your application's `.env` file to `redis`. +Your application's `docker-compose.yml` file also contains an entry for a [Redis](https://redis.io) container. This container uses a [Docker volume](https://docs.docker.com/storage/volumes/) so that the data stored in your Redis instance is persisted even when stopping and restarting your containers. Once you have started your containers, you may connect to the Redis instance within your application by setting your `REDIS_HOST` environment variable within your application's `.env` file to `redis`. To connect to your application's Redis database from your local machine, you may use a graphical database management application such as [TablePlus](https://tableplus.com). By default, the Redis database is accessible at `localhost` port 6379. + +### Valkey + +If you choose to install Valkey service when installing Sail, your application's `docker-compose.yml` file will contain an entry for [Valkey](https://valkey.io/). This container uses a [Docker volume](https://docs.docker.com/storage/volumes/) so that the data stored in your Valkey instance is persisted even when stopping and restarting your containers. You can connect to this container in you application by setting your `REDIS_HOST` environment variable within your application's `.env` file to `valkey`. + +To connect to your application's Valkey database from your local machine, you may use a graphical database management application such as [TablePlus](https://tableplus.com). By default, the Valkey database is accessible at `localhost` port 6379. + ### Meilisearch From c1f0f269efd002ada4f699e8ee19378088758f76 Mon Sep 17 00:00:00 2001 From: Jonathan Shull <58316242+aMytho@users.noreply.github.com> Date: Mon, 30 Dec 2024 10:07:28 -0600 Subject: [PATCH 324/325] Add Sanctum CSRF Token Encoding Info (#10089) * Add note about CSRF token encoding * Update sanctum.md * Update sanctum.md --------- Co-authored-by: Taylor Otwell --- sanctum.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sanctum.md b/sanctum.md index ee09eaba6d2..06e1f17f5f2 100644 --- a/sanctum.md +++ b/sanctum.md @@ -306,7 +306,7 @@ axios.get('/sanctum/csrf-cookie').then(response => { }); ``` -During this request, Laravel will set an `XSRF-TOKEN` cookie containing the current CSRF token. This token should then be passed in an `X-XSRF-TOKEN` header on subsequent requests, which some HTTP client libraries like Axios and the Angular HttpClient will do automatically for you. If your JavaScript HTTP library does not set the value for you, you will need to manually set the `X-XSRF-TOKEN` header to match the value of the `XSRF-TOKEN` cookie that is set by this route. +During this request, Laravel will set an `XSRF-TOKEN` cookie containing the current CSRF token. This token should then be URL decoded and passed in an `X-XSRF-TOKEN` header on subsequent requests, which some HTTP client libraries like Axios and the Angular HttpClient will do automatically for you. If your JavaScript HTTP library does not set the value for you, you will need to manually set the `X-XSRF-TOKEN` header to match the URL decoded value of the `XSRF-TOKEN` cookie that is set by this route. #### Logging In From 8fb4d801525a6cafcfd40b71b1f9c22bf6bb90d3 Mon Sep 17 00:00:00 2001 From: Emily <98989685+EmilyTheFox@users.noreply.github.com> Date: Tue, 31 Dec 2024 18:48:32 +0100 Subject: [PATCH 325/325] [11.x] Update validation.md documentation for uuid to mention RFC 9562 (#10094) * Update validation.md RFC 4122 has been made obsolete by RFC 9562 which the uuid rule does actually implement. So uuid validation rule docs should be updated to reflect that change * Update validation.md --------- Co-authored-by: Taylor Otwell --- validation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validation.md b/validation.md index e89a9c934dc..5d101fedb62 100644 --- a/validation.md +++ b/validation.md @@ -1907,7 +1907,7 @@ The field under validation must be a valid [Universally Unique Lexicographically #### uuid -The field under validation must be a valid RFC 4122 (version 1, 3, 4, or 5) universally unique identifier (UUID). +The field under validation must be a valid RFC 9562 (version 1, 3, 4, 5, 6, 7, or 8) universally unique identifier (UUID). ## Conditionally Adding Rules