Last active
May 16, 2017 16:10
-
-
Save anthonybudd/1c7ee27f778e0004c08b8c072391cf86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Class Product{ | |
| ... | |
| public $virtual = [ | |
| 'humanWeight', | |
| 'seller', | |
| ]; | |
| public function _getHumanWeight(){ | |
| return $this->weight . 'Kg'; | |
| } | |
| public function _getSeller(){ | |
| return Seller::find($this->seller_id); | |
| } | |
| } | |
| $product = Product::find(10); | |
| $productWeight = $product->humanWeight; // '10Kg' | |
| $productSellerName = $product->seller->full_name; // 'John Doe' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment