Esempio n. 1
0
 public static function index()
 {
     $posts = Posts::all()->fetchAll(\PDO::FETCH_CLASS);
     $categories = Categories::all()->fetchAll(\PDO::FETCH_CLASS);
     $comments = Comments::all()->fetchAll(\PDO::FETCH_CLASS);
     View::render('admin/home', ['posts' => $posts, 'categories' => $categories, 'comments' => $comments]);
 }
Esempio n. 2
0
 public static function index()
 {
     $posts = Posts::all((new DbCriteria())->order_by('created_at')->DESC());
     # set criteria
     $criteria = (new DbCriteria())->order_by('viewers')->DESC()->LIMIT(5);
     $hotposts = Posts::all($criteria);
     $users = Accounts::find(['type' => 2]);
     $categories = Categories::all();
     # /app/views/waitress/order.php
     View::render('home', ['hotposts' => $hotposts, 'posts' => $posts, 'users' => $users, 'categories' => $categories]);
 }
Esempio n. 3
0
 public function index($id = null)
 {
     $logintest = false;
     if (Auth::check('default')) {
         $logintest = true;
     }
     $posts = Posts::all();
     /*
     //delete
     if(!is_null($id)){
     	//$post=Posts::find('first', array('conditions' =>array('_id'=>$id)));
     	$posts = Posts::remove(array('_id' => $id), array("justOne" => true));
     	//echo "<h1>a sdasdkajsdkansdkansdnnasdkjanskdnkajsn</h1>";
        }
     */
     return compact('posts', 'logintest');
     //return array('foo' => 'bar', 'title' => 'Posts');
 }
 public static function index()
 {
     # if user was login before and the session is still valid
     if (Request::is_authenticated()) {
         if (Request::is_admin()) {
             AdminController::index();
         } else {
             MemberController::index();
         }
     } else {
         $posts = Posts::all((new DbCriteria())->order_by('created_at')->DESC());
         # set criteria
         $criteria = (new DbCriteria())->order_by('viewers')->DESC()->LIMIT(5);
         $hotposts = Posts::all($criteria)->fetchAll();
         $users = Accounts::find(['type' => 2]);
         $categories = Categories::all();
         # /app/views/home.php
         View::render('home', ['hotposts' => $hotposts, 'posts' => $posts, 'users' => $users, 'categories' => $categories]);
     }
 }
 public function index()
 {
     $posts = Posts::all();
     $message = 'regular';
     return compact('posts', 'message');
 }
Esempio n. 6
0
 public function index()
 {
     $posts = Posts::all();
     return compact('posts');
 }
Esempio n. 7
0
 public static function index()
 {
     $users = Accounts::find(['type' => 2]);
     # /app/views/waitress/order.php
     View::render('home', ['users' => $users, 'posts' => Posts::all(), 'categories' => Categories::all()]);
 }
Esempio n. 8
0
 /**
  * DELETANDO TAG || DELETE TAG
  *
  * @param  int  $id
  * @return Response
  */
 public function excluirTags($id)
 {
     $tags_first = Tags::where('tag_id', $id)->first();
     $nova_tag_s = '';
     $tags_array = array();
     if (empty($id)) {
         return 'campovazio';
     } else {
         $posts = Posts::all();
         $tags = array();
         if (count($posts) > 0) {
             foreach ($posts as $post) {
                 if (strpos($post->post_tags, (string) $tags_first->tag_id) != false || $post->post_tags == (string) $tags_first->tag_id) {
                     $tags = explode(",", $post->post_tags);
                     if (count($tags) > 0) {
                         foreach ($tags as $key => $value) {
                             if ($tags_first->tag_id != $value) {
                                 array_push($tags_array, $value);
                             }
                         }
                         $nova_tag_s = implode(",", $tags_array);
                     }
                     //Atualizando as tags
                     Posts::where('post_id', $post->post_id)->update(array('post_tags' => $nova_tag_s));
                     $nova_tag_s = '';
                     $tags_array = array();
                     $tags = array();
                 }
             }
         }
         // Apagando a tag
         if (Tags::where('tag_id', $id)->delete()) {
             return 'sucesso';
         }
     }
 }