Skip to content

__set in \App\Entities\Sample doesnt works #499

Description

@nowackipawel

I'm trying to use Entities.
In my model SampleModel.php I've got:

    protected $table = 't_sample';
    protected $primaryKey = 'smp_id';
    protected $returnType = '\App\Entities\Sample';


    protected $allowedFields = [
        'all_fields_from_t_sample... without id ;)'
    ];

and in Entity Sample.php

<?php

namespace App\Entities;

class Sample
{
    protected $all_fields_1;
    protected $all_fields_2;
    protected $all_fields_3; ...


    public function __get($key)
    {...}

    public function __set($key, $value)
    {
                ddd($this->$key);
        if (isset($this->$key))
        {
            if($key == 'all_fields_1') {
                $this->$key = sthdifferent;
            }
            else
                $this->$key = $value;
        }
    }
}

but that __set is never used by BASEPATH.'Model.php'.
I can also define __set in my SampleModel instead od Entity which called Sample... but why?

And why when I change method __set in SampleModel like that:

    public function __set($key, $value)
    {
        d($key, $value);
}

it prints only salt and their value ?
Is it a bug?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions