/**
  * Show the category articles
  *
  * @param Category $category
  * @return Response
  */
 public function index(Category $category)
 {
     $fbLikeCounter = $this->fbLikes->facebookLike();
     $totalMembers = $this->ipb->getTotalMembers();
     $articles = $category->articles()->published()->orderBy('published_at', 'desc')->paginate(5);
     return view('application.category.index', compact('articles', 'category', 'fbLikeCounter', 'totalMembers'));
 }
 /**
  * Remove the specified language from storage.
  *
  * @param  Language  $language
  * @return Response
  */
 public function destroy(Language $language)
 {
     $checkLang = Category::whereLanguageId($language->id)->all();
     if (!empty($checkLang)) {
         Flash::error('This language already in use. Please change the languages in the Category first!');
         return Redirect::back();
     }
     return $this->destroyFlashRedirect($language);
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->model('article', 'LTF\\Article');
     $router->bind('article_slug', function ($slug) {
         return Article::findBySlugOrFail($slug);
     });
     $router->model('category', 'LTF\\Category');
     $router->bind('category_slug', function ($slug) {
         return Category::findBySlugOrFail($slug);
     });
     $router->model('language', 'LTF\\Language');
     $router->model('page', 'LTF\\Page');
     $router->bind('page_slug', function ($slug) {
         return Page::findBySlugOrFail($slug);
     });
     $router->model('setting', 'LTF\\Setting');
     $router->model('user', 'LTF\\User');
 }
 /**
  * Get the query object to be processed by datatables.
  *
  * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder
  */
 public function query()
 {
     $categories = Category::with('articles')->whereLanguageId(session('current_lang')->id);
     return $this->applyScopes($categories);
 }
Пример #5
0
 /**
  * Get data, if image column is passed, upload it
  *
  * @param $request
  * @return mixed
  */
 public function getData($request)
 {
     if (!empty($request->image)) {
         $imageColumn = $request->image;
         $imageCategory = strtolower($this->model);
         if ($imageCategory === 'article') {
             $getImageCategory = Category::find($request->category_id);
             $imageCategory = strtolower($getImageCategory->title);
         }
         $data = $request->except($imageColumn);
         if ($request->file($imageColumn)) {
             $file = $request->file($imageColumn);
             $request->file($imageColumn);
             $fileName = rename_file($imageCategory, $file->getClientOriginalExtension());
             $path = '/assets/images/' . str_slug($imageCategory, '-') . '/';
             $move_path = public_path() . $path;
             $file->move($move_path, $fileName);
             Queue::push(ImageResizerJob::class, ['path' => $path, 'filename' => $fileName]);
             $data['image_path'] = $path;
             $data['image_name'] = $fileName;
         }
         return $data;
     }
     return $request->all();
 }