/**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     //$contents = Content::all();
     $contents = Content::orderBy('created_at', 'desc')->paginate(15);
     return View('admin.contents.content')->with('contents', $contents);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $search = (object) array();
     $search->from = $request->input('searchFrom') ? $request->input('searchFrom') : Carbon::today()->subMonth()->format('Y-m-d');
     $search->to = $request->input('searchTo') ? $request->input('searchTo') : Carbon::today()->addMonth()->format('Y-m-d');
     if ($request->input('searchName') && $request->input('searchName') != '') {
         $search->name = $request->input('searchName');
     }
     if ($request->input('searchCategory') && $request->input('searchCategory') != '') {
         $search->category = $request->input('searchCategory');
     }
     if ($request->input('searchStatus') && $request->input('searchStatus') != '') {
         $search->status = $request->input('searchStatus');
     }
     $contents = Content::orderBy('created_at');
     if (Auth::user()->types === 'author') {
         $contents->where('user_id', Auth::user()->id);
     }
     if (isset($search->name)) {
         $contents->where('name', 'like', '%' . spaceToLike($search->name) . '%');
     }
     if (isset($search->category)) {
         $contents->where('category_id', $search->category);
     }
     if (isset($search->status)) {
         $contents->where('status', $search->status);
     }
     if (isset($search->from) && isset($search->to)) {
         $contents->where('created_at', '>=', $search->from);
         $contents->where('created_at', '<=', $search->to);
     }
     $contents = $contents->paginate(config('app.admin.content.per_page'))->appends(['searchName' => $request->input('searchName'), 'searchCategory' => $request->input('searchCategory'), 'searchStatus' => $request->input('searchStatus'), 'searchFrom' => $request->input('searchFrom'), 'searchTo' => $request->input('searchTo')]);
     return view('admin/content', ['search' => $search, 'contents' => $contents, 'categories' => Category::all()->sortBy('order')]);
 }
 public function index()
 {
     if (!isset($_GET['page'])) {
         $_GET['page'] = 1;
     }
     $contents = Cache::remember('contents-' . $_GET['page'], 60, function () {
         $data = Content::orderBy('id', 'desc')->paginate(5);
         $data->setPath('/');
         return $data;
     });
     return view('Site.main', ['contents' => $contents, 'popular' => \App\Layout::popular()]);
 }
Exemple #4
0
 public function getContents($request, $type = null, $category_slug = null)
 {
     $contents = Content::orderBy('created_at', 'desc')->where('status', 'publish');
     if ($request->has('title')) {
         $contents->where('title', 'like', '%' . $request->get('title') . '%');
     }
     if ($request->has('category_id')) {
         $contents->where('category_id', $request->get('category_id'));
     }
     if ($request->has('type')) {
         $contents->where('type', $request->get('type'));
     }
     if ($type != null) {
         $contents->where('type', $type);
     }
     if ($category_slug != null) {
         switch ($type) {
             case 1:
             case 2:
                 $category = Category::where('slug', $category_slug)->first();
                 break;
             case 3:
                 $category = Project::where('slug', $category_slug)->first();
                 break;
         }
         $contents->where('category_id', $category->id);
     }
     if ($request->has('status')) {
         $status = $request->get('status');
         if ($status == 'trashed') {
             $contents->onlyTrashed();
         } else {
             $contents->where('status', $request->get('status'));
         }
     }
     $contents = $contents->paginate(15)->appends($request->except('page'));
     return $contents;
 }
 public function showContent()
 {
     $contents = Content::orderBy('created_at', 'desc')->get();
     return view('home')->with('contents', $contents);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $pages = Content::orderBy('id', 'desc')->get();
     return view('cms.pages.page', compact('pages'));
 }
 public function show()
 {
     $content = Content::orderBy('updated_at', 'desc')->get();
     return \Theme::display('content.admin-list', ['content' => $content]);
 }
 public function web(Web $web)
 {
     $feed = Content::orderBy('publish_date', 'desc')->take(3)->get();
     return view('main.web', compact('web', 'feed'));
 }