/** * @param \Minhbang\Ebook\Ebook $ebook * * @return string */ public function itemList(Ebook $ebook) { $ds = ''; $ds .= '<dt>' . trans("ebook::common.language_id") . '</dt><dd>' . $ebook->language . '</dd>'; $ds .= '<dt>' . trans("ebook::common.pages") . '</dt><dd>' . $ebook->pages . '</dd>'; $url = $ebook->url; $publisher = trans("ebook::common.publisher_id_th") . ': ' . $ebook->publisher; return <<<ITEM <div class="col-md-12"> <div class="ebook-list-item"> <a href="{$url}"> <div class="ebook-cover"> {$ebook->present()->featured_image} <div class="security">{$ebook->present()->securityFormated('success')}</div> </div> </a> <div class="inner"> <blockquote> <a href="{$url}"><div class="title">{$ebook->title}</div></a> <footer>{$ebook->writer}, {$publisher}, {$ebook->pyear}</footer> </blockquote> <div class="details"> <dl class="dl-horizontal">{$ds}</dl> <small>{$ebook->present()->fileicon} {$ebook->present()->filesize}</small> </div> </div> </div> </div> ITEM; }
/** * @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')); }
/** * * @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\View\View */ public function index() { $tableOptions = ['id' => 'reader-manage', 'class' => 'table-readers', 'row_index' => true]; $options = ['aoColumnDefs' => [['sClass' => 'min-width text-right', 'aTargets' => [0, 1]], ['sClass' => 'min-width', 'aTargets' => [2, -1, -2]]]]; $table = Datatable::table()->addColumn('', trans('ilib::reader.code_th'), trans('user::user.name'), trans('ebook::common.ebook'), trans('ilib::reader.expires_at'), '')->setOptions($options)->setCustomValues($tableOptions); $this->buildHeading([trans('common.manage'), trans('ilib::reader.allow_ebooks')], 'fa-file-pdf-o', [route($this->route_prefix . 'backend.reader.index') => trans('ilib::reader.reader'), '#' => trans('ilib::reader.allowed')]); $readers = Reader::forSelectize()->get()->all(); $ebooks = Ebook::forSelectize()->orderUpdated()->get()->all(); return view('ilib::backend.reader.ebook', compact('tableOptions', 'options', 'table', 'readers', 'ebooks')); }
public function category() { $this->buildHeading([trans("ilib::common.statistics"), trans("ilib::common.statistics_category")], 'fa-bar-chart', ['#' => trans("ilib::common.statistics")]); /** @var Category[] $categories */ $categories = CategoryManager::of(Ebook::class)->root()->getDescendants(); $data = []; foreach ($categories as $category) { $data[] = ['title' => $category->title, 'depth' => $category->depth, 'count' => Ebook::categorized($category)->count()]; } return view('ilib::backend.statistics.category', compact('data')); }
/** * 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')); }
/** * @param \Minhbang\Ebook\Ebook $ebook * @param string $slug * * @return bool */ protected function checkPermission($ebook, $slug) { abort_unless($slug == $ebook->slug, 404); /** @var User $user */ $user = user(); /** @var Reader $reader */ $reader = Reader::find($user->id); return $user->hasRole('tv.*') || $ebook->isPublished() && $reader && $reader->canRead($ebook); }
/** * Lấy danh sách ebooks sử dụng cho selectize ebooks * * @param string $title * * @return \Illuminate\Http\JsonResponse */ public function select($title) { return response()->json(Ebook::forSelectize()->orderUpdated()->findText('title', $title)->get()->all()); }
/** * @param Ebook $model * * @return bool */ protected function quickUpdateAllowed($model) { return $model->allowed(user(), 'update'); }