Esempio n. 1
0
 public function __construct()
 {
     self::$model['singular'] = ucfirst(\Supernova\Inflector::singularize(\Supernova\Core::$elements['controller']));
     self::$model['plural'] = ucfirst(\Supernova\Inflector::pluralize(\Supernova\Core::$elements['controller']));
     self::$action = ucfirst(\Supernova\Inflector::underToCamel(\Supernova\Core::$elements['prefix']));
     self::$action .= ucfirst(\Supernova\Inflector::underToCamel(\Supernova\Core::$elements['action']));
 }
Esempio n. 2
0
 private function get($value)
 {
     $modelName = \Supernova\Inflector::singularize($value);
     $value = \Supernova\Inflector::camelToUnder($value);
     if (isset($this->results[$value])) {
         return $this->results[$value];
     } else {
         // Check for belongsTo or hasMany
         if (isset($this->belongsTo) && !empty($this->belongsTo)) {
             if (array_key_exists($modelName, $this->belongsTo)) {
                 $namespace = "\\App\\Model\\" . $modelName;
                 $vars = get_class_vars($namespace);
                 $foreingKey = $this->belongsTo[$modelName]['foreingKey'];
                 return $namespace::find(array('where' => array($vars['primaryKey'] => array('=' => $this->results[$foreingKey]))));
             }
         }
         trigger_error(__("Can't get value, column not exist") . ": " . $value, E_USER_ERROR);
     }
 }