Skip to content

Commit

Permalink
Put all namesapce on it's on line as reflective of PSR coding style a…
Browse files Browse the repository at this point in the history
…nd what's in the codebase
  • Loading branch information
yadakhov committed Jun 12, 2015
1 parent f7faea2 commit c183ef4
Show file tree
Hide file tree
Showing 36 changed files with 327 additions and 109 deletions.
4 changes: 3 additions & 1 deletion artisan.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ The `handle` method will be called when your command is executed. You may place

Note that we are able to inject any dependencies we need into the command's constructor. The Laravel [service container](/docs/{{version}}/container) will automatically inject all dependencies type-hinted in the constructor. For greater code reusability, it is good practice to keep your console commands light and let them defer to application services to accomplish their tasks.

<?php namespace App\Console\Commands;
<?php

namespace App\Console\Commands;

use App\User;
use App\DripEmailer;
Expand Down
16 changes: 12 additions & 4 deletions authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ You may access the authenticated user via the `Auth` facade:

Alternatively, once a user is authenticated, you may access the authenticated user via an `Illuminate\Http\Request` instance:

<?php namespace App\Http\Controllers;
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
Expand Down Expand Up @@ -204,7 +206,9 @@ Of course, you are not required to use the authentication controllers included w

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:

<?php namespace App\Http\Controllers;
<?php

namespace App\Http\Controllers;

use Auth;
use Illuminate\Routing\Controller;
Expand Down Expand Up @@ -470,7 +474,9 @@ You will also need to add credentials for the OAuth services your application ut

Next, you are ready to authenticate users! You will need two routes: one for redirecting the user to the OAuth provider, and another for receiving the callback from the provider after authentication. We will access Socialite using the `Socialite` [facade](/docs/{{version}}/facades):

<?php namespace App\Http\Controllers;
<?php

namespace App\Http\Controllers;

use Illuminate\Routing\Controller;

Expand Down Expand Up @@ -529,7 +535,9 @@ Once you have a user instance, you can grab a few more details about the user:

If you are not using a traditional relational database to store your users, you will need to extend Laravel with your own authentication driver. We will use the `extend` method on the `Auth` facade to define a custom driver. You should place this call to `extend` within a [service provider](/docs/{{version}}/providers):

<?php namespace App\Providers;
<?php

namespace App\Providers;

use Auth;
use App\Extensions\RiakUserProvider;
Expand Down
4 changes: 3 additions & 1 deletion billing.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,9 @@ Since Stripe webhooks need to bypass Laravel's [CSRF verification](/docs/{{versi

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.

<?php namespace App\Http\Controller;
<?php

namespace App\Http\Controller;

use Laravel\Cashier\WebhookController as BaseController;

Expand Down
4 changes: 3 additions & 1 deletion blade.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ Blade even allows you to define your own custom directives. You can use the `dir

The following example creates a `@datetime($var)` directive which formats a given `$var`:

<?php namespace App\Providers;
<?php

namespace App\Providers;

use Blade;
use Illuminate\Support\ServiceProvider;
Expand Down
12 changes: 9 additions & 3 deletions cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ However, you may also use the `Cache` facade, which is what we will use througho

For example, let's import the `Cache` facade into a controller:

<?php namespace App\Http\Controllers;
<?php

namespace App\Http\Controllers;

use Cache;
use Illuminate\Routing\Controller;
Expand Down Expand Up @@ -190,7 +192,9 @@ To extend the Laravel cache with a custom driver, we will use the `extend` metho

For example, to register a new cache driver named "mongo":

<?php namespace App\Providers;
<?php

namespace App\Providers;

use Cache;
use App\Extensions\MongoStore;
Expand Down Expand Up @@ -227,7 +231,9 @@ The call to `Cache::extend` could be done in the `boot` method of the default `A

To create our custom cache driver, we first need to implement the `Illuminate\Contracts\Cache\Store` [contract](/docs/{{version}}/contracts) contract. So, our MongoDB cache implementation would look something like this:

<?php namespace App\Extensions;
<?php

namespace App\Extensions;

class MongoStore implements \Illuminate\Contracts\Cache\Store
{
Expand Down
8 changes: 6 additions & 2 deletions container.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ The Laravel service container is a powerful tool for managing class dependencies

Let's look at a simple example:

<?php namespace App\Jobs;
<?php

namespace App\Jobs;

use App\User;
use Illuminate\Contracts\Mail\Mailer;
Expand Down Expand Up @@ -158,7 +160,9 @@ Lastly, but most importantly, you may simply "type-hint" the dependency in the c

The container will automatically inject dependencies for the classes it resolves. 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:

<?php namespace App\Http\Controllers;
<?php

namespace App\Http\Controllers;

use Illuminate\Routing\Controller;
use App\Users\Repository as UserRepository;
Expand Down
12 changes: 9 additions & 3 deletions contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ You may have several questions regarding contracts. Why use interfaces at all? I

First, let's review some code that is tightly coupled to a cache implementation. Consider the following:

<?php namespace App\Orders;
<?php

namespace App\Orders;

class Repository
{
Expand Down Expand Up @@ -67,7 +69,9 @@ Likewise, if we want to replace our underlying cache technology (Memcached) with

**Instead of this approach, we can improve our code by depending on a simple, vendor agnostic interface:**

<?php namespace App\Orders;
<?php

namespace App\Orders;

use Illuminate\Contracts\Cache\Repository as Cache;

Expand Down Expand Up @@ -143,7 +147,9 @@ Many types of classes in Laravel are resolved through the [service container](/d

For example, take a look at this event listener:

<?php namespace App\Listeners;
<?php

namespace App\Listeners;

use App\User;
use App\Events\NewUserRegistered;
Expand Down
24 changes: 18 additions & 6 deletions controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ Instead of defining all of your request handling logic in a single `routes.php`

Here is an example of a basic controller class. All Laravel controllers should extend the base controller class included with the default Laravel installation:

<?php namespace App\Http\Controllers;
<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;

Expand Down Expand Up @@ -152,7 +154,9 @@ Sometimes you may need to define routes to a "nested" resource. For example, a p

This route will register a "nested" resource that may be accessed with URLs like the following: `photos/{photos}/comments/{comments}`.

<?php namespace App\Http\Controllers;
<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;

Expand Down Expand Up @@ -190,7 +194,9 @@ Laravel allows you to easily define a single route to handle every action in a c

Next, just add methods to your controller. The method names should begin with the HTTP verb they respond to followed by the title case version of the URI:

<?php namespace App\Http\Controllers;
<?php

namespace App\Http\Controllers;

class UserController extends Controller
{
Expand Down Expand Up @@ -244,7 +250,9 @@ If you would like to [name](/docs/{{version}}/routing#named-routes) some of the

The Laravel [service container](/docs/{{version}}/container) is used to resolve all Laravel controllers. As a result, you are able to type-hint any dependencies your controller may need in its constructor. The dependencies will automatically be resolved and injected into the controller instance:

<?php namespace App\Http\Controllers;
<?php

namespace App\Http\Controllers;

use Illuminate\Routing\Controller;
use App\Repositories\UserRepository;
Expand Down Expand Up @@ -274,7 +282,9 @@ Of course, you may also type-hint any [Laravel contract](/docs/{{version}}/contr

In addition to constructor injection, you may also type-hint dependencies on your controller's action methods. For example, let's type-hint the `Illuminate\Http\Request` instance on one of our methods:

<?php namespace App\Http\Controllers;
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
Expand All @@ -297,7 +307,9 @@ 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:

<?php namespace App\Http\Controllers;
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
Expand Down
8 changes: 6 additions & 2 deletions database.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ Once you have configured your database connection, you may run queries using the

To run a basic query, we can use the `select` method on the `DB` facade:

<?php namespace App\Http\Controllers;
<?php

namespace App\Http\Controllers;

use DB;
use App\Http\Controllers\Controller;
Expand Down Expand Up @@ -122,7 +124,9 @@ Some database statements should not return any value. For these types of operati

If you would like to receive each SQL query executed by your application, you may use the `listen` method. This method is useful for logging queries or debugging. You may register your query listener in a [service provider](/docs/{{version}}/providers):

<?php namespace App\Providers;
<?php

namespace App\Providers;

use DB;
use Illuminate\Support\ServiceProvider;
Expand Down
4 changes: 3 additions & 1 deletion eloquent-collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ All Eloquent collections extend the base [Laravel collection](/docs/{{version}}/

If you need to use a custom `Collection` object with your own extension methods, you may override the `newCollection` method on your model:

<?php namespace App;
<?php

namespace App;

use App\CustomCollection;
use Illuminate\Database\Eloquent\Model;
Expand Down
20 changes: 15 additions & 5 deletions eloquent-mutators.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ In addition to custom accessors and mutators, Eloquent can also automatically ca

To define an accessor, create a `getFooAttribute` method on your model where `Foo` is the "camel" cased name of the column you wish to access. In this example, we'll defined an accessor for the `first_name` attribute. The accessor will automatically be called by Eloquent when attempting to retrieve the value of `first_name`:

<?php namespace App;
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

Expand Down Expand Up @@ -47,7 +49,9 @@ As you can see, the original value of the column is passed to the accessor, allo

To define a mutator, define a `setFooAttribute` method on your model where `Foo` is the "camel" cased name of the column you wish to access. So, again, let's define a mutator for the `first_name` attribute. This mutator will be automatically called when we attempt to set the value of the `first_name` attribute on the model:

<?php namespace App;
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

Expand Down Expand Up @@ -80,7 +84,9 @@ By default, Eloquent will convert the `created_at` and `updated_at` columns to i

You may customize which fields are automatically mutated, and even completely disable this mutation, by overriding the `$dates` property of your model:

<?php namespace App;
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

Expand Down Expand Up @@ -115,7 +121,9 @@ The `$casts` property on your model provides a convenient method of converting a

For example, let's cast the `is_admin` attribute, which is stored in our database as an integer (`0` or `1`) to a boolean value:

<?php namespace App;
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

Expand Down Expand Up @@ -143,7 +151,9 @@ Now the `is_admin` attribute will always be cast to a boolean when you access it

The `array` cast type is particularly useful when working with columns that are stored as serialized JSON. For example, if your database has a `TEXT` field type that contains serialized JSON, adding the `array` cast to that attribute will automatically deserialize the attribute to a PHP array when you access it on your Eloquent model:

<?php namespace App;
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

Expand Down
Loading

0 comments on commit c183ef4

Please sign in to comment.