public function watch($id)
 {
     $video = DB::table('katalog')->leftjoin('publisher', 'katalog.publisher', '=', 'publisher.id')->where('katalog.id', '=', $id)->get(array('katalog.id', 'katalog.title', 'katalog.release', 'katalog.numpage', 'publisher.publishername', 'katalog.file', 'katalog.ISBN'));
     $authors = AuthorKatalog::get_author_katalog($id);
     $katalog = Katalog::find($id);
     $katalog->view++;
     $katalog->save();
     return View::make('front.watch', compact('video', 'authors'));
 }
 public function home()
 {
     $quotes = Quote::all()->toArray();
     //var_dump($quotes);
     $quote = $quotes[rand(0, count($quotes) - 1)];
     $mostviewed = Katalog::orderBy('view', 'desc')->take(9)->get();
     $lastrelease = Katalog::orderBy('created_at', 'desc')->take(9)->get();
     return View::make('home', compact('quote', 'mostviewed', 'lastrelease'));
 }
 public function addArtikel()
 {
     $act = 'add';
     $author = Author::all();
     $tags = Tag::all();
     if (Input::has('submit')) {
         $rules = array('title' => 'required', 'tag' => 'required', 'content' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->passes()) {
             $katalog = new Katalog();
             $katalog->title = Input::get('title');
             $katalog->category = 3;
             $katalog->summary = Input::get('content');
             $katalog->release = date('Y');
             $katalog->save();
             foreach (Input::get('author') as $value) {
                 $author = new AuthorKatalog();
                 $author->idkatalog = $katalog->id;
                 $author->author = $value;
                 $author->save();
             }
             $tag = str_replace(' ', '', Input::get('tag'));
             $tags = explode(',', $tag);
             foreach ($tags as $tag) {
                 $katalogtag = new KatalogTag();
                 $katalogtag->idkatalog = $katalog->id;
                 $idtag = Tag::where('tag', '=', $tag)->get();
                 if (count($idtag) > 0) {
                     $katalogtag->idtag = $idtag[0]->id;
                     $katalogtag->save();
                 } else {
                     $tagclass = new Tag();
                     $tagclass->tag = $tag;
                     $tagclass->save();
                     $katalogtag->idtag = $tagclass->id;
                     $katalogtag->save();
                 }
             }
             return Redirect::to('admin/rkmartikel')->with('sukses', 'Berhasil rekam Artikel!');
         } else {
             return Redirect::to('admin/rkmartikel')->withInput()->withErrors($validator);
         }
     } else {
         return View::make('admin.artikel', compact('act', 'author', 'tags'));
     }
 }