docs: add and use auth()->getProvider()#692
Merged
kenjis merged 4 commits intocodeigniter4:developfrom Mar 25, 2023
Merged
Conversation
lonnieezell
approved these changes
Mar 25, 2023
datamweb
approved these changes
Mar 25, 2023
Collaborator
datamweb
left a comment
There was a problem hiding this comment.
If a dev customizes the UserModel and changes the model name, the sample code dose not work.
Command php spark shield:model selects the name UserModel by default, if the user uses this command to generate the model, the sample codes should work.
Otherwise, it should apply the following changes.
php spark shield:model KenjiModel-public string $userProvider = UserModel::class;
+public string $userProvider = \App\Models\KenjiModel::class;-$users = model('UserModel');
+$users = model('KenjiModel');
$user = $users->findById(1);
$user->fill([
'first_name' => 'kenji',
'username' =>'kenjis'
]);
$users->save($user, true);C:\Users\ppars\OneDrive\Desktop\hi>php spark db:table users
CodeIgniter v4.3.2 Command Line Tool - Server Time: 2023-03-25 11:31:53 UTC+00:00
Data of Table "users":
+----+----------+--------+----------------+--------+--------------------+--------------------+--------------------+------------+------------+
| id | username | status | status_message | active | last_active | created_at | updated_at | deleted_at | first_name |
+----+----------+--------+----------------+--------+--------------------+--------------------+--------------------+------------+------------+
| 1 | kenjis | | | 1 | 2023-03-21 16:3... | 2023-03-21 15:3... | 2023-03-25 11:3... | | kenji |
+----+----------+--------+----------------+--------+--------------------+--------------------+--------------------+------------+------------+In any case, using auth()->getProvider() seems good.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If a dev customizes the UserModel and changes the model name, the sample code dose not work.