public function tagsAdd(Request $request, Response $response)
    {
        if ($check = $this->sentinel->hasPerm('blog_tags.create', 'dashboard', $this->config['blog-enabled'])) {
            return $check;
        }

        if ($request->isPost()) {
            $tagName = $request->getParam('tag_name');
            $tagSlug = $request->getParam('tag_slug');

            $this->validator->validate($request, [
                'tag_name' => V::length(2, 25)->alpha('\''),
                'tag_slug' => V::slug()
            ]);

            $checkSlug = BT::where('slug', '=', $request->getParam('tag_slug'))->get()->count();

            if ($checkSlug > 0) {
                $this->validator->addError('tag_slug', 'Slug already in use.');
            }

            if ($this->validator->isValid()) {
                $addTag = new BT;
                $addTag->name = $tagName;
                $addTag->slug = $tagSlug;

                if ($addTag->save()) {
                    $this->flash('success', 'Category added successfully.');
                    return $this->redirect($response, 'admin-blog');
                }
            }

            $this->flash('danger', 'There was a problem adding the tag.');
            return $this->redirect($response, 'admin-blog');
        }
    }
public function tagsAdd(Request $request, Response $response)
    {
        if ($check = $this->sentinel->hasPerm('blog_tags.create', 'dashboard', $this->config['blog-enabled'])) {
            return $check;
        }

        if ($request->isPost()) {
            $tagName = $request->getParam('tag_name');
            $tagSlug = $request->getParam('tag_slug');

            $this->validator->validate($request, [
                'tag_name' => V::length(2, 25)->alpha('\''),
                'tag_slug' => V::slug()
            ]);

            $checkSlug = BT::where('slug', '=', $request->getParam('tag_slug'))->get()->count();

            if ($checkSlug > 0) {
                $this->validator->addError('tag_slug', 'Slug already in use.');
            }

            if ($this->validator->isValid()) {
                $addTag = new BT;
                $addTag->name = $tagName;
                $addTag->slug = $tagSlug;

                if ($addTag->save()) {
                    $this->flash('success', 'Category added successfully.');
                    return $this->redirect($response, 'admin-blog');
                }
            }

            $this->flash('danger', 'There was a problem adding the tag.');
            return $this->redirect($response, 'admin-blog');
        }
    }
public function tagsAdd ( Request $ request , Response $ response ) { if ( $ check = $ this -> sentinel -> hasPerm ( 'blog_tags.create' , 'dashboard' , $ this -> config [ 'blog-enabled' ] ) ) { return $ check ; } if ( $ request -> isPost ( ) ) { $ tagName = $ request -> getParam ( 'tag_name' ) ; $ tagSlug = $ request -> getParam ( 'tag_slug' ) ; $ this -> validator -> validate ( $ request , [ 'tag_name' => V :: length ( 2 , 25 ) -> alpha ( '\'' ) , 'tag_slug' => V :: slug ( ) ] ) ; $ checkSlug = BT :: where ( 'slug' , '=' , $ request -> getParam ( 'tag_slug' ) ) -> get ( ) -> count ( ) ; if ( $ checkSlug > 0 ) { $ this -> validator -> addError ( 'tag_slug' , 'Slug already in use.' ) ; } if ( $ this -> validator -> isValid ( ) ) { $ addTag = new BT ; $ addTag -> name = $ tagName ; $ addTag -> slug = $ tagSlug ; if ( $ addTag -> save ( ) ) { $ this -> flash ( 'success' , 'Category added successfully.' ) ; return $ this -> redirect ( $ response , 'admin-blog' ) ; } } $ this -> flash ( 'danger' , 'There was a problem adding the tag.' ) ; return $ this -> redirect ( $ response , 'admin-blog' ) ; } }
Add New Blog Tag
Add New Blog Tag