/** * * @param \Illuminate\Http\Request $request * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function index(Request $request) { $this->buildBreadcrumbs(['#' => trans('ilib::common.search')]); $q = $request->get('q'); $params = $request->only(array_keys($this->key_column)); $attributes = $this->getAttributes($params); $advanced = !empty($attributes); $category_id = mb_array_extract('category_id', $attributes); $pyear_start = (int) mb_array_extract('pyear_start', $attributes); $pyear_end = (int) mb_array_extract('pyear_end', $attributes); $pyear_end = $pyear_end >= $pyear_start ? $pyear_end : 0; $query = Ebook::queryDefault()->published()->withEnumTitles()->withCategoryTitle()->whereAttributes($attributes)->searchKeyword($q); if ($pyear_start || $pyear_end) { if ($pyear_start) { if ($pyear_end) { $query->whereBetween('ebooks.pyear', [$pyear_start, $pyear_end]); } else { $query->where('ebooks.pyear', '>=', $pyear_start); } } else { $query->where('ebooks.pyear', '<=', $pyear_end); } } if ($category_id && ($category = Category::find($category_id))) { $query->categorized($category); } $ebooks = $this->optionAppliedPaginate($query); $total = $ebooks->total(); $ebook_widget = new EbookWidget(); $categories = CategoryManager::of(Ebook::class)->selectize(); $enums = (new Ebook())->loadEnums('id'); $column_key = array_combine(array_values($this->key_column), array_keys($this->key_column)); return view('ilib::frontend.search.index', $enums + compact('q', 'ebooks', 'ebook_widget', 'total', 'categories', 'params', 'column_key', 'advanced')); }
/** * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function index() { $ebook_widget = new EbookWidget(); $query = Ebook::queryDefault()->published()->withEnumTitles()->withCategoryTitle()->orderUpdated(); $query1 = clone $query; $ebook_latest = $query->take(6)->get(); $ebook_featured = $query1->featured()->get(); return view('ilib::frontend.index', compact('ebook_widget', 'ebook_latest', 'ebook_featured')); }
/** * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function index() { $ebook = new Ebook(); $statuses = $ebook->accessControl()->pluck('title'); $colors = ['', 'white', 'yellow', 'red', 'navy']; $counters = []; foreach ($statuses as $status => $title) { $counters[] = ['status' => $status, 'title' => $title, 'color' => $colors[$status], 'count' => Ebook::status($status)->count()]; } $latest_ebooks = Ebook::queryDefault()->withEnumTitles()->latest()->take(5)->get(); return view('ilib::backend.index', compact('counters', 'latest_ebooks')); }
/** * Duyệt danh sách Tài liệu thuộc $category * * @param \Minhbang\Category\Category $category * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function show(Category $category) { $paths = $category->getRoot1Path(['id', 'title'], false); $breadcrumbs = []; foreach ($paths as $cat) { $breadcrumbs[route('ilib.category.show', ['category' => $cat->id])] = $cat->title; } $breadcrumbs['#'] = $category->title; $this->buildBreadcrumbs($breadcrumbs); $ebooks = $this->optionAppliedPaginate(Ebook::queryDefault()->published()->withEnumTitles()->categorized($category)); $ebook_widget = new EbookWidget(); return view('ilib::frontend.category.show', compact('category', 'ebooks', 'ebook_widget')); }
/** * Danh sách Ebook theo định dạng của Datatables. * * @return \Datatable JSON */ public function data() { /** @var \Minhbang\Ebook\Ebook $query */ $query = Ebook::queryDefault()->status($this->status)->orderUpdated()->withEnumTitles(); if (Request::has('search_form')) { $query = $query->searchWhereBetween('ebooks.created_at', 'mb_date_vn2mysql')->searchWhereBetween('ebooks.updated_at', 'mb_date_vn2mysql'); } return $this->datatable->make('backend', $query); }