• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem with response and entity

#8
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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.