/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // $posts = post::where('group_id', $id)->get(); $group = group::find($id); $in = player_in_group::where('player_id', Auth::user()->id)->where('group_id', $id)->count(); return view('player.group.group_index', ['group' => $group, 'posts' => $posts, 'in' => $in]); }
public function showpdf($slug) { $artikel = \App\post::where('slug', $slug)->first(); if (!empty($artikel)) { $data = array('data' => $artikel); $pdf = \PDF::loadView('artikel.pdf', $data); return $pdf->stream(); /*return $pdf->download($slug. 'pdf');*/ } else { return redirect(url()); } }
public function template($slug) { $restaurant = template::where('slug', $slug)->first(); $profile = template::where('slug', $slug)->first(); if ($restaurant->user->role == 1) { return view('restaurant.profile', compact('restaurant')); } if ($profile->user->role == 3) { $tatoo = post::where('user_id', $profile->user->id)->OrderBy('id', 'ASC')->paginate(6); return view('tatoo.profile', compact('profile', 'tatoo')); } }
public function getartikel($slug) { $data = array(post::where('slug', $slug)->first()); return view('artikel.list')->with('data', $data); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($slug) { $data = array('data' => post::where('slug', $slug)->first()); return view('artikel.show')->with($data); }
public function index() { $todos = post::where('user_id', Auth::id())->get(); return $todos; }
public function updateComment($post_id) { $post_model = App\post::where('post_id', $post_id)->first(); $page_id = $post_model->page_id; $post_model->comments()->delete(); $comment_data = $this->getComment($post_id); $sentiment_data = $this->sentiment($comment_data); $count = 0; foreach ($comment_data as $comment) { $comment_model = new App\comment(); $comment_model->comment = $comment['comment']; $comment_model->commenter = $comment['commenter']; $comment_model->commenter_id = $comment['commenter_id']; $comment_model->comment_datetime = $comment['comment_datetime']; $post_model->comments()->save($comment_model); $sentiment_model = new App\commentSentiment(); $sentiment_model->joy = $sentiment_data[$count]['joy']; $sentiment_model->sadness = $sentiment_data[$count]['sadness']; $sentiment_model->trust = $sentiment_data[$count]['trust']; $sentiment_model->disgust = $sentiment_data[$count]['disgust']; $sentiment_model->fear = $sentiment_data[$count]['fear']; $sentiment_model->anger = $sentiment_data[$count]['anger']; $sentiment_model->surprise = $sentiment_data[$count]['surprise']; $sentiment_model->anticipation = $sentiment_data[$count]['anticipation']; $sentiment_model->result = $sentiment_data[$count]['result']; $comment_model->sentiment()->save($sentiment_model); $count++; } return redirect('post/' . $page_id . '/' . $post_id); }
$arr[] = array('slug' => $key['slug'], 'isi' => $key['isi'], 'create_at' => $key['created_at'], 'author' => \App\User::find($key['idpengguna'])->first()['email'], 'tag' => $key['tag'], 'sampul' => url('images/', $key['sampul']), 'judul' => $key['judul']); } echo json_encode($arr); }); Route::get("api/artikel/detail/{slug}", function ($slug) { $data = \App\post::where('slug', $slug)->first(); $arr = array('slug' => $key['slug'], 'isi' => $key['isi'], 'create_at' => $key['created_at'], 'author' => \App\User::find($key['idpengguna'])->first()['email'], 'tag' => $key['tag'], 'sampul' => url('images/', $key['sampul']), 'judul' => $key['judul']); if (sizeof($key) == 0) { $data = array('status' => "Erorr", 'error_code' => 404, 'name' => 'artikel_notfound', 'msg' => 'Artikel Not Found'); echo json_encode($data); } else { echo json_encode($arr); } }); Route::get("api/artikel/{type}/{slug}", function ($type, $cari) { $data = \App\post::where($type, $cari)->get(); $arr = array(); foreach ($data as $key) { $arr[] = array('slug' => $key['slug'], 'isi' => $key['isi'], 'create_at' => $key['created_at'], 'author' => \App\User::find($key['idpengguna'])->first()['email'], 'tag' => $key['tag'], 'sampul' => url('images/', $key['sampul']), 'judul' => $key['judul']); } if (sizeof($data) == 0) { $data = array('status' => "Erorr", 'error_code' => 404, 'name' => 'artikel_notfound', 'msg' => 'Artikel Not Found'); echo json_encode($data); } else { echo json_encode($arr); } if (sizeof($data) == 0) { $data = array('status' => "Erorr", 'error_code' => 304, 'name' => 'type_notfound', 'msg' => 'Type Not Found'); echo json_encode($data); } });
private function getStatistic($user_id) { $post_data = array(); $posts = DB::table('post_user')->where('user_id', $user_id)->take(5)->orderBy('updated_at', 'decs')->get(); $count = 0; foreach ($posts as $post) { $post_model = App\post::where('post_id', $post->post_id)->first(); $post_data[$count]['page_id'] = $post_model->page_id; $post_data[$count]['id'] = $post->post_id; $num_joy = DB::table('commentSentiment')->join('comment', 'comment.comment_id', '=', 'commentSentiment.comment_id')->where('comment.post_id', $post->post_id)->where('result', 'joy')->count('commentSentiment.id'); $num_sadness = DB::table('commentSentiment')->join('comment', 'comment.comment_id', '=', 'commentSentiment.comment_id')->where('comment.post_id', $post->post_id)->where('result', 'sadness')->count('commentSentiment.id'); $num_trust = DB::table('commentSentiment')->join('comment', 'comment.comment_id', '=', 'commentSentiment.comment_id')->where('comment.post_id', $post->post_id)->where('result', 'trust')->count('commentSentiment.id'); $num_disgust = DB::table('commentSentiment')->join('comment', 'comment.comment_id', '=', 'commentSentiment.comment_id')->where('comment.post_id', $post->post_id)->where('result', 'disgust')->count('commentSentiment.id'); $num_fear = DB::table('commentSentiment')->join('comment', 'comment.comment_id', '=', 'commentSentiment.comment_id')->where('comment.post_id', $post->post_id)->where('result', 'fear')->count('commentSentiment.id'); $num_anger = DB::table('commentSentiment')->join('comment', 'comment.comment_id', '=', 'commentSentiment.comment_id')->where('comment.post_id', $post->post_id)->where('result', 'anger')->count('commentSentiment.id'); $num_surprise = DB::table('commentSentiment')->join('comment', 'comment.comment_id', '=', 'commentSentiment.comment_id')->where('comment.post_id', $post->post_id)->where('result', 'surprise')->count('commentSentiment.id'); $num_anticipation = DB::table('commentSentiment')->join('comment', 'comment.comment_id', '=', 'commentSentiment.comment_id')->where('comment.post_id', $post->post_id)->where('result', 'anticipation')->count('commentSentiment.id'); $post_data[$count]['sentiment'] = array('joy' => $num_joy, 'sadness' => $num_sadness, 'trust' => $num_trust, 'disgust' => $num_disgust, 'fear' => $num_fear, 'anger' => $num_anger, 'surprise' => $num_surprise, 'anticipation' => $num_anticipation); // DB::table('commentSentiment') // ->join('comment', 'comment.comment_id', '=', 'commentSentiment.comment_id') // ->where('comment.post_id', $post->post_id) // ->get( // array( // DB::raw('COUNT(id) AS joy'), // DB::raw('COUNT(id) AS sadness'), // DB::raw('COUNT(id) AS trust'), // DB::raw('COUNT(id) AS disgust'), // DB::raw('COUNT(id) AS fear'), // DB::raw('COUNT(id) AS anger'), // DB::raw('COUNT(id) AS surprise'), // DB::raw('COUNT(id) AS anticipation'), // ) // ); $count++; } return $post_data; }