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

well... that the same

Code:
[
    {}
]

PHP Code:
<?php
namespace App\Controllers;

use 
CodeIgniter\Resource\ResourceController;
// use CodeIgniter\Controller;
use CodeIgniter\API\ResponseTrait;

use 
Restserver\Libraries\Format;

use 
App\Models\UserModel;
use 
App\Entities\User;

class 
Users extends ResourceController
{
    use 
ResponseTrait;

    public function 
index()
    {
        
$userModel  = new UserModel();
        
$users_data $userModel->findAll();

        if (
$users_data)
        {
            return 
$this->respond($users_data);
        }
        else
        {
            return 
$this->fail('No Users'404);
        }
    }
    
//--------------------------------------------------------------------
    // End of file Users.php
    //--------------------------------------------------------------------


i will try to make a custom entity and a sort of toString() or toJson() method who will read the protected vars and reconstruct a correct object.

a json_encode() si not enough for that kind of object.
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