You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 16, 2023. It is now read-only.
@@ -264,15 +264,15 @@ For example, you may use `beforeSave` to hash a users password:
264
264
265
265
```php
266
266
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
+
}
276
276
}
277
277
```
278
278
@@ -282,13 +282,13 @@ class User extends \LaravelBook\Ardent\Ardent {
282
282
283
283
```php
284
284
$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
+
}
292
292
);
293
293
```
294
294
@@ -359,8 +359,9 @@ function __construct() {
359
359
}
360
360
```
361
361
362
-
<aname="uniquerules"></a>
363
-
## Updates with Unique Rules
362
+
363
+
<aname="secure"></a>
364
+
## Automatically Transform Secure-Text Attributes
364
365
365
366
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!
366
367
@@ -376,8 +377,9 @@ class User extends \LaravelBook\Ardent\Ardent {
376
377
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.
377
378
378
379
379
-
<aname="secure"></a>
380
-
## Automatically Transform Secure-Text Attributes
380
+
<aname="uniquerules"></a>
381
+
## Updates with Unique Rules
382
+
381
383
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.
0 commit comments