Skip to content

Commit 5c45cdd

Browse files
committed
Add documentation for using a custom member model
1 parent a771cf3 commit 5c45cdd

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

docs/advanced/authentication.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Authentication
22

3-
Coilpack comes with it's own Authentication Guard for Laravel so that you can retrieve the active ExpressionEngine member as an Eloquent Model with the following code:
3+
Coilpack comes with it's own Authentication Guard for Laravel so that you can retrieve the active ExpressionEngine Member as an Eloquent model with the following code:
44

55
```php
66
auth('coilpack')->user()
@@ -21,4 +21,36 @@ We are not making any assumptions about your setup and so the `'coilpack'` guard
2121

2222
This can simplify your authentication calls to look like the standard `auth()->user()`.
2323

24-
For more information on [Laravel's Authentication](https://laravel.com/docs/9.x/authentication) capabilities please review their documentation.
24+
For more information on [Laravel's Authentication](https://laravel.com/docs/9.x/authentication) capabilities please review their documentation.
25+
26+
## Custom Member Model
27+
28+
The Eloquent model used by Coilpack's authentication guard can be extended to add functionality and other customizations.
29+
30+
Instead of starting with a blank Eloquent model we recommend that you extend the included Member model `Expressionengine\Coilpack\Models\Member\Member`
31+
32+
Your custom model might look like this:
33+
```php
34+
# app/Models/Member.php
35+
<?php
36+
37+
namespace App\Models;
38+
39+
use Expressionengine\Coilpack\Models\Member\Member as BaseMember;
40+
41+
class Member extends BaseMember
42+
{
43+
44+
}
45+
```
46+
47+
Coilpack doesn't know about this custom model until you update the `member_model` setting in your `config/coilpack.php`.
48+
49+
```php
50+
# config/coilpack.php
51+
return [
52+
...
53+
'member_model' => \App\Models\Member::class,
54+
...
55+
];
56+
```

0 commit comments

Comments
 (0)