public function showChildSlug($slug, $childSlug)
 {
     $type = TypeNew::findBySlug($slug);
     $typeName = $type->name;
     $data = AdminNew::findBySlug($childSlug);
     $related = AdminNew::where('type_new_id', $data->type_new_id)->whereNotIn('id', [$data->id])->orderBy('id', 'desc')->limit(PAGINATE_RELATED)->get();
     return View::make('site.news.showNews')->with(compact('data', 'related', 'typeName', 'slug'));
 }
Exemple #2
0
 public static function getLatestNews()
 {
     if (Cache::has('newsLatest')) {
         $news = Cache::get('newsLatest');
     } else {
         $now = Carbon\Carbon::now();
         $news = AdminNew::where('start_date', '<=', $now)->orderBy('start_date', 'desc')->first();
         Cache::put('newsLatest', $news, CACHETIME);
     }
     if ($news) {
         return $news;
     } else {
         return null;
     }
 }
Exemple #3
0
 public static function searchNews($input)
 {
     $data = AdminNew::where(function ($query) use($input) {
         if ($input['type_new_id'] != 0) {
             $query = $query->where('type_new_id', $input['type_new_id']);
         }
         if ($input['name']) {
             $query = $query->where('name', 'like', '%' . $input['name'] . '%');
         }
         // if($input['start_date'] != ''){
         // 	$query = $query->where('start_date', '>=', $input['start_date']);
         // }
         // if($input['end_date'] != ''){
         // 	$query = $query->where('start_date', '<=', $input['end_date']);
         // }
     })->orderBy('id', 'desc')->paginate(PAGINATE);
     return $data;
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($slug)
 {
     $inputNew = AdminNew::findBySlug($slug);
     $inputRelated = AdminNew::where('type_new_id', $inputNew->type_new_id)->whereNotIn('id', [$inputNew->id])->where('start_date', '<=', Carbon\Carbon::now())->orderBy('id', 'desc')->limit(PAGINATE_RELATED)->get();
     return View::make('site.news.showNews')->with(compact('inputNew', 'inputRelated'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $new = AdminNew::where('type_new_id', $id)->first();
     if ($new) {
         AdminNew::where('type_new_id', $id)->delete();
     }
     Common::deleteLanguage($id, 'TypeNew');
     return Redirect::action('NewsTypeController@index');
 }
Exemple #6
0
 public static function getNewUrlSiteMap()
 {
     $now = Carbon\Carbon::now();
     $news = AdminNew::where('start_date', '<=', $now)->orderBy('start_date', 'desc')->get();
     return $news;
 }