コード例 #1
0
ファイル: BaseModel.php プロジェクト: zigiphp/zigiphp-2
 /**
  * Save bean to database
  */
 public function save()
 {
     foreach ($this->_bean->getProperties() as $prop => &$propValue) {
         if (substr($prop, 0, 3) === 'own') {
             $propsToUpdate = [];
             foreach ($propValue as $subValue) {
                 if ($subValue instanceof BaseModel) {
                     $subValue = $subValue->getBean();
                     $propsToUpdate[] = $subValue;
                 }
             }
             $this->__set($prop, $propsToUpdate);
         }
         if (substr($prop, 0, 6) === 'shared') {
             $propsToUpdate = [];
             foreach ($propValue as $subValue) {
                 if ($subValue instanceof BaseModel) {
                     $subValue = $subValue->getBean();
                     $propsToUpdate[] = $subValue;
                 }
             }
             $this->__set($prop, $propsToUpdate);
         }
     }
     if ($this->_timestamps) {
         $this->_bean->{'updated_at'} = Carbon::now();
     }
     R::store($this->_bean);
 }