Exemple #1
0
 public function setSlugAttribute($value)
 {
     $slug = JarboeBuilder::urlify($value);
     $slugs = $this->where('parent_id', $this->parent_id)->where('id', '<>', $this->id)->whereRaw("slug REGEXP '^{$slug}(-[0-9]*)?\$'")->lists('slug');
     $slugCount = '';
     if ($slugs) {
         $slugCount = 0;
         foreach ($slugs as $existedSlug) {
             preg_match('~(\\d+)$~', $existedSlug, $matches);
             if (isset($matches[1])) {
                 $slugCount = $slugCount > $matches[1] ? $slugCount : $matches[1];
             }
         }
         $slugCount++;
     }
     $slug = $slugCount ? $slug . '-' . $slugCount : $slug;
     $this->attributes['slug'] = $slug;
 }
 public function handlePage($page)
 {
     $options = array('url' => '/admin/' . $page, 'def_name' => $page);
     return JarboeFacade::table($options);
 }