original_string: public function tagsEdit(Request $request, Response $response, $tagId)
      {
          if ($check = $this->sentinel->hasPerm('blog_tags.update', 'dashboard', $this->config['blog-enabled'])) {
              return $check;
          }
  
          $tag = BT::find($tagId);
  
          if (!$tag) {
              $this->flash('danger', 'Tag doesn\'t exist.');
              return $this->redirect($response, 'admin-blog');
          }
  
          if ($request->isPost()) {
              // Get Vars
              $tagName = $request->getParam('tag_name');
              $tagSlug = $request->getParam('tag_slug');
  
              // Validate Data
              $validateData = array(
                  'tag_name' => array(
                      'rules' => V::length(2, 25)->alpha('\''),
                      'messages' => array(
                          'length' => 'Must be between 2 and 25 characters.',
                          'alpha' => 'Letters only and can contain \''
                          )
                  ),
                  'tag_slug' => array(
                      'rules' => V::slug(),
                      'messages' => array(
                          'slug' => 'May only contain lowercase letters, numbers and hyphens.'
                          )
                  )
              );
  
              $this->validator->validate($request, $validateData);
  
              //Validate Category Slug
              $checkSlug = $tag->where('id', '!=', $tagId)->where('slug', '=', $tagSlug)->get()->count();
              if ($checkSlug > 0 && $tagSlug != $tag['slug']) {
                  $this->validator->addError('tag_slug', 'Category slug is already in use.');
              }
  
  
              if ($this->validator->isValid()) {
                  $tag->name = $tagName;
                  $tag->slug = $tagSlug;
  
                  if ($tag->save()) {
                      $this->flash('success', 'Category has been updated successfully.');
                      return $this->redirect($response, 'admin-blog');
                  }
  
                  $this->flash('success', 'An  unknown error occured.');
              }
          }
          return $this->view->render($response, 'blog-tags-edit.twig', ['tag' => $tag]);
      }
code: public function tagsEdit(Request $request, Response $response, $tagId)
      {
          if ($check = $this->sentinel->hasPerm('blog_tags.update', 'dashboard', $this->config['blog-enabled'])) {
              return $check;
          }
  
          $tag = BT::find($tagId);
  
          if (!$tag) {
              $this->flash('danger', 'Tag doesn\'t exist.');
              return $this->redirect($response, 'admin-blog');
          }
  
          if ($request->isPost()) {
              // Get Vars
              $tagName = $request->getParam('tag_name');
              $tagSlug = $request->getParam('tag_slug');
  
              // Validate Data
              $validateData = array(
                  'tag_name' => array(
                      'rules' => V::length(2, 25)->alpha('\''),
                      'messages' => array(
                          'length' => 'Must be between 2 and 25 characters.',
                          'alpha' => 'Letters only and can contain \''
                          )
                  ),
                  'tag_slug' => array(
                      'rules' => V::slug(),
                      'messages' => array(
                          'slug' => 'May only contain lowercase letters, numbers and hyphens.'
                          )
                  )
              );
  
              $this->validator->validate($request, $validateData);
  
              //Validate Category Slug
              $checkSlug = $tag->where('id', '!=', $tagId)->where('slug', '=', $tagSlug)->get()->count();
              if ($checkSlug > 0 && $tagSlug != $tag['slug']) {
                  $this->validator->addError('tag_slug', 'Category slug is already in use.');
              }
  
  
              if ($this->validator->isValid()) {
                  $tag->name = $tagName;
                  $tag->slug = $tagSlug;
  
                  if ($tag->save()) {
                      $this->flash('success', 'Category has been updated successfully.');
                      return $this->redirect($response, 'admin-blog');
                  }
  
                  $this->flash('success', 'An  unknown error occured.');
              }
          }
          return $this->view->render($response, 'blog-tags-edit.twig', ['tag' => $tag]);
      }
code_tokens: public function tagsEdit ( Request $ request , Response $ response , $ tagId ) { if ( $ check = $ this -> sentinel -> hasPerm ( 'blog_tags.update' , 'dashboard' , $ this -> config [ 'blog-enabled' ] ) ) { return $ check ; } $ tag = BT :: find ( $ tagId ) ; if ( ! $ tag ) { $ this -> flash ( 'danger' , 'Tag doesn\'t exist.' ) ; return $ this -> redirect ( $ response , 'admin-blog' ) ; } if ( $ request -> isPost ( ) ) { // Get Vars $ tagName = $ request -> getParam ( 'tag_name' ) ; $ tagSlug = $ request -> getParam ( 'tag_slug' ) ; // Validate Data $ validateData = array ( 'tag_name' => array ( 'rules' => V :: length ( 2 , 25 ) -> alpha ( '\'' ) , 'messages' => array ( 'length' => 'Must be between 2 and 25 characters.' , 'alpha' => 'Letters only and can contain \'' ) ) , 'tag_slug' => array ( 'rules' => V :: slug ( ) , 'messages' => array ( 'slug' => 'May only contain lowercase letters, numbers and hyphens.' ) ) ) ; $ this -> validator -> validate ( $ request , $ validateData ) ; //Validate Category Slug $ checkSlug = $ tag -> where ( 'id' , '!=' , $ tagId ) -> where ( 'slug' , '=' , $ tagSlug ) -> get ( ) -> count ( ) ; if ( $ checkSlug > 0 && $ tagSlug != $ tag [ 'slug' ] ) { $ this -> validator -> addError ( 'tag_slug' , 'Category slug is already in use.' ) ; } if ( $ this -> validator -> isValid ( ) ) { $ tag -> name = $ tagName ; $ tag -> slug = $ tagSlug ; if ( $ tag -> save ( ) ) { $ this -> flash ( 'success' , 'Category has been updated successfully.' ) ; return $ this -> redirect ( $ response , 'admin-blog' ) ; } $ this -> flash ( 'success' , 'An  unknown error occured.' ) ; } } return $ this -> view -> render ( $ response , 'blog-tags-edit.twig' , [ 'tag' => $ tag ] ) ; }
docstring: Edit Blog Tag
docstring_tokens: Edit Blog Tag