Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Object of class stdClass could not be converted to string

Trying to run that code: ```php

    $user = parent::me();

    $user->nome        = $this->request->getPost('nome');
    $user->celular     = $this->request->getPost('celular');
    $user->birthday    = \DateTime::createFromFormat('d/m/Y', $this->request->getPost('birthday'))->format('Y-m-d H:i:s');
    $user->cep         = $this->request->getPost('cep');
    $user->rua         = $this->request->getPost('rua');
    $user->numero      = $this->request->getPost('numero');
    $user->complemento = $this->request->getPost('complemento');
    $user->bairro      = $this->request->getPost('bairro');
    $user->cidade      = $this->request->getPost('cidade');
    $user->estado      = $this->request->getPost('estado');
    $user->updatedAt   = date('y-m-d H:i:s');

    if ($user->usertype == 2) {
        $user->bank      = $this->request->getPost('bank');
        $user->ag        = $this->request->getPost('ag');
        $user->cc        = $this->request->getPost('cc');
        $user->profissao = $this->request->getPost('profissao');
    }

    try {
        $user->save(); // line 301

```

Returning: Catchable fatal error: Object of class stdClass could not be converted to string in line 301

Someone can help me?

Ps* parent::me() -> User::findFirstByUserid($this->session->get('user')['userid']); Ps2* $user seems to be ok, the error occurs only on save



107.4k
Accepted
answer

Some property which is column have stdclass value and it can't be converted to string.



30.7k

Hi,

following the given suggestion, comment line 301 and put a var_dump($user) on its place

Solved the issue. I was overriding one property with an object in afterFetch method, so wehn try to save some record it have the object =/ Thx for your sup

Hi,

following the given suggestion, comment line 301 and put a var_dump($user) on its place