Don't say simply

This commit is contained in:
Jim Fisher 2018-01-23 17:48:13 +00:00
parent 44562181ed
commit e73c40f0de
No known key found for this signature in database
GPG Key ID: 0C99B6534D90BDFC
47 changed files with 95 additions and 95 deletions

View File

@ -25,7 +25,7 @@ Artisan is the command-line interface included with Laravel. It provides a numbe
php artisan list
Every command also includes a "help" screen which displays and describes the command's available arguments and options. To view a help screen, simply precede the name of the command with `help`:
Every command also includes a "help" screen which displays and describes the command's available arguments and options. To view a help screen, precede the name of the command with `help`:
php artisan help migrate
@ -431,7 +431,7 @@ You may also specify the connection or queue the Artisan command should be dispa
#### Passing Array Values
If your command defines an option that accepts an array, you may simply pass an array of values to that option:
If your command defines an option that accepts an array, you may pass an array of values to that option:
Route::get('/foo', function () {
$exitCode = Artisan::call('email:send', [

View File

@ -67,7 +67,7 @@ The `make:auth` command will also create a `resources/views/layouts` directory c
<a name="included-authenticating"></a>
### Authenticating
Now that you have routes and views setup for the included authentication controllers, you are ready to register and authenticate new users for your application! You may simply access your application in a browser since the authentication controllers already contain the logic (via their traits) to authenticate existing users and store new users in the database.
Now that you have routes and views setup for the included authentication controllers, you are ready to register and authenticate new users for your application! You may access your application in a browser since the authentication controllers already contain the logic (via their traits) to authenticate existing users and store new users in the database.
#### Path Customization
@ -285,7 +285,7 @@ Of course, you may specify the guard instance you would like to use:
#### Authenticate A User By ID
To log a user into the application by their ID, you may use the `loginUsingId` method. This method simply accepts the primary key of the user you wish to authenticate:
To log a user into the application by their ID, you may use the `loginUsingId` method. This method accepts the primary key of the user you wish to authenticate:
Auth::loginUsingId(1);

View File

@ -121,7 +121,7 @@ Next, register the `Laravel\Cashier\CashierServiceProvider` [service provider](/
Before using Cashier with Braintree, you will need to define a `plan-credit` discount in your Braintree control panel. This discount will be used to properly prorate subscriptions that change from yearly to monthly billing, or from monthly to yearly billing.
The discount amount configured in the Braintree control panel can be any value you wish, as Cashier will simply override the defined amount with our own custom amount each time we apply the coupon. This coupon is needed since Braintree does not natively support prorating subscriptions across subscription frequencies.
The discount amount configured in the Braintree control panel can be any value you wish, as Cashier will override the defined amount with our own custom amount each time we apply the coupon. This coupon is needed since Braintree does not natively support prorating subscriptions across subscription frequencies.
#### Database Migrations
@ -147,7 +147,7 @@ Before using Cashier, we'll need to [prepare the database](/docs/{{version}}/mig
$table->timestamps();
});
Once the migrations have been created, simply run the `migrate` Artisan command.
Once the migrations have been created, run the `migrate` Artisan command.
#### Billable Model
@ -331,7 +331,7 @@ The `taxPercentage` method enables you to apply a tax rate on a model-by-model b
<a name="cancelling-subscriptions"></a>
### Cancelling Subscriptions
To cancel a subscription, simply call the `cancel` method on the user's subscription:
To cancel a subscription, call the `cancel` method on the user's subscription:
$user->subscription('main')->cancel();
@ -354,7 +354,7 @@ If a user has cancelled their subscription and you wish to resume it, use the `r
$user->subscription('main')->resume();
If the user cancels a subscription and then resumes that subscription before the subscription has fully expired, they will not be billed immediately. Instead, their subscription will simply be re-activated, and they will be billed on the original billing cycle.
If the user cancels a subscription and then resumes that subscription before the subscription has fully expired, they will not be billed immediately. Instead, their subscription will be re-activated, and they will be billed on the original billing cycle.
<a name="updating-credit-cards"></a>
### Updating Credit Cards
@ -394,7 +394,7 @@ You may determine if the user is within their trial period using either the `onT
<a name="without-credit-card-up-front"></a>
### Without Credit Card Up Front
If you would like to offer trial periods without collecting the user's payment method information up front, you may simply set the `trial_ends_at` column on the user record to your desired trial ending date. This is typically done during user registration:
If you would like to offer trial periods without collecting the user's payment method information up front, you may set the `trial_ends_at` column on the user record to your desired trial ending date. This is typically done during user registration:
$user = User::create([
// Populate other user properties...
@ -446,7 +446,7 @@ Since Stripe webhooks need to bypass Laravel's [CSRF protection](/docs/{{version
<a name="defining-webhook-event-handlers"></a>
### Defining Webhook Event Handlers
Cashier automatically handles subscription cancellation on failed charges, but if you have additional Stripe webhook events you would like to handle, simply extend the Webhook controller. Your method names should correspond to Cashier's expected convention, specifically, methods should be prefixed with `handle` and the "camel case" name of the Stripe webhook you wish to handle. For example, if you wish to handle the `invoice.payment_succeeded` webhook, you should add a `handleInvoicePaymentSucceeded` method to the controller:
Cashier automatically handles subscription cancellation on failed charges, but if you have additional Stripe webhook events you would like to handle, extend the Webhook controller. Your method names should correspond to Cashier's expected convention, specifically, methods should be prefixed with `handle` and the "camel case" name of the Stripe webhook you wish to handle. For example, if you wish to handle the `invoice.payment_succeeded` webhook, you should add a `handleInvoicePaymentSucceeded` method to the controller:
<?php
@ -505,7 +505,7 @@ Since Braintree webhooks need to bypass Laravel's [CSRF protection](/docs/{{vers
<a name="defining-braintree-webhook-event-handlers"></a>
### Defining Webhook Event Handlers
Cashier automatically handles subscription cancellation on failed charges, but if you have additional Braintree webhook events you would like to handle, simply extend the Webhook controller. Your method names should correspond to Cashier's expected convention, specifically, methods should be prefixed with `handle` and the "camel case" name of the Braintree webhook you wish to handle. For example, if you wish to handle the `dispute_opened` webhook, you should add a `handleDisputeOpened` method to the controller:
Cashier automatically handles subscription cancellation on failed charges, but if you have additional Braintree webhook events you would like to handle, extend the Webhook controller. Your method names should correspond to Cashier's expected convention, specifically, methods should be prefixed with `handle` and the "camel case" name of the Braintree webhook you wish to handle. For example, if you wish to handle the `dispute_opened` webhook, you should add a `handleDisputeOpened` method to the controller:
<?php

View File

@ -103,7 +103,7 @@ The `{{ $slot }}` variable will contain the content we wish to inject into the c
<strong>Whoops!</strong> Something went wrong!
@endcomponent
Sometimes it is helpful to define multiple slots for a component. Let's modify our alert component to allow for the injection of a "title". Named slots may be displayed by simply "echoing" the variable that matches their name:
Sometimes it is helpful to define multiple slots for a component. Let's modify our alert component to allow for the injection of a "title". Named slots may be displayed by "echoing" the variable that matches their name:
<!-- /resources/views/alert.blade.php -->

View File

@ -325,7 +325,7 @@ To register the custom cache driver with Laravel, we will use the `extend` metho
The first argument passed to the `extend` method is the name of the driver. This will correspond to your `driver` option in the `config/cache.php` configuration file. The second argument is a Closure that should return an `Illuminate\Cache\Repository` instance. The Closure will be passed an `$app` instance, which is an instance of the [service container](/docs/{{version}}/container).
Once your extension is registered, simply update your `config/cache.php` configuration file's `driver` option to the name of your extension.
Once your extension is registered, update your `config/cache.php` configuration file's `driver` option to the name of your extension.
<a name="events"></a>
## Events

View File

@ -823,7 +823,7 @@ The `implode` method joins the items in a collection. Its arguments depend on th
// Desk, Chair
If the collection contains simple strings or numeric values, simply pass the "glue" as the only argument to the method:
If the collection contains simple strings or numeric values, pass the "glue" as the only argument to the method:
collect([1, 2, 3, 4, 5])->implode('-');

View File

@ -79,7 +79,7 @@ You should typically run the `php artisan config:cache` command as part of your
When your application is in maintenance mode, a custom view will be displayed for all requests into your application. This makes it easy to "disable" your application while it is updating or when you are performing maintenance. A maintenance mode check is included in the default middleware stack for your application. If the application is in maintenance mode, a `MaintenanceModeException` will be thrown with a status code of 503.
To enable maintenance mode, simply execute the `down` Artisan command:
To enable maintenance mode, execute the `down` Artisan command:
php artisan down

View File

@ -198,7 +198,7 @@ If some of your class' dependencies are not resolvable via the container, you ma
<a name="automatic-injection"></a>
#### Automatic Injection
Alternatively, and importantly, you may simply "type-hint" the dependency in the constructor of a class that is resolved by the container, including [controllers](/docs/{{version}}/controllers), [event listeners](/docs/{{version}}/events), [queue jobs](/docs/{{version}}/queues), [middleware](/docs/{{version}}/middleware), and more. In practice, this is how most of your objects should be resolved by the container.
Alternatively, and importantly, you may "type-hint" the dependency in the constructor of a class that is resolved by the container, including [controllers](/docs/{{version}}/controllers), [event listeners](/docs/{{version}}/events), [queue jobs](/docs/{{version}}/queues), [middleware](/docs/{{version}}/middleware), and more. In practice, this is how most of your objects should be resolved by the container.
For example, you may type-hint a repository defined by your application in a controller's constructor. The repository will automatically be resolved and injected into the class:

View File

@ -62,7 +62,7 @@ Now, when a request matches the specified route URI, the `show` method on the `U
It is very important to note that we did not need to specify the full controller namespace when defining the controller route. Since the `RouteServiceProvider` loads your route files within a route group that contains the namespace, we only specified the portion of the class name that comes after the `App\Http\Controllers` portion of the namespace.
If you choose to nest your controllers deeper into the `App\Http\Controllers` directory, simply use the specific class name relative to the `App\Http\Controllers` root namespace. So, if your full controller class is `App\Http\Controllers\Photos\AdminController`, you should register routes to the controller like so:
If you choose to nest your controllers deeper into the `App\Http\Controllers` directory, use the specific class name relative to the `App\Http\Controllers` root namespace. So, if your full controller class is `App\Http\Controllers\Photos\AdminController`, you should register routes to the controller like so:
Route::get('foo', 'Photos\AdminController@method');
@ -323,7 +323,7 @@ In addition to constructor injection, you may also type-hint dependencies on you
}
}
If your controller method is also expecting input from a route parameter, simply list your route arguments after your other dependencies. For example, if your route is defined like so:
If your controller method is also expecting input from a route parameter, list your route arguments after your other dependencies. For example, if your route is defined like so:
Route::put('user/{id}', 'UserController@update');

View File

@ -45,7 +45,7 @@ The `--model` option may be used to indicate the name of the model created by th
<a name="resetting-the-database-after-each-test"></a>
## Resetting The Database After Each Test
It is often useful to reset your database after each test so that data from a previous test does not interfere with subsequent tests. The `RefreshDatabase` trait takes the most optimal approach to migrating your test database depending on if you are using an in-memory database or a traditional database. Simply use the trait on your test class and everything will be handled for you:
It is often useful to reset your database after each test so that data from a previous test does not interfere with subsequent tests. The `RefreshDatabase` trait takes the most optimal approach to migrating your test database depending on if you are using an in-memory database or a traditional database. Use the trait on your test class and everything will be handled for you:
<?php

View File

@ -80,7 +80,7 @@ To get started, open your `tests/DuskTestCase.php` file, which is the base Dusk
// static::startChromeDriver();
}
Next, you may simply modify the `driver` method to connect to the URL and port of your choice. In addition, you may modify the "desired capabilities" that should be passed to the WebDriver:
Next, you may modify the `driver` method to connect to the URL and port of your choice. In addition, you may modify the "desired capabilities" that should be passed to the WebDriver:
/**
* Create the RemoteWebDriver instance.
@ -196,7 +196,7 @@ As you can see in the example above, the `browse` method accepts a callback. A b
#### Creating Multiple Browsers
Sometimes you may need multiple browsers in order to properly carry out a test. For example, multiple browsers may be needed to test a chat screen that interacts with websockets. To create multiple browsers, simply "ask" for more than one browser in the signature of the callback given to the `browse` method:
Sometimes you may need multiple browsers in order to properly carry out a test. For example, multiple browsers may be needed to test a chat screen that interacts with websockets. To create multiple browsers, "ask" for more than one browser in the signature of the callback given to the `browse` method:
$this->browse(function ($first, $second) {
$first->loginAs(User::find(1))
@ -922,7 +922,7 @@ If you are using CircleCI 1.0 to run your Dusk tests, you may use this configura
<a name="running-tests-on-codeship"></a>
### Codeship
To run Dusk tests on [Codeship](https://codeship.com), add the following commands to your Codeship project. Of course, these commands are simply a starting point and you are free to add additional commands as needed:
To run Dusk tests on [Codeship](https://codeship.com), add the following commands to your Codeship project. Of course, these commands are a starting point and you are free to add additional commands as needed:
phpenv local 7.1
cp .env.testing .env

View File

@ -43,7 +43,7 @@ To define an accessor, create a `getFooAttribute` method on your model where `Fo
}
}
As you can see, the original value of the column is passed to the accessor, allowing you to manipulate and return the value. To access the value of the accessor, you may simply access the `first_name` attribute on a model instance:
As you can see, the original value of the column is passed to the accessor, allowing you to manipulate and return the value. To access the value of the accessor, you may access the `first_name` attribute on a model instance:
$user = App\User::find(1);

View File

@ -291,7 +291,7 @@ In addition to customizing the name of the joining table, you may also customize
#### Defining The Inverse Of The Relationship
To define the inverse of a many-to-many relationship, you simply place another call to `belongsToMany` on your related model. To continue our user roles example, let's define the `users` method on the `Role` model:
To define the inverse of a many-to-many relationship, you place another call to `belongsToMany` on your related model. To continue our user roles example, let's define the `users` method on the `Role` model:
<?php
@ -310,7 +310,7 @@ To define the inverse of a many-to-many relationship, you simply place another c
}
}
As you can see, the relationship is defined exactly the same as its `User` counterpart, with the exception of simply referencing the `App\User` model. Since we're reusing the `belongsToMany` method, all of the usual table and key customization options are available when defining the inverse of many-to-many relationships.
As you can see, the relationship is defined exactly the same as its `User` counterpart, with the exception of referencing the `App\User` model. Since we're reusing the `belongsToMany` method, all of the usual table and key customization options are available when defining the inverse of many-to-many relationships.
#### Retrieving Intermediate Table Columns
@ -521,7 +521,7 @@ Next, let's examine the model definitions needed to build this relationship:
#### Retrieving Polymorphic Relations
Once your database table and models are defined, you may access the relationships via your models. For example, to access all of the comments for a post, we can simply use the `comments` dynamic property:
Once your database table and models are defined, you may access the relationships via your models. For example, to access all of the comments for a post, we can use the `comments` dynamic property:
$post = App\Post::find(1);
@ -626,7 +626,7 @@ Next, on the `Tag` model, you should define a method for each of its related mod
#### Retrieving The Relationship
Once your database table and models are defined, you may access the relationships via your models. For example, to access all of the tags for a post, you can simply use the `tags` dynamic property:
Once your database table and models are defined, you may access the relationships via your models. For example, to access all of the tags for a post, you can use the `tags` dynamic property:
$post = App\Post::find(1);
@ -677,7 +677,7 @@ You are able to use any of the [query builder](/docs/{{version}}/queries) method
<a name="relationship-methods-vs-dynamic-properties"></a>
### Relationship Methods Vs. Dynamic Properties
If you do not need to add additional constraints to an Eloquent relationship query, you may simply access the relationship as if it were a property. For example, continuing to use our `User` and `Post` example models, we may access all of a user's posts like so:
If you do not need to add additional constraints to an Eloquent relationship query, you may access the relationship as if it were a property. For example, continuing to use our `User` and `Post` example models, we may access all of a user's posts like so:
$user = App\User::find(1);

View File

@ -27,7 +27,7 @@ To generate a resource class, you may use the `make:resource` Artisan command. B
In addition to generating resources that transform individual models, you may generate resources that are responsible for transforming collections of models. This allows your response to include links and other meta information that is relevant to an entire collection of a given resource.
To create a resource collection, you should use the `--collection` flag when creating the resource. Or, simply including the word `Collection` in the resource name will indicate to Laravel that it should create a collection resource. Collection resources extend the `Illuminate\Http\Resources\Json\ResourceCollection` class:
To create a resource collection, you should use the `--collection` flag when creating the resource. Or, including the word `Collection` in the resource name will indicate to Laravel that it should create a collection resource. Collection resources extend the `Illuminate\Http\Resources\Json\ResourceCollection` class:
php artisan make:resource Users --collection
@ -170,7 +170,7 @@ Once a resource has been defined, it may be returned directly from a route or co
#### Relationships
If you would like to include related resources in your response, you may simply add them to the array returned by your `toArray` method. In this example, we will use the `Post` resource's `collection` method to add the user's blog posts to the resource response:
If you would like to include related resources in your response, you may add them to the array returned by your `toArray` method. In this example, we will use the `Post` resource's `collection` method to add the user's blog posts to the resource response:
/**
* Transform the resource into an array.
@ -510,7 +510,7 @@ In addition to conditionally including relationship information in your resource
<a name="adding-meta-data"></a>
### Adding Meta Data
Some JSON API standards require the addition of meta data to your resource and resource collections responses. This often includes things like `links` to the resource or related resources, or meta data about the resource itself. If you need to return additional meta data about a resource, simply include it in your `toArray` method. For example, you might include `link` information when transforming a resource collection:
Some JSON API standards require the addition of meta data to your resource and resource collections responses. This often includes things like `links` to the resource or related resources, or meta data about the resource itself. If you need to return additional meta data about a resource, include it in your `toArray` method. For example, you might include `link` information when transforming a resource collection:
/**
* Transform the resource into an array.
@ -528,7 +528,7 @@ Some JSON API standards require the addition of meta data to your resource and r
];
}
When returning additional meta data from your resources, you never have to worry about accidentally overriding the `links` or `meta` keys that are automatically added by Laravel when returning paginated responses. Any additional `links` you define will simply be merged with the links provided by the paginator.
When returning additional meta data from your resources, you never have to worry about accidentally overriding the `links` or `meta` keys that are automatically added by Laravel when returning paginated responses. Any additional `links` you define will be merged with the links provided by the paginator.
#### Top Level Meta Data

View File

@ -189,7 +189,7 @@ For Eloquent methods like `all` and `get` which retrieve multiple results, an in
return $flight->cancelled;
});
Of course, you may also simply loop over the collection like an array:
Of course, you may also loop over the collection like an array:
foreach ($flights as $flight) {
echo $flight->name;
@ -260,7 +260,7 @@ You may also use the `count`, `sum`, `max`, and other [aggregate methods](/docs/
<a name="inserts"></a>
### Inserts
To create a new record in the database, simply create a new model instance, set attributes on the model, then call the `save` method:
To create a new record in the database, create a new model instance, set attributes on the model, then call the `save` method:
<?php
@ -290,7 +290,7 @@ To create a new record in the database, simply create a new model instance, set
}
}
In this example, we simply assign the `name` parameter from the incoming HTTP request to the `name` attribute of the `App\Flight` model instance. When we call the `save` method, a record will be inserted into the database. The `created_at` and `updated_at` timestamps will automatically be set when the `save` method is called, so there is no need to set them manually.
In this example, we assign the `name` parameter from the incoming HTTP request to the `name` attribute of the `App\Flight` model instance. When we call the `save` method, a record will be inserted into the database. The `created_at` and `updated_at` timestamps will automatically be set when the `save` method is called, so there is no need to set them manually.
<a name="updates"></a>
### Updates
@ -641,7 +641,7 @@ If you would like to remove several or even all of the global scopes, you may us
<a name="local-scopes"></a>
### Local Scopes
Local scopes allow you to define common sets of constraints that you may easily re-use throughout your application. For example, you may need to frequently retrieve all users that are considered "popular". To define a scope, simply prefix an Eloquent model method with `scope`.
Local scopes allow you to define common sets of constraints that you may easily re-use throughout your application. For example, you may need to frequently retrieve all users that are considered "popular". To define a scope, prefix an Eloquent model method with `scope`.
Scopes should always return a query builder instance:

View File

@ -78,7 +78,7 @@ By default, Monolog is instantiated with name that matches the current environme
<a name="report-method"></a>
### The Report Method
All exceptions are handled by the `App\Exceptions\Handler` class. This class contains two methods: `report` and `render`. We'll examine each of these methods in detail. The `report` method is used to log exceptions or send them to an external service like [Bugsnag](https://bugsnag.com) or [Sentry](https://github.com/getsentry/sentry-laravel). By default, the `report` method simply passes the exception to the base class where the exception is logged. However, you are free to log exceptions however you wish.
All exceptions are handled by the `App\Exceptions\Handler` class. This class contains two methods: `report` and `render`. We'll examine each of these methods in detail. The `report` method is used to log exceptions or send them to an external service like [Bugsnag](https://bugsnag.com) or [Sentry](https://github.com/getsentry/sentry-laravel). By default, the `report` method passes the exception to the base class where the exception is logged. However, you are free to log exceptions however you wish.
For example, if you need to report different types of exceptions in different ways, you may use the PHP `instanceof` comparison operator:

View File

@ -19,7 +19,7 @@
Laravel's events provides a simple observer implementation, allowing you to subscribe and listen for various events that occur in your application. Event classes are typically stored in the `app/Events` directory, while their listeners are stored in `app/Listeners`. Don't worry if you don't see these directories in your application, since they will be created for you as you generate events and listeners using Artisan console commands.
Events serve as a great way to decouple various aspects of your application, since a single event can have multiple listeners that do not depend on each other. For example, you may wish to send a Slack notification to your user each time an order has shipped. Instead of coupling your order processing code to your Slack notification code, you can simply raise an `OrderShipped` event, which a listener can receive and transform into a Slack notification.
Events serve as a great way to decouple various aspects of your application, since a single event can have multiple listeners that do not depend on each other. For example, you may wish to send a Slack notification to your user each time an order has shipped. Instead of coupling your order processing code to your Slack notification code, you can raise an `OrderShipped` event, which a listener can receive and transform into a Slack notification.
<a name="registering-events-and-listeners"></a>
## Registering Events & Listeners
@ -40,7 +40,7 @@ The `EventServiceProvider` included with your Laravel application provides a con
<a name="generating-events-and-listeners"></a>
### Generating Events & Listeners
Of course, manually creating the files for each event and listener is cumbersome. Instead, simply add listeners and events to your `EventServiceProvider` and use the `event:generate` command. This command will generate any events or listeners that are listed in your `EventServiceProvider`. Of course, events and listeners that already exist will be left untouched:
Of course, manually creating the files for each event and listener is cumbersome. Instead, add listeners and events to your `EventServiceProvider` and use the `event:generate` command. This command will generate any events or listeners that are listed in your `EventServiceProvider`. Of course, events and listeners that already exist will be left untouched:
php artisan event:generate
@ -74,7 +74,7 @@ You may even register listeners using the `*` as a wildcard parameter, allowing
<a name="defining-events"></a>
## Defining Events
An event class is simply a data container which holds the information related to the event. For example, let's assume our generated `OrderShipped` event receives an [Eloquent ORM](/docs/{{version}}/eloquent) object:
An event class is a data container which holds the information related to the event. For example, let's assume our generated `OrderShipped` event receives an [Eloquent ORM](/docs/{{version}}/eloquent) object:
<?php
@ -101,7 +101,7 @@ An event class is simply a data container which holds the information related to
}
}
As you can see, this event class contains no logic. It is simply a container for the `Order` instance that was purchased. The `SerializesModels` trait used by the event will gracefully serialize any Eloquent models if the event object is serialized using PHP's `serialize` function.
As you can see, this event class contains no logic. It is a container for the `Order` instance that was purchased. The `SerializesModels` trait used by the event will gracefully serialize any Eloquent models if the event object is serialized using PHP's `serialize` function.
<a name="defining-listeners"></a>
## Defining Listeners

View File

@ -172,7 +172,7 @@ Using real-time facades, you may treat any class in your application as if it we
}
}
Injecting a publisher implementation into the method allows us to easily test the method in isolation since we can mock the injected publisher. However, it requires us to always pass a publisher instance each time we call the `publish` method. Using real-time facades, we can maintain the same testability while not being required to explicitly pass a `Publisher` instance. To generate a real-time facade, simply prefix the namespace of the imported class with `Facades`:
Injecting a publisher implementation into the method allows us to easily test the method in isolation since we can mock the injected publisher. However, it requires us to always pass a publisher instance each time we call the `publish` method. Using real-time facades, we can maintain the same testability while not being required to explicitly pass a `Publisher` instance. To generate a real-time facade, prefix the namespace of the imported class with `Facades`:
<?php

View File

@ -24,7 +24,7 @@ Laravel provides a powerful filesystem abstraction thanks to the wonderful [Flys
<a name="configuration"></a>
## Configuration
The filesystem configuration file is located at `config/filesystems.php`. Within this file you may configure all of your "disks". Each disk represents a particular storage driver and storage location. Example configurations for each supported driver are included in the configuration file. So, simply modify the configuration to reflect your storage preferences and credentials.
The filesystem configuration file is located at `config/filesystems.php`. Within this file you may configure all of your "disks". Each disk represents a particular storage driver and storage location. Example configurations for each supported driver are included in the configuration file. So, modify the configuration to reflect your storage preferences and credentials.
Of course, you may configure as many disks as you like, and may even have multiple disks that use the same driver.
@ -210,7 +210,7 @@ The `copy` method may be used to copy an existing file to a new location on the
<a name="file-uploads"></a>
### File Uploads
In web applications, one of the most common use-cases for storing files is storing user uploaded files such as profile pictures, photos, and documents. Laravel makes it very easy to store uploaded files using the `store` method on an uploaded file instance. Simply call the `store` method with the path at which you wish to store the uploaded file:
In web applications, one of the most common use-cases for storing files is storing user uploaded files such as profile pictures, photos, and documents. Laravel makes it very easy to store uploaded files using the `store` method on an uploaded file instance. Call the `store` method with the path at which you wish to store the uploaded file:
<?php

View File

@ -28,7 +28,7 @@ If you would like to remove the frontend scaffolding from your application, you
<a name="writing-css"></a>
## Writing CSS
Laravel's `package.json` file includes the `bootstrap-sass` package to help you get started prototyping your application's frontend using Bootstrap. However, feel free to add or remove packages from the `package.json` file as needed for your own application. You are not required to use the Bootstrap framework to build your Laravel application - it is simply provided as a good starting point for those who choose to use it.
Laravel's `package.json` file includes the `bootstrap-sass` package to help you get started prototyping your application's frontend using Bootstrap. However, feel free to add or remove packages from the `package.json` file as needed for your own application. You are not required to use the Bootstrap framework to build your Laravel application - it is provided as a good starting point for those who choose to use it.
Before compiling your CSS, install your project's frontend dependencies using the [Node package manager (NPM)](https://www.npmjs.org):
@ -67,7 +67,7 @@ By default, fresh Laravel applications contain an `ExampleComponent.vue` Vue com
require('./components/ExampleComponent.vue')
);
To use the component in your application, you may simply drop it into one of your HTML templates. For example, after running the `make:auth` Artisan command to scaffold your application's authentication and registration screens, you could drop the component into the `home.blade.php` Blade template:
To use the component in your application, you may drop it into one of your HTML templates. For example, after running the `make:auth` Artisan command to scaffold your application's authentication and registration screens, you could drop the component into the `home.blade.php` Blade template:
@extends('layouts.app')

View File

@ -704,7 +704,7 @@ The `__` function translates the given translation string or translation key usi
echo __('messages.welcome');
If the specified translation string or key does not exist, the `__` function will simply return the given value. So, using the example above, the `__` function would return `messages.welcome` if that translation key does not exist.
If the specified translation string or key does not exist, the `__` function will return the given value. So, using the example above, the `__` function would return `messages.welcome` if that translation key does not exist.
<a name="method-camel-case"></a>
#### `camel_case()` {#collection-method}
@ -973,7 +973,7 @@ The `trans` function translates the given translation key using your [localizati
echo trans('messages.welcome');
If the specified translation key does not exist, the `trans` function will simply return the given key. So, using the example above, the `trans` function would return `messages.welcome` if the translation key does not exist.
If the specified translation key does not exist, the `trans` function will return the given key. So, using the example above, the `trans` function would return `messages.welcome` if the translation key does not exist.
<a name="method-trans-choice"></a>
#### `trans_choice()` {#collection-method}
@ -982,7 +982,7 @@ The `trans_choice` function translates the given translation key with inflection
echo trans_choice('messages.notifications', $unreadCount);
If the specified translation key does not exist, the `trans_choice` function will simply return the given key. So, using the example above, the `trans_choice` function would return `messages.notifications` if the translation key does not exist.
If the specified translation key does not exist, the `trans_choice` function will return the given key. So, using the example above, the `trans_choice` function would return `messages.notifications` if the translation key does not exist.
<a name="urls"></a>
## URLs
@ -1363,7 +1363,7 @@ The `old` function [retrieves](/docs/{{version}}/requests#retrieving-input) an [
<a name="method-optional"></a>
#### `optional()` {#collection-method}
The `optional` function accepts any argument and allows you to access properties or call methods on that object. If the given object is `null`, properties and methods will simply return `null` instead of causing an error:
The `optional` function accepts any argument and allows you to access properties or call methods on that object. If the given object is `null`, properties and methods will return `null` instead of causing an error:
return optional($user->address)->street;

View File

@ -87,7 +87,7 @@ If this command fails, make sure your Vagrant installation is up to date.
#### Installing Homestead
You may install Homestead by simply cloning the repository. Consider cloning the repository into a `Homestead` folder within your "home" directory, as the Homestead box will serve as the host to all of your Laravel projects:
You may install Homestead by cloning the repository. Consider cloning the repository into a `Homestead` folder within your "home" directory, as the Homestead box will serve as the host to all of your Laravel projects:
git clone https://github.com/laravel/homestead.git ~/Homestead
@ -181,7 +181,7 @@ To destroy the machine, you may use the `vagrant destroy --force` command.
<a name="per-project-installation"></a>
### Per Project Installation
Instead of installing Homestead globally and sharing the same Homestead box across all of your projects, you may instead configure a Homestead instance for each project you manage. Installing Homestead per project may be beneficial if you wish to ship a `Vagrantfile` with your project, allowing others working on the project to simply `vagrant up`.
Instead of installing Homestead globally and sharing the same Homestead box across all of your projects, you may instead configure a Homestead instance for each project you manage. Installing Homestead per project may be beneficial if you wish to ship a `Vagrantfile` with your project, allowing others working on the project to `vagrant up`.
To install Homestead directly into your project, require it using Composer:
@ -287,7 +287,7 @@ To connect to your MySQL or PostgreSQL database from your host machine's databas
<a name="adding-additional-sites"></a>
### Adding Additional Sites
Once your Homestead environment is provisioned and running, you may want to add additional Nginx sites for your Laravel applications. You can run as many Laravel installations as you wish on a single Homestead environment. To add an additional site, simply add the site to your `Homestead.yaml` file:
Once your Homestead environment is provisioned and running, you may want to add additional Nginx sites for your Laravel applications. You can run as many Laravel installations as you wish on a single Homestead environment. To add an additional site, add the site to your `Homestead.yaml` file:
sites:
- map: homestead.test
@ -459,7 +459,7 @@ You can update Homestead in two simple steps. First, you should update the Vagra
vagrant box update
Next, you need to update the Homestead source code. If you cloned the repository you can simply `git pull origin master` at the location you originally cloned the repository.
Next, you need to update the Homestead source code. If you cloned the repository you can `git pull origin master` at the location you originally cloned the repository.
If you have installed Homestead via your project's `composer.json` file, you should ensure your `composer.json` file contains `"laravel/homestead": "^7"` and update your dependencies:

View File

@ -16,7 +16,7 @@ The goal of this document is to give you a good, high-level overview of how the
### First Things
The entry point for all requests to a Laravel application is the `public/index.php` file. All requests are directed to this file by your web server (Apache / Nginx) configuration. The `index.php` file doesn't contain much code. Rather, it is simply a starting point for loading the rest of the framework.
The entry point for all requests to a Laravel application is the `public/index.php` file. All requests are directed to this file by your web server (Apache / Nginx) configuration. The `index.php` file doesn't contain much code. Rather, it is a starting point for loading the rest of the framework.
The `index.php` file loads the Composer generated autoloader definition, and then retrieves an instance of the Laravel application from `bootstrap/app.php` script. The first action taken by Laravel itself is to create an instance of the application / [service container](/docs/{{version}}/container).

View File

@ -21,7 +21,7 @@ Laravel's localization features provide a convenient way to retrieve strings in
/es
messages.php
All language files simply return an array of keyed strings. For example:
All language files return an array of keyed strings. For example:
<?php
@ -68,7 +68,7 @@ Typically, translation strings are stored in files within the `resources/lang` d
/es
messages.php
All language files simply return an array of keyed strings. For example:
All language files return an array of keyed strings. For example:
<?php
@ -104,7 +104,7 @@ Of course if you are using the [Blade templating engine](/docs/{{version}}/blade
@lang('messages.welcome')
If the specified translation string does not exist, the `__` function will simply return the translation string key. So, using the example above, the `__` function would return `messages.welcome` if the translation string does not exist.
If the specified translation string does not exist, the `__` function will return the translation string key. So, using the example above, the `__` function would return `messages.welcome` if the translation string does not exist.
<a name="replacing-parameters-in-translation-strings"></a>
### Replacing Parameters In Translation Strings

View File

@ -417,7 +417,7 @@ This command will publish the Markdown mail components to the `resources/views/v
After exporting the components, the `resources/views/vendor/mail/html/themes` directory will contain a `default.css` file. You may customize the CSS in this file and your styles will automatically be in-lined within the HTML representations of your Markdown mail messages.
> {tip} If you would like to build an entirely new theme for the Markdown components, simply write a new CSS file within the `html/themes` directory and change the `theme` option of your `mail` configuration file.
> {tip} If you would like to build an entirely new theme for the Markdown components, write a new CSS file within the `html/themes` directory and change the `theme` option of your `mail` configuration file.
<a name="previewing-mailables-in-the-browser"></a>
## Previewing Mailables In The Browser

View File

@ -52,7 +52,7 @@ This command will place a new `CheckAge` class within your `app/Http/Middleware`
}
}
As you can see, if the given `age` is less than or equal to `200`, the middleware will return an HTTP redirect to the client; otherwise, the request will be passed further into the application. To pass the request deeper into the application (allowing the middleware to "pass"), simply call the `$next` callback with the `$request`.
As you can see, if the given `age` is less than or equal to `200`, the middleware will return an HTTP redirect to the client; otherwise, the request will be passed further into the application. To pass the request deeper into the application (allowing the middleware to "pass"), call the `$next` callback with the `$request`.
It's best to envision middleware as a series of "layers" HTTP requests must pass through before they hit your application. Each layer can examine the request and even reject it entirely.
@ -102,12 +102,12 @@ However, this middleware would perform its task **after** the request is handled
<a name="global-middleware"></a>
### Global Middleware
If you want a middleware to run during every HTTP request to your application, simply list the middleware class in the `$middleware` property of your `app/Http/Kernel.php` class.
If you want a middleware to run during every HTTP request to your application, list the middleware class in the `$middleware` property of your `app/Http/Kernel.php` class.
<a name="assigning-middleware-to-routes"></a>
### Assigning Middleware To Routes
If you would like to assign middleware to specific routes, you should first assign the middleware a key in your `app/Http/Kernel.php` file. By default, the `$routeMiddleware` property of this class contains entries for the middleware included with Laravel. To add your own, simply append it to this list and assign it a key of your choosing. For example:
If you would like to assign middleware to specific routes, you should first assign the middleware a key in your `app/Http/Kernel.php` file. By default, the `$routeMiddleware` property of this class contains entries for the middleware included with Laravel. To add your own, append it to this list and assign it a key of your choosing. For example:
// Within App\Http\Kernel Class...
@ -168,7 +168,7 @@ Out of the box, Laravel comes with `web` and `api` middleware groups that contai
],
];
Middleware groups may be assigned to routes and controller actions using the same syntax as individual middleware. Again, middleware groups simply make it more convenient to assign many middleware to a route at once:
Middleware groups may be assigned to routes and controller actions using the same syntax as individual middleware. Again, middleware groups make it more convenient to assign many middleware to a route at once:
Route::get('/', function () {
//

View File

@ -34,7 +34,7 @@ To create a migration, use the `make:migration` [Artisan command](/docs/{{versio
The new migration will be placed in your `database/migrations` directory. Each migration file name contains a timestamp which allows Laravel to determine the order of the migrations.
The `--table` and `--create` options may also be used to indicate the name of the table and whether the migration will be creating a new table. These options simply pre-fill the generated migration stub file with the specified table:
The `--table` and `--create` options may also be used to indicate the name of the table and whether the migration will be creating a new table. These options pre-fill the generated migration stub file with the specified table:
php artisan make:migration create_users_table --create=users
@ -45,7 +45,7 @@ If you would like to specify a custom output path for the generated migration, y
<a name="migration-structure"></a>
## Migration Structure
A migration class contains two methods: `up` and `down`. The `up` method is used to add new tables, columns, or indexes to your database, while the `down` method should simply reverse the operations performed by the `up` method.
A migration class contains two methods: `up` and `down`. The `up` method is used to add new tables, columns, or indexes to your database, while the `down` method should reverse the operations performed by the `up` method.
Within both of these methods you may use the Laravel schema builder to expressively create and modify tables. To learn about all of the methods available on the `Schema` builder, [check out its documentation](#creating-tables). For example, this migration example creates a `flights` table:
@ -363,7 +363,7 @@ Command | Description
<a name="creating-indexes"></a>
### Creating Indexes
The schema builder supports several types of indexes. First, let's look at an example that specifies a column's values should be unique. To create the index, we can simply chain the `unique` method onto the column definition:
The schema builder supports several types of indexes. First, let's look at an example that specifies a column's values should be unique. To create the index, we can chain the `unique` method onto the column definition:
$table->string('email')->unique();
@ -410,7 +410,7 @@ Alternatively, you may enable the `innodb_large_prefix` option for your database
<a name="dropping-indexes"></a>
### Dropping Indexes
To drop an index, you must specify the index's name. By default, Laravel automatically assigns a reasonable name to the indexes. Simply concatenate the table name, the name of the indexed column, and the index type. Here are some examples:
To drop an index, you must specify the index's name. By default, Laravel automatically assigns a reasonable name to the indexes. Concatenate the table name, the name of the indexed column, and the index type. Here are some examples:
Command | Description
------- | -----------

2
mix.md
View File

@ -194,7 +194,7 @@ Though disabled by default, source maps may be activated by calling the `mix.sou
<a name="working-with-scripts"></a>
## Working With JavaScript
Mix provides several features to help you work with your JavaScript files, such as compiling ECMAScript 2015, module bundling, minification, and simply concatenating plain JavaScript files. Even better, this all works seamlessly, without requiring an ounce of custom configuration:
Mix provides several features to help you work with your JavaScript files, such as compiling ECMAScript 2015, module bundling, minification, and concatenating plain JavaScript files. Even better, this all works seamlessly, without requiring an ounce of custom configuration:
mix.js('resources/assets/js/app.js', 'public/js');

View File

@ -298,4 +298,4 @@ We can mock the call to the `Cache` facade by using the `shouldReceive` method,
}
}
> {note} You should not mock the `Request` facade. Instead, pass the input you desire into the HTTP helper methods such as `get` and `post` when running your test. Likewise, instead of mocking the `Config` facade, simply call the `Config::set` method in your tests.
> {note} You should not mock the `Request` facade. Instead, pass the input you desire into the HTTP helper methods such as `get` and `post` when running your test. Likewise, instead of mocking the `Config` facade, call the `Config::set` method in your tests.

View File

@ -374,7 +374,7 @@ This command will publish the Markdown mail components to the `resources/views/v
After exporting the components, the `resources/views/vendor/mail/html/themes` directory will contain a `default.css` file. You may customize the CSS in this file and your styles will automatically be in-lined within the HTML representations of your Markdown notifications.
> {tip} If you would like to build an entirely new theme for the Markdown components, simply write a new CSS file within the `html/themes` directory and change the `theme` option of your `mail` configuration file.
> {tip} If you would like to build an entirely new theme for the Markdown components, write a new CSS file within the `html/themes` directory and change the `theme` option of your `mail` configuration file.
<a name="database-notifications"></a>
## Database Notifications
@ -867,7 +867,7 @@ Laravel ships with a handful of notification channels, but you may want to write
}
}
Once your notification channel class has been defined, you may simply return the class name from the `via` method of any of your notifications:
Once your notification channel class has been defined, you may return the class name from the `via` method of any of your notifications:
<?php

View File

@ -19,7 +19,7 @@
Packages are the primary way of adding functionality to Laravel. Packages might be anything from a great way to work with dates like [Carbon](https://github.com/briannesbitt/Carbon), or an entire BDD testing framework like [Behat](https://github.com/Behat/Behat).
Of course, there are different types of packages. Some packages are stand-alone, meaning they work with any PHP framework. Carbon and Behat are examples of stand-alone packages. Any of these packages may be used with Laravel by simply requesting them in your `composer.json` file.
Of course, there are different types of packages. Some packages are stand-alone, meaning they work with any PHP framework. Carbon and Behat are examples of stand-alone packages. Any of these packages may be used with Laravel by requesting them in your `composer.json` file.
On the other hand, other packages are specifically intended for use with Laravel. These packages may have routes, controllers, views, and configuration specifically intended to enhance a Laravel application. This guide primarily covers the development of those packages that are Laravel specific.

View File

@ -121,7 +121,7 @@ If you wish to append a "hash fragment" to the paginator's URLs, you may use the
<a name="converting-results-to-json"></a>
### Converting Results To JSON
The Laravel paginator result classes implement the `Illuminate\Contracts\Support\Jsonable` Interface contract and expose the `toJson` method, so it's very easy to convert your pagination results to JSON. You may also convert a paginator instance to JSON by simply returning it from a route or controller action:
The Laravel paginator result classes implement the `Illuminate\Contracts\Support\Jsonable` Interface contract and expose the `toJson` method, so it's very easy to convert your pagination results to JSON. You may also convert a paginator instance to JSON by returning it from a route or controller action:
Route::get('users', function () {
return App\User::paginate();
@ -165,7 +165,7 @@ However, the easiest way to customize the pagination views is by exporting them
php artisan vendor:publish --tag=laravel-pagination
This command will place the views in the `resources/views/vendor/pagination` directory. The `default.blade.php` file within this directory corresponds to the default pagination view. Simply edit this file to modify the pagination HTML.
This command will place the views in the `resources/views/vendor/pagination` directory. The `default.blade.php` file within this directory corresponds to the default pagination view. Edit this file to modify the pagination HTML.
<a name="paginator-instance-methods"></a>
## Paginator Instance Methods

View File

@ -42,7 +42,7 @@ Again, Laravel will generate all of the necessary views for password reset when
<a name="after-resetting-passwords"></a>
## After Resetting Passwords
Once you have defined the routes and views to reset your user's passwords, you may simply access the route in your browser at `/password/reset`. The `ForgotPasswordController` included with the framework already includes the logic to send the password reset link e-mails, while the `ResetPasswordController` includes the logic to reset user passwords.
Once you have defined the routes and views to reset your user's passwords, you may access the route in your browser at `/password/reset`. The `ForgotPasswordController` included with the framework already includes the logic to send the password reset link e-mails, while the `ResetPasswordController` includes the logic to reset user passwords.
After a password is reset, the user will automatically be logged into the application and redirected to `/home`. You can customize the post password reset redirect location by defining a `redirectTo` property on the `ResetPasswordController`:

View File

@ -102,7 +102,7 @@ You may type-hint dependencies for your service provider's `boot` method. The [s
All service providers are registered in the `config/app.php` configuration file. This file contains a `providers` array where you can list the class names of your service providers. By default, a set of Laravel core service providers are listed in this array. These providers bootstrap the core Laravel components, such as the mailer, queue, cache, and others.
To register your provider, simply add it to the array:
To register your provider, add it to the array:
'providers' => [
// Other Service Providers

View File

@ -272,7 +272,7 @@ For example, here is a query that verifies the value of the "votes" column is eq
$users = DB::table('users')->where('votes', '=', 100)->get();
For convenience, if you simply want to verify that a column is equal to a given value, you may pass the value directly as the second argument to the `where` method:
For convenience, if you want to verify that a column is equal to a given value, you may pass the value directly as the second argument to the `where` method:
$users = DB::table('users')->where('votes', 100)->get();
@ -587,7 +587,7 @@ When updating a JSON column, you should use `->` syntax to access the appropriat
<a name="increment-and-decrement"></a>
### Increment & Decrement
The query builder also provides convenient methods for incrementing or decrementing the value of a given column. This is simply a shortcut, providing a more expressive and terse interface compared to manually writing the `update` statement.
The query builder also provides convenient methods for incrementing or decrementing the value of a given column. This is a shortcut, providing a more expressive and terse interface compared to manually writing the `update` statement.
Both of these methods accept at least one argument: the column to modify. A second argument may optionally be passed to control the amount by which the column should be incremented or decremented:

View File

@ -31,7 +31,7 @@
Laravel queues provide a unified API across a variety of different queue backends, such as Beanstalk, Amazon SQS, Redis, or even a relational database. Queues allow you to defer the processing of a time consuming task, such as sending an email, until a later time. Deferring these time consuming tasks drastically speeds up web requests to your application.
The queue configuration file is stored in `config/queue.php`. In this file you will find connection configurations for each of the queue drivers that are included with the framework, which includes a database, [Beanstalkd](https://kr.github.io/beanstalkd/), [Amazon SQS](https://aws.amazon.com/sqs/), [Redis](https://redis.io), and a synchronous driver that will execute jobs immediately (for local use). A `null` queue driver is also included which simply discards queued jobs.
The queue configuration file is stored in `config/queue.php`. In this file you will find connection configurations for each of the queue drivers that are included with the framework, which includes a database, [Beanstalkd](https://kr.github.io/beanstalkd/), [Amazon SQS](https://aws.amazon.com/sqs/), [Redis](https://redis.io), and a synchronous driver that will execute jobs immediately (for local use). A `null` queue driver is also included which discards queued jobs.
<a name="connections-vs-queues"></a>
### Connections Vs. Queues

View File

@ -37,7 +37,7 @@ If your route has parameters, you may pass them as the second argument to the `r
#### Populating Parameters Via Eloquent Models
If you are redirecting to a route with an "ID" parameter that is being populated from an Eloquent model, you may simply pass the model itself. The ID will be extracted automatically:
If you are redirecting to a route with an "ID" parameter that is being populated from an Eloquent model, you may pass the model itself. The ID will be extracted automatically:
// For a route with the following URI: profile/{id}

View File

@ -79,7 +79,7 @@ By default, clusters will perform client-side sharding across your nodes, allowi
<a name="predis"></a>
### Predis
In addition to the default `host`, `port`, `database`, and `password` server configuration options, Predis supports additional [connection parameters](https://github.com/nrk/predis/wiki/Connection-Parameters) that may be defined for each of your Redis servers. To utilize these additional configuration options, simply add them to your Redis server configuration in the `config/database.php` configuration file:
In addition to the default `host`, `port`, `database`, and `password` server configuration options, Predis supports additional [connection parameters](https://github.com/nrk/predis/wiki/Connection-Parameters) that may be defined for each of your Redis servers. To utilize these additional configuration options, add them to your Redis server configuration in the `config/database.php` configuration file:
'default' => [
'host' => env('REDIS_HOST', 'localhost'),
@ -141,7 +141,7 @@ You may interact with Redis by calling various methods on the `Redis` [facade](/
}
}
Of course, as mentioned above, you may call any of the Redis commands on the `Redis` facade. Laravel uses magic methods to pass the commands to the Redis server, so simply pass the arguments the Redis command expects:
Of course, as mentioned above, you may call any of the Redis commands on the `Redis` facade. Laravel uses magic methods to pass the commands to the Redis server, so pass the arguments the Redis command expects:
Redis::set('name', 'Taylor');

View File

@ -219,7 +219,7 @@ A rule object only has two methods: `passes` and `message`. The `passes` method
}
}
Once the rule has been defined, you may use it by simply passing an instance of the rule object with your other validation rules:
Once the rule has been defined, you may use it by passing an instance of the rule object with your other validation rules:
use App\Rules\ValidName;

View File

@ -21,7 +21,7 @@
#### Strings & Arrays
All routes and controllers should return a response to be sent back to the user's browser. Laravel provides several different ways to return responses. The most basic response is simply returning a string from a route or controller. The framework will automatically convert the string into a full HTTP response:
All routes and controllers should return a response to be sent back to the user's browser. Laravel provides several different ways to return responses. The most basic response is returning a string from a route or controller. The framework will automatically convert the string into a full HTTP response:
Route::get('/', function () {
return 'Hello World';
@ -130,7 +130,7 @@ If your route has parameters, you may pass them as the second argument to the `r
#### Populating Parameters Via Eloquent Models
If you are redirecting to a route with an "ID" parameter that is being populated from an Eloquent model, you may simply pass the model itself. The ID will be extracted automatically:
If you are redirecting to a route with an "ID" parameter that is being populated from an Eloquent model, you may pass the model itself. The ID will be extracted automatically:
// For a route with the following URI: profile/{id}

View File

@ -23,7 +23,7 @@
<a name="basic-routing"></a>
## Basic Routing
The most basic Laravel routes simply accept a URI and a `Closure`, providing a very simple and expressive method of defining routes:
The most basic Laravel routes accept a URI and a `Closure`, providing a very simple and expressive method of defining routes:
Route::get('foo', function () {
return 'Hello World';

View File

@ -190,7 +190,7 @@ You may also use the `searchable` method on an Eloquent query to update a collec
<a name="removing-records"></a>
### Removing Records
To remove a record from your index, simply `delete` the model from the database. This form of removal is even compatible with [soft deleted](/docs/{{version}}/eloquent#soft-deleting) models:
To remove a record from your index, `delete` the model from the database. This form of removal is even compatible with [soft deleted](/docs/{{version}}/eloquent#soft-deleting) models:
$order = App\Order::find(1);

View File

@ -68,7 +68,7 @@ For example, let's create 50 users and attach a relationship to each user:
<a name="calling-additional-seeders"></a>
### Calling Additional Seeders
Within the `DatabaseSeeder` class, you may use the `call` method to execute additional seed classes. Using the `call` method allows you to break up your database seeding into multiple files so that no single seeder class becomes overwhelmingly large. Simply pass the name of the seeder class you wish to run:
Within the `DatabaseSeeder` class, you may use the `call` method to execute additional seed classes. Using the `call` method allows you to break up your database seeding into multiple files so that no single seeder class becomes overwhelmingly large. Pass the name of the seeder class you wish to run:
/**
* Run the database seeds.

View File

@ -219,7 +219,7 @@ Your custom session driver should implement the `SessionHandlerInterface`. This
Since the purpose of these methods is not readily understandable, let's quickly cover what each of the methods do:
<div class="content-list" markdown="1">
- The `open` method would typically be used in file based session store systems. Since Laravel ships with a `file` session driver, you will almost never need to put anything in this method. You can leave it as an empty stub. It is simply a fact of poor interface design (which we'll discuss later) that PHP requires us to implement this method.
- The `open` method would typically be used in file based session store systems. Since Laravel ships with a `file` session driver, you will almost never need to put anything in this method. You can leave it as an empty stub. It is a fact of poor interface design (which we'll discuss later) that PHP requires us to implement this method.
- The `close` method, like the `open` method, can also usually be disregarded. For most drivers, it is not needed.
- The `read` method should return the string version of the session data associated with the given `$sessionId`. There is no need to do any serialization or other encoding when retrieving or storing session data in your driver, as Laravel will perform the serialization for you.
- The `write` method should write the given `$data` string associated with the `$sessionId` to some persistent storage system, such as MongoDB, Dynamo, etc. Again, you should not perform any serialization - Laravel will have already handled that for you.

View File

@ -104,7 +104,7 @@ The `vendor` directory contains your [Composer](https://getcomposer.org) depende
The majority of your application is housed in the `app` directory. By default, this directory is namespaced under `App` and is autoloaded by Composer using the [PSR-4 autoloading standard](http://www.php-fig.org/psr/psr-4/).
The `app` directory contains a variety of additional directories such as `Console`, `Http`, and `Providers`. Think of the `Console` and `Http` directories as providing an API into the core of your application. The HTTP protocol and CLI are both mechanisms to interact with your application, but do not actually contain application logic. In other words, they are simply two ways of issuing commands to your application. The `Console` directory contains all of your Artisan commands, while the `Http` directory contains your controllers, middleware, and requests.
The `app` directory contains a variety of additional directories such as `Console`, `Http`, and `Providers`. Think of the `Console` and `Http` directories as providing an API into the core of your application. The HTTP protocol and CLI are both mechanisms to interact with your application, but do not actually contain application logic. In other words, they are two ways of issuing commands to your application. The `Console` directory contains all of your Artisan commands, while the `Http` directory contains your controllers, middleware, and requests.
A variety of other directories will be generated inside the `app` directory as you use the `make` Artisan commands to generate classes. So, for example, the `app/Jobs` directory will not exist until you execute the `make:job` Artisan command to generate a job class.

View File

@ -11,7 +11,7 @@ Laravel is built with testing in mind. In fact, support for testing with PHPUnit
By default, your application's `tests` directory contains two directories: `Feature` and `Unit`. Unit tests are tests that focus on a very small, isolated portion of your code. In fact, most unit tests probably focus on a single method. Feature tests may test a larger portion of your code, including how several objects interact with each other or even a full HTTP request to a JSON endpoint.
An `ExampleTest.php` file is provided in both the `Feature` and `Unit` test directories. After installing a new Laravel application, simply run `phpunit` on the command line to run your tests.
An `ExampleTest.php` file is provided in both the `Feature` and `Unit` test directories. After installing a new Laravel application, run `phpunit` on the command line to run your tests.
<a name="environment"></a>
## Environment
@ -31,7 +31,7 @@ To create a new test case, use the `make:test` Artisan command:
// Create a test in the Unit directory...
php artisan make:test UserTest --unit
Once the test has been generated, you may define test methods as you normally would using PHPUnit. To run your tests, simply execute the `phpunit` command from your terminal:
Once the test has been generated, you may define test methods as you normally would using PHPUnit. To run your tests, execute the `phpunit` command from your terminal:
<?php

View File

@ -104,7 +104,7 @@ To get a better understanding of the `validate` method, let's jump back into the
// The blog post is valid...
}
As you can see, we simply pass the 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.
As you can see, we pass the 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
@ -254,7 +254,7 @@ Since all form requests extend the base Laravel request class, we may use the `u
If the `authorize` method returns `false`, a HTTP response with a 403 status code will automatically be returned and your controller method will not execute.
If you plan to have authorization logic in another part of your application, simply return `true` from the `authorize` method:
If you plan to have authorization logic in another part of your application, return `true` from the `authorize` method:
/**
* Determine if the user is authorized to make this request.
@ -339,7 +339,7 @@ If you would like to create a validator instance manually but still take advanta
<a name="named-error-bags"></a>
### Named Error Bags
If you have multiple forms on a single page, you may wish to name the `MessageBag` of errors, allowing you to retrieve the error messages for a specific form. Simply pass a name as the second argument to `withErrors`:
If you have multiple forms on a single page, you may wish to name the `MessageBag` of errors, allowing you to retrieve the error messages for a specific form. Pass a name as the second argument to `withErrors`:
return redirect('register')
->withErrors($validator, 'login');