Skip to content

Commit

Permalink
Eliminate (almost) all instances of "of course" and "as you might exp…
Browse files Browse the repository at this point in the history
…ect"

These phrases were overused, didn't add any value, and seemed
a bit condescending. People are reading the Laravel docs to
become educated. The docs shouldn't imply that everything
Laravel does is natural or a matter "of course", because that
could make people feel bad for having to learn how it works
instead of instinctively knowing it already.

fixes #4973
  • Loading branch information
markjaquith committed Feb 13, 2019
1 parent 3d66c78 commit b1b37c9
Show file tree
Hide file tree
Showing 45 changed files with 83 additions and 83 deletions.
10 changes: 5 additions & 5 deletions authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ To determine if the user is already logged into your application, you may use th
// Only authenticated users may enter...
})->middleware('auth');

Of course, if you are using [controllers](/docs/{{version}}/controllers), you may call the `middleware` method from the controller's constructor instead of attaching it in the route definition directly:
If you are using [controllers](/docs/{{version}}/controllers), you may call the `middleware` method from the controller's constructor instead of attaching it in the route definition directly:

public function __construct()
{
Expand Down Expand Up @@ -214,7 +214,7 @@ If you are using Laravel's built-in `LoginController` class, the `Illuminate\Fou
<a name="authenticating-users"></a>
## Manually Authenticating Users

Of course, you are not required to use the authentication controllers included with Laravel. If you choose to remove these controllers, you will need to manage user authentication using the Laravel authentication classes directly. Don't worry, it's a cinch!
Note that you are not required to use the authentication controllers included with Laravel. If you choose to remove these controllers, you will need to manage user authentication using the Laravel authentication classes directly. Don't worry, it's a cinch!

We will access Laravel's authentication services via the `Auth` [facade](/docs/{{version}}/facades), so we'll need to make sure to import the `Auth` facade at the top of the class. Next, let's check out the `attempt` method:

Expand Down Expand Up @@ -280,7 +280,7 @@ To log users out of your application, you may use the `logout` method on the `Au
<a name="remembering-users"></a>
### Remembering Users

If you would like to provide "remember me" functionality in your application, you may pass a boolean value as the second argument to the `attempt` method, which will keep the user authenticated indefinitely, or until they manually logout. Of course, your `users` table must include the string `remember_token` column, which will be used to store the "remember me" token.
If you would like to provide "remember me" functionality in your application, you may pass a boolean value as the second argument to the `attempt` method, which will keep the user authenticated indefinitely, or until they manually logout. Your `users` table must include the string `remember_token` column, which will be used to store the "remember me" token.

if (Auth::attempt(['email' => $email, 'password' => $password], $remember)) {
// The user is being remembered...
Expand All @@ -299,14 +299,14 @@ If you are "remembering" users, you may use the `viaRemember` method to determin

#### Authenticate A User Instance

If you need to log an existing user instance into your application, you may call the `login` method with the user instance. The given object must be an implementation of the `Illuminate\Contracts\Auth\Authenticatable` [contract](/docs/{{version}}/contracts). Of course, the `App\User` model included with Laravel already implements this interface:
If you need to log an existing user instance into your application, you may call the `login` method with the user instance. The given object must be an implementation of the `Illuminate\Contracts\Auth\Authenticatable` [contract](/docs/{{version}}/contracts). The `App\User` model included with Laravel already implements this interface:

Auth::login($user);

// Login and "remember" the given user...
Auth::login($user, true);

Of course, you may specify the guard instance you would like to use:
You may specify the guard instance you would like to use:

Auth::guard('admin')->login($user);

Expand Down
2 changes: 1 addition & 1 deletion billing.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ Occasionally, you may wish to create a Stripe customer without beginning a subsc

$user->createAsStripeCustomer();

Of course, once the customer has been created in Stripe, you may begin a subscription at a later date.
Once the customer has been created in Stripe, you may begin a subscription at a later date.

> {tip} The Braintree equivalent of this method is the `createAsBraintreeCustomer` method.
Expand Down
4 changes: 2 additions & 2 deletions blade.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ You may display the contents of the `name` variable like so:

> {tip} Blade `{{ }}` statements are automatically sent through PHP's `htmlspecialchars` function to prevent XSS attacks.
Of course, you are not limited to displaying the contents of the variables passed to the view. You may also echo the results of any PHP function. In fact, you can put any PHP code you wish inside of a Blade echo statement:
You are not limited to displaying the contents of the variables passed to the view. You may also echo the results of any PHP function. In fact, you can put any PHP code you wish inside of a Blade echo statement:

The current UNIX timestamp is {{ time() }}.

Expand Down Expand Up @@ -475,7 +475,7 @@ Even though the included view will inherit all data available in the parent view

@include('view.name', ['some' => 'data'])

Of course, if you attempt to `@include` a view which does not exist, Laravel will throw an error. If you would like to include a view that may or may not be present, you should use the `@includeIf` directive:
If you attempt to `@include` a view which does not exist, Laravel will throw an error. If you would like to include a view that may or may not be present, you should use the `@includeIf` directive:

@includeIf('view.name', ['some' => 'data'])

Expand Down
2 changes: 1 addition & 1 deletion broadcasting.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ Next, register your channel in your `routes/channels.php` file:

Broadcast::channel('order.{order}', OrderChannel::class);

Finally, you may place the authorization logic for your channel in the channel class' `join` method. This `join` method will house the same logic you would have typically placed in your channel authorization Closure. Of course, you may also take advantage of channel model binding:
Finally, you may place the authorization logic for your channel in the channel class' `join` method. This `join` method will house the same logic you would have typically placed in your channel authorization Closure. You may also take advantage of channel model binding:

<?php

Expand Down
4 changes: 2 additions & 2 deletions controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ You can define a route to this controller action like so:

Route::get('user/{id}', 'UserController@show');

Now, when a request matches the specified route URI, the `show` method on the `UserController` class will be executed. Of course, the route parameters will also be passed to the method.
Now, when a request matches the specified route URI, the `show` method on the `UserController` class will be executed. The route parameters will also be passed to the method.

> {tip} Controllers are not **required** to extend a base class. However, you will not have access to convenience features such as the `middleware`, `validate`, and `dispatch` methods.
Expand Down Expand Up @@ -305,7 +305,7 @@ The Laravel [service container](/docs/{{version}}/container) is used to resolve
}
}

Of course, you may also type-hint any [Laravel contract](/docs/{{version}}/contracts). If the container can resolve it, you can type-hint it. Depending on your application, injecting your dependencies into your controller may provide better testability.
You may also type-hint any [Laravel contract](/docs/{{version}}/contracts). If the container can resolve it, you can type-hint it. Depending on your application, injecting your dependencies into your controller may provide better testability.

#### Method Injection

Expand Down
2 changes: 1 addition & 1 deletion database-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Laravel provides a variety of helpful tools to make it easier to test your datab

You can also use the `assertDatabaseMissing` helper to assert that data does not exist in the database.

Of course, the `assertDatabaseHas` method and other helpers like it are for convenience. You are free to use any of PHPUnit's built-in assertion methods to supplement your tests.
The `assertDatabaseHas` method and other helpers like it are for convenience. You are free to use any of PHPUnit's built-in assertion methods to supplement your tests.

<a name="generating-factories"></a>
## Generating Factories
Expand Down
2 changes: 1 addition & 1 deletion database.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Laravel makes interacting with databases extremely simple across a variety of da

The database configuration for your application is located at `config/database.php`. In this file you may define all of your database connections, as well as specify which connection should be used by default. Examples for most of the supported database systems are provided in this file.

By default, Laravel's sample [environment configuration](/docs/{{version}}/configuration#environment-configuration) is ready to use with [Laravel Homestead](/docs/{{version}}/homestead), which is a convenient virtual machine for doing Laravel development on your local machine. Of course, you are free to modify this configuration as needed for your local database.
By default, Laravel's sample [environment configuration](/docs/{{version}}/configuration#environment-configuration) is ready to use with [Laravel Homestead](/docs/{{version}}/homestead), which is a convenient virtual machine for doing Laravel development on your local machine. You are free to modify this configuration as needed for your local database.

#### SQLite Configuration

Expand Down
2 changes: 1 addition & 1 deletion dusk.md
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ If you are using CircleCI to run your Dusk tests, you may use this configuration
<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 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. These commands are just a starting point and you are free to add additional commands as needed:

phpenv local 7.2
cp .env.testing .env
Expand Down
2 changes: 1 addition & 1 deletion eloquent-collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

All multi-result sets returned by Eloquent are instances of the `Illuminate\Database\Eloquent\Collection` object, including results retrieved via the `get` method or accessed via a relationship. The Eloquent collection object extends the Laravel [base collection](/docs/{{version}}/collections), so it naturally inherits dozens of methods used to fluently work with the underlying array of Eloquent models.

Of course, all collections also serve as iterators, allowing you to loop over them as if they were simple PHP arrays:
All collections also serve as iterators, allowing you to loop over them as if they were simple PHP arrays:

$users = App\User::where('active', 1)->get();

Expand Down
4 changes: 2 additions & 2 deletions eloquent-mutators.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ As you can see, the original value of the column is passed to the accessor, allo

$firstName = $user->first_name;

Of course, you may also use accessors to return new, computed values from existing attributes:
You may also use accessors to return new, computed values from existing attributes:

/**
* Get the user's full name.
Expand Down Expand Up @@ -121,7 +121,7 @@ By default, Eloquent will convert the `created_at` and `updated_at` columns to i

> {tip} You may disable the default `created_at` and `updated_at` timestamps by setting the public `$timestamps` property of your model to `false`.
When a column is considered a date, you may set its value to a UNIX timestamp, date string (`Y-m-d`), date-time string, and of course a `DateTime` / `Carbon` instance. The date's value will be correctly converted and stored in your database:
When a column is considered a date, you may set its value to a UNIX timestamp, date string (`Y-m-d`), date-time string, or a `DateTime` / `Carbon` instance. The date's value will be correctly converted and stored in your database:

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

Expand Down
10 changes: 5 additions & 5 deletions eloquent-relationships.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Once the relationship has been defined, we can access the collection of comments
//
}

Of course, since all relationships also serve as query builders, you can add further constraints to which comments are retrieved by calling the `comments` method and continuing to chain conditions onto the query:
Since all relationships also serve as query builders, you can add further constraints to which comments are retrieved by calling the `comments` method and continuing to chain conditions onto the query:

$comment = App\Post::find(1)->comments()->where('title', 'foo')->first();

Expand Down Expand Up @@ -248,7 +248,7 @@ Once the relationship is defined, you may access the user's roles using the `rol
//
}

Of course, like all other relationship types, you may call the `roles` method to continue chaining query constraints onto the relationship:
Like all other relationship types, you may call the `roles` method to continue chaining query constraints onto the relationship:

$roles = App\User::find(1)->roles()->orderBy('name')->get();

Expand Down Expand Up @@ -363,7 +363,7 @@ When defining the `UserRole` model, we will extend the `Pivot` class:
//
}

Of course, you can combine `using` and `withPivot` in order to retrieve columns from the intermediate table. For example, you may retrieve the `created_by` and `updated_by` columns from the `UserRole` pivot table by passing the column names to the `withPivot` method:
You can combine `using` and `withPivot` in order to retrieve columns from the intermediate table. For example, you may retrieve the `created_by` and `updated_by` columns from the `UserRole` pivot table by passing the column names to the `withPivot` method:

<?php

Expand Down Expand Up @@ -933,7 +933,7 @@ Sometimes you may wish to eager load a relationship, but also specify additional
$query->where('title', 'like', '%first%');
}])->get();

In this example, Eloquent will only eager load posts where the post's `title` column contains the word `first`. Of course, you may call other [query builder](/docs/{{version}}/queries) methods to further customize the eager loading operation:
In this example, Eloquent will only eager load posts where the post's `title` column contains the word `first`. You may call other [query builder](/docs/{{version}}/queries) methods to further customize the eager loading operation:

$users = App\User::with(['posts' => function ($query) {
$query->orderBy('created_at', 'desc');
Expand Down Expand Up @@ -1102,7 +1102,7 @@ When attaching a relationship to a model, you may also pass an array of addition

$user->roles()->attach($roleId, ['expires' => $expires]);

Of course, sometimes it may be necessary to remove a role from a user. To remove a many-to-many relationship record, use the `detach` method. The `detach` method will delete the appropriate record out of the intermediate table; however, both models will remain in the database:
Sometimes it may be necessary to remove a role from a user. To remove a many-to-many relationship record, use the `detach` method. The `detach` method will delete the appropriate record out of the intermediate table; however, both models will remain in the database:

// Detach a single role from the user...
$user->roles()->detach($roleId);
Expand Down
4 changes: 2 additions & 2 deletions eloquent-resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ If you are returning a collection of resources or a paginated response, you may
return UserResource::collection(User::all());
});

Of course, this does not allow any addition of meta data that may need to be returned with the collection. If you would like to customize the resource collection response, you may create a dedicated resource to represent the collection:
Note that this does not allow any addition of meta data that may need to be returned with the collection. If you would like to customize the resource collection response, you may create a dedicated resource to represent the collection:

php artisan make:resource UserCollection

Expand Down Expand Up @@ -319,7 +319,7 @@ If you would like to disable the wrapping of the outer-most resource, you may us

You have total freedom to determine how your resource's relationships are wrapped. If you would like all resource collections to be wrapped in a `data` key, regardless of their nesting, you should define a resource collection class for each resource and return the collection within a `data` key.

Of course, you may be wondering if this will cause your outer-most resource to be wrapped in two `data` keys. Don't worry, Laravel will never let your resources be accidentally double-wrapped, so you don't have to be concerned about the nesting level of the resource collection you are transforming:
You may be wondering if this will cause your outer-most resource to be wrapped in two `data` keys. Don't worry, Laravel will never let your resources be accidentally double-wrapped, so you don't have to be concerned about the nesting level of the resource collection you are transforming:

<?php

Expand Down
10 changes: 5 additions & 5 deletions eloquent.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ For Eloquent methods like `all` and `get` which retrieve multiple results, an in
return $flight->cancelled;
});

Of course, you may also loop over the collection like an array:
You may also loop over the collection like an array:

foreach ($flights as $flight) {
echo $flight->name;
Expand Down Expand Up @@ -260,7 +260,7 @@ The `cursor` method allows you to iterate through your database records using a
<a name="retrieving-single-models"></a>
## Retrieving Single Models / Aggregates

Of course, in addition to retrieving all of the records for a given table, you may also retrieve single records using `find` or `first`. Instead of returning a collection of models, these methods return a single model instance:
In addition to retrieving all of the records for a given table, you may also retrieve single records using `find` or `first`. Instead of returning a collection of models, these methods return a single model instance:

// Retrieve a model by its primary key...
$flight = App\Flight::find(1);
Expand Down Expand Up @@ -391,7 +391,7 @@ If you already have a model instance, you may use the `fill` method to populate

#### Guarding Attributes

While `$fillable` serves as a "white list" of attributes that should be mass assignable, you may also choose to use `$guarded`. The `$guarded` property should contain an array of attributes that you do not want to be mass assignable. All other attributes not in the array will be mass assignable. So, `$guarded` functions like a "black list". Of course, you should use either `$fillable` or `$guarded` - not both. In the example below, all attributes **except for `price`** will be mass assignable:
While `$fillable` serves as a "white list" of attributes that should be mass assignable, you may also choose to use `$guarded`. The `$guarded` property should contain an array of attributes that you do not want to be mass assignable. All other attributes not in the array will be mass assignable. So, `$guarded` functions like a "black list". Importantly, you should use either `$fillable` or `$guarded` - not both. In the example below, all attributes **except for `price`** will be mass assignable:

<?php

Expand Down Expand Up @@ -477,7 +477,7 @@ In the example above, we are retrieving the model from the database before calli

#### Deleting Models By Query

Of course, you may also run a delete statement on a set of models. In this example, we will delete all flights that are marked as inactive. Like mass updates, mass deletes will not fire any model events for the models that are deleted:
You can also run a delete statement on a set of models. In this example, we will delete all flights that are marked as inactive. Like mass updates, mass deletes will not fire any model events for the models that are deleted:

$deletedRows = App\Flight::where('active', 0)->delete();

Expand Down Expand Up @@ -507,7 +507,7 @@ In addition to actually removing records from your database, Eloquent can also "
protected $dates = ['deleted_at'];
}

Of course, you should add the `deleted_at` column to your database table. The Laravel [schema builder](/docs/{{version}}/migrations) contains a helper method to create this column:
You should also add the `deleted_at` column to your database table. The Laravel [schema builder](/docs/{{version}}/migrations) contains a helper method to create this column:

Schema::table('flights', function (Blueprint $table) {
$table->softDeletes();
Expand Down
Loading

0 comments on commit b1b37c9

Please sign in to comment.