Example #1
0
 static function getModelAttribute($model, $attribute, $type)
 {
     if ($type) {
         return R::getRow('SELECT ' . $type . ' FROM models m INNER JOIN rel_model_attr r ON m.id = r.model_id INNER JOIN attributes a ON a.id = r.attr_id  WHERE m.name = ? AND a.name = ?', [$model, $attribute])[$type];
     } else {
         $attr_id = self::attrExists($attribute)->id;
         $model_id = self::modelExists($model)->id;
         return R::findOne('rel_model_attr', 'attr_id = ? AND model_id = ?', [$attr_id, $model_id]);
     }
 }