Home > Net >  How to update a user using the 'Ion Auth' authentication library in CodeIgniter 4 framewor
How to update a user using the 'Ion Auth' authentication library in CodeIgniter 4 framewor

Time:02-17

Below is my code snippet. I want to reduce the balance of a user in the database using Codeigniter 4?

dd($this->ionAuth->update($this->ionAuth->users()->row()->id, ['balance' => 1000]));

*I'm using Ion Auth for updating. It's just a big burden when updating the database using modelling data.

CodePudding user response:

It looks like you intend to use $this->ion_auth->user() instead of $this->ion_auth->users().

Also keep in mind that executing a dump and die on $this->ion_auth->update(...) returns a boolean not the updated user data.

References:

users() gets all users.

users()
Get the users.

Parameters

'Group IDs, group names, or group IDs and names' - array OPTIONAL. If an array of group ids, of group names, or of group ids and names are passed (or a single group id or name) this will return the users in those groups.

Usage

$users = $this->ion_auth->users()->result(); // get all users

user() gets a single user.

user()
Get a user.

Parameters

'Id' - integer OPTIONAL. If a user id is not passed the id of the currently logged in user will be used.

Usage

$user = $this->ion_auth->user()->row();
echo $user->email;

CodePudding user response:

look here authentcate library for ci4

https://github.com/lonnieezell/myth-auth

go there download it

ionAuth is not compablitablke with ci4

  • Related