Welcome Guest, Not a member yet? Register   Sign In
problem with response and entity
#8

(This post was last modified: 02-28-2019, 11:24 AM by keulu.)

yeepee !!!!

Code:
[
    {
        "id": "1",
        "firstname": "Darth",
        "lastname": "Vader",
        "username": null,
        "email": "[email protected]",
        "password": "5e884898da28047151d0e56f8dc6292",
        "created_at": {
            "date": "2019-02-08 12:27:42.000000",
            "timezone_type": 3,
            "timezone": "Europe/Paris"
        },
        "updated_at": null,
        "deleted": false,
        "deleted_at": null
    }
]

so basically, i wrote a toArray() method

PHP Code:
public function toArray(){
        
$vars get_object_vars($this);
        
$ar = [];
        foreach(
$vars as $k => $v){
            if (
$k[0] != '_'){
                
$ar[$k] = $this->__get($k);
            }
        }
        return 
$ar;
    } 

and VOILA !

so i will wrote MY_Entity with many converters json, xml, yaml maybe ....

and my own MY_Model who will call my converters after find.

and maybe something like that.

And I saw that call inside a model $this->created_at is not the same as $this->__get('created_at').
Is that the normal behavior ?
Reply


Messages In This Thread
problem with response and entity - by keulu - 02-27-2019, 12:01 PM
RE: problem with response and entity - by ciadmin - 02-27-2019, 12:21 PM
RE: problem with response and entity - by keulu - 02-27-2019, 01:24 PM
RE: problem with response and entity - by ciadmin - 02-27-2019, 01:33 PM
RE: problem with response and entity - by keulu - 02-27-2019, 01:39 PM
RE: problem with response and entity - by keulu - 02-27-2019, 01:40 PM
RE: problem with response and entity - by keulu - 02-28-2019, 11:04 AM
RE: problem with response and entity - by keulu - 02-28-2019, 11:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB