Laravel Responsable - Get Output Attribute -


class transformresponse implements responsable {     public $name;      public function __construct($name)     {         $this->name = $name;     }      public function toresponse($request)     {         $this->name = 'mr. ' . $this->name;         return response(['name' => $this->name]);     } } 

-

$res = new \transformresponse('orocimaru'); return $res; // output { "name": "mr. orocimaru" } return $res->name; // output "orocimaru" # expected output "mr. orochimaru" 

-

how expected output?

whether right mutation inside toresponse()?

i follow https://laravel-news.com/laravel-5-5-responsable


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -