/**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $title = 'Dashboard';
     $posts = Posts::all()->take(3);
     $comments = Comments::all()->take(3);
     return view('dashboard')->withTitle($title)->withPosts($posts)->withComments($comments);
     //return home.blade.php template from resources/views folder
 }
Esempio n. 2
0
 public function managePost()
 {
     $user_id = Auth::user()->id;
     if ($user_id == 1) {
         $arrPost = Posts::all();
     } else {
         $arrPost = Posts::where('user_id', '=', $user_id)->get();
     }
     return view('pages.managePost', array('arrPost' => $arrPost));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     // Info we need to grab. //
     ///////////////////////////
     // New users: Today, this week + month. ---> just queery our database with a where->created == today || month || week
     // Total categories
     // unread admin messages.
     $data = array('new_users' => \App\User::all()->orderBy('created_at', 'DES')->limit(10), 'active_nav' => $this->active_nav, 'total_users' => \App\User::all()->count(), 'logged_in' => \App\User::where('logged_in', '=', 1)->count(), 'total_posts' => \App\Posts::all()->count());
     return view('includes/admin/home')->with($data);
 }
Esempio n. 4
0
 public function getPosts()
 {
     try {
         $statusCode = 200;
         $response = ['posts' => []];
         $posts = Posts::all();
     } catch (Exception $e) {
         $statusCode = 400;
     } finally {
         // return Response::json($response, $statusCode);
         return Response::json(array('statuscode' => $statusCode, 'posts' => $posts->toArray()));
     }
 }
Esempio n. 5
0
 public function home()
 {
     $posts = Posts::all();
     $allTxt = array();
     $i = 0;
     foreach ($posts as $post) {
         if ($post->active == 1 && !$post->expired() && $post->type == 0 && empty($post->image)) {
             $allTxt[$i] = array('title' => $post->title, 'description' => $post->description, 'uname' => $post->user->userName(), 'dateon' => date('d-M-y h:i a', strtotime($post->created_at)), 'deptname' => $post->deptName->name);
             $i++;
         }
     }
     return view('newUI')->with('posts', $posts)->with('allTxt', $allTxt);
 }
Esempio n. 6
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $data = array('data' => Posts::all());
     return view('artikel.all')->with($data);
 }
Esempio n. 7
0
 public function searchPostsByHashtag(Request $request)
 {
     $data = $request->all();
     preg_match_all('/\\b([a-zA-Z0-9]+)\\b/', strtoupper($data['HashtagSearch']), $matches, PREG_PATTERN_ORDER);
     $hashtags = $matches[1];
     $posts = Posts::all()->toArray();
     $rank = array();
     foreach ($hashtags as $ht) {
         foreach ($posts as $key => $post) {
             if (!array_key_exists($key, $rank)) {
                 $rank += array($key => 0);
             }
             $postHashtag = Tags::where('PostID', '=', $post['id'])->get()->toArray();
             foreach ($postHashtag as $pht) {
                 if (stripos(Hashtags::find($pht['HashtagID'])->Hashtag, $ht) !== false) {
                     $rank[$key]++;
                 }
             }
         }
     }
     foreach ($rank as $key => $value) {
         if ($value < 1) {
             unset($rank[$key]);
         }
     }
     arsort($rank);
     $result = array();
     $posts = Posts::all();
     foreach ($rank as $key => $value) {
         $result += array($key => $posts[$key]);
     }
     preg_match_all('/\\b([a-zA-Z0-9]+)\\b/', $data['HashtagSearch'], $matches, PREG_PATTERN_ORDER);
     $hashtags = $matches[1];
     $Hashtags = '';
     foreach ($hashtags as $ht) {
         $Hashtags .= $ht . ' ';
     }
     return view('search')->with(['Posts' => $result, 'Hashtags' => $Hashtags]);
 }
Esempio n. 8
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return \App\Posts::all();
 }
Esempio n. 9
0
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('api/artikel/all', function () {
    $data = array('artikel' => array('id' => 1, 'judul' => 'judul artikel', 'isi' => 'isi artikel', 'timestamp' => '2015-01-01 01:01:01'));
    //echo "<pre>".print_r($data,1)."<pre>";
    //echo $data->artikel->id;
    $json = json_encode($data);
    echo $json;
    //$obj = json_decode($json);
    //echo "<pre>".print_r($obj,1)."<pre>";
    //echo $obj['artikel']['id'];
});
Route::get('api/artikel/all', function () {
    $data = \App\Posts::all();
    $arr = array();
    foreach ($data as $key) {
        $arr[] = array('slug' => $key['slug'], 'isi' => $key['isi'], 'created_at' => $key['created_at'], 'author' => \App\User::find($key['idpengguna'])['email'], 'tag' => $key['tag'], 'judul' => $key['judul']);
    }
    echo json_encode($arr);
    // echo "<pre>".json_encode($data)."<pre>";
});
Route::get('api/artikel/detail/{slug}', function ($slug) {
    $key = \App\Posts::where('slug', $slug)->first();
    $arr = array();
    $arr[] = array('slug' => $key['slug'], 'isi' => $key['isi'], 'created_at' => $key['created_at'], 'author' => \App\User::find($key['idpengguna'])['email'], 'tag' => $key['tag'], 'sampul' => url('images/' . $key['sampul']), 'judul' => $key['judul']);
    echo json_encode($arr);
});
Route::get('api/artikel/{type}/{cari}', function ($type, $cari) {
    $data = \App\Posts::where($type, $cari)->get();
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $data = array('active_nav' => $this->active_nav, 'posts' => \App\Posts::all());
     return view('includes/admin/manage-posts')->with($data);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $admin_messages = \App\AdminMessages::where('read', '=', 0);
     $data = array('active_nav' => $this->active_nav, 'total_users' => \App\User::all()->count(), 'logged_in' => \App\User::where('logged_in', '=', 1)->count(), 'total_categories' => \App\categories::count(), 'total_posts' => \App\Posts::all()->count(), 'latest_users' => \App\User::orderBy('created_at', 'ASC')->limit(10)->get(), 'latest_posts' => \App\Posts::orderBy('created_at', 'ASC')->limit(10)->get(), 'unread_admin_messages' => $admin_messages->count(), 'new_users_month' => \App\User::getFromDate(date('y-m-0'))->count(), 'new_users_week' => \App\User::getFromDate(date('y-m-d', strtotime('-7 day')))->count(), 'new_users_day' => \App\User::getFromDate(date('y-m-d', strtotime('-1 day')))->count(), 'new_posts_month' => \App\Posts::getFromDate(date('y-m-0'))->count(), 'new_posts_week' => \App\Posts::getFromDate(date('y-m-d', strtotime('-7 day')))->count(), 'new_posts_day' => \App\Posts::getFromDate(date('y-m-d', strtotime('-1 day')))->count(), 'admin_messages' => $admin_messages->get());
     return view('includes/admin/home')->with($data);
 }
 /**
  * @return mixed
  */
 public function add()
 {
     $response = [];
     $message = "Inserted ok";
     $statusCode = 200;
     $data = json_decode(file_get_contents('php://input'));
     if (!empty($data)) {
         try {
             $title = $data->title;
             $description = $data->description;
             $content = $data->content;
             $published = $data->published;
             DB::table('posts')->insert([['title' => $title, 'description' => $description, 'content' => $content, 'published' => $published]]);
             $response['posts'] = Posts::all();
             $statusCode = 200;
         } catch (Exception $e) {
             $message = $e->getMessage();
             $statusCode = 400;
         } finally {
             $response['status'] = $statusCode;
             $response['message'] = $message;
         }
     } else {
         $statusCode = 400;
     }
     return \Response::json($response, $statusCode);
 }