Skip to content

Commit fbc228a

Browse files
committed
Merge branch '5.4'
2 parents d2884d9 + 561e9b5 commit fbc228a

7 files changed

+56
-6
lines changed

billing.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ First, add the Cashier package for Braintree to your dependencies:
117117

118118
#### Service Provider
119119

120-
Next, register the `Laravel\Cashier\CashierServiceProvider` [service provider](/docs/{{version}}/providers) in your `config/app.php` configuration file.
120+
Next, register the `Laravel\Cashier\CashierServiceProvider` [service provider](/docs/{{version}}/providers) in your `config/app.php` configuration file:
121+
122+
Laravel\Cashier\CashierServiceProvider::class
121123

122124
#### Plan Credit Coupon
123125

@@ -200,7 +202,7 @@ To create a subscription, first retrieve an instance of your billable model, whi
200202

201203
$user = User::find(1);
202204

203-
$user->newSubscription('main', 'monthly')->create($stripeToken);
205+
$user->newSubscription('main', 'premium')->create($stripeToken);
204206

205207
The first argument passed to the `newSubscription` method should be the name of the subscription. If your application only offers a single subscription, you might call this `main` or `primary`. The second argument is the specific Stripe / Braintree plan the user is subscribing to. This value should correspond to the plan's identifier in Stripe or Braintree.
206208

container.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ You may also bind an existing object instance into the container using the `inst
9999

100100
$api = new HelpSpot\API(new HttpClient);
101101

102-
$this->app->instance('HelpSpot\Api', $api);
102+
$this->app->instance('HelpSpot\API', $api);
103103

104104
#### Binding Primitives
105105

eloquent-relationships.md

+35
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,41 @@ If your parent model does not use `id` as its primary key, or you wish to join t
120120
return $this->belongsTo('App\User', 'foreign_key', 'other_key');
121121
}
122122

123+
<a name="default-models"></a>
124+
#### Default Models
125+
126+
The `belongsTo` relationship allows you to define a default model that will be returned if the given relationship is `null`. This pattern is often referred to as the [Null Object pattern](https://en.wikipedia.org/wiki/Null_Object_pattern) and can help remove conditional checks in your code. In the following example, the `user` relation will return an empty `App\User` model if no `user` is attached to the post:
127+
128+
/**
129+
* Get the author of the post.
130+
*/
131+
public function user()
132+
{
133+
return $this->belongsTo('App\User')->withDefault();
134+
}
135+
136+
To populate the default model with attributes, you may pass an array or Closure to the `withDefault` method:
137+
138+
/**
139+
* Get the author of the post.
140+
*/
141+
public function user()
142+
{
143+
return $this->belongsTo('App\User')->withDefault([
144+
'name' => 'Guest Author',
145+
]);
146+
}
147+
148+
/**
149+
* Get the author of the post.
150+
*/
151+
public function user()
152+
{
153+
return $this->belongsTo('App\User')->withDefault(function ($user) {
154+
$user->name = 'Guest Author';
155+
});
156+
}
157+
123158
<a name="one-to-many"></a>
124159
### One To Many
125160

notifications.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ Before you can send notifications via Slack, you must install the Guzzle HTTP li
630630

631631
composer require guzzlehttp/guzzle
632632

633-
You will also need to configure an "Incoming Webhook" integration for your Slack team. This integration will provide you with a URL you may use when [routing Slack notifications](#routing-slack-notifications).
633+
You will also need to configure an ["Incoming Webhook"](https://api.slack.com/incoming-webhooks) integration for your Slack team. This integration will provide you with a URL you may use when [routing Slack notifications](#routing-slack-notifications).
634634

635635
<a name="formatting-slack-notifications"></a>
636636
### Formatting Slack Notifications

scout.md

+4
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ Since Scout searches return a collection of Eloquent models, you may even return
235235
return App\Order::search($request->search)->get();
236236
});
237237

238+
If you would like to get the raw results before they are converted to Eloquent models, you should use the `raw` method:
239+
240+
$orders = App\Order::search('Star Trek')->raw();
241+
238242
<a name="where-clauses"></a>
239243
### Where Clauses
240244

upgrade.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ In order to allow Laravel to autoload any new tests you generate using the Larav
397397

398398
First install the `laravel/browser-kit-testing` package:
399399

400-
composer require laravel/browser-kit-testing --dev
400+
composer require laravel/browser-kit-testing="1.*" --dev
401401

402402
Once the package has been installed, create a copy of your `tests/TestCase.php` file and save it to your `tests` directory as `BrowserKitTestCase.php`. Then, modify the file to extend the `Laravel\BrowserKitTesting\TestCase` class. Once you have done this, you should have two base test classes in your `tests` directory: `TestCase.php` and `BrowserKitTestCase.php`. In order for your `BrowserKitTestCase` class to be properly loaded, you may need to add it to your `composer.json` file:
403403

validation.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,16 @@ The field under validation may be `null`. This is particularly useful when valid
828828
<a name="rule-not-in"></a>
829829
#### not_in:_foo_,_bar_,...
830830

831-
The field under validation must not be included in the given list of values.
831+
The field under validation must not be included in the given list of values. The `Rule::notIn` method may be used to fluently construct the rule:
832+
833+
use Illuminate\Validation\Rule;
834+
835+
Validator::make($data, [
836+
'toppings' => [
837+
'required',
838+
Rule::notIn(['sprinkles', 'cherries']),
839+
],
840+
]);
832841

833842
<a name="rule-numeric"></a>
834843
#### numeric

0 commit comments

Comments
 (0)