/** * 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 saveartikel(Request $request) { $post = new post(); $post->author = Input::get('author'); $post->judul = Input::get('judul'); $post->isi = Input::get('message'); $post->slug = str_slug(Input::get('judul')); if (Input::hasFile('gambar')) { $sampul = date("YmdHis"); uniqid() . "." . Input::file('gambar')->getClientOriginalExtension(); Input::file('gambar')->move(storage_path(), $sampul); $post->sampul = $sampul; } $post->save(); return redirect(url('artikel/openssl_pkey_get_details(key)')); }
/** * Show the application dashboard to the user. * * @return Response */ public function index() { $data = array('data' => \App\post::paginate(5)); return view('welcome')->with($data); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $data = array('data' => post::all()); return view('artikel.all')->with($data); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { post::find($id)->delete(); return redirect(url('artikel')); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($slug) { $user_id = Auth::id(); $todo = post::findBySlugorfail($slug); $todo->delete(); return $todo; }
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); }
<?php /* |-------------------------------------------------------------------------- | Routes File |-------------------------------------------------------------------------- | | Here is where you will register all of the routes in an application. | 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('/', function () { $post = \App\post::OrderBy('id', 'ASC')->paginate(9); $event = \App\event::OrderBy('id', 'ASC')->paginate(9); $user = \App\template::OrderBy('id', 'ASC')->paginate(6); return view('welcome', compact('post', 'event', 'user')); }); Route::get('/load', function () { return view('load'); }); /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | This route group applies the "web" middleware group to every route | it contains. The "web" middleware group is defined in your HTTP | kernel and includes session state, CSRF protection, and more. | */
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $post = post::find($id); return view('player.post.group_topic', ['post' => $post]); }
$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; }