Codeigniter 4 Visual Studio database objects suggestions

34 Views Asked by At

I've setup a new Codeigniter 4 project and I would like to use the inbuilt model functions. While I'm using them I noticed my Visual Studio is unable to suggest the correct object attributes in fetched data objects. Is there a way to accomplish this?

Maybe somebody can share his settings for that?

I have a simple UserModel like that below:

class UserModel extends Model
{
protected $table      = 'users';
protected $primaryKey = 'id';

protected $useAutoIncrement = true;

protected $returnType     = 'object';
protected $useSoftDeletes = true;

protected $allowedFields = ['username', 'status', 'status_message'];

// Dates
protected $useTimestamps = false;
protected $dateFormat    = 'datetime';
protected $createdField  = 'created_at';
protected $updatedField  = 'updated_at';
protected $deletedField  = 'deleted_at';

// Validation
protected $validationRules      = [];
protected $validationMessages   = [];
protected $skipValidation       = false;
protected $cleanValidationRules = true;

// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert   = [];
protected $afterInsert    = [];
protected $beforeUpdate   = [];
protected $afterUpdate    = [];
protected $beforeFind     = [];
protected $afterFind      = [];
protected $beforeDelete   = [];
protected $afterDelete    = [];

// Entities and Models
protected $authIdentitiesModel  = null;

protected $user                 = null;
protected $entityClass          = User::class;

public function __construct(){
    parent::__construct();
    $this->authIdentitiesModel  = new AuthIdentitiesModel();
    $this->user                 = new User;
}

public function getPasswordHash(int $userID){
    return $this->authIdentitiesModel->find($userID)->secret2;
}

public function resetPassword(string $newPassword){
    return $this->authIdentitiesModel->resetPassword($newPassword);
}
}

Now it would be cool, and I know PhPStorm/Intellij is able to do that, and I am sure there is also a way in VisualStudioCode, that VSCode gives me suggestions when I am using the objects:

  function test(){
     $users = $this->findAll();
     foreach($users as $user){
         $user->[ HERE SUGGESTIONS TAB with the attributes like (user_id, username, ...) ]
     }
  }

I am using PHP IntelliSense extension and PHP Intelephense, but I think I am doing something wrong.I also already setup the entities and included them correctly, but I dont get any suggestions.

Thanks for any advice!

0

There are 0 best solutions below