Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit e56e6b5

Browse files
nightowl77igorsantos07
authored andcommitted
Fixed heading for "Updates with Unique Rules" in documentation
1 parent e316250 commit e56e6b5

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

README.md

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ to your database, obviously):
3030

3131
```php
3232
\LaravelBook\Ardent\Ardent::configureAsExternal(array(
33-
'driver' => 'mysql',
34-
'host' => 'localhost',
35-
'port' => 3306,
36-
'database' => 'my_system',
37-
'username' => 'myself',
38-
'password' => 'h4ckr',
39-
'charset' => 'utf8',
40-
'collation' => 'utf8_unicode_ci'
33+
'driver' => 'mysql',
34+
'host' => 'localhost',
35+
'port' => 3306,
36+
'database' => 'my_system',
37+
'username' => 'myself',
38+
'password' => 'h4ckr',
39+
'charset' => 'utf8',
40+
'collation' => 'utf8_unicode_ci'
4141
));
4242
```
4343

@@ -141,8 +141,8 @@ class User extends \LaravelBook\Ardent\Ardent {
141141
public static $rules = array(
142142
'name' => 'required|between:4,16',
143143
'email' => 'required|email',
144-
'password' => 'required|alpha_num|between:4,8|confirmed',
145-
'password_confirmation' => 'required|alpha_num|between:4,8',
144+
'password' => 'required|alpha_num|between:4,8|confirmed',
145+
'password_confirmation' => 'required|alpha_num|between:4,8',
146146
);
147147
}
148148
```
@@ -264,15 +264,15 @@ For example, you may use `beforeSave` to hash a users password:
264264

265265
```php
266266
class User extends \LaravelBook\Ardent\Ardent {
267-
public function beforeSave() {
268-
// if there's a new password, hash it
269-
if($this->isDirty('password')) {
270-
$this->password = Hash::make($this->password);
271-
}
272-
273-
return true;
274-
//or don't return nothing, since only a boolean false will halt the operation
275-
}
267+
public function beforeSave() {
268+
// if there's a new password, hash it
269+
if($this->isDirty('password')) {
270+
$this->password = Hash::make($this->password);
271+
}
272+
273+
return true;
274+
//or don't return nothing, since only a boolean false will halt the operation
275+
}
276276
}
277277
```
278278

@@ -282,13 +282,13 @@ class User extends \LaravelBook\Ardent\Ardent {
282282

283283
```php
284284
$user->save(array(), array(),
285-
function ($model) { // closure for beforeSave
286-
echo "saving the model object...";
287-
return true;
288-
},
289-
function ($model) { // closure for afterSave
290-
echo "done!";
291-
}
285+
function ($model) { // closure for beforeSave
286+
echo "saving the model object...";
287+
return true;
288+
},
289+
function ($model) { // closure for afterSave
290+
echo "done!";
291+
}
292292
);
293293
```
294294

@@ -359,8 +359,9 @@ function __construct() {
359359
}
360360
```
361361

362-
<a name="uniquerules"></a>
363-
## Updates with Unique Rules
362+
363+
<a name="secure"></a>
364+
## Automatically Transform Secure-Text Attributes
364365

365366
Suppose you have an attribute named `password` in your model class, but don't want to store the plain-text version in the database. The pragmatic thing to do would be to store the hash of the original content. Worry not, Ardent is fully capable of transmogrifying any number of secure fields automatically for you!
366367

@@ -376,8 +377,9 @@ class User extends \LaravelBook\Ardent\Ardent {
376377
Ardent will automatically replace the plain-text password attribute with secure hash checksum and save it to database. It uses the Laravel `Hash::make()` method internally to generate hash.
377378

378379

379-
<a name="secure"></a>
380-
## Automatically Transform Secure-Text Attributes
380+
<a name="uniquerules"></a>
381+
## Updates with Unique Rules
382+
381383
Ardent can assist you with unique updates. According to the Lavavel Documentation, when you update (and therefore validate) a field with a unique rule, you have to pass in the unique ID of the record you are updating. Without passing this ID, validation will fail because Laravel's Validator will think this record is a duplicate.
382384

383385
From the Laravel Documentation:

0 commit comments

Comments
 (0)