コード例 #1
0
ファイル: TaggableTrait.php プロジェクト: sharenjoy/axes
 /**
  * sync tagger
  *
  * @param  string $key   field
  * @param  model $model eloquent model
  *
  * @return model
  */
 public function eventSyncToTags($key, $model)
 {
     if (!isset(self::$inputData['tag'])) {
         return;
     }
     if (empty(self::$inputData['tag'])) {
         return $model->tags()->detach();
     }
     $data = explode(',', self::$inputData['tag']);
     return $model->tags()->sync($data);
 }
コード例 #2
0
ファイル: model.php プロジェクト: remyla/damas-core
 /**
  * Get the tags id of a node
  * @param {Integer} $id node id
  * @return {array} tags 
  */
 static function tags($id)
 {
     $array = array();
     // PROTOTYPE BEGIN
     $protoname = model::getKey($id, 'prototype');
     if ($protoname) {
         $proto = model::searchKey('id', $protoname);
         $proto = $proto[0];
         if ($proto) {
             $array = model::tags($proto);
         }
     }
     // PROTOTYPE END
     $query = "SELECT name FROM tag WHERE node_id='{$id}';";
     $result = mysql_query($query);
     while ($row = mysql_fetch_array($result)) {
         $array[] = $row["name"];
     }
     return $array;
 }
コード例 #3
0
ファイル: model_json.php プロジェクト: remyla/damas-core
 /**
  * Get the links id of a node
  * @param {Integer} $id node id
  * @return {array} links
  */
 static function rlink($id)
 {
     $result = model::rlinks($id);
     for ($i = 0; $i < sizeof($result); $i++) {
         $childcount = model::countChildren($id);
         $result[$i]["childcount"] = $childcount;
         $result[$i]["rlinks"] = model::countRLinks($result[$i]["id"]);
         $result[$i]["tags"] = model::tags($result[$i]["id"]);
         $result[$i]["keys"] = model::keys($result[$i]["id"]);
     }
     return $result;
 }