Ejemplo n.º 1
0
 public function save(array $options = array())
 {
     $validator = \Validator::make(array('name' => $this->name), array('name' => 'required|min:1'));
     if ($validator->passes()) {
         $this->slug = TaggingUtil::slug($this->name);
         parent::save($options);
     } else {
         throw new \Exception('Tag Name is required');
     }
 }
Ejemplo n.º 2
0
 public function test_slug()
 {
     $this->assertEquals('sugar-free', TaggingUtil::slug('Sugar Free'));
     $str = 'ПЧ�Цщ';
     $this->assertNotEquals(TaggingUtil::slug($str), $str);
     $str = 'quiénsí';
     $this->assertNotEquals(TaggingUtil::slug($str), $str);
     $str = 'ČĢ';
     $this->assertNotEquals(TaggingUtil::slug($str), $str);
     $str = 'same-slug';
     $this->assertEquals(TaggingUtil::slug($str), $str);
     $str = '&=*!$&&,';
     $this->assertNotEquals(TaggingUtil::slug($str), $str);
 }
Ejemplo n.º 3
0
 /**
  * Removes a single tag
  * 
  * @param $tagName string
  */
 private function removeTag($tagName)
 {
     $tagName = trim($tagName);
     $tagSlug = TaggingUtil::slug($tagName);
     if ($count = $this->tagged()->where('tag_slug', '=', $tagSlug)->delete()) {
         TaggingUtil::decrementCount($tagName, $tagSlug, $count);
     }
 }