Skip to content

Commit

Permalink
Document wildcard listeners.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed May 3, 2013
1 parent 50b1e71 commit 8a8d2c3
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 1 deletion.
6 changes: 5 additions & 1 deletion database.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ You may listen for query events using the `DB::listen` method:

When using multiple connections, you may access them via the `DB::connection` method:

$users = DB::connection('foo')->select(...);
$users = DB::connection('foo')->select(...);

Sometimes you may need to reconnect to a given database:

DB::reconnect('foo');
4 changes: 4 additions & 0 deletions eloquent.md
Original file line number Diff line number Diff line change
Expand Up @@ -796,3 +796,7 @@ Sometimes you may wish to limit the attributes that are included in your model's
protected $hidden = array('password');

}

Alternatively, you may use the `visible` property to define a white-list:

protected $visible = array('first_name', 'last_name');
15 changes: 15 additions & 0 deletions events.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Events

- [Basic Usage](#basic-usage)
- [Wildcard Listeners](#wildcard-listeners)
- [Using Classes As Listeners](#using-classes-as-listeners)
- [Queued Events](#queued-events)
- [Event Subscribers](#event-subscribers)
Expand Down Expand Up @@ -42,6 +43,20 @@ Sometimes, you may wish to stop the propagation of an event to other listeners.
return false;
});

<a name="wildcard-listeners"></a>
## Wildcard Listeners

When registering an event listener, you may use asterisks to specify wildcard listeners:

**Registering Wildcard Event Listeners**

Event::listen('foo.*', function($param, $event)
{
// Handle the event...
});

This listener will handle all events that begin with "foo.". Note that the full event name is passed as the last argument to the handler.

<a name="using-classes-as-listeners"></a>
## Using Classes As Listeners

Expand Down
20 changes: 20 additions & 0 deletions schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [Adding Columns](#adding-columns)
- [Renaming Columns](#renaming-columns)
- [Dropping Columns](#dropping-columns)
- [Checking Existence](#checking-existence)
- [Adding Indexes](#adding-indexes)
- [Dropping Indexes](#dropping-indexes)

Expand Down Expand Up @@ -106,6 +107,25 @@ To rename a column, you may use the `renameColumn` method on the Schema builder:
$table->dropColumn('votes', 'avatar', 'location');
});

<a name="checking-existence"></a>
## Checking Existence

You may easily check for the existence of a table or column using the `hasTable` and `hasColumn` methods:

**Checking For Existence Of Table**

if (Schema::hasTable('users'))
{
//
}

**Checking For Existence Of Columns**

if (Schema::hasColumn('users', 'email'))
{
//
}

<a name="adding-indexes"></a>
## Adding Indexes

Expand Down
10 changes: 10 additions & 0 deletions validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ Below is a list of all available validation rules and their function:
- [Numeric](#rule-numeric)
- [Regular Expression](#rule-regex)
- [Required](#rule-required)
- [Required If](#rule-required-if)
- [Required With](#rule-required-with)
- [Same](#rule-same)
- [Size](#rule-size)
Expand Down Expand Up @@ -293,6 +294,11 @@ The field under validation must match the given regular expression.

The field under validation must be present in the input data.

<a name="rule-required-if"></a>
#### required_if:_foo_,_bar_

The field under validation must be present if the _foo_ field is equal to _bar_.

<a name="rule-required-with"></a>
#### required_with:_foo_,_bar_,...

Expand Down Expand Up @@ -388,6 +394,10 @@ Laravel provides a variety of helpful validation rules; however, you may wish to
The custom validator Closure receives three arguments: the name of the `$attribute` being validated, the `$value` of the attribute, and an array of `$parameters` passed to the rule.

You may also pass a class and method to the `extend` method instead of a Closure:

Validator::extend('foo', 'FooValidator@validate');

Note that you will also need to define an error message for your custom rules. You can do so either using an inline custom message array or by adding an entry in the validation language file.

Instead of using Closure callbacks to extend the Validator, you may also extend the Validator class itself. To do so, write a Validator class that extends `Illuminate\Validation\Validator`. You may add validation methods to the class by prefixing them with `validate`:
Expand Down

0 comments on commit 8a8d2c3

Please sign in to comment.