public function blogEdit(Request $request, Response $response, $postId)
    {

        //die(var_dump($request->getAttribute('route')));
        if ($check = $this->sentinel->hasPerm('blog.update', 'dashboard', $this->config['blog-enabled'])) {
            return $check;
        }

        $post = BlogPosts::where('id', $postId)->with('category')->with('tags')->first();

        if (!$post) {
            $this->flash('danger', 'That post does not exist.');
            return $this->redirect($response, 'admin-blog');
        }

        if (!$this->auth->check()->inRole('manager')
            && !$this->auth->check()->inRole('admin')
            && $post->user_id != $this->auth->check()->id) {
            $this->flash('danger', 'You do not have permission to edit that post.');
            return $this->redirect($response, 'admin-blog');
        }

        if ($request->isPost()) {
            if ($this->blogUtils->updatePost($post->id)) {
                return $this->redirect($this->container->response, 'admin-blog');
            }
        }

        $currentTags = $post->tags->pluck('id');

        return $this->view->render(
            $response,
            'blog-edit.twig',
            array(
                "post" => $post->toArray(),
                "categories" => BlogCategories::get(),
                "tags" => BlogTags::get(),
                "currentTags" => $currentTags
            )
        );
    }
public function blogEdit(Request $request, Response $response, $postId)
    {

        //die(var_dump($request->getAttribute('route')));
        if ($check = $this->sentinel->hasPerm('blog.update', 'dashboard', $this->config['blog-enabled'])) {
            return $check;
        }

        $post = BlogPosts::where('id', $postId)->with('category')->with('tags')->first();

        if (!$post) {
            $this->flash('danger', 'That post does not exist.');
            return $this->redirect($response, 'admin-blog');
        }

        if (!$this->auth->check()->inRole('manager')
            && !$this->auth->check()->inRole('admin')
            && $post->user_id != $this->auth->check()->id) {
            $this->flash('danger', 'You do not have permission to edit that post.');
            return $this->redirect($response, 'admin-blog');
        }

        if ($request->isPost()) {
            if ($this->blogUtils->updatePost($post->id)) {
                return $this->redirect($this->container->response, 'admin-blog');
            }
        }

        $currentTags = $post->tags->pluck('id');

        return $this->view->render(
            $response,
            'blog-edit.twig',
            array(
                "post" => $post->toArray(),
                "categories" => BlogCategories::get(),
                "tags" => BlogTags::get(),
                "currentTags" => $currentTags
            )
        );
    }
public function blogEdit ( Request $ request , Response $ response , $ postId ) { //die(var_dump($request->getAttribute('route'))); if ( $ check = $ this -> sentinel -> hasPerm ( 'blog.update' , 'dashboard' , $ this -> config [ 'blog-enabled' ] ) ) { return $ check ; } $ post = BlogPosts :: where ( 'id' , $ postId ) -> with ( 'category' ) -> with ( 'tags' ) -> first ( ) ; if ( ! $ post ) { $ this -> flash ( 'danger' , 'That post does not exist.' ) ; return $ this -> redirect ( $ response , 'admin-blog' ) ; } if ( ! $ this -> auth -> check ( ) -> inRole ( 'manager' ) && ! $ this -> auth -> check ( ) -> inRole ( 'admin' ) && $ post -> user_id != $ this -> auth -> check ( ) -> id ) { $ this -> flash ( 'danger' , 'You do not have permission to edit that post.' ) ; return $ this -> redirect ( $ response , 'admin-blog' ) ; } if ( $ request -> isPost ( ) ) { if ( $ this -> blogUtils -> updatePost ( $ post -> id ) ) { return $ this -> redirect ( $ this -> container -> response , 'admin-blog' ) ; } } $ currentTags = $ post -> tags -> pluck ( 'id' ) ; return $ this -> view -> render ( $ response , 'blog-edit.twig' , array ( "post" => $ post -> toArray ( ) , "categories" => BlogCategories :: get ( ) , "tags" => BlogTags :: get ( ) , "currentTags" => $ currentTags ) ) ; }
Edit Blog Post
Edit Blog Post