From 8d1dd36dc9bd1ed5260cd0601d94fe1df75af047 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 14 Feb 2025 22:51:36 -0600 Subject: [PATCH] single indent of multiline chains continuation of #10166 --- cashier-paddle.md | 5 +- console-tests.md | 40 ++++---- container.md | 48 ++++----- controllers.md | 6 +- database.md | 8 +- dusk.md | 94 +++++++++--------- eloquent-mutators.md | 4 +- eloquent-resources.md | 10 +- eloquent.md | 18 ++-- facades.md | 12 +-- helpers.md | 38 +++---- http-tests.md | 4 +- mail.md | 30 +++--- migrations.md | 10 +- mocking.md | 12 +-- notifications.md | 226 +++++++++++++++++++++--------------------- octane.md | 6 +- processes.md | 22 ++-- queries.md | 10 +- queues.md | 36 +++---- responses.md | 30 +++--- routing.md | 8 +- scheduling.md | 138 +++++++++++++------------- seeding.md | 6 +- strings.md | 24 ++--- views.md | 4 +- 26 files changed, 425 insertions(+), 424 deletions(-) diff --git a/cashier-paddle.md b/cashier-paddle.md index 9b6c2e0f47c..abae510c863 100644 --- a/cashier-paddle.md +++ b/cashier-paddle.md @@ -1081,8 +1081,9 @@ If you would like to offer trial periods to your customers while still collectin use Illuminate\Http\Request; Route::get('/user/subscribe', function (Request $request) { - $checkout = $request->user()->subscribe('pri_monthly') - ->returnTo(route('home')); + $checkout = $request->user() + ->subscribe('pri_monthly') + ->returnTo(route('home')); return view('billing', ['checkout' => $checkout]); }); diff --git a/console-tests.md b/console-tests.md index 826a7a9f938..6c4bb9863ff 100644 --- a/console-tests.md +++ b/console-tests.md @@ -63,11 +63,11 @@ You may test this command with the following test: ```php tab=Pest test('console command', function () { $this->artisan('question') - ->expectsQuestion('What is your name?', 'Taylor Otwell') - ->expectsQuestion('Which language do you prefer?', 'PHP') - ->expectsOutput('Your name is Taylor Otwell and you prefer PHP.') - ->doesntExpectOutput('Your name is Taylor Otwell and you prefer Ruby.') - ->assertExitCode(0); + ->expectsQuestion('What is your name?', 'Taylor Otwell') + ->expectsQuestion('Which language do you prefer?', 'PHP') + ->expectsOutput('Your name is Taylor Otwell and you prefer PHP.') + ->doesntExpectOutput('Your name is Taylor Otwell and you prefer Ruby.') + ->assertExitCode(0); }); ``` @@ -78,11 +78,11 @@ test('console command', function () { public function test_console_command(): void { $this->artisan('question') - ->expectsQuestion('What is your name?', 'Taylor Otwell') - ->expectsQuestion('Which language do you prefer?', 'PHP') - ->expectsOutput('Your name is Taylor Otwell and you prefer PHP.') - ->doesntExpectOutput('Your name is Taylor Otwell and you prefer Ruby.') - ->assertExitCode(0); + ->expectsQuestion('What is your name?', 'Taylor Otwell') + ->expectsQuestion('Which language do you prefer?', 'PHP') + ->expectsOutput('Your name is Taylor Otwell and you prefer PHP.') + ->doesntExpectOutput('Your name is Taylor Otwell and you prefer Ruby.') + ->assertExitCode(0); } ``` @@ -91,12 +91,12 @@ If you are utilizing the `search` or `multisearch` functions provided by [Larave ```php tab=Pest test('console command', function () { $this->artisan('example') - ->expectsSearch('What is your name?', search: 'Tay', answers: [ + ->expectsSearch('What is your name?', search: 'Tay', answers: [ 'Taylor Otwell', 'Taylor Swift', 'Darian Taylor' - ], answer: 'Taylor Otwell') - ->assertExitCode(0); + ], answer: 'Taylor Otwell') + ->assertExitCode(0); }); ``` @@ -107,12 +107,12 @@ test('console command', function () { public function test_console_command(): void { $this->artisan('example') - ->expectsSearch('What is your name?', search: 'Tay', answers: [ + ->expectsSearch('What is your name?', search: 'Tay', answers: [ 'Taylor Otwell', 'Taylor Swift', 'Darian Taylor' - ], answer: 'Taylor Otwell') - ->assertExitCode(0); + ], answer: 'Taylor Otwell') + ->assertExitCode(0); } ``` @@ -121,8 +121,8 @@ You may also assert that a console command does not generate any output using th ```php tab=Pest test('console command', function () { $this->artisan('example') - ->doesntExpectOutput() - ->assertExitCode(0); + ->doesntExpectOutput() + ->assertExitCode(0); }); ``` @@ -143,8 +143,8 @@ The `expectsOutputToContain` and `doesntExpectOutputToContain` methods may be us ```php tab=Pest test('console command', function () { $this->artisan('example') - ->expectsOutputToContain('Taylor') - ->assertExitCode(0); + ->expectsOutputToContain('Taylor') + ->assertExitCode(0); }); ``` diff --git a/container.md b/container.md index a538174bab5..9e809664bf8 100644 --- a/container.md +++ b/container.md @@ -222,16 +222,16 @@ Sometimes you may have two classes that utilize the same interface, but you wish use Illuminate\Support\Facades\Storage; $this->app->when(PhotoController::class) - ->needs(Filesystem::class) - ->give(function () { - return Storage::disk('local'); - }); + ->needs(Filesystem::class) + ->give(function () { + return Storage::disk('local'); + }); $this->app->when([VideoController::class, UploadController::class]) - ->needs(Filesystem::class) - ->give(function () { - return Storage::disk('s3'); - }); + ->needs(Filesystem::class) + ->give(function () { + return Storage::disk('s3'); + }); ### Contextual Attributes @@ -349,8 +349,8 @@ Sometimes you may have a class that receives some injected classes, but also nee use App\Http\Controllers\UserController; $this->app->when(UserController::class) - ->needs('$variableName') - ->give($value); + ->needs('$variableName') + ->give($value); Sometimes a class may depend on an array of [tagged](#tagging) instances. Using the `giveTagged` method, you may easily inject all of the container bindings with that tag: @@ -397,24 +397,24 @@ Occasionally, you may have a class that receives an array of typed objects using Using contextual binding, you may resolve this dependency by providing the `give` method with a closure that returns an array of resolved `Filter` instances: $this->app->when(Firewall::class) - ->needs(Filter::class) - ->give(function (Application $app) { - return [ - $app->make(NullFilter::class), - $app->make(ProfanityFilter::class), - $app->make(TooLongFilter::class), - ]; - }); + ->needs(Filter::class) + ->give(function (Application $app) { + return [ + $app->make(NullFilter::class), + $app->make(ProfanityFilter::class), + $app->make(TooLongFilter::class), + ]; + }); For convenience, you may also just provide an array of class names to be resolved by the container whenever `Firewall` needs `Filter` instances: $this->app->when(Firewall::class) - ->needs(Filter::class) - ->give([ - NullFilter::class, - ProfanityFilter::class, - TooLongFilter::class, - ]); + ->needs(Filter::class) + ->give([ + NullFilter::class, + ProfanityFilter::class, + TooLongFilter::class, + ]); #### Variadic Tag Dependencies diff --git a/controllers.md b/controllers.md index da3a3d4b726..cab0c88c16d 100644 --- a/controllers.md +++ b/controllers.md @@ -208,9 +208,9 @@ Typically, a 404 HTTP response will be generated if an implicitly bound resource use Illuminate\Support\Facades\Redirect; Route::resource('photos', PhotoController::class) - ->missing(function (Request $request) { - return Redirect::route('photos.index'); - }); + ->missing(function (Request $request) { + return Redirect::route('photos.index'); + }); #### Soft Deleted Models diff --git a/database.md b/database.md index 829eca93572..089c925baf0 100644 --- a/database.md +++ b/database.md @@ -464,10 +464,10 @@ public function boot(): void { Event::listen(function (DatabaseBusy $event) { Notification::route('mail', 'dev@example.com') - ->notify(new DatabaseApproachingMaxConnections( - $event->connectionName, - $event->connections - )); + ->notify(new DatabaseApproachingMaxConnections( + $event->connectionName, + $event->connections + )); }); } ``` diff --git a/dusk.md b/dusk.md index fb8afd15278..95b8e5b790d 100644 --- a/dusk.md +++ b/dusk.md @@ -350,10 +350,10 @@ test('basic example', function () { $this->browse(function (Browser $browser) use ($user) { $browser->visit('/login') - ->type('email', $user->email) - ->type('password', 'password') - ->press('Login') - ->assertPathIs('/home'); + ->type('email', $user->email) + ->type('password', 'password') + ->press('Login') + ->assertPathIs('/home'); }); }); ``` @@ -383,10 +383,10 @@ class ExampleTest extends DuskTestCase $this->browse(function (Browser $browser) use ($user) { $browser->visit('/login') - ->type('email', $user->email) - ->type('password', 'password') - ->press('Login') - ->assertPathIs('/home'); + ->type('email', $user->email) + ->type('password', 'password') + ->press('Login') + ->assertPathIs('/home'); }); } } @@ -401,17 +401,17 @@ Sometimes you may need multiple browsers in order to properly carry out a test. $this->browse(function (Browser $first, Browser $second) { $first->loginAs(User::find(1)) - ->visit('/home') - ->waitForText('Message'); + ->visit('/home') + ->waitForText('Message'); $second->loginAs(User::find(2)) - ->visit('/home') - ->waitForText('Message') - ->type('message', 'Hey Taylor') - ->press('Send'); + ->visit('/home') + ->waitForText('Message') + ->type('message', 'Hey Taylor') + ->press('Send'); $first->waitForText('Hey Taylor') - ->assertSee('Jeffrey Way'); + ->assertSee('Jeffrey Way'); }); @@ -489,8 +489,8 @@ The `macro` function accepts a name as its first argument, and a closure as its $this->browse(function (Browser $browser) use ($user) { $browser->visit('/pay') - ->scrollToElement('#credit-card-details') - ->assertSee('Enter Credit Card Details'); + ->scrollToElement('#credit-card-details') + ->assertSee('Enter Credit Card Details'); }); @@ -503,7 +503,7 @@ Often, you will be testing pages that require authentication. You can use Dusk's $this->browse(function (Browser $browser) { $browser->loginAs(User::find(1)) - ->visit('/home'); + ->visit('/home'); }); > [!WARNING] @@ -650,7 +650,7 @@ Note that, although the method accepts one if necessary, we are not required to To append text to a field without clearing its content, you may use the `append` method: $browser->type('tags', 'foo') - ->append('tags', ', bar, baz'); + ->append('tags', ', bar, baz'); You may clear the value of an input using the `clear` method: @@ -665,7 +665,7 @@ You can instruct Dusk to type slowly using the `typeSlowly` method. By default, You may use the `appendSlowly` method to append text slowly: $browser->type('tags', 'foo') - ->appendSlowly('tags', ', bar, baz'); + ->appendSlowly('tags', ', bar, baz'); #### Dropdowns @@ -850,8 +850,8 @@ The `clickAndHold` method may be used to simulate a mouse button being clicked a $browser->clickAndHold('.selector'); $browser->clickAndHold() - ->pause(1000) - ->releaseMouse(); + ->pause(1000) + ->releaseMouse(); The `controlClick` method may be used to simulate the `ctrl+click` event within the browser: @@ -926,7 +926,7 @@ Sometimes you may wish to perform several operations while scoping all of the op $browser->with('.table', function (Browser $table) { $table->assertSee('Hello World') - ->clickLink('Delete'); + ->clickLink('Delete'); }); You may occasionally need to execute assertions outside of the current scope. You may use the `elsewhere` and `elsewhereWhenAvailable` methods to accomplish this: @@ -1013,7 +1013,7 @@ Occasionally, you may wish to wait for an element to appear that matches a given $browser->whenAvailable('.modal', function (Browser $modal) { $modal->assertSee('Hello World') - ->press('OK'); + ->press('OK'); }); @@ -1087,7 +1087,7 @@ If you need to wait for a page to reload after performing an action, use the `wa Since the need to wait for the page to reload typically occurs after clicking a button, you may use the `clickAndWaitForReload` method for convenience: $browser->clickAndWaitForReload('.selector') - ->assertSee('something'); + ->assertSee('something'); #### Waiting on JavaScript Expressions @@ -1152,7 +1152,7 @@ Many of the "wait" methods in Dusk rely on the underlying `waitUsing` method. Yo Sometimes you may not be able to click on an element because it is outside of the viewable area of the browser. The `scrollIntoView` method will scroll the browser window until the element at the given selector is within the view: $browser->scrollIntoView('.selector') - ->click('.selector'); + ->click('.selector'); ## Available Assertions @@ -1816,7 +1816,7 @@ You may assert on the state of the Vue component like so: test('vue', function () { $this->browse(function (Browser $browser) { $browser->visit('/') - ->assertVue('user.name', 'Taylor', '@profile-component'); + ->assertVue('user.name', 'Taylor', '@profile-component'); }); }); ``` @@ -1829,7 +1829,7 @@ public function test_vue(): void { $this->browse(function (Browser $browser) { $browser->visit('/') - ->assertVue('user.name', 'Taylor', '@profile-component'); + ->assertVue('user.name', 'Taylor', '@profile-component'); }); } ``` @@ -1976,8 +1976,8 @@ In addition to the default methods defined on pages, you may define additional m public function createPlaylist(Browser $browser, string $name): void { $browser->type('name', $name) - ->check('share') - ->press('Create Playlist'); + ->check('share') + ->press('Create Playlist'); } } @@ -2049,15 +2049,15 @@ As shown above, a "date picker" is an example of a component that might exist th public function selectDate(Browser $browser, int $year, int $month, int $day): void { $browser->click('@date-field') - ->within('@year-list', function (Browser $browser) use ($year) { - $browser->click($year); - }) - ->within('@month-list', function (Browser $browser) use ($month) { - $browser->click($month); - }) - ->within('@day-list', function (Browser $browser) use ($day) { - $browser->click($day); - }); + ->within('@year-list', function (Browser $browser) use ($year) { + $browser->click($year); + }) + ->within('@month-list', function (Browser $browser) use ($month) { + $browser->click($month); + }) + ->within('@day-list', function (Browser $browser) use ($day) { + $browser->click($day); + }); } } @@ -2078,10 +2078,10 @@ uses(DatabaseMigrations::class); test('basic example', function () { $this->browse(function (Browser $browser) { $browser->visit('/') - ->within(new DatePicker, function (Browser $browser) { - $browser->selectDate(2019, 1, 30); - }) - ->assertSee('January'); + ->within(new DatePicker, function (Browser $browser) { + $browser->selectDate(2019, 1, 30); + }) + ->assertSee('January'); }); }); ``` @@ -2105,10 +2105,10 @@ class ExampleTest extends DuskTestCase { $this->browse(function (Browser $browser) { $browser->visit('/') - ->within(new DatePicker, function (Browser $browser) { - $browser->selectDate(2019, 1, 30); - }) - ->assertSee('January'); + ->within(new DatePicker, function (Browser $browser) { + $browser->selectDate(2019, 1, 30); + }) + ->assertSee('January'); }); } } diff --git a/eloquent-mutators.md b/eloquent-mutators.md index cf4a4c012f3..60c6aefe87b 100644 --- a/eloquent-mutators.md +++ b/eloquent-mutators.md @@ -515,7 +515,7 @@ Sometimes you may need to apply casts while executing a query, such as when sele $users = User::select([ 'users.*', 'last_posted_at' => Post::selectRaw('MAX(created_at)') - ->whereColumn('user_id', 'users.id') + ->whereColumn('user_id', 'users.id') ])->get(); The `last_posted_at` attribute on the results of this query will be a simple string. It would be wonderful if we could apply a `datetime` cast to this attribute when executing the query. Thankfully, we may accomplish this using the `withCasts` method: @@ -523,7 +523,7 @@ The `last_posted_at` attribute on the results of this query will be a simple str $users = User::select([ 'users.*', 'last_posted_at' => Post::selectRaw('MAX(created_at)') - ->whereColumn('user_id', 'users.id') + ->whereColumn('user_id', 'users.id') ])->withCasts([ 'last_posted_at' => 'datetime' ])->get(); diff --git a/eloquent-resources.md b/eloquent-resources.md index ea01e2d81bf..e57209bf81e 100644 --- a/eloquent-resources.md +++ b/eloquent-resources.md @@ -738,9 +738,9 @@ Sometimes you may wish to only include certain meta data with a resource respons You may also add top-level data when constructing resource instances in your route or controller. The `additional` method, which is available on all resources, accepts an array of data that should be added to the resource response: return (new UserCollection(User::all()->load('roles'))) - ->additional(['meta' => [ - 'key' => 'value', - ]]); + ->additional(['meta' => [ + 'key' => 'value', + ]]); ## Resource Responses @@ -761,8 +761,8 @@ However, sometimes you may need to customize the outgoing HTTP response before i Route::get('/user', function () { return (new UserResource(User::find(1))) - ->response() - ->header('X-Value', 'True'); + ->response() + ->header('X-Value', 'True'); }); Alternatively, you may define a `withResponse` method within the resource itself. This method will be called when the resource is returned as the outermost resource in a response: diff --git a/eloquent.md b/eloquent.md index ecfc101c216..74504364dda 100644 --- a/eloquent.md +++ b/eloquent.md @@ -403,9 +403,9 @@ Once you have created a model and [its associated database table](/docs/{{versio The Eloquent `all` method will return all of the results in the model's table. However, since each Eloquent model serves as a [query builder](/docs/{{version}}/queries), you may add additional constraints to queries and then invoke the `get` method to retrieve the results: $flights = Flight::where('active', 1) - ->orderBy('name') - ->take(10) - ->get(); + ->orderBy('name') + ->take(10) + ->get(); > [!NOTE] > Since Eloquent models are query builders, you should review all of the methods provided by Laravel's [query builder](/docs/{{version}}/queries). You may use any of these methods when writing your Eloquent queries. @@ -745,8 +745,8 @@ In the example below, if a flight exists with a `departure` location of `Oakland Updates can also be performed against models that match a given query. In this example, all flights that are `active` and have a `destination` of `San Diego` will be marked as delayed: Flight::where('active', 1) - ->where('destination', 'San Diego') - ->update(['delayed' => 1]); + ->where('destination', 'San Diego') + ->update(['delayed' => 1]); The `update` method expects an array of column and value pairs representing the columns that should be updated. The `update` method returns the number of affected rows. @@ -1038,8 +1038,8 @@ As noted above, soft deleted models will automatically be excluded from query re use App\Models\Flight; $flights = Flight::withTrashed() - ->where('account_id', 1) - ->get(); + ->where('account_id', 1) + ->get(); The `withTrashed` method may also be called when building a [relationship](/docs/{{version}}/eloquent-relationships) query: @@ -1051,8 +1051,8 @@ The `withTrashed` method may also be called when building a [relationship](/docs The `onlyTrashed` method will retrieve **only** soft deleted models: $flights = Flight::onlyTrashed() - ->where('airline_id', 1) - ->get(); + ->where('airline_id', 1) + ->get(); ## Pruning Models diff --git a/facades.md b/facades.md index 175c50ea358..a8621e52502 100644 --- a/facades.md +++ b/facades.md @@ -74,8 +74,8 @@ use Illuminate\Support\Facades\Cache; test('basic example', function () { Cache::shouldReceive('get') - ->with('key') - ->andReturn('value'); + ->with('key') + ->andReturn('value'); $response = $this->get('/cache'); @@ -92,8 +92,8 @@ use Illuminate\Support\Facades\Cache; public function test_basic_example(): void { Cache::shouldReceive('get') - ->with('key') - ->andReturn('value'); + ->with('key') + ->andReturn('value'); $response = $this->get('/cache'); @@ -126,8 +126,8 @@ The `cache` helper is going to call the `get` method on the class underlying the public function test_basic_example(): void { Cache::shouldReceive('get') - ->with('key') - ->andReturn('value'); + ->with('key') + ->andReturn('value'); $response = $this->get('/cache'); diff --git a/helpers.md b/helpers.md index bde5d85235d..66691c59daa 100644 --- a/helpers.md +++ b/helpers.md @@ -2576,19 +2576,19 @@ use App\Models\User; use Illuminate\Support\Facades\Pipeline; $user = Pipeline::send($user) - ->through([ - function (User $user, Closure $next) { - // ... - - return $next($user); - }, - function (User $user, Closure $next) { - // ... - - return $next($user); - }, - ]) - ->then(fn (User $user) => $user); + ->through([ + function (User $user, Closure $next) { + // ... + + return $next($user); + }, + function (User $user, Closure $next) { + // ... + + return $next($user); + }, + ]) + ->then(fn (User $user) => $user); ``` As you can see, each invokable class or closure in the pipeline is provided the input and a `$next` closure. Invoking the `$next` closure will invoke the next callable in the pipeline. As you may have noticed, this is very similar to [middleware](/docs/{{version}}/middleware). @@ -2599,12 +2599,12 @@ Of course, as discussed previously, you are not limited to providing closures to ```php $user = Pipeline::send($user) - ->through([ - GenerateProfilePhoto::class, - ActivateSubscription::class, - SendWelcomeEmail::class, - ]) - ->then(fn (User $user) => $user); + ->through([ + GenerateProfilePhoto::class, + ActivateSubscription::class, + SendWelcomeEmail::class, + ]) + ->then(fn (User $user) => $user); ``` diff --git a/http-tests.md b/http-tests.md index 3826c0e994b..ece2b3a7c8c 100644 --- a/http-tests.md +++ b/http-tests.md @@ -729,7 +729,7 @@ You may only want to assert that the properties in the JSON response are of a ce $response->assertJson(fn (AssertableJson $json) => $json->whereType('id', 'integer') - ->whereAllType([ + ->whereAllType([ 'users.0.name' => 'string', 'meta' => 'array' ]) @@ -739,7 +739,7 @@ You may specify multiple types using the `|` character, or passing an array of t $response->assertJson(fn (AssertableJson $json) => $json->whereType('name', 'string|null') - ->whereType('id', ['string', 'integer']) + ->whereType('id', ['string', 'integer']) ); The `whereType` and `whereAllType` methods recognize the following types: `string`, `integer`, `double`, `boolean`, `array`, and `null`. diff --git a/mail.md b/mail.md index fe4acb5eb82..df107438282 100644 --- a/mail.md +++ b/mail.md @@ -490,8 +490,8 @@ When attaching files to a message, you may also specify the display name and / o { return [ Attachment::fromPath('/path/to/file') - ->as('name.pdf') - ->withMime('application/pdf'), + ->as('name.pdf') + ->withMime('application/pdf'), ]; } @@ -523,8 +523,8 @@ Of course, you may also specify the attachment's name and MIME type: { return [ Attachment::fromStorage('/path/to/file') - ->as('name.pdf') - ->withMime('application/pdf'), + ->as('name.pdf') + ->withMime('application/pdf'), ]; } @@ -539,8 +539,8 @@ The `fromStorageDisk` method may be used if you need to specify a storage disk o { return [ Attachment::fromStorageDisk('s3', '/path/to/file') - ->as('name.pdf') - ->withMime('application/pdf'), + ->as('name.pdf') + ->withMime('application/pdf'), ]; } @@ -558,7 +558,7 @@ The `fromData` attachment method may be used to attach a raw string of bytes as { return [ Attachment::fromData(fn () => $this->pdf, 'Report.pdf') - ->withMime('application/pdf'), + ->withMime('application/pdf'), ]; } @@ -644,8 +644,8 @@ In addition, you may create attachment instances via data that you have in memor Laravel also provides additional methods that you may use to customize your attachments. For example, you may use the `as` and `withMime` methods to customize the file's name and MIME type: return Attachment::fromPath('/path/to/file') - ->as('Photo Name') - ->withMime('image/jpeg'); + ->as('Photo Name') + ->withMime('image/jpeg'); ### Headers @@ -885,8 +885,8 @@ Occasionally, you may need to send a mailable to a list of recipients by iterati By default, Laravel will send email using the mailer configured as the `default` mailer in your application's `mail` configuration file. However, you may use the `mailer` method to send a message using a specific mailer configuration: Mail::mailer('postmark') - ->to($request->user()) - ->send(new OrderShipped($order)); + ->to($request->user()) + ->send(new OrderShipped($order)); ### Queueing Mail @@ -919,8 +919,8 @@ If you wish to delay the delivery of a queued email message, you may use the `la Since all mailable classes generated using the `make:mail` command make use of the `Illuminate\Bus\Queueable` trait, you may call the `onQueue` and `onConnection` methods on any mailable class instance, allowing you to specify the connection and queue name for the message: $message = (new OrderShipped($order)) - ->onConnection('sqs') - ->onQueue('emails'); + ->onConnection('sqs') + ->onQueue('emails'); Mail::to($request->user()) ->cc($moreUsers) @@ -1223,8 +1223,8 @@ The mailable instance also includes several helpful methods for examining the at Mail::assertSent(OrderShipped::class, function (OrderShipped $mail) { return $mail->hasAttachment( Attachment::fromPath('/path/to/file') - ->as('name.pdf') - ->withMime('application/pdf') + ->as('name.pdf') + ->withMime('application/pdf') ); }); diff --git a/migrations.md b/migrations.md index 6c27e425e86..f77fbd56360 100644 --- a/migrations.md +++ b/migrations.md @@ -1255,9 +1255,9 @@ The `foreignId` method creates an `UNSIGNED BIGINT` equivalent column, while the You may also specify the desired action for the "on delete" and "on update" properties of the constraint: $table->foreignId('user_id') - ->constrained() - ->onUpdate('cascade') - ->onDelete('cascade'); + ->constrained() + ->onUpdate('cascade') + ->onDelete('cascade'); An alternative, expressive syntax is also provided for these actions: @@ -1279,8 +1279,8 @@ An alternative, expressive syntax is also provided for these actions: Any additional [column modifiers](#column-modifiers) must be called before the `constrained` method: $table->foreignId('user_id') - ->nullable() - ->constrained(); + ->nullable() + ->constrained(); #### Dropping Foreign Keys diff --git a/mocking.md b/mocking.md index 186e29f6bdf..28d8bff165b 100644 --- a/mocking.md +++ b/mocking.md @@ -112,9 +112,9 @@ use Illuminate\Support\Facades\Cache; test('get index', function () { Cache::shouldReceive('get') - ->once() - ->with('key') - ->andReturn('value'); + ->once() + ->with('key') + ->andReturn('value'); $response = $this->get('/users'); @@ -135,9 +135,9 @@ class UserControllerTest extends TestCase public function test_get_index(): void { Cache::shouldReceive('get') - ->once() - ->with('key') - ->andReturn('value'); + ->once() + ->with('key') + ->andReturn('value'); $response = $this->get('/users'); diff --git a/notifications.md b/notifications.md index aeea2809029..58dc24b2b4f 100644 --- a/notifications.md +++ b/notifications.md @@ -332,10 +332,10 @@ Sometimes you may need to send a notification to someone who is not stored as a use Illuminate\Support\Facades\Notification; Notification::route('mail', 'taylor@example.com') - ->route('vonage', '5555555555') - ->route('slack', '#slack-channel') - ->route('broadcast', [new Channel('channel-name')]) - ->notify(new InvoicePaid($invoice)); + ->route('vonage', '5555555555') + ->route('slack', '#slack-channel') + ->route('broadcast', [new Channel('channel-name')]) + ->notify(new InvoicePaid($invoice)); If you would like to provide the recipient's name when sending an on-demand notification to the `mail` route, you may provide an array that contains the email address as the key and the name as the value of the first element in the array: @@ -368,11 +368,11 @@ The `MailMessage` class contains a few simple methods to help you build transact $url = url('/invoice/'.$this->invoice->id); return (new MailMessage) - ->greeting('Hello!') - ->line('One of your invoices has been paid!') - ->lineIf($this->amount > 0, "Amount paid: {$this->amount}") - ->action('View Invoice', $url) - ->line('Thank you for using our application!'); + ->greeting('Hello!') + ->line('One of your invoices has been paid!') + ->lineIf($this->amount > 0, "Amount paid: {$this->amount}") + ->action('View Invoice', $url) + ->line('Thank you for using our application!'); } > [!NOTE] @@ -396,9 +396,9 @@ Some notifications inform users of errors, such as a failed invoice payment. You public function toMail(object $notifiable): MailMessage { return (new MailMessage) - ->error() - ->subject('Invoice Payment Failed') - ->line('...'); + ->error() + ->subject('Invoice Payment Failed') + ->line('...'); } @@ -452,8 +452,8 @@ By default, the email's sender / from address is defined in the `config/mail.php public function toMail(object $notifiable): MailMessage { return (new MailMessage) - ->from('barrett@example.com', 'Barrett Blair') - ->line('...'); + ->from('barrett@example.com', 'Barrett Blair') + ->line('...'); } @@ -499,8 +499,8 @@ By default, the email's subject is the class name of the notification formatted public function toMail(object $notifiable): MailMessage { return (new MailMessage) - ->subject('Notification Subject') - ->line('...'); + ->subject('Notification Subject') + ->line('...'); } @@ -514,8 +514,8 @@ By default, the email notification will be sent using the default mailer defined public function toMail(object $notifiable): MailMessage { return (new MailMessage) - ->mailer('postmark') - ->line('...'); + ->mailer('postmark') + ->line('...'); } @@ -538,8 +538,8 @@ To add attachments to an email notification, use the `attach` method while build public function toMail(object $notifiable): MailMessage { return (new MailMessage) - ->greeting('Hello!') - ->attach('/path/to/file'); + ->greeting('Hello!') + ->attach('/path/to/file'); } > [!NOTE] @@ -553,11 +553,11 @@ When attaching files to a message, you may also specify the display name and / o public function toMail(object $notifiable): MailMessage { return (new MailMessage) - ->greeting('Hello!') - ->attach('/path/to/file', [ - 'as' => 'name.pdf', - 'mime' => 'application/pdf', - ]); + ->greeting('Hello!') + ->attach('/path/to/file', [ + 'as' => 'name.pdf', + 'mime' => 'application/pdf', + ]); } Unlike attaching files in mailable objects, you may not attach a file directly from a storage disk using `attachFromStorage`. You should rather use the `attach` method with an absolute path to the file on the storage disk. Alternatively, you could return a [mailable](/docs/{{version}}/mail#generating-mailables) from the `toMail` method: @@ -570,8 +570,8 @@ Unlike attaching files in mailable objects, you may not attach a file directly f public function toMail(object $notifiable): Mailable { return (new InvoicePaidMailable($this->invoice)) - ->to($notifiable->email) - ->attachFromStorage('/path/to/file'); + ->to($notifiable->email) + ->attachFromStorage('/path/to/file'); } When necessary, multiple files may be attached to a message using the `attachMany` method: @@ -582,14 +582,14 @@ When necessary, multiple files may be attached to a message using the `attachMan public function toMail(object $notifiable): MailMessage { return (new MailMessage) - ->greeting('Hello!') - ->attachMany([ - '/path/to/forge.svg', - '/path/to/vapor.svg' => [ - 'as' => 'Logo.svg', - 'mime' => 'image/svg+xml', - ], - ]); + ->greeting('Hello!') + ->attachMany([ + '/path/to/forge.svg', + '/path/to/vapor.svg' => [ + 'as' => 'Logo.svg', + 'mime' => 'image/svg+xml', + ], + ]); } @@ -603,10 +603,10 @@ The `attachData` method may be used to attach a raw string of bytes as an attach public function toMail(object $notifiable): MailMessage { return (new MailMessage) - ->greeting('Hello!') - ->attachData($this->pdf, 'name.pdf', [ - 'mime' => 'application/pdf', - ]); + ->greeting('Hello!') + ->attachData($this->pdf, 'name.pdf', [ + 'mime' => 'application/pdf', + ]); } @@ -620,9 +620,9 @@ Some third-party email providers such as Mailgun and Postmark support message "t public function toMail(object $notifiable): MailMessage { return (new MailMessage) - ->greeting('Comment Upvoted!') - ->tag('upvote') - ->metadata('comment_id', $this->comment->id); + ->greeting('Comment Upvoted!') + ->tag('upvote') + ->metadata('comment_id', $this->comment->id); } 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). @@ -642,11 +642,11 @@ The `withSymfonyMessage` method of the `MailMessage` class allows you to registe public function toMail(object $notifiable): MailMessage { return (new MailMessage) - ->withSymfonyMessage(function (Email $message) { - $message->getHeaders()->addTextHeader( - 'Custom-Header', 'Header Value' - ); - }); + ->withSymfonyMessage(function (Email $message) { + $message->getHeaders()->addTextHeader( + 'Custom-Header', 'Header Value' + ); + }); } @@ -663,7 +663,7 @@ If needed, you may return a full [mailable object](/docs/{{version}}/mail) from public function toMail(object $notifiable): Mailable { return (new InvoicePaidMailable($this->invoice)) - ->to($notifiable->email); + ->to($notifiable->email); } @@ -685,7 +685,7 @@ If you are sending an [on-demand notification](#on-demand-notifications), the `$ : $notifiable->email; return (new InvoicePaidMailable($this->invoice)) - ->to($address); + ->to($address); } @@ -700,7 +700,7 @@ When designing a mail notification template, it is convenient to quickly preview $invoice = Invoice::find(1); return (new InvoicePaid($invoice)) - ->toMail($invoice->user); + ->toMail($invoice->user); }); @@ -727,8 +727,8 @@ Like all other mail notifications, notifications that use Markdown templates sho $url = url('/invoice/'.$this->invoice->id); return (new MailMessage) - ->subject('Invoice Paid') - ->markdown('mail.invoice.paid', ['url' => $url]); + ->subject('Invoice Paid') + ->markdown('mail.invoice.paid', ['url' => $url]); } @@ -813,9 +813,9 @@ To customize the theme for an individual notification, you may call the `theme` public function toMail(object $notifiable): MailMessage { return (new MailMessage) - ->theme('invoice') - ->subject('Invoice Paid') - ->markdown('mail.invoice.paid', ['url' => $url]); + ->theme('invoice') + ->subject('Invoice Paid') + ->markdown('mail.invoice.paid', ['url' => $url]); } @@ -951,8 +951,8 @@ The `broadcast` channel broadcasts notifications using Laravel's [event broadcas All broadcast notifications are queued for broadcasting. If you would like to configure the queue connection or queue name that is used to queue the broadcast operation, you may use the `onConnection` and `onQueue` methods of the `BroadcastMessage`: return (new BroadcastMessage($data)) - ->onConnection('sqs') - ->onQueue('broadcasts'); + ->onConnection('sqs') + ->onQueue('broadcasts'); #### Customizing the Notification Type @@ -1032,7 +1032,7 @@ If a notification supports being sent as an SMS, you should define a `toVonage` public function toVonage(object $notifiable): VonageMessage { return (new VonageMessage) - ->content('Your SMS message content'); + ->content('Your SMS message content'); } @@ -1048,8 +1048,8 @@ If your SMS message will contain unicode characters, you should call the `unicod public function toVonage(object $notifiable): VonageMessage { return (new VonageMessage) - ->content('Your unicode message') - ->unicode(); + ->content('Your unicode message') + ->unicode(); } @@ -1065,8 +1065,8 @@ If you would like to send some notifications from a phone number that is differe public function toVonage(object $notifiable): VonageMessage { return (new VonageMessage) - ->content('Your SMS message content') - ->from('15554443333'); + ->content('Your SMS message content') + ->from('15554443333'); } @@ -1082,8 +1082,8 @@ If you would like to keep track of costs per user, team, or client, you may add public function toVonage(object $notifiable): VonageMessage { return (new VonageMessage) - ->clientReference((string) $notifiable->id) - ->content('Your SMS message content'); + ->clientReference((string) $notifiable->id) + ->content('Your SMS message content'); } @@ -1158,20 +1158,20 @@ If a notification supports being sent as a Slack message, you should define a `t public function toSlack(object $notifiable): SlackMessage { return (new SlackMessage) - ->text('One of your invoices has been paid!') - ->headerBlock('Invoice Paid') - ->contextBlock(function (ContextBlock $block) { - $block->text('Customer #1234'); - }) - ->sectionBlock(function (SectionBlock $block) { - $block->text('An invoice has been paid.'); - $block->field("*Invoice No:*\n1000")->markdown(); - $block->field("*Invoice Recipient:*\ntaylor@laravel.com")->markdown(); - }) - ->dividerBlock() - ->sectionBlock(function (SectionBlock $block) { - $block->text('Congratulations!'); - }); + ->text('One of your invoices has been paid!') + ->headerBlock('Invoice Paid') + ->contextBlock(function (ContextBlock $block) { + $block->text('Customer #1234'); + }) + ->sectionBlock(function (SectionBlock $block) { + $block->text('An invoice has been paid.'); + $block->field("*Invoice No:*\n1000")->markdown(); + $block->field("*Invoice Recipient:*\ntaylor@laravel.com")->markdown(); + }) + ->dividerBlock() + ->sectionBlock(function (SectionBlock $block) { + $block->text('Congratulations!'); + }); } @@ -1209,7 +1209,7 @@ Instead of using the fluent message builder methods to construct your Block Kit JSON; return (new SlackMessage) - ->usingBlockKitTemplate($template); + ->usingBlockKitTemplate($template); } @@ -1230,21 +1230,21 @@ In the following example, which utilizes the `actionsBlock` method, Slack will s public function toSlack(object $notifiable): SlackMessage { return (new SlackMessage) - ->text('One of your invoices has been paid!') - ->headerBlock('Invoice Paid') - ->contextBlock(function (ContextBlock $block) { - $block->text('Customer #1234'); - }) - ->sectionBlock(function (SectionBlock $block) { - $block->text('An invoice has been paid.'); - }) - ->actionsBlock(function (ActionsBlock $block) { - // ID defaults to "button_acknowledge_invoice"... - $block->button('Acknowledge Invoice')->primary(); - - // Manually configure the ID... - $block->button('Deny')->danger()->id('deny_invoice'); - }); + ->text('One of your invoices has been paid!') + ->headerBlock('Invoice Paid') + ->contextBlock(function (ContextBlock $block) { + $block->text('Customer #1234'); + }) + ->sectionBlock(function (SectionBlock $block) { + $block->text('An invoice has been paid.'); + }) + ->actionsBlock(function (ActionsBlock $block) { + // ID defaults to "button_acknowledge_invoice"... + $block->button('Acknowledge Invoice')->primary(); + + // Manually configure the ID... + $block->button('Deny')->danger()->id('deny_invoice'); + }); } @@ -1264,25 +1264,25 @@ If you would like users to be required to confirm an action before it is perform public function toSlack(object $notifiable): SlackMessage { return (new SlackMessage) - ->text('One of your invoices has been paid!') - ->headerBlock('Invoice Paid') - ->contextBlock(function (ContextBlock $block) { - $block->text('Customer #1234'); - }) - ->sectionBlock(function (SectionBlock $block) { - $block->text('An invoice has been paid.'); - }) - ->actionsBlock(function (ActionsBlock $block) { - $block->button('Acknowledge Invoice') - ->primary() - ->confirm( - 'Acknowledge the payment and send a thank you email?', - function (ConfirmObject $dialog) { - $dialog->confirm('Yes'); - $dialog->deny('No'); - } - ); - }); + ->text('One of your invoices has been paid!') + ->headerBlock('Invoice Paid') + ->contextBlock(function (ContextBlock $block) { + $block->text('Customer #1234'); + }) + ->sectionBlock(function (SectionBlock $block) { + $block->text('An invoice has been paid.'); + }) + ->actionsBlock(function (ActionsBlock $block) { + $block->button('Acknowledge Invoice') + ->primary() + ->confirm( + 'Acknowledge the payment and send a thank you email?', + function (ConfirmObject $dialog) { + $dialog->confirm('Yes'); + $dialog->deny('No'); + } + ); + }); } diff --git a/octane.md b/octane.md index 1a4d891abaf..343eb97d931 100644 --- a/octane.md +++ b/octane.md @@ -589,15 +589,15 @@ In this example, we will register a closure to be invoked every 10 seconds. Typi ```php Octane::tick('simple-ticker', fn () => ray('Ticking...')) - ->seconds(10); + ->seconds(10); ``` Using the `immediate` method, you may instruct Octane to immediately invoke the tick callback when the Octane server initially boots, and every N seconds thereafter: ```php Octane::tick('simple-ticker', fn () => ray('Ticking...')) - ->seconds(10) - ->immediate(); + ->seconds(10) + ->immediate(); ``` diff --git a/processes.md b/processes.md index 46051b96b84..7195f182029 100644 --- a/processes.md +++ b/processes.md @@ -111,16 +111,16 @@ Environment variables may be provided to the process via the `env` method. The i ```php $result = Process::forever() - ->env(['IMPORT_PATH' => __DIR__]) - ->run('bash import.sh'); + ->env(['IMPORT_PATH' => __DIR__]) + ->run('bash import.sh'); ``` If you wish to remove an inherited environment variable from the invoked process, you may provide that environment variable with a value of `false`: ```php $result = Process::forever() - ->env(['LOAD_PATH' => false]) - ->run('bash import.sh'); + ->env(['LOAD_PATH' => false]) + ->run('bash import.sh'); ``` @@ -504,8 +504,8 @@ If the code you are testing invokes multiple processes with the same command, yo ```php Process::fake([ 'ls *' => Process::sequence() - ->push(Process::result('First invocation')) - ->push(Process::result('Second invocation')), + ->push(Process::result('First invocation')) + ->push(Process::result('Second invocation')), ]); ``` @@ -537,11 +537,11 @@ To properly fake this process, we need to be able to describe how many times the ```php Process::fake([ 'bash import.sh' => Process::describe() - ->output('First line of standard output') - ->errorOutput('First line of error output') - ->output('Second line of standard output') - ->exitCode(0) - ->iterations(3), + ->output('First line of standard output') + ->errorOutput('First line of error output') + ->output('Second line of standard output') + ->exitCode(0) + ->iterations(3), ]); ``` diff --git a/queries.md b/queries.md index 8852b192c8c..72e474e858e 100644 --- a/queries.md +++ b/queries.md @@ -169,8 +169,8 @@ DB::table('users')->where(function ($query) { })->chunkById(100, function (Collection $users) { foreach ($users as $user) { DB::table('users') - ->where('id', $user->id) - ->update(['credits' => 3]); + ->where('id', $user->id) + ->update(['credits' => 3]); } }); ``` @@ -380,7 +380,7 @@ If you would like to use a "where" clause on your joins, you may use the `where` DB::table('users') ->join('contacts', function (JoinClause $join) { $join->on('users.id', '=', 'contacts.user_id') - ->where('contacts.user_id', '>', 5); + ->where('contacts.user_id', '>', 5); }) ->get(); @@ -1137,8 +1137,8 @@ In the example above, Laravel will attempt to insert two records. If a record al In addition to inserting records into the database, the query builder can also update existing records using the `update` method. The `update` method, like the `insert` method, accepts an array of column and value pairs indicating the columns to be updated. The `update` method returns the number of affected rows. You may constrain the `update` query using `where` clauses: $affected = DB::table('users') - ->where('id', 1) - ->update(['votes' => 1]); + ->where('id', 1) + ->update(['votes' => 1]); #### Update or Insert diff --git a/queues.md b/queues.md index e1a54c79db0..edef55942a1 100644 --- a/queues.md +++ b/queues.md @@ -415,16 +415,16 @@ Instead of rate limiting in the handle method, we could define a job middleware public function handle(object $job, Closure $next): void { Redis::throttle('key') - ->block(0)->allow(1)->every(5) - ->then(function () use ($job, $next) { - // Lock obtained... - - $next($job); - }, function () use ($job) { - // Could not obtain lock... - - $job->release(5); - }); + ->block(0)->allow(1)->every(5) + ->then(function () use ($job, $next) { + // Lock obtained... + + $next($job); + }, function () use ($job) { + // Could not obtain lock... + + $job->release(5); + }); } } @@ -790,7 +790,7 @@ If you would like to specify that a job should not be immediately available for // ... ProcessPodcast::dispatch($podcast) - ->delay(now()->addMinutes(10)); + ->delay(now()->addMinutes(10)); return redirect('/podcasts'); } @@ -1058,8 +1058,8 @@ If your application interacts with multiple queue connections, you may specify w You may chain the `onConnection` and `onQueue` methods together to specify the connection and the queue for a job: ProcessPodcast::dispatch($podcast) - ->onConnection('sqs') - ->onQueue('processing'); + ->onConnection('sqs') + ->onQueue('processing'); Alternatively, you may specify the job's connection by calling the `onConnection` method within the job's constructor: @@ -2186,11 +2186,11 @@ public function boot(): void { Event::listen(function (QueueBusy $event) { Notification::route('mail', 'dev@example.com') - ->notify(new QueueHasLongWaitTime( - $event->connection, - $event->queue, - $event->size - )); + ->notify(new QueueHasLongWaitTime( + $event->connection, + $event->queue, + $event->size + )); }); } ``` diff --git a/responses.md b/responses.md index 559ed9f3fab..68ef7b3bcdc 100644 --- a/responses.md +++ b/responses.md @@ -47,7 +47,7 @@ Returning a full `Response` instance allows you to customize the response's HTTP Route::get('/home', function () { return response('Hello World', 200) - ->header('Content-Type', 'text/plain'); + ->header('Content-Type', 'text/plain'); }); @@ -67,18 +67,18 @@ You may also return [Eloquent ORM](/docs/{{version}}/eloquent) models and collec Keep in mind that most response methods are chainable, allowing for the fluent construction of response instances. For example, you may use the `header` method to add a series of headers to the response before sending it back to the user: return response($content) - ->header('Content-Type', $type) - ->header('X-Header-One', 'Header Value') - ->header('X-Header-Two', 'Header Value'); + ->header('Content-Type', $type) + ->header('X-Header-One', 'Header Value') + ->header('X-Header-Two', 'Header Value'); Or, you may use the `withHeaders` method to specify an array of headers to be added to the response: return response($content) - ->withHeaders([ - 'Content-Type' => $type, - 'X-Header-One' => 'Header Value', - 'X-Header-Two' => 'Header Value', - ]); + ->withHeaders([ + 'Content-Type' => $type, + 'X-Header-One' => 'Header Value', + 'X-Header-Two' => 'Header Value', + ]); #### Cache Control Middleware @@ -255,8 +255,8 @@ The `response` helper may be used to generate other types of response instances. If you need control over the response's status and headers but also need to return a [view](/docs/{{version}}/views) as the response's content, you should use the `view` method: return response() - ->view('hello', $data, 200) - ->header('Content-Type', $type); + ->view('hello', $data, 200) + ->header('Content-Type', $type); Of course, if you do not need to pass a custom HTTP status code or custom headers, you may use the global `view` helper function. @@ -273,8 +273,8 @@ The `json` method will automatically set the `Content-Type` header to `applicati If you would like to create a JSONP response, you may use the `json` method in combination with the `withCallback` method: return response() - ->json(['name' => 'Abigail', 'state' => 'CA']) - ->withCallback($request->input('callback')); + ->json(['name' => 'Abigail', 'state' => 'CA']) + ->withCallback($request->input('callback')); ### File Downloads @@ -343,8 +343,8 @@ Sometimes you may wish to turn the string response of a given operation into a d return response()->streamDownload(function () { echo GitHub::api('repo') - ->contents() - ->readme('laravel', 'laravel')['contents']; + ->contents() + ->readme('laravel', 'laravel')['contents']; }, 'laravel-readme.md'); diff --git a/routing.md b/routing.md index 14ca74b0302..debcd9bd6f2 100644 --- a/routing.md +++ b/routing.md @@ -620,10 +620,10 @@ Typically, a 404 HTTP response will be generated if an implicitly bound model is use Illuminate\Support\Facades\Redirect; Route::get('/locations/{location:slug}', [LocationsController::class, 'show']) - ->name('locations.view') - ->missing(function (Request $request) { - return Redirect::route('locations.index'); - }); + ->name('locations.view') + ->missing(function (Request $request) { + return Redirect::route('locations.index'); + }); ### Implicit Enum Binding diff --git a/scheduling.md b/scheduling.md index f8ae4b4f0ed..77fa6c1ddbb 100644 --- a/scheduling.md +++ b/scheduling.md @@ -175,10 +175,10 @@ These methods may be combined with additional constraints to create even more fi // Run hourly from 8 AM to 5 PM on weekdays... Schedule::command('foo') - ->weekdays() - ->hourly() - ->timezone('America/Chicago') - ->between('8:00', '17:00'); + ->weekdays() + ->hourly() + ->timezone('America/Chicago') + ->between('8:00', '17:00'); A list of additional schedule constraints may be found below: @@ -211,8 +211,8 @@ The `days` method may be used to limit the execution of a task to specific days use Illuminate\Support\Facades\Schedule; Schedule::command('emails:send') - ->hourly() - ->days([0, 3]); + ->hourly() + ->days([0, 3]); Alternatively, you may use the constants available on the `Illuminate\Console\Scheduling\Schedule` class when defining the days on which a task should run: @@ -220,8 +220,8 @@ Alternatively, you may use the constants available on the `Illuminate\Console\Sc use Illuminate\Console\Scheduling\Schedule; Facades\Schedule::command('emails:send') - ->hourly() - ->days([Schedule::SUNDAY, Schedule::WEDNESDAY]); + ->hourly() + ->days([Schedule::SUNDAY, Schedule::WEDNESDAY]); #### Between Time Constraints @@ -229,14 +229,14 @@ Alternatively, you may use the constants available on the `Illuminate\Console\Sc The `between` method may be used to limit the execution of a task based on the time of day: Schedule::command('emails:send') - ->hourly() - ->between('7:00', '22:00'); + ->hourly() + ->between('7:00', '22:00'); Similarly, the `unlessBetween` method can be used to exclude the execution of a task for a period of time: Schedule::command('emails:send') - ->hourly() - ->unlessBetween('23:00', '4:00'); + ->hourly() + ->unlessBetween('23:00', '4:00'); #### Truth Test Constraints @@ -261,8 +261,8 @@ When using chained `when` methods, the scheduled command will only execute if al The `environments` method may be used to execute tasks only on the given environments (as defined by the `APP_ENV` [environment variable](/docs/{{version}}/configuration#environment-configuration)): Schedule::command('emails:send') - ->daily() - ->environments(['staging', 'production']); + ->daily() + ->environments(['staging', 'production']); ### Timezones @@ -272,8 +272,8 @@ Using the `timezone` method, you may specify that a scheduled task's time should use Illuminate\Support\Facades\Schedule; Schedule::command('report:generate') - ->timezone('America/New_York') - ->at('2:00') + ->timezone('America/New_York') + ->at('2:00') If you are repeatedly assigning the same timezone to all of your scheduled tasks, you can specify which timezone should be assigned to all schedules by defining a `schedule_timezone` option within your application's `app` configuration file: @@ -314,9 +314,9 @@ To indicate that the task should run on only one server, use the `onOneServer` m use Illuminate\Support\Facades\Schedule; Schedule::command('report:generate') - ->fridays() - ->at('17:00') - ->onOneServer(); + ->fridays() + ->at('17:00') + ->onOneServer(); #### Naming Single Server Jobs @@ -325,14 +325,14 @@ Sometimes you may need to schedule the same job to be dispatched with different ```php Schedule::job(new CheckUptime('https://laravel.com')) - ->name('check_uptime:laravel.com') - ->everyFiveMinutes() - ->onOneServer(); + ->name('check_uptime:laravel.com') + ->everyFiveMinutes() + ->onOneServer(); Schedule::job(new CheckUptime('https://vapor.laravel.com')) - ->name('check_uptime:vapor.laravel.com') - ->everyFiveMinutes() - ->onOneServer(); + ->name('check_uptime:vapor.laravel.com') + ->everyFiveMinutes() + ->onOneServer(); ``` Similarly, scheduled closures must be assigned a name if they are intended to be run on one server: @@ -352,8 +352,8 @@ By default, multiple tasks scheduled at the same time will execute sequentially use Illuminate\Support\Facades\Schedule; Schedule::command('analytics:report') - ->daily() - ->runInBackground(); + ->daily() + ->runInBackground(); > [!WARNING] > The `runInBackground` method may only be used when scheduling tasks via the `command` and `exec` methods. @@ -444,27 +444,27 @@ The Laravel scheduler provides several convenient methods for working with the o use Illuminate\Support\Facades\Schedule; Schedule::command('emails:send') - ->daily() - ->sendOutputTo($filePath); + ->daily() + ->sendOutputTo($filePath); If you would like to append the output to a given file, you may use the `appendOutputTo` method: Schedule::command('emails:send') - ->daily() - ->appendOutputTo($filePath); + ->daily() + ->appendOutputTo($filePath); Using the `emailOutputTo` method, you may email the output to an email address of your choice. Before emailing the output of a task, you should configure Laravel's [email services](/docs/{{version}}/mail): Schedule::command('report:generate') - ->daily() - ->sendOutputTo($filePath) - ->emailOutputTo('taylor@example.com'); + ->daily() + ->sendOutputTo($filePath) + ->emailOutputTo('taylor@example.com'); If you only want to email the output if the scheduled Artisan or system command terminates with a non-zero exit code, use the `emailOutputOnFailure` method: Schedule::command('report:generate') - ->daily() - ->emailOutputOnFailure('taylor@example.com'); + ->daily() + ->emailOutputOnFailure('taylor@example.com'); > [!WARNING] > The `emailOutputTo`, `emailOutputOnFailure`, `sendOutputTo`, and `appendOutputTo` methods are exclusive to the `command` and `exec` methods. @@ -477,37 +477,37 @@ Using the `before` and `after` methods, you may specify code to be executed befo use Illuminate\Support\Facades\Schedule; Schedule::command('emails:send') - ->daily() - ->before(function () { - // The task is about to execute... - }) - ->after(function () { - // The task has executed... - }); + ->daily() + ->before(function () { + // The task is about to execute... + }) + ->after(function () { + // The task has executed... + }); The `onSuccess` and `onFailure` methods allow you to specify code to be executed if the scheduled 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() - ->onSuccess(function () { - // The task succeeded... - }) - ->onFailure(function () { - // The task failed... - }); + ->daily() + ->onSuccess(function () { + // The task succeeded... + }) + ->onFailure(function () { + // The task failed... + }); If output is available from your command, you may access it in your `after`, `onSuccess` or `onFailure` hooks by type-hinting an `Illuminate\Support\Stringable` instance as the `$output` argument of your hook's closure definition: use Illuminate\Support\Stringable; Schedule::command('emails:send') - ->daily() - ->onSuccess(function (Stringable $output) { - // The task succeeded... - }) - ->onFailure(function (Stringable $output) { - // The task failed... - }); + ->daily() + ->onSuccess(function (Stringable $output) { + // The task succeeded... + }) + ->onFailure(function (Stringable $output) { + // The task failed... + }); #### Pinging URLs @@ -515,28 +515,28 @@ If output is available from your command, you may access it in your `after`, `on Using the `pingBefore` and `thenPing` methods, the scheduler can automatically ping a given URL before or after a task is executed. This method is useful for notifying an external service, such as [Envoyer](https://envoyer.io), that your scheduled task is beginning or has finished execution: Schedule::command('emails:send') - ->daily() - ->pingBefore($url) - ->thenPing($url); + ->daily() + ->pingBefore($url) + ->thenPing($url); 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() - ->pingOnSuccess($successUrl) - ->pingOnFailure($failureUrl); + ->daily() + ->pingOnSuccess($successUrl) + ->pingOnFailure($failureUrl); 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() - ->pingBeforeIf($condition, $url) - ->thenPingIf($condition, $url); + ->daily() + ->pingBeforeIf($condition, $url) + ->thenPingIf($condition, $url); Schedule::command('emails:send') - ->daily() - ->pingOnSuccessIf($condition, $successUrl) - ->pingOnFailureIf($condition, $failureUrl); + ->daily() + ->pingOnSuccessIf($condition, $successUrl) + ->pingOnFailureIf($condition, $failureUrl); ## Events diff --git a/seeding.md b/seeding.md index 400bbcb308d..94433c619be 100644 --- a/seeding.md +++ b/seeding.md @@ -70,9 +70,9 @@ For example, let's create 50 users that each has one related post: public function run(): void { User::factory() - ->count(50) - ->hasPosts(1) - ->create(); + ->count(50) + ->hasPosts(1) + ->create(); } diff --git a/strings.md b/strings.md index f5b1b957326..15166f189fd 100644 --- a/strings.md +++ b/strings.md @@ -2860,9 +2860,9 @@ The `when` method invokes the given closure if a given condition is `true`. The use Illuminate\Support\Stringable; $string = Str::of('Taylor') - ->when(true, function (Stringable $string) { - return $string->append(' Otwell'); - }); + ->when(true, function (Stringable $string) { + return $string->append(' Otwell'); + }); // 'Taylor Otwell' @@ -2877,9 +2877,9 @@ The `whenContains` method invokes the given closure if the string contains the g use Illuminate\Support\Stringable; $string = Str::of('tony stark') - ->whenContains('tony', function (Stringable $string) { - return $string->title(); - }); + ->whenContains('tony', function (Stringable $string) { + return $string->title(); + }); // 'Tony Stark' @@ -2891,9 +2891,9 @@ You may also pass an array of values to determine if the given string contains a use Illuminate\Support\Stringable; $string = Str::of('tony stark') - ->whenContains(['tony', 'hulk'], function (Stringable $string) { - return $string->title(); - }); + ->whenContains(['tony', 'hulk'], function (Stringable $string) { + return $string->title(); + }); // Tony Stark @@ -2906,9 +2906,9 @@ The `whenContainsAll` method invokes the given closure if the string contains al use Illuminate\Support\Stringable; $string = Str::of('tony stark') - ->whenContainsAll(['tony', 'stark'], function (Stringable $string) { - return $string->title(); - }); + ->whenContainsAll(['tony', 'stark'], function (Stringable $string) { + return $string->title(); + }); // 'Tony Stark' diff --git a/views.md b/views.md index 6f9d3fc2ae2..d57a46f1cce 100644 --- a/views.md +++ b/views.md @@ -112,8 +112,8 @@ When passing information in this manner, the data should be an array with key / As an alternative to passing a complete array of data to the `view` helper function, you may use the `with` method to add individual pieces of data to the view. The `with` method returns an instance of the view object so that you can continue chaining methods before returning the view: return view('greeting') - ->with('name', 'Victoria') - ->with('occupation', 'Astronaut'); + ->with('name', 'Victoria') + ->with('occupation', 'Astronaut'); ### Sharing Data With All Views