示例#1
0
 private function manyToOne($name)
 {
     /**
      * many to one relation assistance
      */
     if (preg_match('/^(.*)_id$/', $name, $m)) {
         return Inflect::pluralize($m[1]) . '_id';
     }
     return $name;
 }
示例#2
0
 public function __construct($table = null)
 {
     if (!is_null($table)) {
         $this->_table = $table;
     } elseif (empty($this->_table)) {
         $class = get_called_class();
         $class = explode('\\', $class);
         $class = array_pop($class);
         $this->_table = strtolower(Inflect::pluralize($class));
     }
     $this->_bean = R::dispense($this->_table);
     if ($this->_timestamps) {
         $this->_bean->{'created_at'} = Carbon::now();
     }
 }