did this object came from the DB? i haven't used laravel, but maybe the have an API that results an associative array instead of objects. · yes ... ... <看更多>
This is one of the reasons why view models were created. Define a class that holds the necessary data for the view and this question becomes ... ... <看更多>
Apparently, it is possible to cast objects to arrays like following: <?php class Foo { public $bar = 'barValue'; } $foo = new Foo(); $arrayFoo = (array) ... ... <看更多>