/** * Display a listing of the resource. * * @return Response */ public function index(Request $request) { if ($request->ajax()) { return response(Tag::all()); } $tags = Tag::with('articles')->orderBy('created_at', 'desc')->paginate(8); return view('admin.tag.index', ['tags' => $tags]); }
public function tag($name) { if (is_numeric($name)) { $tag = Tag::with('articles')->where('id', '=', $name)->firstOrFail(); } else { $tag = Tag::with('articles')->where('name', '=', $name)->firstOrFail(); } return view('page.tag')->with('tag', $tag)->with('articles', $tag->articles()->where('display', '=', true)->orderBy('created_at', 'desc')->paginate(10)); }