Laravel,当使用Eloquent检索数据分页和获取方法时返回不同的输出

I am having a hard time with Laravel. I have a query that returns all the table columns. The problem is that a field "foto" returns as an empty string in the JSON when I use the "get" or "find" methods. Paginate it works as expected.

This query:

$resultado = $query
           ->where('id_admin', '=', $id_admin)
           ->with('telasPermissao.itemPermissao')
           ->paginate(50);

foto comes as:

"foto": "data/image:93483940349"

Now, with this:

$resultado = $query
           ->where('id_admin', '=', $id_admin)
           ->with('telasPermissao.itemPermissao')
           ->find(1);



$resultado = $query
           ->where('id_admin', '=', $id_admin)
           ->with('telasPermissao.itemPermissao')
           ->get(50);

foto comes as:

"foto" : ""

I am returning the data from the controller like this:

return response()->json($resultado, 200);

In my operador model I have the following mutator:

public function getFotoAttribute($value)
{
    if ($value != null)
    {
        return pg_escape_string(fgets($value));
    }

        return null;
}

Try updating your mutator like this:

public function getFotoAttribute()
{
    if ($this->attributes['foto'] != null)
    {
        return pg_escape_string(fgets($this->attributes['foto']));
    }

    return null;
}

After fighting 2 hours, I give up. As a workoaround I used this to replace the find method.

      $resultado = $query->where('id_admin', '=', $id_admin)->with('telasPermissao.itemPermissao')->where('id', 517 )->paginate(1)

If someone knows what happened please post an answer.