Skip to content

Commit eff2f84

Browse files
committed
Updating documentation.
1 parent 6c2631f commit eff2f84

File tree

7 files changed

+101
-4
lines changed

7 files changed

+101
-4
lines changed

cache.md

+21
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- [Configuration](#configuration)
44
- [Cache Usage](#cache-usage)
5+
- [Increments & Decrements](#increments-and-decrements)
56
- [Database Cache](#database-cache)
67

78
<a name="configuration"></a>
@@ -18,6 +19,10 @@ The cache configuration file also contains various other options, which are docu
1819

1920
Cache::put('key', 'value', $minutes);
2021

22+
**Storing An Item In The Cache If It Doesn't Exist**
23+
24+
Cache::add('key', 'value', $minutes);
25+
2126
**Retrieving An Item From The Cache**
2227

2328
$value = Cache::get('key');
@@ -52,6 +57,22 @@ Note that all items stored in the cache are serialized, so you are free to store
5257

5358
Cache::forget('key');
5459

60+
<a name="increments-and-decrements"></a>
61+
62+
All drivers except `file` and `database` support the `increment` and `decrement` operations:
63+
64+
**Incrementing A Value**
65+
66+
Cache::increment('key');
67+
68+
Cache::increment('key', $amount);
69+
70+
**Decrementing A Value**
71+
72+
Cache::decrement('key');
73+
74+
Cache::decrement('key', $amount);
75+
5576
<a name="database-cache"></a>
5677
## Database Cache
5778

commands.md

+4
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ You may also use the `ask` and `confirm` methods to prompt the user for input:
9595

9696
$name = $this->ask('What is your name?');
9797

98+
**Asking The User For Secret Input**
99+
100+
$password = $this->secret('What is the password?');
101+
98102
**Asking The User For Confirmation**
99103

100104
if ($this->confirm('Do you wish to continue? [yes|no]'))

eloquent.md

+21
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- [Basic Usage](#basic-usage)
55
- [Insert, Update, Delete](#insert-update-delete)
66
- [Timestamps](#timestamps)
7+
- [Query Scopes](#query-scopes)
78
- [Relationships](#relationships)
89
- [Eager Loading](#eager-loading)
910
- [Inserting Related Models](#inserting-related-models)
@@ -148,6 +149,26 @@ If you wish to customize the format of your timestamps, you may override the `fr
148149

149150
}
150151

152+
<a name="query-scopes"></a>
153+
## Query Scopes
154+
155+
Scopes allow you to easily re-use query logic in your models. To define a scope, simply prefix a model method with `scope`:
156+
157+
**Defining A Query Scope**
158+
159+
class User extends Eloquent {
160+
161+
public function scopePopular($query)
162+
{
163+
return $query->where('votes', '>', 100);
164+
}
165+
166+
}
167+
168+
**Utilizing A Query Scope**
169+
170+
$users = User::popular()->orderBy('created_at')->get();
171+
151172
<a name="relationships"></a>
152173
## Relationships
153174

lifecycle.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Of course, if you have other environments in addition to `local`, you may create
2121
<a name="application-events"></a>
2222
## Application Events
2323

24-
You may also do pre and post request processing by registering `before` and `after` application events:
24+
You may also do pre and post request processing by registering `before`, `after`, `close`, `finish`, and `shutdown` application events:
2525

2626
**Registering Application Events**
2727

@@ -30,7 +30,7 @@ You may also do pre and post request processing by registering `before` and `aft
3030
//
3131
});
3232

33-
App::after(function()
33+
App::after(function($request, $response)
3434
{
3535
//
3636
});

packages.md

+2
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ Some packages may have assets such as JavaScript, CSS, and images. However, we a
170170

171171
**Moving Package Assets To Public**
172172

173+
php artisan asset:publish
174+
173175
php artisan asset:publish vendor/package
174176

175177
If the package is still in the `workbench`, use the `--bench` directive:

queues.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
The Laravel Queue component provides a unified API across a variety of different queue services. Queues allow you to defer the processing of a time consuming task, such as sending an e-mail, until a later time, thus drastically speeding up the web requests to your application.
1111

12-
The queue configuration file is stored in `app/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 [Beanstalkd](http://kr.github.com/beanstalkd) and synchronous (for local use) driver.
12+
The queue configuration file is stored in `app/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 [Beanstalkd](http://kr.github.com/beanstalkd), [IronMQ](http://iron.io), [Amazon SQS](http://aws.amazon.com/sqs), and synchronous (for local use) driver.
1313

1414
<a name="basic-usage"></a>
1515
## Basic Usage
@@ -85,7 +85,13 @@ You may also specify which queue connection the listener should utilize:
8585

8686
Note that once this task has started, it will continue to run until it is manually stopped. You may use a process monitor such as [Supervisor](http://supervisord.org/) to ensure that the queue listener does not stop running.
8787

88-
To process the only the first job on the queue, you may use the `queue:work` command:
88+
You may also set the length of time (in seconds) each job should be allowed run:
89+
90+
**Specifying The Job Timeout Parameter**
91+
92+
php artisan queue:listen --timeout=60
93+
94+
To process only the first job on the queue, you may use the `queue:work` command:
8995

9096
**Processing The First Job On The Queue**
9197

testing.md

+43
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- [Test Environment](#test-environment)
66
- [Calling Routes From Tests](#calling-routes-from-tests)
77
- [Mocking Facades](#mocking-facades)
8+
- [Framework Assertions](#framework-assertions)
89
- [Helper Methods](#helper-methods)
910

1011
<a name="introduction"></a>
@@ -105,6 +106,48 @@ We can mock the call to the `Event` class by using the `shouldReceive` method on
105106

106107
> **Note:** You should not mock the `Request` facade. Instead, pass the input you desire into the `call` method when running your test.
107108
109+
<a name="framework-assertions"></a>
110+
## Framework Assertions
111+
112+
Laravel ships with several `assert` methods to make testing a little easier:
113+
114+
**Asserting Responses Are OK**
115+
116+
public function testMethod()
117+
{
118+
$this->call('GET', '/');
119+
120+
$this->assertRepsonseIsOk();
121+
}
122+
123+
**Asserting Responses Are Redirects**
124+
125+
$this->assertRedirectedTo('foo');
126+
127+
$this->assertRedirectedToRoute('route.name');
128+
129+
$this->assertRedirectedToAction('Controller@method');
130+
131+
**Asserting A View Has Some Data**
132+
133+
public function testMethod()
134+
{
135+
$this->call('GET', '/');
136+
137+
$this->assertViewHas('name');
138+
$this->assertViewHas('age', $value);
139+
}
140+
141+
**Asserting The Session Has Some Data**
142+
143+
public function testMethod()
144+
{
145+
$this->call('GET', '/');
146+
147+
$this->assertSessionHas('name');
148+
$this->assertSessionHas('age', $value);
149+
}
150+
108151
<a name="helper-methods"></a>
109152
## Helper Methods
110153

0 commit comments

Comments
 (0)