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.
Copy file name to clipboardExpand all lines: README.md
+40-58Lines changed: 40 additions & 58 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,26 +61,26 @@ to your database, obviously):
61
61
How often do you find yourself re-creating the same boilerplate code in the applications you build? Does this typical form processing code look all too familiar to you?
@@ -91,12 +91,12 @@ Implementing this yourself often results in a lot of repeated boilerplate code.
91
91
What if someone else did all the heavy-lifting for you? What if, instead of regurgitating the above mess, all you needed to type was these few lines?...
92
92
93
93
```php
94
-
Route::post('register', function() {
94
+
Route::post('register', function() {
95
95
$user = new User;
96
-
if ($user->save()) {
97
-
return Redirect::to('/')->with('message', 'Thanks for registering!');
96
+
if ($user->save()) {
97
+
return Redirect::to('/')->with('message', 'Thanks for registering!');
@@ -119,7 +119,7 @@ For example, user registration or blog post submission is a common coding requir
119
119
120
120
`Ardent` aims to extend the `Eloquent` base class without changing its core functionality. Since `Ardent` itself is a descendant of `Illuminate\Database\Eloquent\Model`, all your `Ardent` models are fully compatible with `Eloquent` and can harness the full power of Laravels awesome OR/M.
121
121
122
-
To create a new Ardent model, simply make your model class derive from the `Ardent` base class:
122
+
To create a new Ardent model, simply make your model class derive from the `Ardent` base class. In the next examples we will use the complete namespaced class to make examples cleaner, but you're encouraged to make use of `use` in all your classes:
123
123
124
124
```php
125
125
use LaravelBook\Ardent\Ardent;
@@ -135,22 +135,15 @@ class User extends Ardent {}
135
135
Ardent models use Laravel's built-in [Validator class](http://doc.laravelbook.com/validation/). Defining validation rules for a model is simple and is typically done in your model class as a static variable:
Just like the Laravel Validator, Ardent lets you set custom error messages using the [same sytax](http://doc.laravelbook.com/validation/#custom-error-messages).
256
250
257
251
```php
258
-
use LaravelBook\Ardent\Ardent;
259
-
260
-
class User extends Ardent {
252
+
class User extends \LaravelBook\Ardent\Ardent {
261
253
262
-
/**
263
-
* Ardent Messages
264
-
*/
265
254
public static $customMessages = array(
266
-
'required' => 'The :attribute field is required.'
255
+
'required' => 'The :attribute field is required.',
256
+
...
267
257
);
268
258
269
-
...
270
-
271
259
}
272
260
```
273
261
@@ -284,9 +272,9 @@ Ardent is capable of hydrating your entity model class from the form input submi
284
272
Let's see it action. Consider this snippet of code:
@@ -305,9 +293,7 @@ Believe it or not, the code above performs essentially the same task as its olde
305
293
To enable the auto-hydration feature, simply set the `$autoHydrateEntityFromInput` instance variable to `true` in your model class:
306
294
307
295
```php
308
-
use LaravelBook\Ardent\Ardent;
309
-
310
-
class User extends Ardent {
296
+
class User extends \LaravelBook\Ardent\Ardent {
311
297
312
298
public $autoHydrateEntityFromInput = true;
313
299
@@ -322,9 +308,7 @@ Ardent models can *auto-magically* purge redundant input data (such as *password
322
308
To enable this feature, simply set the `$autoPurgeRedundantAttributes` instance variable to `true` in your model class:
323
309
324
310
```php
325
-
use LaravelBook\Ardent\Ardent;
326
-
327
-
class User extends Ardent {
311
+
class User extends \LaravelBook\Ardent\Ardent {
328
312
329
313
public $autoPurgeRedundantAttributes = true;
330
314
@@ -339,11 +323,9 @@ Suppose you have an attribute named `password` in your model class, but don't wa
339
323
To do that, add the attribute name to the `Ardent::$passwordAttributes` static array variable in your model class, and set the `$autoHashPasswordAttributes` instance variable to `true`:
340
324
341
325
```php
342
-
use LaravelBook\Ardent\Ardent;
343
-
344
-
class User extends Ardent {
326
+
class User extends \LaravelBook\Ardent\Ardent {
345
327
346
-
public static $passwordAttributes = array('password');
328
+
public static $passwordAttributes = array('password');
0 commit comments