Example #1
1
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $articles = Article::with('author')->orderBy('position', 'DESC')->orderBy('created_at', 'DESC')->limit(4)->get();
     //		TODO: abstract to model
     $sliders = Photo::join('photo_albums', 'photo_albums.id', '=', 'photos.photo_album_id')->where('photos.slider', 1)->orderBy('photos.position', 'DESC')->orderBy('photos.created_at', 'DESC')->select('photos.filename', 'photos.name', 'photos.description', 'photo_albums.folder_id')->get();
     $photoAlbums = PhotoAlbum::select(array('photo_albums.id', 'photo_albums.name', 'photo_albums.description', 'photo_albums.folder_id', DB::raw('(select filename from ' . DB::getTablePrefix() . 'photos WHERE album_cover=TRUE and ' . DB::getTablePrefix() . 'photos.photo_album_id=' . DB::getTablePrefix() . 'photo_albums.id LIMIT 1) AS album_image'), DB::raw('(select filename from ' . DB::getTablePrefix() . 'photos WHERE ' . DB::getTablePrefix() . 'photos.photo_album_id=' . DB::getTablePrefix() . 'photo_albums.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();
     $videoAlbums = VideoAlbum::select(array('video_albums.id', 'video_albums.name', 'video_albums.description', 'video_albums.folder_id', DB::raw('(select youtube from ' . DB::getTablePrefix() . 'videos WHERE album_cover=TRUE and ' . DB::getTablePrefix() . 'videos.video_album_id=' . DB::getTablePrefix() . 'video_albums.id LIMIT 1) AS album_image'), DB::raw('(select youtube from ' . DB::getTablePrefix() . 'videos WHERE ' . DB::getTablePrefix() . 'videos.video_album_id=' . DB::getTablePrefix() . 'video_albums.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();
     $categoriesArray = Object::where('type', 'category')->get();
     $categories = array();
     foreach ($categoriesArray as $category) {
         $categories[] = array($category->title);
     }
     $categories = Object::where('type', 'category')->get();
     global $types;
     $types = Object::getTypes()->select(array('id', DB::raw("REPLACE(name, '_object_type_', '') as name"), DB::raw("REPLACE(title, 'Object Type: ', '') as title"), 'created_at'))->get();
     return view('pages.home', compact('articles', 'sliders', 'videoAlbums', 'photoAlbums', 'categories', 'types'));
     //return view('pages.welcome');
 }
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $articles = Article::with('author')->orderBy('position', 'DESC')->orderBy('created_at', 'DESC')->limit(4)->get();
     $photoAlbums = PhotoAlbum::select(array('photo_albums.id', 'photo_albums.name', 'photo_albums.description', 'photo_albums.folder_id', DB::raw('(select filename from photos WHERE album_cover=TRUE and photos.photo_album_id=photo_albums.id LIMIT 1) AS album_image'), DB::raw('(select filename from photos WHERE photos.photo_album_id=photo_albums.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();
     $videoAlbums = VideoAlbum::select(array('video_albums.id', 'video_albums.name', 'video_albums.description', 'video_albums.folder_id', DB::raw('(select youtube from videos WHERE album_cover=TRUE and videos.video_album_id=video_albums.id LIMIT 1) AS album_image'), DB::raw('(select youtube from videos WHERE videos.video_album_id=video_albums.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();
     return view('pages.home', compact('articles', 'videoAlbums', 'photoAlbums'));
 }
Example #3
0
 public function getArticolo($slug)
 {
     // dettaglio di un singolo articolo
     //$categories = \App\Category::all();
     $article = \App\Article::with('categories', 'user')->where('slug', '=', $slug)->first();
     return view('blog.article', compact('article'));
 }
 /**
  * Get the query object to be processed by datatables.
  *
  * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder
  */
 public function query()
 {
     $articles = Article::with('category')->whereHas('category', function ($q) {
         $q->where('language_id', session('current_lang')->id);
     });
     return $this->applyScopes($articles);
 }
 public function index(Request $request)
 {
     $orderby = $request->orderby ? $request->orderby : 'created_at';
     $articles = Article::with('user')->Orderby($orderby, 'DESC')->simplePaginate(10);
     // $articles = $this->articles->allWithNotActived();
     return view('admin.articles.index', compact('articles', 'orderby'));
 }
Example #6
0
 public function index(Request $request)
 {
     $orderby = $request->orderby ? $request->orderby : 'created_at';
     $title = $request->title ? $request->title : '';
     $articles = Article::with('user')->whereTitle($title)->Orderby($orderby, 'DESC')->simplePaginate(10);
     return view('admin.articles.index', compact('articles', 'orderby', 'title'));
 }
 public function get($id)
 {
     $article = Article::with('tags')->find($id);
     if (!$article) {
         return response()->json(null, 404);
     }
     return response()->json($article);
 }
 protected function recent()
 {
     view()->composer('widgets.recent', function ($view) {
         $view->with('articles', Cache::remember('widgets_recent', 10, function () {
             return Article::with('tags', 'category')->public()->orderby('published_at', 'desc')->take(5)->get();
         }));
     });
 }
 /**
  * Display a listing of the articles.
  *
  * @return Response
  */
 public function index()
 {
     $page_size = env('num_per_page');
     //take: set the limit of the query
     //get: Execute the query as a "select" statement.
     $articles = \App\Article::with('tags', 'category')->published()->orderBy('updated_at', 'desc')->take($page_size)->get();
     return view('blog.index', compact('articles'));
 }
Example #10
0
 public function articleSearcher()
 {
     $modelsList = BrandModel::lists('name', 'id')->prepend('(all)', '');
     $brandsList = Brand::lists('name', 'id')->prepend('(all)', '');
     $partsList = PartType::lists('name', 'id')->prepend('(all)', '');
     $articles = Article::with('articleType', 'brand', 'model', 'partType')->orderBy('name', 'asc')->get();
     return view('backoffice.articles.ArticleSearcher')->with(compact('modelsList'))->with(compact('brandsList'))->with(compact('partsList'))->with(compact('articles'));
 }
 /**
  * Returns a view of all articles in the system
  *
  * @return \Illuminate\View\View
  */
 public function index()
 {
     $articles = array();
     foreach (Article::with('user')->with('template')->get() as $article) {
         array_push($articles, $article);
     }
     //return $articles;
     return view('admin.articles.index', compact('articles'));
 }
Example #12
0
 /**
  * Display the specified resource.
  *
  * @param int $id
  *
  * @return Response
  */
 public function show($slug)
 {
     //$articles = Tag::findBySlug($slug)->articles()->latest('articles.created_at')->paginate(8);
     $page_size = setting('page_size');
     $tag = Tag::findBySlug($slug);
     $articles = \App\Article::with('tags', 'category')->whereHas('tags', function ($query) use($slug) {
         $query->whereSlug($slug);
     })->latest()->paginate($page_size);
     return view('home.tags.show', compact('articles', 'tag'));
 }
Example #13
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $articles = Article::with('author')->orderBy('position', 'DESC')->orderBy('created_at', 'DESC')->limit(4)->get();
     //		TODO: abstract to model
     $sliders = Photo::join('photo_albums', 'photo_albums.id', '=', 'photos.photo_album_id')->where('photos.slider', 1)->orderBy('photos.position', 'DESC')->orderBy('photos.created_at', 'DESC')->select('photos.filename', 'photos.name', 'photos.description', 'photo_albums.folder_id')->get();
     $photoAlbums = PhotoAlbum::select(array('photo_albums.id', 'photo_albums.name', 'photo_albums.description', 'photo_albums.folder_id', DB::raw('(select filename from ' . DB::getTablePrefix() . 'photos WHERE album_cover=TRUE and ' . DB::getTablePrefix() . 'photos.photo_album_id=' . DB::getTablePrefix() . 'photo_albums.id LIMIT 1) AS album_image'), DB::raw('(select filename from ' . DB::getTablePrefix() . 'photos WHERE ' . DB::getTablePrefix() . 'photos.photo_album_id=' . DB::getTablePrefix() . 'photo_albums.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();
     $videoAlbums = VideoAlbum::select(array('video_albums.id', 'video_albums.name', 'video_albums.description', 'video_albums.folder_id', DB::raw('(select youtube from ' . DB::getTablePrefix() . 'videos WHERE album_cover=TRUE and ' . DB::getTablePrefix() . 'videos.video_album_id=' . DB::getTablePrefix() . 'video_albums.id LIMIT 1) AS album_image'), DB::raw('(select youtube from ' . DB::getTablePrefix() . 'videos WHERE ' . DB::getTablePrefix() . 'videos.video_album_id=' . DB::getTablePrefix() . 'video_albums.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();
     return view('pages.home', compact('articles', 'sliders', 'videoAlbums', 'photoAlbums'));
     //return view('pages.welcome');
 }
 public function index()
 {
     $article = Article::with('users')->limit(2)->orderBy('updated_at', 'desc')->get();
     $app = Application::with('users')->paginate(6);
     $ArticleCategory = ArticleCategory::all();
     $AppCategory = AppCategory::all();
     $test = AppCategory::with('applications')->where('name', '=', 'communication')->get();
     dd($test);
     return view('homepage.welcome', compact('article', 'app', 'ArticleCategory', 'AppCategory'));
 }
Example #15
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function share_index($page = '')
 {
     if (Input::get('class')) {
         $lifes = Article::with('cla')->orderBy('created_at', 'DESC')->where('classify', (int) Input::get('class'))->paginate(10)->setPath('share');
     } else {
         $classify = Classify::where('pid', '=', '2')->lists('id');
         $lifes = Article::with('cla')->orderBy('created_at', 'DESC')->whereIn('classify', $classify)->paginate(10)->setPath('share');
     }
     return view('home.life')->withLifes($lifes);
 }
Example #16
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // ------------------------------------------------------------------------------------------------------------
     // GET HEADLINE
     // ------------------------------------------------------------------------------------------------------------
     $headlines = \App\Headline::with('travel_agent')->activeOn(\Carbon\Carbon::now())->orderBy('priority')->get();
     $headlines = $headlines->sortByDesc(function ($data) {
         return $data->travel_agent->active_packages[0]->priority;
     });
     // ------------------------------------------------------------------------------------------------------------
     // GET HOMEGRID
     // ------------------------------------------------------------------------------------------------------------
     $homegrids = \App\HomegridSetting::orderby('name')->get();
     // get upcoming package schedules
     $homegrid_destination_ids = new Collection();
     foreach ($homegrids as $k => $v) {
         if (str_is('destination', $v->type)) {
             $homegrid_destination_ids->push($v->destination);
         }
     }
     if ($homegrid_destination_ids->count()) {
         $homegrid_destinations = \App\Destination::with('tours', 'tours.schedules')->whereIn('id', $homegrid_destination_ids)->get();
         foreach ($homegrids as $k => $v) {
             $homegrids[$k]->destination_detail = $homegrid_destinations->find($v->destination);
         }
     }
     // ------------------------------------------------------------------------------------------------------------
     // QUERY PAKET PROMO TERBARU
     // ------------------------------------------------------------------------------------------------------------
     $tours = \App\Tour::with('destinations', 'schedules', 'destinations.images', 'places', 'places.images', 'travel_agent', 'travel_agent.images', 'images')->has('schedules')->select('tours.*')->join('travel_agencies', 'travel_agencies.id', '=', 'travel_agent_id')->published()->latest('tours.created_at')->limit(8)->groupBy('travel_agent_id')->get();
     // ------------------------------------------------------------------------------------------------------------
     // GET BLOG TERBARU
     // ------------------------------------------------------------------------------------------------------------
     $articles = Article::with('images')->published()->latest('published_at')->take(6)->get();
     // ------------------------------------------------------------------------------------------------------------
     // GET USER
     // ------------------------------------------------------------------------------------------------------------
     $total_subscriber = \App\Subscriber::active()->count();
     $this->info(' ---------------------------------------------------------------------------------------------- ');
     $this->info(' BLAST NEWSLETTER ');
     $this->info(' ---------------------------------------------------------------------------------------------- ');
     $this->info(' * Sending Newsletter to ' . $total_subscriber . ' subscribers');
     \App\Subscriber::with('user')->active()->orderby('id')->chunk(100, function ($subscribers) {
         foreach ($subscribers as $subscriber) {
             Mail::queue('web.v4.emails.newsletters.weekly', ['headlines' => $headlines, 'homegrids' => $homegrids, 'tours' => $tours, 'articles' => $articles, 'subscriber' => $subscriber], function ($m) use($subscriber) {
                 $m->to($subscriber->email, $subscriber->user ? $subscriber->user->name : $subscriber->email)->subject('CAPCUS.id - Newsletter Edisi ' . \Carbon\Carbon::now()->year . '.' . \Carbon\Carbon::now()->format('W'));
             });
             $this->info(' * Newsletter sent to ' . $subscriber->email . ' *');
         }
     });
     $this->info(' ---------------------------------------------------------------------------------------------- ');
     $this->info(' BLAST NEWSLETTER COMPLETED');
     $this->info(' ---------------------------------------------------------------------------------------------- ');
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($slug)
 {
     $page_size = env('num_per_page');
     //        $articles = Tag::findBySlug($slug)->articles()->latest()->paginate($page_size);
     $articles = \App\Article::with('tags', 'category')->published()->whereHas('tags', function ($query) use($slug) {
         $query->whereSlug($slug);
     })->latest()->paginate($page_size);
     $Tag = Tag::whereSlug($slug)->firstOrFail();
     $Tagname = $Tag->name;
     return view('blog.tags.show', compact('articles', 'Tagname'));
 }
Example #18
0
 public function index()
 {
     $modele = Modeles::with('category', 'brand')->get();
     $supp = Supplier::all();
     $articles_modeles = Article::with('theModels.brand', 'theModels.category', 'supplier')->get();
     $leftmenu['model'] = 'active';
     $leftmenu['model_article'] = 'active';
     if (isset($_GET['sel_modele'])) {
         $response = ['leftmenu' => $leftmenu, 'modeles' => $modele, 'article_modele' => $articles_modeles, 'suppliers' => $supp, 'selection' => $_GET['sel_modele']];
     } else {
         $response = ['leftmenu' => $leftmenu, 'modeles' => $modele, 'article_modele' => $articles_modeles, 'suppliers' => $supp];
     }
     return view('/articles/index', $response);
 }
 public function show($slug)
 {
     $article = Article::with('tags')->where('slug', $slug)->first();
     if (!$article) {
         abort(404);
     } else {
         if (\Request::method() == 'GET') {
             return view('front.post', ['article' => $article, 'tags' => $this->tags, 'setting' => $this->setting, 'links' => $this->links]);
         } else {
             //判断密码
             $validator = \Validator::make(\Request::all(), ['password' => 'required|max:255'], [], ['password' => '密码']);
             //为错误信息添加id,防止前台多个密码区域显示错误
             $validator->after(function ($validator) use($article) {
                 if ($validator->errors()->has('password')) {
                     $validator->errors()->add('id', $article->id);
                 }
             });
             if ($validator->fails()) {
                 return redirect()->back()->withErrors($validator->errors());
             }
             $password = \Request::get('password');
             if (strstr($article->password, ',' . $password . ',') > -1) {
                 $ip = \Request::getClientIp();
                 $passed = new Passed();
                 $passed->ip = $ip;
                 $passed->article_id = $article->id;
                 $passed->save();
                 \Session::set('passed_' . $article->id, true);
                 return redirect()->action('IndexController@show', $article->slug);
             } else {
                 $validator->errors()->add('password', '密码不匹配!');
                 $validator->errors()->add('id', $article->id);
                 return redirect()->back()->withErrors($validator->errors());
             }
         }
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  string $slug
  * @return Response
  */
 public function show($slug)
 {
     return view('articles.show', ['article' => Article::with('tags', 'category')->where('slug', $slug)->firstOrFail()]);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $articles = Article::with('tags')->latest()->paginate(10);
     return view('goenitz.article.index', ['articles' => $articles]);
 }
Example #22
0
 /**
  * Remove the specified resource from storage.
  *
  * @param \Illuminate\Http\Request $request
  * @param  int                     $id
  * @return \Illuminate\Http\Response
  * @throws \Exception
  */
 public function destroy(Request $request, $id)
 {
     $article = Article::with('attachments', 'comments')->findOrFail($id);
     foreach ($article->attachments as $attachment) {
         \File::delete(attachment_path($attachment->name));
     }
     $article->attachments()->delete();
     $article->comments->each(function ($comment) {
         app(\App\Http\Controllers\CommentsController::class)->recursiveDestroy($comment);
     });
     $article->delete();
     event(new ModelChanged('articles'));
     if ($request->ajax()) {
         return response()->json('', 204);
     }
     flash()->success(trans('forum.deleted'));
     return redirect(route('articles.index'));
 }
Example #23
0
 public function forUser($user_id)
 {
     return Article::with('user')->where('user_id', $user_id)->latest()->simplePaginate(10);
 }
 /**
  * @param $categoryId
  * @param int $limit
  * @return mixed
  */
 public function articlesForCategory($categoryId, $limit = 3)
 {
     $query = Article::with('images', 'categories')->category($categoryId)->latestPublished()->{$this->scope}();
     return $query->paginate($limit);
 }
Example #25
0
 public function showArticle($articleid)
 {
     $article = Article::with('pictures')->findOrFail($articleid);
     return view('online_shop.Article.item')->with(compact('article'));
 }
 public function getDownloadPDF()
 {
     $limit = \Input::get('limit') ?: 7;
     $articles = Article::with('user')->paginate($limit);
     $pdf = PDF::loadView('articles', compact('articles'));
     //$pdf = PDF::loadHTML('<h1>Test</h1>');
     //dd($pdf);
     return $pdf->download('download.pdf');
 }
Example #27
-1
 public function show($year, $month, $slug)
 {
     // ------------------------------------------------------------------------------------------------------------
     // QUERY ARTICLE DETAIL
     // ------------------------------------------------------------------------------------------------------------
     $article = Cache::remember('blog_with_slug_' . $slug, 30, function () use($slug) {
         return Article::with('images', 'destinations')->slugIs($slug)->published()->first();
     });
     if (!$article || $article->published_at->year != $year * 1 || $article->published_at->month != $month * 1) {
         return App::abort(404);
     }
     // ------------------------------------------------------------------------------------------------------------
     // QUERY RELATED ARTICLES
     // ------------------------------------------------------------------------------------------------------------
     $destinations = $article->destinations;
     $related_articles = Cache::remember('related_article_by_slug' . $slug, 30, function () use($article, $destinations) {
         $related_articles = Article::InDestinationByIds($destinations->lists('id')->toArray())->where('id', '!=', $article->id)->published()->latest('published_at')->limit(6)->get();
         if (!$related_articles->count()) {
             $related_articles = Article::latest('published_at')->where('id', '!=', $article->id)->limit(6)->get();
         }
         return $related_articles;
     });
     // ------------------------------------------------------------------------------------------------------------
     // QUERY RELATED TOUR
     // ------------------------------------------------------------------------------------------------------------
     // $tours = Tour::scheduledBetween(\Carbon\Carbon::now(), \Carbon\Carbon::now()->addYear(1))
     // 				->latest('published_at')
     // 				->take(5)
     // 				->get();
     // ------------------------------------------------------------------------------------------------------------
     // SHOW DISPLAY
     // ------------------------------------------------------------------------------------------------------------
     $this->layout->page = view($this->page_base_dir . 'blog_detail');
     $this->layout->page->article = $article;
     $this->layout->page->related_articles = $related_articles;
     $this->layout->page->latest_tours = $this->get_latest_tours();
     $this->layout->page->top_destinations = $this->get_top_destinations();
     $this->layout->title = $article->title . ' - Capcus.id';
     $this->layout->og['title'] = $this->layout->title;
     $this->layout->og['type'] = 'article';
     $this->layout->og['image'] = $article->images->where('name', 'LargeImage')->first()->path;
     $this->layout->og['image:type'] = pathinfo('images/' . $this->layout->og['image'], PATHINFO_EXTENSION);
     $this->layout->og['image:width'] = 600;
     $this->layout->og['image:height'] = 400;
     $this->layout->og['article:published_at'] = $article->published_at->format('Y-m-d H:i:s');
     return $this->layout;
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $articles = Article::with(['user', 'category', 'comments', 'views', 'stars']);
     $sort = Request::get('sort');
     if ($sort == 'most-commented') {
         $articles = $articles->mostCommented();
     } elseif ($sort == 'most-viewed') {
         $articles = $articles->mostViewed();
     } elseif ($sort == 'most-starred') {
         $articles = $articles->mostStarred();
     } else {
         $sort = '';
         $articles = $articles->recent();
     }
     if ($category_id = Request::get('cat')) {
         $articles->filterBy(['category_id' => $category_id]);
     }
     $articles = $articles->paginate(Config::get('frontend.articles_per_page'));
     return view('articles.index', compact('articles'));
 }
 public function index($slug)
 {
     $category = Category::where('slug', $slug)->firstOrFail();
     $articles = Article::with('tags', 'category')->where('category_id', $category->id)->public()->latest('published_at')->simplePaginate(setting_value('paginate_size'));
     return view('categories', ['category' => $category, 'articles' => $articles]);
 }
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function show($slug)
 {
     $page_size = env('num_per_page');
     //        //method I.               num of queries:  17.
     //        $articles = Category::findBySlug($slug)->articles()->latest()->paginate($page_size);
     //method II: eager loading. num of queries 5
     //http://php.net/manual/en/functions.anonymous.php   "use" to inherit variables from its parent scope
     //whereSlug($slug) equals to where('slug', '=', $slug).
     $articles = \App\Article::with('tags', 'category')->published()->whereHas('category', function ($query) use($slug) {
         $query->whereSlug($slug);
     })->latest()->paginate($page_size);
     $Catname = Category::whereSlug($slug)->firstOrFail()->name;
     return view('blog.cats.show', compact('articles', 'Catname'));
 }