Skip to content

Commit

Permalink
Merge remote-tracking branch 'laravel/5.2' into 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
curogihu committed Feb 9, 2016
2 parents 14af7a5 + 3d770c1 commit 6575c1d
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 15 deletions.
4 changes: 4 additions & 0 deletions authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,4 +586,8 @@ Laravel raises a variety of [events](/docs/{{version}}/events) during the authen
'Illuminate\Auth\Events\Logout' => [
'App\Listeners\LogSuccessfulLogout',
],

'Illuminate\Auth\Events\Lockout' => [
'App\Listeners\LogLockout',
],
];
2 changes: 1 addition & 1 deletion billing.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ To cancel a subscription, simply call the `cancel` method on the user's subscrip

$user->subscription('main')->cancel();

When a subscription is cancelled, Cashier will automatically set the `subscription_ends_at` column in your database. This column is used to know when the `subscribed` method should begin returning `false`. For example, if a customer cancels a subscription on March 1st, but the subscription was not scheduled to end until March 5th, the `subscribed` method will continue to return `true` until March 5th.
When a subscription is cancelled, Cashier will automatically set the `ends_at` column in your database. This column is used to know when the `subscribed` method should begin returning `false`. For example, if a customer cancels a subscription on March 1st, but the subscription was not scheduled to end until March 5th, the `subscribed` method will continue to return `true` until March 5th.

You may determine if a user has cancelled their subscription but are still on their "grace period" using the `onGracePeriod` method:

Expand Down
34 changes: 33 additions & 1 deletion collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ You may select any method from this table to see an example of its usage:
[values](#method-values)
[where](#method-where)
[whereLoose](#method-whereloose)
[whereIn](#method-wherein)
[whereInLoose](#method-whereinloose)
[zip](#method-zip)
</div>

Expand Down Expand Up @@ -1231,13 +1233,43 @@ The `where` method filters the collection by a given key / value pair:
]
*/

The `where` method uses strict comparisons when checking item values. Use the [`whereLoose`](#where-loose) method to filter using "loose" comparisons.
The `where` method uses strict comparisons when checking item values. Use the [`whereLoose`](#method-whereloose) method to filter using "loose" comparisons.

<a name="method-whereloose"></a>
#### `whereLoose()` {#collection-method}

This method has the same signature as the [`where`](#method-where) method; however, all values are compared using "loose" comparisons.

<a name="method-wherein"></a>
#### `whereIn()` {#collection-method}

The `whereIn` method filters the collection by a given key / value contained within the given array.

$collection = collect([
['product' => 'Desk', 'price' => 200],
['product' => 'Chair', 'price' => 100],
['product' => 'Bookcase', 'price' => 150],
['product' => 'Door', 'price' => 100],
]);

$filtered = $collection->whereIn('price', [150, 200]);

$filtered->all();

/*
[
['product' => 'Bookcase', 'price' => 150],
['product' => 'Desk', 'price' => 200],
]
*/

The `whereIn` method uses strict comparisons when checking item values. Use the [`whereInLoose`](#method-whereinloose) method to filter using "loose" comparisons.

<a name="method-whereinloose"></a>
#### `whereInLoose()` {#collection-method}

This method has the same signature as the [`whereIn`](#method-wherein) method; however, all values are compared using "loose" comparisons.

<a name="method-zip"></a>
#### `zip()` {#collection-method}

Expand Down
7 changes: 4 additions & 3 deletions elixir.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ elixir(function(mix) {
<a name="browserify"></a>
### Browserify

Elixir also ships with a `browserify` method, which gives you all the benefits of requiring modules in the browser and using ECMAScript 6.
Elixir also ships with a `browserify` method, which gives you all the benefits of requiring modules in the browser and using ECMAScript 6 and JSX.

This task assumes that your scripts are stored in `resources/assets/js` and will place the resulting file in `public/js/main.js`:

Expand Down Expand Up @@ -226,13 +226,14 @@ elixir(function(mix) {
<a name="babel"></a>
### Babel

The `babel` method may be used to compile [ECMAScript 6 and 7](https://babeljs.io/docs/learn-es2015/) into plain JavaScript. This function accepts an array of files relative to the `resources/assets/js` directory, and generates a single `all.js` file in the `public/js` directory:
The `babel` method may be used to compile [ECMAScript 6 and 7](https://babeljs.io/docs/learn-es2015/) and [JSX](https://facebook.github.io/react/docs/jsx-in-depth.html) into plain JavaScript. This function accepts an array of files relative to the `resources/assets/js` directory, and generates a single `all.js` file in the `public/js` directory:

```javascript
elixir(function(mix) {
mix.babel([
'order.js',
'product.js'
'product.js',
'react-component.jsx'
]);
});
```
Expand Down
8 changes: 8 additions & 0 deletions eloquent-relationships.md
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,14 @@ For convenience, `attach` and `detach` also accept arrays of IDs as input:

$user->roles()->attach([1 => ['expires' => $expires], 2, 3]);

#### Updating A Record On A Pivot Table

If you need to update an existing row in your pivot table, you may use `updateExistingPivot` method:

$user = App\User::find(1);

$user->roles()->updateExistingPivot($roleId, $attributes);

#### Syncing For Convenience

You may also use the `sync` method to construct many-to-many associations. The `sync` method accepts an array of IDs to place on the intermediate table. Any IDs that are not in the given array will be removed from the intermediate table. So, after this operation is complete, only the IDs in the array will exist in the intermediate table:
Expand Down
4 changes: 4 additions & 0 deletions eloquent.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ Of course, in addition to retrieving all of the records for a given table, you m
// Retrieve the first model matching the query constraints...
$flight = App\Flight::where('active', 1)->first();

You may also call the `find` method with an array of primary keys, which will return a collection of the matching records:

$flights = App\Flight::find([1, 2, 3]);

#### Not Found Exceptions

Sometimes you may wish to throw an exception if a model is not found. This is particularly useful in routes or controllers. The `findOrFail` and `firstOrFail` methods will retrieve the first result of the query. However, if no result is found, a `Illuminate\Database\Eloquent\ModelNotFoundException` will be thrown:
Expand Down
2 changes: 2 additions & 0 deletions encryption.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ For example, we may use the `encrypt` method to encrypt a secret and store it on
}
}

> **Note:** Encrypted values are passed through `serialize` during encryption, which allows for "encryption" of objects and arrays. Thus, non-PHP clients receiving encrypted values will need to `unserialize` the data.
#### Decrypting A Value

Of course, you may decrypt values using the `decrypt` method on the `Crypt` facade. If the value can not be properly decrypted, such as when the MAC is invalid, an `Illuminate\Contracts\Encryption\DecryptException` will be thrown:
Expand Down
2 changes: 1 addition & 1 deletion helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ The `array_has` function checks that a given item exists in an array using "dot"

$array = ['products' => ['desk' => ['price' => 100]]];

$hasDesk = array_has($array, ['products.desk']);
$hasDesk = array_has($array, 'products.desk');

// true

Expand Down
4 changes: 2 additions & 2 deletions installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ First, download the Laravel installer using Composer:

composer global require "laravel/installer"

Make sure to place the `~/.composer/vendor/bin` directory in your PATH so the `laravel` executable can be located by your system.
Make sure to place the `~/.composer/vendor/bin` directory (or the equivalent directory for your OS) in your PATH so the `laravel` executable can be located by your system.

Once installed, the `laravel new` command will create a fresh Laravel installation in the directory you specify. For instance, `laravel new blog` will create a directory named `blog` containing a fresh Laravel installation with all of Laravel's dependencies already installed. This method of installation is much faster than installing via Composer:

Expand All @@ -57,7 +57,7 @@ After installing Laravel, you may need to configure some permissions. Directorie

#### Application Key

The next thing you should do after installing Laravel is set your application key to a random string. If you installed Laravel via Composer or the Laravel installer, this key has already been set for you by the `key:generate` command. Typically, this string should be 32 characters long. The key can be set in the `.env` environment file. If you have not renamed the `.env.example` file to `.env`, you should do that now. **If the application key is not set, your user sessions and other encrypted data will not be secure!**
The next thing you should do after installing Laravel is set your application key to a random string. If you installed Laravel via Composer or the Laravel installer, this key has already been set for you by the `artisan key:generate` command. Typically, this string should be 32 characters long. The key can be set in the `.env` environment file. If you have not renamed the `.env.example` file to `.env`, you should do that now. **If the application key is not set, your user sessions and other encrypted data will not be secure!**

#### Additional Configuration

Expand Down
6 changes: 3 additions & 3 deletions queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,17 @@ You may stop further chunks from being processed by returning `false` from the `

#### Retrieving A List Of Column Values

If you would like to retrieve an array containing the values of a single column, you may use the `lists` method. In this example, we'll retrieve an array of role titles:
If you would like to retrieve an array containing the values of a single column, you may use the `pluck` method. In this example, we'll retrieve an array of role titles:

$titles = DB::table('roles')->lists('title');
$titles = DB::table('roles')->pluck('title');

foreach ($titles as $title) {
echo $title;
}

You may also specify a custom key column for the returned array:

$roles = DB::table('roles')->lists('title', 'name');
$roles = DB::table('roles')->pluck('title', 'name');

foreach ($roles as $name => $title) {
echo $title;
Expand Down
1 change: 0 additions & 1 deletion queues.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
- [Job Class Structure](#job-class-structure)
- [Pushing Jobs Onto The Queue](#pushing-jobs-onto-the-queue)
- [Delayed Jobs](#delayed-jobs)
- [Dispatching Jobs From Requests](#dispatching-jobs-from-requests)
- [Job Events](#job-events)
- [Running The Queue Listener](#running-the-queue-listener)
- [Supervisor Configuration](#supervisor-configuration)
Expand Down
2 changes: 1 addition & 1 deletion quickstart-intermediate.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ Now, all we have to do is add the authentication routes to our routes file. We c

Since we know we're going to need to retrieve and store tasks, let's create a `TaskController` using the Artisan CLI, which will place the new controller in the `app/Http/Controllers` directory:

php artisan make:controller TaskController --plain
php artisan make:controller TaskController

Now that the controller has been generated, let's go ahead and stub out some routes in our `app/Http/routes.php` file to point to the controller:

Expand Down
1 change: 1 addition & 0 deletions scheduling.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Method | Description
`->monthly();` | Run the task every month
`->quarterly();` | Run the task every quarter
`->yearly();` | Run the task every year
`->timezone('America/New_York');` | Set the timezone

These methods may be combined with additional constraints to create even more finely tuned schedules that only run on certain days of the week. For example, to schedule a command to run weekly on Monday:

Expand Down
2 changes: 1 addition & 1 deletion seeding.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Once you have written your seeder classes, you may use the `db:seed` Artisan com

php artisan db:seed

php artisan db:seed --class=UserTableSeeder
php artisan db:seed --class=UsersTableSeeder

You may also seed your database using the `migrate:refresh` command, which will also rollback and re-run all of your migrations. This command is useful for completely re-building your database:

Expand Down
3 changes: 2 additions & 1 deletion upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ The `json` column type now creates actual JSON columns when used by the MySQL dr

#### Seeding

When runnning database seeds, all Eloquent models are now unguarded by default. Previously a call to `Model::unguard()` was required. You can call `Model::reguard()` at the top of your `DatabaseSeeder` class if you would like models to be guarded during seeding.
When running database seeds, all Eloquent models are now unguarded by default. Previously a call to `Model::unguard()` was required. You can call `Model::reguard()` at the top of your `DatabaseSeeder` class if you would like models to be guarded during seeding.

### Eloquent

Expand Down Expand Up @@ -161,6 +161,7 @@ Some of the core events fired by Laravel now use event objects instead of string

Old | New
------------- | -------------
`artisan.start` | `Illuminate\Console\Events\ArtisanStarting`
`auth.attempting` | `Illuminate\Auth\Events\Attempting`
`auth.login` | `Illuminate\Auth\Events\Login`
`auth.logout` | `Illuminate\Auth\Events\Logout`
Expand Down
11 changes: 11 additions & 0 deletions validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ To get a better understanding of the `validate` method, let's jump back into the

As you can see, we simply pass the incoming HTTP request and desired validation rules into the `validate` method. Again, if the validation fails, the proper response will automatically be generated. If the validation passes, our controller will continue executing normally.

#### Stopping On First Validation Failure

Sometimes you may wish to stop running validation rules on an attribute after the first validation failure. To do so, assign the `bail` rule to the attribute:

$this->validate($request, [
'title' => 'bail|required|unique:posts|max:255',
'body' => 'required',
]);

In this example, if the `required` rule on the `title` attribute fails, the `unique` rule will not be checked. Rules will be validated in the order they are assigned.

#### A Note On Nested Attributes

If your HTTP request contains "nested" parameters, you may specify them in your validation rules using "dot" syntax:
Expand Down

0 comments on commit 6575c1d

Please sign in to comment.