public function getThumbsDown($id) { try { $valid_ip = Thumb::where('ip', '=', Puskice::getIP())->where('object_type', '=', 5)->where('object_id', '=', $id)->first(); if ($valid_ip != null) { throw new Exception("Error valid IP", 1); } $news = News::findOrFail($id); $news->thumbs_down++; $news->save(); $thumb = new Thumb(); $thumb->ip = Puskice::getIP(); $thumb->object_id = $news->id; $thumb->object_type = 5; $thumb->save(); $thumbs = array(); if (Cookie::get('ps_thumbs')) { $cookie = Cookie::get('ps_thumbs'); $thumbs = unserialize($cookie); if (isset($thumbs['page'][$news->id])) { return Response::json(array('status' => 'fail', 'message' => __("Већ сте оценили ову вест"))); } } $thumbs['page'][$news->id] = 'down'; Cookie::queue('ps_thumbs', serialize($thumbs), 2628000); return Response::json(array('status' => 'success', 'message' => _("Ваш глас је забележен. Хвала на труду"), 'thumbsUp' => $news->thumbs_up, 'thumbsDown' => $news->thumbs_down)); } catch (Exception $e) { return Response::json(array('status' => 'fail', 'message' => _("Већ сте оценили ову страницу"))); } }
public function show($id) { $news = News::findOrFail($id); $data['room'] = Rooms::select('roomtype.RoomType_Name', 'roomtype.ID_RoomType', 'roomtype_pic.Picture')->join('roomtype_pic', 'roomtype.ID_RoomType', '=', 'roomtype_pic.ID_RoomType')->where('roomtype_pic.Main_Pic', '=', 'YES')->where('roomtype.Status', '=', 'Active')->take(40)->get()->all(); $data['offer'] = Offer::where('Status', '=', 'Active')->take(40)->get()->all(); $data['about'] = About::get()->all(); return View::make('News.show', compact('news'))->with('news_active', 'active')->with('data', $data); }
/** * Update the specified news in storage. * * @param int $id * @return Response */ public function update($id) { $news = News::findOrFail($id); $validator = Validator::make($data = Input::all(), News::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $news->update($data); return Redirect::route('news.index'); }
/** * @param $id * @return mixed */ public function find($id) { return $this->news->findOrFail($id); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function getDelete($id) { if (Session::get('user_level') < Config::get('cms.deleteNews')) { return Redirect::to(_l(URL::action('AdminHomeController@getIndex')))->with('message', Lang::get('admin.notPermitted'))->with('notif', 'warning'); } try { $news = News::findOrFail($id); $news->comments()->delete(); $news->subjects()->delete(); $news->files()->delete(); $news->delete(); return Redirect::to(_l(URL::action('NewsController@getIndex')))->with('message', Lang::get('admin.newsDeleted'))->with('notif', 'success'); } catch (Exception $e) { return Redirect::to(_l(URL::action('NewsController@getIndex')))->with('message', Lang::get('admin.noSuchNews'))->with('notif', 'danger'); } }
/** * Show the form for creating a new resource. * * @return Response */ public function getCreate($id) { if (Session::get('user_level') < Config::get('cms.editComments')) { return Redirect::to(_l(URL::action('AdminHomeController@getIndex')))->with('message', Lang::get('admin.notPermitted'))->with('notif', 'warning'); } try { $_SESSION['RF']['subfolder'] = 'images/'; $news = News::findOrFail($id); $this->setLayout(); View::share('title', Lang::get('admin.newComment') . ": " . dots($news->title, 60)); View::share('news', $news); View::share('id', $id); $this->layout->content = View::make('backend.comments.create'); } catch (Exception $e) { return Redirect::to(_l(URL::action('CommentController@getIndex')))->with('message', Lang::get('admin.noSuchComment'))->with('notif', 'danger'); } }
public function postCreate($id) { try { $this->googleAnalytics('/comments/create/' . $id); $comment = new Comment(); $news = News::findOrFail($id); if (Input::get('createdAt')) { $comment->created_at = date("Y-m-d H:i:s", strtotime(Input::get('createdAt'))); } else { $comment->created_at = date("Y-m-d H:i:s", strtotime('now')); } $comment->comment_content = Input::get('commentContent'); $akismet = new Akismet('http://www.puskice.org/', '5fa6e0236f7b'); $akismet->setCommentAuthor($comment->username); $akismet->setCommentAuthorEmail($comment->email); $akismet->setCommentAuthorURL(""); $akismet->setCommentContent($comment->comment_content); $akismet->setPermalink('http://www.puskice.org/vest/' . Puskice::dateToUrl($news->created_at) . '/' . $news->permalink); if ($akismet->isCommentSpam()) { $comment->deleted_at = date('Y-m-d H:i:s', strtotime('now')); } if (Input::get('user_id')) { $comment->published = 1; } else { $comment->published = 0; } if (Input::get('user_id')) { $user = User::find(Input::get('user_id')); $comment->username = $user->username; $comment->email = $user->email; } else { $comment->username = Input::get('username'); $comment->email = Input::get('email'); } if (Input::get('user_id')) { $comment->user_id = Input::get('user_id'); } else { $comment->user_id = 0; } $comment->news_id = $id; $comment->ip_address = Puskice::getIP(); $comment->save(); if ($comment->deleted_at == null) { $user = array('email' => '*****@*****.**', 'name' => 'Info tim'); // the data that will be passed into the mail view blade template $data = array('url' => "http://www.puskice.org/" . Config::get('settings.admin_url') . "/comments/edit/" . $comment->id, 'approve_url' => "http://www.puskice.org/" . Config::get('settings.admin_url') . "/comments/publish/" . $comment->id, 'delete_url' => "http://www.puskice.org/" . Config::get('settings.admin_url') . "/comments/trash/" . $comment->id, 'username' => $comment->username, 'email' => $comment->email, 'title' => $news->title, 'news' => 1, 'news_id' => $news->id, 'content' => $comment->comment_content); // use Mail::send function to send email passing the data and using the $user variable in the closure Mail::send('emails.new_comment', $data, function ($message) use($user) { $message->from('*****@*****.**', "Puškice cenzura"); $message->to('*****@*****.**', 'Info tim Puškice')->subject('Novi komentar čeka moderaciju'); }); } return Response::json(array('status' => 'success', 'message' => __("Ваш коментар је успешно прослеђен"))); } catch (Exception $e) { return Response::json(array('status' => 'fail')); } }
/** * Store a newly created resource in storage. * * @return Response */ public function postStore() { if (Session::get('user_level') < Config::get('cms.addFile')) { return Redirect::to(_l(URL::action('AdminHomeController@getIndex')))->with('message', Lang::get('admin.notPermitted'))->with('notif', 'warning'); } $rules = array('description' => 'Required', 'url' => 'Required', 'title' => 'Required'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to(_l(URL::action('FileController@getCreate') . '/' . Input::get('newsId')))->withErrors($validator)->withInput(); } else { try { $news = News::findOrFail(Input::get('newsId')); $file = new Files(); if (Input::get('createdAt')) { $file->created_at = date("Y-m-d H:i:s", strtotime(Input::get('createdAt'))); } else { $file->created_at = date("Y-m-d H:i:s", strtotime('now')); } $file->description = Input::get('description'); $file->published = Input::get('published'); $file->user_id = Session::get('id'); $file->url = Input::get('url'); $file->news_id = Input::get('newsId'); $file->title = Input::get('title'); $file->save(); return Redirect::to(_l(URL::action('FileController@getEdit') . "/" . $file->id))->with('message', Lang::get('admin.fileSaved'))->with('notif', 'success'); } catch (Exception $e) { return Redirect::to(_l(URL::action('FileController@getIndex')))->with('message', Lang::get('admin.noSuchFile'))->with('notif', 'danger'); } } }
public function get_newsremove($id) { $news = News::findOrFail($id); //This should be easy... $news->delete(); return Redirect::route('consolenews')->with("message", "The news item was successfully removed and is subsequently no longer visible"); }