fork download
  1. <?php
  2.  
  3. class Pituh {
  4. public function __get($name) {
  5. echo "Called " . $name . PHP_EOL;
  6. }
  7. }
  8.  
  9. class LaraCart {
  10. static public function getItems() {
  11. return [new Pituh()];
  12. }
  13. }
  14.  
  15. foreach ($cart = LaraCart::getItems() as $product) {
  16. $product->id;
  17. $product->name;
  18. $product->title_slug;
  19. $product->price;
  20. $product->qty;
  21. $product->photo;
  22. $product->item_type;
  23. }
  24.  
Success #stdin #stdout 0.02s 24260KB
stdin
Standard input is empty
stdout
Called id
Called name
Called title_slug
Called price
Called qty
Called photo
Called item_type