src/controllers/BlogController.php
public function getShare($id,$social)
    {
        $url = '';
        $post = \App\Blog::find($id);
        if($post == NULL){
            App::abort(404);
        }

        // add social point if it is not robot
        if (!isset($_SERVER['HTTP_USER_AGENT']) && !preg_match('/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT'])) {
            $post->socialPoint ++;
            $post->save();
        }
        switch ($social){
            case 'twitter' :
                $url  = 'https://twitter.com/home?status=';
                $url .= $post['title'] . ' ' . $post->getUrl();
            break;
            case 'facebook' :
                $url  = 'https://www.facebook.com/sharer/sharer.php?u=';
                $url .=  $post->getUrl();
            break;
            case 'googlePlus' :
                $url  = 'https://plus.google.com/share?url=';
                $url .= $post->getUrl();
            break;
            case 'linkedIn' :
                $url  = 'https://www.linkedin.com/shareArticle?mini=true&';
                $url .= 'url='.$post->getUrl().'&title='.$post['title'].'&summary=&source=';
            break;          
        }
        return \Redirect::to($url);
    }
public function getShare($id,$social)
    {
        $url = '';
        $post = \App\Blog::find($id);
        if($post == NULL){
            App::abort(404);
        }

        // add social point if it is not robot
        if (!isset($_SERVER['HTTP_USER_AGENT']) && !preg_match('/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT'])) {
            $post->socialPoint ++;
            $post->save();
        }
        switch ($social){
            case 'twitter' :
                $url  = 'https://twitter.com/home?status=';
                $url .= $post['title'] . ' ' . $post->getUrl();
            break;
            case 'facebook' :
                $url  = 'https://www.facebook.com/sharer/sharer.php?u=';
                $url .=  $post->getUrl();
            break;
            case 'googlePlus' :
                $url  = 'https://plus.google.com/share?url=';
                $url .= $post->getUrl();
            break;
            case 'linkedIn' :
                $url  = 'https://www.linkedin.com/shareArticle?mini=true&';
                $url .= 'url='.$post->getUrl().'&title='.$post['title'].'&summary=&source=';
            break;          
        }
        return \Redirect::to($url);
    }
public function getShare ( $ id , $ social ) { $ url = '' ; $ post = \ App \ Blog :: find ( $ id ) ; if ( $ post == NULL ) { App :: abort ( 404 ) ; } // add social point if it is not robot if ( ! isset ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) && ! preg_match ( '/bot|crawl|slurp|spider/i' , $ _SERVER [ 'HTTP_USER_AGENT' ] ) ) { $ post -> socialPoint ++ ; $ post -> save ( ) ; } switch ( $ social ) { case 'twitter' : $ url = 'https://twitter.com/home?status=' ; $ url .= $ post [ 'title' ] . ' ' . $ post -> getUrl ( ) ; break ; case 'facebook' : $ url = 'https://www.facebook.com/sharer/sharer.php?u=' ; $ url .= $ post -> getUrl ( ) ; break ; case 'googlePlus' : $ url = 'https://plus.google.com/share?url=' ; $ url .= $ post -> getUrl ( ) ; break ; case 'linkedIn' : $ url = 'https://www.linkedin.com/shareArticle?mini=true&' ; $ url .= 'url=' . $ post -> getUrl ( ) . '&title=' . $ post [ 'title' ] . '&summary=&source=' ; break ; } return \ Redirect :: to ( $ url ) ; }
Add the point to
Add the point to