当前位置: 首页>>代码示例>>PHP>>正文


PHP News::findOrFail方法代码示例

本文整理汇总了PHP中News::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP News::findOrFail方法的具体用法?PHP News::findOrFail怎么用?PHP News::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在News的用法示例。


在下文中一共展示了News::findOrFail方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getThumbsDown

 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' => _("Већ сте оценили ову страницу")));
     }
 }
开发者ID:Puskice,项目名称:PuskiceCMS,代码行数:30,代码来源:ApiPageController.php

示例2: show

 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);
 }
开发者ID:hilmysyarif,项目名称:hotel-application-laravel,代码行数:8,代码来源:NewsController.php

示例3: update

 /**
  * 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');
 }
开发者ID:jairoserrano,项目名称:SimpleBlogClase,代码行数:16,代码来源:NewsController.php

示例4: find

 /**
  * @param $id
  * @return mixed
  */
 public function find($id)
 {
     return $this->news->findOrFail($id);
 }
开发者ID:phillipmadsen,项目名称:app,代码行数:8,代码来源:NewsRepository.php

示例5: getDelete

 /**
  * 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');
     }
 }
开发者ID:Puskice,项目名称:PuskiceCMS,代码行数:22,代码来源:NewsController.php

示例6: getCreate

 /**
  * 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');
     }
 }
开发者ID:Puskice,项目名称:PuskiceCMS,代码行数:22,代码来源:CommentController.php

示例7: postCreate

 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' => 'info@puskice.org', '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('info@puskice.org', "Puškice cenzura");
                 $message->to('info@puskice.org', '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'));
     }
 }
开发者ID:Puskice,项目名称:PuskiceCMS,代码行数:57,代码来源:ApiCommentController.php

示例8: postStore

 /**
  * 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');
         }
     }
 }
开发者ID:Puskice,项目名称:PuskiceCMS,代码行数:36,代码来源:FileController.php

示例9: get_newsremove

 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");
 }
开发者ID:A-Lawrence,项目名称:VASOPS,代码行数:7,代码来源:ConsoleController.php


注:本文中的News::findOrFail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。