dingo / api

A RESTful API package for the Laravel and Lumen frameworks.
BSD 3-Clause "New" or "Revised" License
9.32k stars 1.25k forks source link

use __get() images method #1691

Open CrazyZard opened 4 years ago

CrazyZard commented 4 years ago
Q A
Bug? yes
New Feature? yes
Framework Laravel
Framework version 5.8.10
Package version 2.0.0-alpha2
PHP version 7.3

Actual Behaviour

when I use __set($key) in my controller and use Dingo\Api\Routing\Helpers to return Data; The system return me "Call to a member function collection() on null"

Code

class Controller extends BaseController {

use Helpers;

public function __set($key) { if($key == 'auth_user'){ return Request::user(); } return $key; }

public function index(){ $list = User::all(); return $this->response->collection($list, NotifyTransformer::class); } }

specialtactics commented 4 years ago

Hi

First of all, your dingo version is extremely old and needs to be updated.

Secondly, you code example doesn't have the use of the Helper class that you mentioned? I'm not really following.