From d4b5e58f976a47dd90f53d13954e83bfbc11c63f Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 25 Mar 2023 12:52:57 +0900 Subject: [PATCH 1/4] docs: replace command with function Because it is a PHP user function. --- docs/authentication.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/authentication.md b/docs/authentication.md index 9d5f505c5..e505f8662 100644 --- a/docs/authentication.md +++ b/docs/authentication.md @@ -50,7 +50,7 @@ public $defaultAuthenticator = 'session'; ## Auth Helper The auth functionality is designed to be used with the `auth_helper` that comes with Shield. This -helper method provides the `auth()` command which returns a convenient interface to the most frequently +helper method provides the `auth()` function which returns a convenient interface to the most frequently used functionality within the auth libraries. ```php From da1666f7f003e385f78e573f028efa343f765361 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 25 Mar 2023 12:54:09 +0900 Subject: [PATCH 2/4] docs: add auth()->getProvider() --- docs/authentication.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/authentication.md b/docs/authentication.md index e505f8662..3b177d3dc 100644 --- a/docs/authentication.md +++ b/docs/authentication.md @@ -61,6 +61,9 @@ auth()->user(); auth()->id(); // or user_id(); + +// get the User Provider (UserModel by default) +auth()->getProvider(); ``` > **Note** From 9e4f5c02e9cef9f8e49b18a392e70d235e4c386f Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 25 Mar 2023 12:55:25 +0900 Subject: [PATCH 3/4] docs: remplace model('UserModel') with auth()->getProvider() --- docs/quickstart.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/quickstart.md b/docs/quickstart.md index 70b960f9c..0e639136e 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -271,7 +271,7 @@ By default, the only values stored in the users table is the username. The first ```php use CodeIgniter\Shield\Entities\User; -$users = model('UserModel'); +$users = auth()->getProvider(); $user = new User([ 'username' => 'foo-bar', 'email' => 'foo.bar@example.com', @@ -291,7 +291,7 @@ $users->addToDefaultGroup($user); A user's data can be spread over a few different tables so you might be concerned about how to delete all of the user's data from the system. This is handled automatically at the database level for all information that Shield knows about, through the `onCascade` settings of the table's foreign keys. You can delete a user like any other entity. ```php -$users = model('UserModel'); +$users = auth()->getProvider(); $users->delete($user->id, true); ``` @@ -302,7 +302,7 @@ $users->delete($user->id, true); The `UserModel::save()`, `update()` and `insert()` methods have been modified to ensure that an email or password previously set on the `User` entity will be automatically updated in the correct `UserIdentity` record. ```php -$users = model('UserModel'); +$users = auth()->getProvider(); $user = $users->findById(123); $user->fill([ From da6e3cc9b19a0dfd864f62f88943b70457231fa4 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 25 Mar 2023 12:58:22 +0900 Subject: [PATCH 4/4] docs: add comments in sample code --- docs/quickstart.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/quickstart.md b/docs/quickstart.md index 0e639136e..49e25a38f 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -271,7 +271,9 @@ By default, the only values stored in the users table is the username. The first ```php use CodeIgniter\Shield\Entities\User; +// Get the User Provider (UserModel by default) $users = auth()->getProvider(); + $user = new User([ 'username' => 'foo-bar', 'email' => 'foo.bar@example.com', @@ -291,7 +293,9 @@ $users->addToDefaultGroup($user); A user's data can be spread over a few different tables so you might be concerned about how to delete all of the user's data from the system. This is handled automatically at the database level for all information that Shield knows about, through the `onCascade` settings of the table's foreign keys. You can delete a user like any other entity. ```php +// Get the User Provider (UserModel by default) $users = auth()->getProvider(); + $users->delete($user->id, true); ``` @@ -302,9 +306,10 @@ $users->delete($user->id, true); The `UserModel::save()`, `update()` and `insert()` methods have been modified to ensure that an email or password previously set on the `User` entity will be automatically updated in the correct `UserIdentity` record. ```php +// Get the User Provider (UserModel by default) $users = auth()->getProvider(); -$user = $users->findById(123); +$user = $users->findById(123); $user->fill([ 'username' => 'JoeSmith111', 'email' => 'joe.smith@example.com',