public static function menu() { $new_sub = array(); foreach (Newtypes::all() as $val) { $new_sub[$val->id]['name'] = $val->name; $new_sub[$val->id]['val'] = Post::where('category', '=', $val->id)->take(10)->get(); } return $new_sub; }
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); }
{{ Form::close() }} <!-- show the nerd (uses the show method found at GET /nerds/{id} --> <a class="btn btn-small btn-success" href="{{ URL::to('posts/' . $value->id) }}">Xem</a> <!-- edit this nerd (uses the edit method found at GET /nerds/{id}/edit --> <a class="btn btn-small btn-info" href="{{ URL::to('posts/' . $value->id . '/edit') }}">Sủa</a> </td> </tr> @endforeach </tbody> </table> </div> </div> <script> $(document).ready(function(){ $('#example').dataTable({ responsive: true }).columnFilter({ aoColumns: [ null, { type: "text" }, { type: "select", values: [<?php foreach (Newtypes::all() as $val) { echo "'" . $val->name . "',"; } ?> ] } ] }); }); </script> @stop
/** * 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'); } }