public function komentar() { $komen = new \App\Komentar(); $komen->idposts = Input::get('idpost'); $komen->isi = Input::get('isi'); $komen->idpengguna = Auth::user()->id; $komen->save(); echo "sukses"; }
Route::get('artikel/delete/{id}', 'ArtikelController@destroy'); Route::post('komentar', 'ArtikelController@komentar'); Route::get('/images/{filename}', function ($filename) { $path = storage_path() . '/' . $filename; $file = File::get($path); $type = File::mimeType($path); $response = Response::make($file, 200); $response->header("Content-Type", $type); return $response; }); Route::get('/{slug}', 'ArtikelController@show'); Route::get('checkpdf/{value?}', function ($value = 'HELLO') { $pdf = App::make('dompdf.wrapper'); $pdf->loadHTML('<h1>' . $value . '</h1>'); return $pdf->stream(); }); Route::get('pdf/{slug}', 'WelcomeController@showpdf'); // Route::get('mail/{slug}', function ($slug) // { // $artikel = \App\Posts::where('slug', $slug)->first(); // Mail::send('artikel.pdf', ['data' => $artikel], // function($message) // { // $message->to(Auth::user()->email, Auth::user()->name)->subject("Update Atikel"); // }); // }); Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']); Route::get('load_comments/{id}', function ($id) { $data = App\Komentar::where('idposts', $id)->get(); echo json_encode($data); });
<div class="panel"> <div class="heading"> <span class="icon"> <span class="mif-bubbles"></span> </span> <span class="title">Comments</span> </div> <div class="content"> <div class="listview-outlook" data-role="listview"> <?php $komentar = App\Komentar::where('idpost', $data->id)->orderBy('id', 'desc')->get(); ?> @if(sizeof($komentar)==0) <form method="POST" action="{{ url('mine/komen/'.$data->id) }}"> <h3>Be the first to comment this post</h3> <div class="input-control textarea full-size"> <input type="hidden" name="_token" value="{{ csrf_token() }}"> <textarea type="text" name="isi"></textarea> </div> <span class="place-right"><button class="button">Submit</button></span> </form> @else <h3>Comment to this post</h3> <form method="POST" action="{{ url('mine/komen/'.$data->id) }}"> <div class="input-control textarea full-size"> <input type="hidden" name="_token" value="{{ csrf_token() }}"> <textarea type="text" name="isi"></textarea> </div> <span class="place-right"><button class="button">Submit</button></span> </form> <br>