Welcome Guest, Not a member yet? Register   Sign In
Shield remove deleted at to user
#1

i i try to remove deleted at symply by :

Code:
      $data_to_update = [

        'deleted_at' => NULL,
      ];

      $users_model->update($id, $data_to_update);

But i receive There is no data to update, i control $id it'ok
Reply
#2

(This post was last modified: 03-23-2025, 11:26 PM by InsiteFX. Edit Reason: Fixed spelling error )

Did you try using set?

PHP Code:
// this also depends on $allowedFields
set('deleted_at'NULL); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(This post was last modified: 03-21-2025, 02:14 AM by warcooft.)

Determine what fields can be modified in the $allowedFields property in the model, make sure deleted_at field exists.
@xxxx[{::::::::::::::::::::::::::::::::>
Reply
#4

In your custom model, add the field as follows:


PHP Code:
<?php

declare(strict_types=1);

namespace 
App\Models;

use 
CodeIgniter\Shield\Models\UserModel as ShieldUserModel;

class 
UserModel extends ShieldUserModel
{
    protected function initialize(): void
    
{
        parent::initialize();

        $this->allowedFields = [
            ...$this->allowedFields,

            // 'first_name',
            'deleted_at',
        ];
    }


Then, register the new model in the Auth.php file:
PHP Code:
-use CodeIgniter\Shield\Models\UserModel;
+use 
App\Models\UserModel

Finally, use it like this:

PHP Code:
auth()->getProvider()->update($id,  [
  'deleted_at' => NULL,
]); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB