Esempio n. 1
0
 public function getTinTuc($category)
 {
     if (@$category == null || @$category == 'all') {
         $new = Post::Paginate(10);
         $type = "mới nhất";
     } else {
         $new = Post::where('category', '=', $category)->paginate(1);
         $new->setBaseUrl($category);
         $type = Newtypes::find($category)->name;
     }
     return View::make("frontend/posts/index")->with('posts', $new)->with('category', $type);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     // delete
     if (count(Post::Where('category', '=', $id)->get()) > 0) {
         Session::flash('message', 'Không thể xóa vì có Tin tức thuộc Thể loại tin này!');
         return Redirect::to('newtypes');
     } else {
         $monk = Newtypes::find($id);
         $monk->delete();
         Logfile::addData('Xóa', 'Loại tin', $monk->id, $monk->name);
         // redirect
         Session::flash('message', 'Thể loại da  bị xóa!');
         return Redirect::to('newtypes');
     }
 }