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 | |
| $product = Product::insert([ | |
| 'weight' => '100' | |
| ]); | |
| dd($product->weightInKGs); |
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 | |
| $product = new Product; | |
| dump($product->new); | |
| $product = Product::find(3); | |
| dump($product->new); | |
| $product->color = 'red'; | |
| dump($product->dirty); |
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 | |
| $product = Product::find(3); | |
| $product->delete(); |
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 | |
| $product = Product::find(1); | |
| dd($product); |
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 | |
| $product = new Product(); | |
| $product->color = 'white'; | |
| $product->weight = 300; | |
| $product->title = 'the post title'; | |
| $product->content = 'the post content'; | |
| $product->save(); | |
| dump($product); |
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 | |
| $products = Product::in([3, 5, 7]); | |
| dd($products); |
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 | |
| Abstract Class WP_Model implements JsonSerializable{ | |
| ... | |
| public function isFilterProperty($attribute){ | |
| return ( | |
| ( | |
| isset($this->filter) && | |
| in_array($attribute, $this->filter) && | |
| method_exists($this, ('_filter'. ucfirst($attribute))) |
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 extends WP_Model{ | |
| ... | |
| public $filter = [ | |
| 'weight' => 'intval' | |
| ]; | |
| } | |
| $product = Product::insert([ | |
| 'weight' => '250', | |
| ]); |
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 | |
| function isAssoc($array){ | |
| return count(array_filter(array_keys($array), 'is_string')) > 0; | |
| } | |
| $indexed = [ | |
| 'apple', | |
| 'pear', | |
| 'grape' |
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 extends WP_Model{ | |
| ... | |
| public $filter = [ | |
| 'weight' | |
| ]; | |
| public function _filterWeight($value){ | |
| return intval($value); |