예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Posts::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'text' => $this->text]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'text_preview', $this->text_preview])->andFilterWhere(['like', 'img', $this->img]);
     return $dataProvider;
 }
예제 #2
0
 /**
  * Finds the Posts model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Posts the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Posts::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #3
0
        </li>
        @endforeach
        <?php 
$link = \App\Modules\Blog\Components\GeneralFunctions::curPageURL();
?>
        @if(!Auth::guest())
        <li>
            <a href="#" onclick="window.open('https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(location.href), 'facebook-share-dialog', 'width=626,height=436');
            return false;">Share on Facebook</a>
        </li>
        <li>

            <?php 
$fb = \App\Modules\Blog\Models\Posts::getTwittercount($link);
$tc = \App\Modules\Blog\Models\Posts::getFacebookcount($link);
$fbcomments = \App\Modules\Blog\Models\Posts::getFacebookComments($link);
// var_dump($tc);
if (isset($tc['0']->share_count)) {
    echo "facebook share count:" . $tc['0']->share_count;
}
?>
        </li>
        <li>

            <script type="text/javascript" src="//newsharecounts.s3-us-west-2.amazonaws.com/nsc.js"></script>
            <a href="https://twitter.com/share" class="twitter-share-button" data-url="https://dev.twitter.com/rest/collections" data-via="Your twitter id" data-related="blogapp">Tweet</a>
            <script>!function(d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location) ? 'http' : 'https';
            if (!d.getElementById(id)) {
                js = d.createElement(s);
                js.id = id;
 public function actionArticle($id)
 {
     $article = Posts::getOne($id);
     return $this->render('article', ['article' => $article]);
 }
예제 #5
0
 /**
  * Get user draft posts
  */
 public function user_posts_draft(Request $request)
 {
     $user = $request->user();
     $posts = Posts::where('author_id', $user->id)->where('active', '0')->orderBy('created_at', 'desc')->paginate(5);
     $title = $user->name;
     return view('Blog::home')->withPosts($posts)->withTitle($title);
 }