From 3e2909319a0d6f2715207fb129f8d979b32f6528 Mon Sep 17 00:00:00 2001 From: Milwad Khosravi <98118400+milwad-dev@users.noreply.github.com> Date: Tue, 17 Jun 2025 16:28:20 +0330 Subject: [PATCH 001/193] Update eloquent-mutators.md (#10506) --- eloquent-mutators.md | 1 + 1 file changed, 1 insertion(+) diff --git a/eloquent-mutators.md b/eloquent-mutators.md index f047c4aa102..f8ef3c27789 100644 --- a/eloquent-mutators.md +++ b/eloquent-mutators.md @@ -214,6 +214,7 @@ The `casts` method should return an array where the key is the name of the attri
- `array` +- `AsFluent::class` - `AsStringable::class` - `AsUri::class` - `boolean` From 3432dc8192532eb74878bda4a9f49bd28d453d3a Mon Sep 17 00:00:00 2001 From: Cedrik <48626242+CedzyC@users.noreply.github.com> Date: Tue, 17 Jun 2025 15:19:06 +0200 Subject: [PATCH 002/193] Added Passport import to "Overriding Default Models" (#10505) * Added Passport import to "Overriding Default Models" * Update passport.md --------- Co-authored-by: Taylor Otwell --- passport.md | 1 + 1 file changed, 1 insertion(+) diff --git a/passport.md b/passport.md index 068a64b3283..f4173299aec 100644 --- a/passport.md +++ b/passport.md @@ -202,6 +202,7 @@ use App\Models\Passport\Client; use App\Models\Passport\DeviceCode; use App\Models\Passport\RefreshToken; use App\Models\Passport\Token; +use Laravel\Passport\Passport; /** * Bootstrap any application services. From 118eb1970420602073990b081b18bef59582c8b3 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 17 Jun 2025 12:18:10 -0500 Subject: [PATCH 003/193] wip --- http-tests.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/http-tests.md b/http-tests.md index c12ad817041..1c786d34c4d 100644 --- a/http-tests.md +++ b/http-tests.md @@ -1005,6 +1005,8 @@ Laravel's `Illuminate\Testing\TestResponse` class provides a variety of custom a [assertPlainCookie](#assert-plain-cookie) [assertRedirect](#assert-redirect) [assertRedirectBack](#assert-redirect-back) +[assertRedirectBackWithErrors](#assert-redirect-back-with-errors) +[assertRedirectBackWithoutErrors](#assert-redirect-back-without-errors) [assertRedirectContains](#assert-redirect-contains) [assertRedirectToRoute](#assert-redirect-to-route) [assertRedirectToSignedRoute](#assert-redirect-to-signed-route) @@ -1561,6 +1563,26 @@ Assert whether the response is redirecting back to the previous page: $response->assertRedirectBack(); ``` + +#### assertRedirectBackWithErrors + +Assert whether the response is redirecting back to the previous page and the [session has the given errors](#assert-session-has-errors): + +```php +$response->assertRedirectBackWithErrors( + array $keys = [], $format = null, $errorBag = 'default' +); +``` + + +#### assertRedirectBackWithoutErrors + +Assert whether the response is redirecting back to the previous page and the session does not contain any error messages: + +```php +$response->assertRedirectBackWithoutErrors(); +``` + #### assertRedirectContains From 013514ac88989dc577ee6bef4776849db35be151 Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Tue, 17 Jun 2025 21:47:20 +0300 Subject: [PATCH 004/193] Clarify the behavior of collapseWithKeys method (#10501) --- collections.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collections.md b/collections.md index dafbc1de412..be8b7f7259f 100644 --- a/collections.md +++ b/collections.md @@ -436,7 +436,7 @@ $collapsed->all(); #### `collapseWithKeys()` {.collection-method} -The `collapseWithKeys` method flattens a collection of arrays or collections into a single collection, keeping the original keys intact: +The `collapseWithKeys` method flattens a collection of arrays or collections into a single collection, keeping the original keys intact. If the collection is already flat, it will return an empty collection: ```php $collection = collect([ From 7656ab839d7af68c06349baf5839a580f176f3c5 Mon Sep 17 00:00:00 2001 From: Luke Kuzmish <42181698+cosmastech@users.noreply.github.com> Date: Tue, 17 Jun 2025 14:55:11 -0400 Subject: [PATCH 005/193] [12.x] `FailOnException` middleware (#10508) * FailOnException middleware * Update queues.md * Update queues.md * formatting * wip --------- Co-authored-by: Taylor Otwell --- queues.md | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/queues.md b/queues.md index 94a48954b05..affb97025e0 100644 --- a/queues.md +++ b/queues.md @@ -1428,6 +1428,64 @@ $this->fail('Something went wrong.'); > [!NOTE] > For more information on failed jobs, check out the [documentation on dealing with job failures](#dealing-with-failed-jobs). + +#### Failing Jobs on Specific Exceptions + +The `FailOnException` [job middleware](#job-middleware) allows you to short-circuit retries when specific exceptions are thrown. This allows retrying on transient exceptions such as external API errors, but failing the job permanently on persistent exceptions, such as a user's permissions being revoked: + +```php +authorize('sync-chat-history'); + + $response = Http::throw()->get( + "https://chat.laravel.test/?user={$user->uuid} + "); + + + // ... + } + + /** + * Get the middleware the job should pass through. + */ + public function middleware(): array + { + return [ + new FailOnException([AuthorizationException::class]) + ]; + } +} +``` + ## Job Batching From 2db745c10a3a367c6bcafb5bfe019fb5d3009ca9 Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Tue, 17 Jun 2025 22:17:29 +0300 Subject: [PATCH 006/193] Missing semi-colon (#10509) --- passport.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/passport.md b/passport.md index f4173299aec..d136ee02071 100644 --- a/passport.md +++ b/passport.md @@ -213,7 +213,7 @@ public function boot(): void Passport::useRefreshTokenModel(RefreshToken::class); Passport::useAuthCodeModel(AuthCode::class); Passport::useClientModel(Client::class); - Passport::useDeviceCodeModel(DeviceCode::class) + Passport::useDeviceCodeModel(DeviceCode::class); } ``` From 35f64d38e2c076c792acc0a0edc6a50182d0a9e9 Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Wed, 18 Jun 2025 15:52:15 +0300 Subject: [PATCH 007/193] Update queues.md (#10512) --- queues.md | 1 - 1 file changed, 1 deletion(-) diff --git a/queues.md b/queues.md index affb97025e0..29770aac665 100644 --- a/queues.md +++ b/queues.md @@ -1470,7 +1470,6 @@ class SyncChatHistory implements ShouldQueue "https://chat.laravel.test/?user={$user->uuid} "); - // ... } From f4b76d3fd9733cdc5331aed5d55ea32730e835db Mon Sep 17 00:00:00 2001 From: Luke Kuzmish <42181698+cosmastech@users.noreply.github.com> Date: Wed, 18 Jun 2025 08:52:50 -0400 Subject: [PATCH 008/193] Update queues.md (#10510) --- queues.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/queues.md b/queues.md index 29770aac665..223c6fd8266 100644 --- a/queues.md +++ b/queues.md @@ -1467,8 +1467,8 @@ class SyncChatHistory implements ShouldQueue $user->authorize('sync-chat-history'); $response = Http::throw()->get( - "https://chat.laravel.test/?user={$user->uuid} - "); + "https://chat.laravel.test/?user={$user->uuid}" + ); // ... } From b398efbb837f1c41b13016e1b010f38999ff08b7 Mon Sep 17 00:00:00 2001 From: Mohsin Ali Date: Wed, 18 Jun 2025 17:53:44 +0500 Subject: [PATCH 009/193] Clarify env() behavior after config caching (#10513) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clarify env() behavior after configuration caching The current documentation states that “all calls to the env function will return null” once the configuration has been cached. However, this is only true for environment variables defined exclusively in the .env file. If the environment variable exists at the system level (e.g., via putenv(), server configuration, env() will still return a value after caching. This clarification helps developers understand that env() is not completely disabled after config:cache, but rather depends on the source of the environment variable. --- helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers.md b/helpers.md index d4135fd342c..186a4e81efe 100644 --- a/helpers.md +++ b/helpers.md @@ -2438,7 +2438,7 @@ $env = env('APP_ENV', 'production'); ``` > [!WARNING] -> If you execute the `config:cache` command during your deployment process, you should be sure that you are only calling the `env` function from within your configuration files. Once the configuration has been cached, the `.env` file will not be loaded and all calls to the `env` function will return `null`. +> If you execute the `config:cache` command during your deployment process, you should be sure that you are only calling the `env` function from within your configuration files. Once the configuration has been cached, the `.env` file will not be loaded and all calls to the `env` function will return external environment variables such as server-level or system-level environment variables or `null`. #### `event()` {.collection-method} From a9716c300bff2a7c773ed46ca14afab5860fdfbe Mon Sep 17 00:00:00 2001 From: Johan Montenij Date: Wed, 18 Jun 2025 20:44:28 +0200 Subject: [PATCH 010/193] Add documentation for fromBase64() (#10514) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add documentation for Str::of(...)->fromBase64() * Add documentation for Str::of(...)->fromBase64() * Apply suggestions Co-authored-by: Sebastian Hädrich <11225821+shaedrich@users.noreply.github.com> * formatting --------- Co-authored-by: Sebastian Hädrich <11225821+shaedrich@users.noreply.github.com> Co-authored-by: Taylor Otwell --- strings.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/strings.md b/strings.md index 67827050dc2..10fc6be5927 100644 --- a/strings.md +++ b/strings.md @@ -52,6 +52,7 @@ Laravel includes a variety of functions for manipulating string values. Many of [Str::endsWith](#method-ends-with) [Str::excerpt](#method-excerpt) [Str::finish](#method-str-finish) +[Str::fromBase64](#method-str-from-base64) [Str::headline](#method-str-headline) [Str::inlineMarkdown](#method-str-inline-markdown) [Str::is](#method-str-is) @@ -154,6 +155,7 @@ Laravel includes a variety of functions for manipulating string values. Many of [excerpt](#method-fluent-str-excerpt) [explode](#method-fluent-str-explode) [finish](#method-fluent-str-finish) +[fromBase64](#method-fluent-str-from-base64) [hash](#method-fluent-str-hash) [headline](#method-fluent-str-headline) [inlineMarkdown](#method-fluent-str-inline-markdown) @@ -653,6 +655,19 @@ $adjusted = Str::finish('this/string/', '/'); // this/string/ ``` + +#### `Str::fromBase64()` {.collection-method} + +The `Str::fromBase64` method decodes the given Base64 string: + +```php +use Illuminate\Support\Str; + +$decoded = Str::fromBase64('TGFyYXZlbA=='); + +// Laravel +``` + #### `Str::headline()` {.collection-method} @@ -2316,6 +2331,19 @@ $adjusted = Str::of('this/string/')->finish('/'); // this/string/ ``` + +#### `fromBase64` {.collection-method} + +The `fromBase64` method decodes the given Base64 string: + +```php +use Illuminate\Support\Str; + +$decoded = Str::of('TGFyYXZlbA==')->fromBase64(); + +// Laravel +``` + #### `hash` {.collection-method} From f0dd01fbfc7a510da582efa03c6e1b31ef188aed Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Thu, 19 Jun 2025 20:19:05 +0300 Subject: [PATCH 011/193] Improve consistency and clarity in Filesystem Directories (#10515) --- filesystem.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/filesystem.md b/filesystem.md index 9b069449c1e..f6534104a72 100644 --- a/filesystem.md +++ b/filesystem.md @@ -730,7 +730,7 @@ Storage::disk('s3')->delete('path/file.jpg'); #### Get All Files Within a Directory -The `files` method returns an array of all of the files in a given directory. If you would like to retrieve a list of all files within a given directory including all subdirectories, you may use the `allFiles` method: +The `files` method returns an array of all files within a given directory. If you would like to retrieve a list of all files within a given directory including subdirectories, you may use the `allFiles` method: ```php use Illuminate\Support\Facades\Storage; @@ -743,7 +743,7 @@ $files = Storage::allFiles($directory); #### Get All Directories Within a Directory -The `directories` method returns an array of all the directories within a given directory. Additionally, you may use the `allDirectories` method to get a list of all directories within a given directory and all of its subdirectories: +The `directories` method returns an array of all directories within a given directory. If you would like to retrieve a list of all directories within a given directory including subdirectories, you may use the `allDirectories` method: ```php $directories = Storage::directories($directory); From b08a9df6d86e1d660dc75b4d665fa60c24b7b0f4 Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Mon, 23 Jun 2025 02:26:51 +0300 Subject: [PATCH 012/193] Add deprecation notice for Laravel Mix (#10519) --- mix.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mix.md b/mix.md index 59ec23ea1ff..1d8259c51d4 100644 --- a/mix.md +++ b/mix.md @@ -5,6 +5,9 @@ ## Introduction +> [!WARNING] +> Laravel Mix is a legacy package that is no longer actively maintained. [Vite](/docs/{{version}}/vite) may be used as a modern alternative. + [Laravel Mix](https://github.com/laravel-mix/laravel-mix), a package developed by [Laracasts](https://laracasts.com) creator Jeffrey Way, provides a fluent API for defining [webpack](https://webpack.js.org) build steps for your Laravel application using several common CSS and JavaScript pre-processors. In other words, Mix makes it a cinch to compile and minify your application's CSS and JavaScript files. Through simple method chaining, you can fluently define your asset pipeline. For example: From 656126b66762040a65ab5857fb3fb764a06cd5e3 Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Mon, 23 Jun 2025 02:27:06 +0300 Subject: [PATCH 013/193] Remove deprecated mix() helper (#10520) --- helpers.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/helpers.md b/helpers.md index 186a4e81efe..f4c7b76660a 100644 --- a/helpers.md +++ b/helpers.md @@ -134,7 +134,6 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct [config_path](#method-config-path) [database_path](#method-database-path) [lang_path](#method-lang-path) -[mix](#method-mix) [public_path](#method-public-path) [resource_path](#method-resource-path) [storage_path](#method-storage-path) @@ -1952,15 +1951,6 @@ $path = lang_path('en/messages.php'); > [!NOTE] > By default, the Laravel application skeleton does not include the `lang` directory. If you would like to customize Laravel's language files, you may publish them via the `lang:publish` Artisan command. - -#### `mix()` {.collection-method} - -The `mix` function returns the path to a [versioned Mix file](/docs/{{version}}/mix): - -```php -$path = mix('css/app.css'); -``` - #### `public_path()` {.collection-method} From 84b720160d5ee80455b6b562df5f734b03a68ccb Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sun, 22 Jun 2025 18:35:20 -0500 Subject: [PATCH 014/193] only use and document the `limit` and `offset` methods (#10516) `skip()` and `take()` are alias methods to `offset()` and `limit()`. IMO we should only use and document the main methods, not the aliases. This will encourage more performant coding, just like we now do in `laravel/framework`. IF it's decided we still want to mention the aliases, I'd recommended listing them second as the alternatives. I can make that change if desired. --- eloquent.md | 2 +- queries.md | 11 +---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/eloquent.md b/eloquent.md index 8c92e4d50cc..acea301ef73 100644 --- a/eloquent.md +++ b/eloquent.md @@ -431,7 +431,7 @@ The Eloquent `all` method will return all of the results in the model's table. H ```php $flights = Flight::where('active', 1) ->orderBy('name') - ->take(10) + ->limit(10) ->get(); ``` diff --git a/queries.md b/queries.md index eaf8230ba6b..02053a8f1f8 100644 --- a/queries.md +++ b/queries.md @@ -1210,16 +1210,7 @@ To build more advanced `having` statements, see the [havingRaw](#raw-methods) me ### Limit and Offset - -#### The `skip` and `take` Methods - -You may use the `skip` and `take` methods to limit the number of results returned from the query or to skip a given number of results in the query: - -```php -$users = DB::table('users')->skip(10)->take(5)->get(); -``` - -Alternatively, you may use the `limit` and `offset` methods. These methods are functionally equivalent to the `take` and `skip` methods, respectively: +You may use the `limit` and `offset` methods to limit the number of results returned from the query or to skip a given number of results in the query: ```php $users = DB::table('users') From f7e7991077d9da880dfa8df53703c7db3f592198 Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Tue, 24 Jun 2025 01:30:05 +0300 Subject: [PATCH 015/193] [12.x] Fix hyphenation of production-ready for grammatical correctness and consistency (#10525) * Update frontend.md * Update vite.md --- frontend.md | 2 +- vite.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend.md b/frontend.md index 2c8d9802cda..31da734876e 100644 --- a/frontend.md +++ b/frontend.md @@ -174,7 +174,7 @@ If you would like to build your frontend using Inertia and Vue / React, you can ## Bundling Assets -Regardless of whether you choose to develop your frontend using Blade and Livewire or Vue / React and Inertia, you will likely need to bundle your application's CSS into production ready assets. Of course, if you choose to build your application's frontend with Vue or React, you will also need to bundle your components into browser ready JavaScript assets. +Regardless of whether you choose to develop your frontend using Blade and Livewire or Vue / React and Inertia, you will likely need to bundle your application's CSS into production-ready assets. Of course, if you choose to build your application's frontend with Vue or React, you will also need to bundle your components into browser ready JavaScript assets. By default, Laravel utilizes [Vite](https://vitejs.dev) to bundle your assets. Vite provides lightning-fast build times and near instantaneous Hot Module Replacement (HMR) during local development. In all new Laravel applications, including those using our [starter kits](/docs/{{version}}/starter-kits), you will find a `vite.config.js` file that loads our light-weight Laravel Vite plugin that makes Vite a joy to use with Laravel applications. diff --git a/vite.md b/vite.md index 6e84c64b4cb..5b970e2da04 100644 --- a/vite.md +++ b/vite.md @@ -34,7 +34,7 @@ ## Introduction -[Vite](https://vitejs.dev) is a modern frontend build tool that provides an extremely fast development environment and bundles your code for production. When building applications with Laravel, you will typically use Vite to bundle your application's CSS and JavaScript files into production ready assets. +[Vite](https://vitejs.dev) is a modern frontend build tool that provides an extremely fast development environment and bundles your code for production. When building applications with Laravel, you will typically use Vite to bundle your application's CSS and JavaScript files into production-ready assets. Laravel integrates seamlessly with Vite by providing an official plugin and Blade directive to load your assets for development and production. From c74eeb16593f20ac46d14f210225749e27351c0d Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Tue, 24 Jun 2025 01:32:20 +0300 Subject: [PATCH 016/193] Remove Mix from Vite docs (#10523) --- vite.md | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/vite.md b/vite.md index 5b970e2da04..805092d3b22 100644 --- a/vite.md +++ b/vite.md @@ -38,21 +38,6 @@ Laravel integrates seamlessly with Vite by providing an official plugin and Blade directive to load your assets for development and production. -> [!NOTE] -> Are you running Laravel Mix? Vite has replaced Laravel Mix in new Laravel installations. For Mix documentation, please visit the [Laravel Mix](https://laravel-mix.com/) website. If you would like to switch to Vite, please see our [migration guide](https://github.com/laravel/vite-plugin/blob/main/UPGRADE.md#migrating-from-laravel-mix-to-vite). - - -#### Choosing Between Vite and Laravel Mix - -Before transitioning to Vite, new Laravel applications utilized [Mix](https://laravel-mix.com/), which is powered by [webpack](https://webpack.js.org/), when bundling assets. Vite focuses on providing a faster and more productive experience when building rich JavaScript applications. If you are developing a Single Page Application (SPA), including those developed with tools like [Inertia](https://inertiajs.com), Vite will be the perfect fit. - -Vite also works well with traditional server-side rendered applications with JavaScript "sprinkles", including those using [Livewire](https://livewire.laravel.com). However, it lacks some features that Laravel Mix supports, such as the ability to copy arbitrary assets into the build that are not referenced directly in your JavaScript application. - - -#### Migrating Back to Mix - -Have you started a new Laravel application using our Vite scaffolding but need to move back to Laravel Mix and webpack? No problem. Please consult our [official guide on migrating from Vite to Mix](https://github.com/laravel/vite-plugin/blob/main/UPGRADE.md#migrating-from-vite-to-laravel-mix). - ## Installation & Setup From 46c13471056c6815c653834b256a4050c097a9aa Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Tue, 24 Jun 2025 01:33:09 +0300 Subject: [PATCH 017/193] Fix order of sections in HTTP Client docs (#10524) --- http-client.md | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/http-client.md b/http-client.md index ca42e16d186..8235b97a7bd 100644 --- a/http-client.md +++ b/http-client.md @@ -701,27 +701,6 @@ Http::fake(function (Request $request) { }); ``` - -### Preventing Stray Requests - -If you would like to ensure that all requests sent via the HTTP client have been faked throughout your individual test or complete test suite, you can call the `preventStrayRequests` method. After calling this method, any requests that do not have a corresponding fake response will throw an exception rather than making the actual HTTP request: - -```php -use Illuminate\Support\Facades\Http; - -Http::preventStrayRequests(); - -Http::fake([ - 'github.com/*' => Http::response('ok'), -]); - -// An "ok" response is returned... -Http::get('https://github.com/laravel/framework'); - -// An exception is thrown... -Http::get('https://laravel.com'); -``` - ### Inspecting Requests @@ -823,6 +802,27 @@ $recorded = Http::recorded(function (Request $request, Response $response) { }); ``` + +### Preventing Stray Requests + +If you would like to ensure that all requests sent via the HTTP client have been faked throughout your individual test or complete test suite, you can call the `preventStrayRequests` method. After calling this method, any requests that do not have a corresponding fake response will throw an exception rather than making the actual HTTP request: + +```php +use Illuminate\Support\Facades\Http; + +Http::preventStrayRequests(); + +Http::fake([ + 'github.com/*' => Http::response('ok'), +]); + +// An "ok" response is returned... +Http::get('https://github.com/laravel/framework'); + +// An exception is thrown... +Http::get('https://laravel.com'); +``` + ## Events From 60cbbad87c35f694cba0b4d69716df58e13c0bcd Mon Sep 17 00:00:00 2001 From: Kevin Bui Date: Tue, 24 Jun 2025 08:47:45 +1000 Subject: [PATCH 018/193] [12.x] Add the failed method to queued mailables. (#10518) * Add the failed method to queued mailables. * formatting --------- Co-authored-by: Taylor Otwell --- mail.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/mail.md b/mail.md index a59c7e9d85f..32b5551871c 100644 --- a/mail.md +++ b/mail.md @@ -1076,6 +1076,33 @@ class OrderShipped extends Mailable implements ShouldQueue > [!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). + +#### Queued Email Failures + +When a queued email fails, the `failed` method on the queued mailable class will be invoked if it has been defined. The `Throwable` instance that caused the queued email to fail will be passed to the `failed` method: + +```php + ## Rendering Mailables From 15719cbad691f3e939012c75d9038d4b44672089 Mon Sep 17 00:00:00 2001 From: Amir Hossein Shokri Date: Tue, 24 Jun 2025 19:37:47 +0330 Subject: [PATCH 019/193] improve queue work command docs (#10531) --- queues.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queues.md b/queues.md index 223c6fd8266..9bda3d92f5b 100644 --- a/queues.md +++ b/queues.md @@ -1933,7 +1933,7 @@ php artisan queue:work > [!NOTE] > To keep the `queue:work` process running permanently in the background, you should use a process monitor such as [Supervisor](#supervisor-configuration) to ensure that the queue worker does not stop running. -You may include the `-v` flag when invoking the `queue:work` command if you would like the processed job IDs to be included in the command's output: +You may include the `-v` flag when invoking the `queue:work` command if you would like the processed job IDs, job connection names, and job queue names to be included in the command's output: ```shell php artisan queue:work -v From d0c3d31bb5b10774ead42265058172598de1ff67 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 24 Jun 2025 18:08:22 +0200 Subject: [PATCH 020/193] wip --- queues.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queues.md b/queues.md index 9bda3d92f5b..f15c69c8ca6 100644 --- a/queues.md +++ b/queues.md @@ -1933,7 +1933,7 @@ php artisan queue:work > [!NOTE] > To keep the `queue:work` process running permanently in the background, you should use a process monitor such as [Supervisor](#supervisor-configuration) to ensure that the queue worker does not stop running. -You may include the `-v` flag when invoking the `queue:work` command if you would like the processed job IDs, job connection names, and job queue names to be included in the command's output: +You may include the `-v` flag when invoking the `queue:work` command if you would like the processed job IDs, connection names, and queue names to be included in the command's output: ```shell php artisan queue:work -v From 128f9eec5d54d10e0ac79b51b2737b2caa5c1965 Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Tue, 24 Jun 2025 19:08:48 +0300 Subject: [PATCH 021/193] Missing semi-colon (#10529) --- helpers.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helpers.md b/helpers.md index f4c7b76660a..7b1792f8538 100644 --- a/helpers.md +++ b/helpers.md @@ -2085,7 +2085,7 @@ The `uri` function generates a [fluent URI instance](#uri) for the given URI: ```php $uri = uri('https://example.com') ->withPath('/users') - ->withQuery(['page' => 1]) + ->withQuery(['page' => 1]); ``` If the `uri` function is given an array containing a callable controller and method pair, the function will create a `Uri` instance for the controller method's route path: @@ -2093,7 +2093,7 @@ If the `uri` function is given an array containing a callable controller and met ```php use App\Http\Controllers\UserController; -$uri = uri([UserController::class, 'show'], ['user' => $user]) +$uri = uri([UserController::class, 'show'], ['user' => $user]); ``` If the controller is invokable, you may simply provide the controller class name: From 1615dd424f6a7823c54fcdad1522ed367b90ff4d Mon Sep 17 00:00:00 2001 From: Jay <602425+jshah4517@users.noreply.github.com> Date: Tue, 24 Jun 2025 17:09:13 +0100 Subject: [PATCH 022/193] [12.x] Allow latest version of predis (#10528) --- redis.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redis.md b/redis.md index 1991d667673..1fdb268af92 100644 --- a/redis.md +++ b/redis.md @@ -20,7 +20,7 @@ Before using Redis with Laravel, we encourage you to install and use the [PhpRed If you are unable to install the PhpRedis extension, you may install the `predis/predis` package via Composer. Predis is a Redis client written entirely in PHP and does not require any additional extensions: ```shell -composer require predis/predis:^2.0 +composer require predis/predis ``` From a15bc84b1841e692f4e07f0a743dcad9104a8c69 Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Tue, 24 Jun 2025 19:09:46 +0300 Subject: [PATCH 023/193] [12.x] Format the Queued Email Failures code (#10527) * Format the code with Pint * wip --- mail.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mail.md b/mail.md index 32b5551871c..ceb50b8e42f 100644 --- a/mail.md +++ b/mail.md @@ -1093,6 +1093,8 @@ use Throwable; class OrderDelayed extends Mailable implements ShouldQueue { + use SerializesModels; + /** * Handle a queued email's failure. */ From 490845661d09402f78e083d6d933fae972d031e9 Mon Sep 17 00:00:00 2001 From: Eszter Czotter Date: Tue, 24 Jun 2025 18:10:07 +0200 Subject: [PATCH 024/193] Fix Paddle documentation and dashboard urls (#10526) --- cashier-paddle.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cashier-paddle.md b/cashier-paddle.md index 6f2cba862a0..3b8562e5248 100644 --- a/cashier-paddle.md +++ b/cashier-paddle.md @@ -92,7 +92,7 @@ php artisan migrate ### Paddle Sandbox -During local and staging development, you should [register a Paddle Sandbox account](https://sandbox-login.paddle.com/signup). This account will give you a sandboxed environment to test and develop your applications without making actual payments. You may use Paddle's [test card numbers](https://developer.paddle.com/concepts/payment-methods/credit-debit-card) to simulate various payment scenarios. +During local and staging development, you should [register a Paddle Sandbox account](https://sandbox-login.paddle.com/signup). This account will give you a sandboxed environment to test and develop your applications without making actual payments. You may use Paddle's [test card numbers](https://developer.paddle.com/concepts/payment-methods/credit-debit-card#test-payment-method) to simulate various payment scenarios. When using the Paddle Sandbox environment, you should set the `PADDLE_SANDBOX` environment variable to `true` within your application's `.env` file: @@ -146,7 +146,7 @@ PADDLE_SANDBOX=true The `PADDLE_SANDBOX` environment variable should be set to `true` when you are using [Paddle's Sandbox environment](#paddle-sandbox). The `PADDLE_SANDBOX` variable should be set to `false` if you are deploying your application to production and are using Paddle's live vendor environment. -The `PADDLE_RETAIN_KEY` is optional and should only be set if you're using Paddle with [Retain](https://developer.paddle.com/paddlejs/retain). +The `PADDLE_RETAIN_KEY` is optional and should only be set if you're using Paddle with [Retain](https://developer.paddle.com/concepts/retain/overview). ### Paddle JS @@ -212,7 +212,7 @@ public function boot(): void > [!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. +Offering product and subscription billing via your application can be intimidating. However, thanks to Cashier and [Paddle's Checkout Overlay](https://developer.paddle.com/concepts/sell/overlay-checkout), you can easily build modern, robust payment integrations. To charge customers for non-recurring, single-charge products, we'll utilize Cashier to charge customers with Paddle's Checkout Overlay, where they will provide their payment details and confirm their purchase. Once the payment has been made via the Checkout Overlay, the customer will be redirected to a success URL of your choosing within your application: @@ -318,7 +318,7 @@ Please refer to Paddle's documentation for more information on the [data contain > [!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. +Offering product and subscription billing via your application can be intimidating. However, thanks to Cashier and [Paddle's Checkout Overlay](https://developer.paddle.com/concepts/sell/overlay-checkout), you can easily build modern, robust payment integrations. To learn how to sell subscriptions using Cashier and Paddle's Checkout Overlay, let's consider the simple scenario of a subscription service with a basic monthly (`price_basic_monthly`) and yearly (`price_basic_yearly`) plan. These two prices could be grouped under a "Basic" product (`pro_basic`) in our Paddle dashboard. In addition, our subscription service might offer an Expert plan as `pro_expert`. @@ -1340,7 +1340,7 @@ Paddle can notify your application of a variety of events via webhooks. By defau By default, this controller will automatically handle canceling subscriptions that have too many failed charges, subscription updates, and payment method changes; however, as we'll soon discover, you can extend this controller to handle any Paddle webhook event you like. -To ensure your application can handle Paddle webhooks, be sure to [configure the webhook URL in the Paddle control panel](https://vendors.paddle.com/alerts-webhooks). By default, Cashier's webhook controller responds to the `/paddle/webhook` URL path. The full list of all webhooks you should enable in the Paddle control panel are: +To ensure your application can handle Paddle webhooks, be sure to [configure the webhook URL in the Paddle control panel](https://vendors.paddle.com/notifications-v2). By default, Cashier's webhook controller responds to the `/paddle/webhook` URL path. The full list of all webhooks you should enable in the Paddle control panel are: - Customer Updated - Transaction Completed @@ -1425,7 +1425,7 @@ CASHIER_WEBHOOK=https://example.com/my-paddle-webhook-url ### Verifying Webhook Signatures -To secure your webhooks, you may use [Paddle's webhook signatures](https://developer.paddle.com/webhook-reference/verifying-webhooks). For convenience, Cashier automatically includes a middleware which validates that the incoming Paddle webhook request is valid. +To secure your webhooks, you may use [Paddle's webhook signatures](https://developer.paddle.com/webhooks/signature-verification). For convenience, Cashier automatically includes a middleware which validates that the incoming Paddle webhook request is valid. To enable webhook verification, ensure that the `PADDLE_WEBHOOK_SECRET` environment variable is defined in your application's `.env` file. The webhook secret may be retrieved from your Paddle account dashboard. From f22bb81a2bb997441069324a588de198cbc5c2e9 Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Tue, 24 Jun 2025 19:11:51 +0300 Subject: [PATCH 025/193] [12.x] Add proper link (#10530) * Add proper links * Update helpers.md --------- Co-authored-by: Taylor Otwell --- helpers.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/helpers.md b/helpers.md index 7b1792f8538..c7b24fcde65 100644 --- a/helpers.md +++ b/helpers.md @@ -2131,6 +2131,8 @@ $full = url()->full(); $previous = url()->previous(); ``` +For more information on working with the `url` function, consult the [URL generation documentation](/docs/{{version}}/urls#generating-urls). + ## Miscellaneous From 2bcd0ef8a85256239b1aad340569c8e42f59ad0e Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Wed, 25 Jun 2025 12:35:59 +0300 Subject: [PATCH 026/193] Redirect helper last argument (#10536) --- helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers.md b/helpers.md index c7b24fcde65..6056d362026 100644 --- a/helpers.md +++ b/helpers.md @@ -2653,7 +2653,7 @@ $policy = policy(App\Models\User::class); The `redirect` function returns a [redirect HTTP response](/docs/{{version}}/responses#redirects), or returns the redirector instance if called with no arguments: ```php -return redirect($to = null, $status = 302, $headers = [], $https = null); +return redirect($to = null, $status = 302, $headers = [], $secure = null); return redirect('/home'); From 8085ccfb1e01266100b897eeebe2018e2c3d923e Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Wed, 25 Jun 2025 12:38:21 +0300 Subject: [PATCH 027/193] [12.x] Add broadcast_if and broadcast_unless methods to helpers (#10533) * Add broadcast_if and broadcast_unless to helpers * add links * 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 6056d362026..044b2b9f9c0 100644 --- a/helpers.md +++ b/helpers.md @@ -170,6 +170,8 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct [bcrypt](#method-bcrypt) [blank](#method-blank) [broadcast](#method-broadcast) +[broadcast_if](#method-broadcast-if) +[broadcast_unless](#method-broadcast-unless) [cache](#method-cache) [class_uses_recursive](#method-class-uses-recursive) [collect](#method-collect) @@ -2256,6 +2258,28 @@ broadcast(new UserRegistered($user)); broadcast(new UserRegistered($user))->toOthers(); ``` + +#### `broadcast_if()` {.collection-method} + +The `broadcast_if` function [broadcasts](/docs/{{version}}/broadcasting) the given [event](/docs/{{version}}/events) to its listeners if a given boolean expression evaluates to `true`: + +```php +broadcast_if($user->isActive(), new UserRegistered($user)); + +broadcast_if($user->isActive(), new UserRegistered($user))->toOthers(); +``` + + +#### `broadcast_unless()` {.collection-method} + +The `broadcast_unless` function [broadcasts](/docs/{{version}}/broadcasting) the given [event](/docs/{{version}}/events) to its listeners if a given boolean expression evaluates to `false`: + +```php +broadcast_unless($user->isBanned(), new UserRegistered($user)); + +broadcast_unless($user->isBanned(), new UserRegistered($user))->toOthers(); +``` + #### `cache()` {.collection-method} From 388799f067a30bc0e0996e8d33fd1576548d1ece Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Thu, 26 Jun 2025 19:44:41 +0300 Subject: [PATCH 028/193] Improve consistency in _if and _unless functions (#10537) --- helpers.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helpers.md b/helpers.md index 044b2b9f9c0..683b6ec2111 100644 --- a/helpers.md +++ b/helpers.md @@ -2702,7 +2702,7 @@ report('Something went wrong.'); #### `report_if()` {.collection-method} -The `report_if` function will report an exception using your [exception handler](/docs/{{version}}/errors#handling-exceptions) if the given condition is `true`: +The `report_if` function will report an exception using your [exception handler](/docs/{{version}}/errors#handling-exceptions) if a given boolean expression evaluates to `true`: ```php report_if($shouldReport, $e); @@ -2713,7 +2713,7 @@ report_if($shouldReport, 'Something went wrong.'); #### `report_unless()` {.collection-method} -The `report_unless` function will report an exception using your [exception handler](/docs/{{version}}/errors#handling-exceptions) if the given condition is `false`: +The `report_unless` function will report an exception using your [exception handler](/docs/{{version}}/errors#handling-exceptions) if a given boolean expression evaluates to `false`: ```php report_unless($reportingDisabled, $e); From 2bb4c0c6f50cea2d007915bff95d507d7803adb6 Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Sat, 28 Jun 2025 20:15:35 +0300 Subject: [PATCH 029/193] Rename the person parameter to users (#10545) --- validation.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/validation.md b/validation.md index 863ff1a6c5e..80930f03040 100644 --- a/validation.md +++ b/validation.md @@ -2471,8 +2471,8 @@ You may also validate each element of an array. For example, to validate that ea ```php $validator = Validator::make($request->all(), [ - 'person.*.email' => 'email|unique:users', - 'person.*.first_name' => 'required_with:person.*.last_name', + 'users.*.email' => 'email|unique:users', + 'users.*.first_name' => 'required_with:users.*.last_name', ]); ``` @@ -2480,8 +2480,8 @@ Likewise, you may use the `*` character when specifying [custom validation messa ```php 'custom' => [ - 'person.*.email' => [ - 'unique' => 'Each person must have a unique email address', + 'users.*.email' => [ + 'unique' => 'Each user must have a unique email address', ] ], ``` From 82a09c0ec769132805cc789ec9ae8848faddf3b3 Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Sat, 28 Jun 2025 20:15:55 +0300 Subject: [PATCH 030/193] Fix wording in Arr::forget method (#10544) --- helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers.md b/helpers.md index 683b6ec2111..49a4372cc51 100644 --- a/helpers.md +++ b/helpers.md @@ -482,7 +482,7 @@ $value = Arr::float($array, 'name'); #### `Arr::forget()` {.collection-method} -The `Arr::forget` method removes a given key / value pair from a deeply nested array using "dot" notation: +The `Arr::forget` method removes a given key / value pairs from a deeply nested array using "dot" notation: ```php use Illuminate\Support\Arr; From 5882483ea1afa05fc6eccfe36751c5ee238f44a2 Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Sat, 28 Jun 2025 20:16:51 +0300 Subject: [PATCH 031/193] Remove outdated PHP version warning from Octane (#10541) --- octane.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/octane.md b/octane.md index 7e5fe5eee14..7ed30a9264f 100644 --- a/octane.md +++ b/octane.md @@ -47,9 +47,6 @@ php artisan octane:install ## Server Prerequisites -> [!WARNING] -> Laravel Octane requires [PHP 8.1+](https://php.net/releases/). - ### FrankenPHP From ce76238475535356a60631a0bfc7fa6be972992d Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Sat, 28 Jun 2025 20:17:08 +0300 Subject: [PATCH 032/193] Improve clarity (#10542) --- helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers.md b/helpers.md index 49a4372cc51..f07bbefb058 100644 --- a/helpers.md +++ b/helpers.md @@ -3415,7 +3415,7 @@ Sleep::assertNeverSlept(); Sleep::assertInsomniac(); ``` -Sometimes it may be useful to perform an action whenever a fake sleep occurs in your application code. To achieve this, you may provide a callback to the `whenFakingSleep` method. In the following example, we use Laravel's [time manipulation helpers](/docs/{{version}}/mocking#interacting-with-time) to instantly progress time by the duration of each sleep: +Sometimes it may be useful to perform an action whenever a fake sleep occurs. To achieve this, you may provide a callback to the `whenFakingSleep` method. In the following example, we use Laravel's [time manipulation helpers](/docs/{{version}}/mocking#interacting-with-time) to instantly progress time by the duration of each sleep: ```php use Carbon\CarbonInterval as Duration; From 944a3fbc1aa83941a81b05b75f7ef2885f069564 Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Sat, 28 Jun 2025 20:17:19 +0300 Subject: [PATCH 033/193] Minor language update (#10540) --- helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers.md b/helpers.md index f07bbefb058..04eb2db2cfb 100644 --- a/helpers.md +++ b/helpers.md @@ -3072,7 +3072,7 @@ To invoke a callback more than once, you may specify the number of iterations th Benchmark::dd(fn () => User::count(), iterations: 10); // 0.5 ms ``` -Sometimes, you may want to benchmark the execution of a callback while still obtaining the value returned by the callback. The `value` method will return a tuple containing the value returned by the callback and the amount of milliseconds it took to execute the callback: +Sometimes, you may want to benchmark the execution of a callback while still obtaining the value returned by the callback. The `value` method will return a tuple containing the value returned by the callback and the number of milliseconds it took to execute the callback: ```php [$count, $duration] = Benchmark::value(fn () => User::count()); From 873c949f1a40e4d99bd76389a9901ac39b451dc0 Mon Sep 17 00:00:00 2001 From: Kevin Bui Date: Sun, 29 Jun 2025 03:21:17 +1000 Subject: [PATCH 034/193] [12.x] Add the orderByDesc method (#10539) * Add the orderByDesc method. * Update queries.md --------- Co-authored-by: Taylor Otwell --- queries.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/queries.md b/queries.md index 02053a8f1f8..74c9a742ecb 100644 --- a/queries.md +++ b/queries.md @@ -1122,6 +1122,14 @@ $users = DB::table('users') ->get(); ``` +The sort direction is optional, and is ascending by default. If you want to sort in descending order, you can specify the second parameter for the `orderBy` method, or just use `orderByDesc`: + +```php +$users = DB::table('users') + ->orderByDesc('verified_at') + ->get(); +``` + #### The `latest` and `oldest` Methods From fa5ace397db97fb06e50fdbe630a9bd0080ce30d Mon Sep 17 00:00:00 2001 From: Jesper Noordsij <45041769+jnoordsij@users.noreply.github.com> Date: Tue, 1 Jul 2025 17:48:37 +0200 Subject: [PATCH 035/193] Add --dev flag for installing Pail (#10554) --- logging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logging.md b/logging.md index 8ec10a49b8e..c80bdc017a8 100644 --- a/logging.md +++ b/logging.md @@ -534,7 +534,7 @@ Laravel Pail is a package that allows you to easily dive into your Laravel appli To get started, install Pail into your project using the Composer package manager: ```shell -composer require laravel/pail +composer require --dev laravel/pail ``` From 390016b5854f02b3e6eecc718241808105e8c978 Mon Sep 17 00:00:00 2001 From: Ahmed Alaa <92916738+AhmedAlaa4611@users.noreply.github.com> Date: Tue, 1 Jul 2025 19:04:35 +0300 Subject: [PATCH 036/193] Fix grammatical inconsistency (#10550) --- blade.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blade.md b/blade.md index 0a901f57547..f34f1a220f3 100644 --- a/blade.md +++ b/blade.md @@ -161,7 +161,7 @@ Sometimes you may pass an array to your view with the intention of rendering it ``` -However, instead of manually calling `json_encode`, you may use the `Illuminate\Support\Js::from` method directive. The `from` method accepts the same arguments as PHP's `json_encode` function; however, it will ensure that the resulting JSON is properly escaped for inclusion within HTML quotes. The `from` method will return a string `JSON.parse` JavaScript statement that will convert the given object or array into a valid JavaScript object: +However, instead of manually calling `json_encode`, you may use the `Illuminate\Support\Js::from` method directive. The `from` method accepts the same arguments as PHP's `json_encode` function; however, it will ensure that the resulting JSON has been properly escaped for inclusion within HTML quotes. The `from` method will return a string `JSON.parse` JavaScript statement that will convert the given object or array into a valid JavaScript object: ```blade