You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use a single indent for chains on a new line, rather than trying to align it with some arbitrary pattern in the first line. this arbitrary alignment very easily gets out of sync as changes occur to the code, and often times the adjustments are not made to the chained alignment. the single indent alignment does not suffer this problem.
this is to bring us in line with laravel/framework#53835 and laravel/framework#53748
this commit only contains whitespace changes.
if accepted, I will make these adjustments to the remaining docs pages.
Copy file name to clipboardExpand all lines: billing.md
+20-20
Original file line number
Diff line number
Diff line change
@@ -842,8 +842,8 @@ The amount of time a customer has to pay their invoice before their subscription
842
842
If you would like to set a specific [quantity](https://stripe.com/docs/billing/subscriptions/quantities) for the price when creating the subscription, you should invoke the `quantity` method on the subscription builder before creating the subscription:
Or, if you would like to apply a [Stripe promotion code](https://stripe.com/docs/billing/subscriptions/discounts/codes), you may use the `withPromotionCode` method:
The given promotion code ID should be the Stripe API ID assigned to the promotion code and not the customer facing promotion code. If you need to find a promotion code ID based on a given customer facing promotion code, you may use the `findPromotionCode` method:
875
875
@@ -1104,8 +1104,8 @@ If the customer is on trial, the trial period will be maintained. Additionally,
1104
1104
If you would like to swap prices and cancel any trial period the customer is currently on, you may invoke the `skipTrial` method:
1105
1105
1106
1106
$user->subscription('default')
1107
-
->skipTrial()
1108
-
->swap('price_yearly');
1107
+
->skipTrial()
1108
+
->swap('price_yearly');
1109
1109
1110
1110
If you would like to swap prices and immediately invoice the customer instead of waiting for their next billing cycle, you may use the `swapAndInvoice` method:
1111
1111
@@ -1237,8 +1237,8 @@ If you want to swap a single price on a subscription, you may do so using the `s
1237
1237
$user = User::find(1);
1238
1238
1239
1239
$user->subscription('default')
1240
-
->findItemOrFail('price_basic')
1241
-
->swap('price_pro');
1240
+
->findItemOrFail('price_basic')
1241
+
->swap('price_pro');
1242
1242
1243
1243
<aname="proration"></a>
1244
1244
#### Proration
@@ -1329,9 +1329,9 @@ To start using usage billing, you will first need to create a new product in you
1329
1329
You may also start a metered subscription via [Stripe Checkout](#checkout):
1330
1330
1331
1331
$checkout = Auth::user()
1332
-
->newSubscription('default', [])
1333
-
->meteredPrice('price_metered')
1334
-
->checkout();
1332
+
->newSubscription('default', [])
1333
+
->meteredPrice('price_metered')
1334
+
->checkout();
1335
1335
1336
1336
return view('your-checkout-view', [
1337
1337
'checkout' => $checkout,
@@ -1441,8 +1441,8 @@ By default, the billing cycle anchor is the date the subscription was created or
1441
1441
$anchor = Carbon::parse('first day of next month');
You may determine if a user is within their trial period using either the `onTrial` method of the user instance or the `onTrial` method of the subscription instance. The two examples below are equivalent:
1530
1530
@@ -2131,7 +2131,7 @@ First, you could redirect your customer to the dedicated payment confirmation pa
Within a sequence closure, you may access the `$index` or `$count` properties on the sequence instance that is injected into the closure. The `$index` property contains the number of iterations through the sequence that have occurred thus far, while the `$count` property contains the total number of times the sequence will be invoked:
For convenience, sequences may also be applied using the `sequence` method, which simply invokes the `state` method internally. The `sequence` method accepts a closure or arrays of sequenced attributes:
298
298
299
299
$users = User::factory()
300
-
->count(2)
301
-
->sequence(
302
-
['name' => 'First User'],
303
-
['name' => 'Second User'],
304
-
)
305
-
->create();
300
+
->count(2)
301
+
->sequence(
302
+
['name' => 'First User'],
303
+
['name' => 'Second User'],
304
+
)
305
+
->create();
306
306
307
307
<aname="factory-relationships"></a>
308
308
## Factory Relationships
@@ -316,51 +316,51 @@ Next, let's explore building Eloquent model relationships using Laravel's fluent
316
316
use App\Models\User;
317
317
318
318
$user = User::factory()
319
-
->has(Post::factory()->count(3))
320
-
->create();
319
+
->has(Post::factory()->count(3))
320
+
->create();
321
321
322
322
By convention, when passing a `Post` model to the `has` method, Laravel will assume that the `User` model must have a `posts` method that defines the relationship. If necessary, you may explicitly specify the name of the relationship that you would like to manipulate:
323
323
324
324
$user = User::factory()
325
-
->has(Post::factory()->count(3), 'posts')
326
-
->create();
325
+
->has(Post::factory()->count(3), 'posts')
326
+
->create();
327
327
328
328
Of course, you may perform state manipulations on the related models. In addition, you may pass a closure based state transformation if your state change requires access to the parent model:
329
329
330
330
$user = User::factory()
331
-
->has(
332
-
Post::factory()
333
-
->count(3)
334
-
->state(function (array $attributes, User $user) {
335
-
return ['user_type' => $user->type];
336
-
})
337
-
)
338
-
->create();
331
+
->has(
332
+
Post::factory()
333
+
->count(3)
334
+
->state(function (array $attributes, User $user) {
For convenience, you may use Laravel's magic factory relationship methods to build relationships. For example, the following example will use convention to determine that the related models should be created via a `posts` relationship method on the `User` model:
344
344
345
345
$user = User::factory()
346
-
->hasPosts(3)
347
-
->create();
346
+
->hasPosts(3)
347
+
->create();
348
348
349
349
When using magic methods to create factory relationships, you may pass an array of attributes to override on the related models:
350
350
351
351
$user = User::factory()
352
-
->hasPosts(3, [
353
-
'published' => false,
354
-
])
355
-
->create();
352
+
->hasPosts(3, [
353
+
'published' => false,
354
+
])
355
+
->create();
356
356
357
357
You may provide a closure based state transformation if your state change requires access to the parent model:
358
358
359
359
$user = User::factory()
360
-
->hasPosts(3, function (array $attributes, User $user) {
361
-
return ['user_type' => $user->type];
362
-
})
363
-
->create();
360
+
->hasPosts(3, function (array $attributes, User $user) {
361
+
return ['user_type' => $user->type];
362
+
})
363
+
->create();
364
364
365
365
<aname="belongs-to-relationships"></a>
366
366
### Belongs To Relationships
@@ -371,32 +371,32 @@ Now that we have explored how to build "has many" relationships using factories,
371
371
use App\Models\User;
372
372
373
373
$posts = Post::factory()
374
-
->count(3)
375
-
->for(User::factory()->state([
376
-
'name' => 'Jessica Archer',
377
-
]))
378
-
->create();
374
+
->count(3)
375
+
->for(User::factory()->state([
376
+
'name' => 'Jessica Archer',
377
+
]))
378
+
->create();
379
379
380
380
If you already have a parent model instance that should be associated with the models you are creating, you may pass the model instance to the `for` method:
For convenience, you may use Laravel's magic factory relationship methods to define "belongs to" relationships. For example, the following example will use convention to determine that the three posts should belong to the `user` relationship on the `Post` model:
393
393
394
394
$posts = Post::factory()
395
-
->count(3)
396
-
->forUser([
397
-
'name' => 'Jessica Archer',
398
-
])
399
-
->create();
395
+
->count(3)
396
+
->forUser([
397
+
'name' => 'Jessica Archer',
398
+
])
399
+
->create();
400
400
401
401
<aname="many-to-many-relationships"></a>
402
402
### Many to Many Relationships
@@ -407,8 +407,8 @@ Like [has many relationships](#has-many-relationships), "many to many" relations
407
407
use App\Models\User;
408
408
409
409
$user = User::factory()
410
-
->has(Role::factory()->count(3))
411
-
->create();
410
+
->has(Role::factory()->count(3))
411
+
->create();
412
412
413
413
<aname="pivot-table-attributes"></a>
414
414
#### Pivot Table Attributes
@@ -419,44 +419,44 @@ If you need to define attributes that should be set on the pivot / intermediate
419
419
use App\Models\User;
420
420
421
421
$user = User::factory()
422
-
->hasAttached(
423
-
Role::factory()->count(3),
424
-
['active' => true]
425
-
)
426
-
->create();
422
+
->hasAttached(
423
+
Role::factory()->count(3),
424
+
['active' => true]
425
+
)
426
+
->create();
427
427
428
428
You may provide a closure based state transformation if your state change requires access to the related model:
429
429
430
430
$user = User::factory()
431
-
->hasAttached(
432
-
Role::factory()
433
-
->count(3)
434
-
->state(function (array $attributes, User $user) {
435
-
return ['name' => $user->name.' Role'];
436
-
}),
437
-
['active' => true]
438
-
)
439
-
->create();
431
+
->hasAttached(
432
+
Role::factory()
433
+
->count(3)
434
+
->state(function (array $attributes, User $user) {
435
+
return ['name' => $user->name.' Role'];
436
+
}),
437
+
['active' => true]
438
+
)
439
+
->create();
440
440
441
441
If you already have model instances that you would like to be attached to the models you are creating, you may pass the model instances to the `hasAttached` method. In this example, the same three roles will be attached to all three users:
For convenience, you may use Laravel's magic factory relationship methods to define many to many relationships. For example, the following example will use convention to determine that the related models should be created via a `roles` relationship method on the `User` model:
454
454
455
455
$user = User::factory()
456
-
->hasRoles(1, [
457
-
'name' => 'Editor'
458
-
])
459
-
->create();
456
+
->hasRoles(1, [
457
+
'name' => 'Editor'
458
+
])
459
+
->create();
460
460
461
461
<aname="polymorphic-relationships"></a>
462
462
### Polymorphic Relationships
@@ -485,17 +485,17 @@ Polymorphic "many to many" (`morphToMany` / `morphedByMany`) relationships may b
485
485
use App\Models\Video;
486
486
487
487
$videos = Video::factory()
488
-
->hasAttached(
489
-
Tag::factory()->count(3),
490
-
['public' => true]
491
-
)
492
-
->create();
488
+
->hasAttached(
489
+
Tag::factory()->count(3),
490
+
['public' => true]
491
+
)
492
+
->create();
493
493
494
494
Of course, the magic `has` method may also be used to create polymorphic "many to many" relationships:
0 commit comments