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


PHP News::findOrFail方法代码示例

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


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

示例1: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $news = News::findOrFail($id);
     $news->delete();
     \Flash::success('Nieuwsartikel verwijderd');
     return redirect('admin/news');
 }
开发者ID:svuvis,项目名称:oshusite,代码行数:13,代码来源:NewsController.php

示例2: update

 public function update($id, CreateNewsRequest $request)
 {
     $news = News::findOrFail($id);
     $news->update($request->all());
     session()->flash('flash_message', 'Je artikel is succesvol aangepast');
     return redirect('news');
 }
开发者ID:jordygroote,项目名称:detoekomstapp,代码行数:7,代码来源:NewsController.php

示例3: update

 /**
  * Update the specified news in storage.
  * @param UpdateNewsRequest|Request $request
  *
  * @param  int  $id
  */
 public function update($id, UpdateNewsRequest $request)
 {
     $news = News::findOrFail($id);
     $request = $this->saveFiles($request);
     $news->update($request->all());
     return redirect()->route('admin.news.index');
 }
开发者ID:AmirHome,项目名称:CMS_20160115,代码行数:13,代码来源:NewsController.php

示例4: show

 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @param Request $request
  * @return Response
  */
 public function show($id, Request $request)
 {
     $news = News::findOrFail($id);
     if ($request->ajax()) {
         return response()->json($news);
     }
     return $news;
 }
开发者ID:jambik,项目名称:sellmecar,代码行数:15,代码来源:NewsController.php

示例5: update

 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['title' => 'required']);
     $item = News::findOrFail($id);
     $item->update($request->all());
     $item->saveImage($item, $request);
     Flash::success("Запись - {$id} обновлена");
     return redirect(route('admin.news.index'));
 }
开发者ID:jambik,项目名称:sellmecar,代码行数:16,代码来源:NewsController.php

示例6: updateNews

 public function updateNews($id, Request $request)
 {
     $news = News::findOrFail($id);
     $this->validate($request, ['title' => 'required', 'content' => 'required']);
     $input = $request->all();
     $news->fill($input)->save();
     Session::flash('flash_message', 'News successfully added!');
     return redirect()->back();
 }
开发者ID:prudywsh,项目名称:tpe,代码行数:9,代码来源:AdminController.php

示例7: getNewsArticle

 /**
  * Get a specific news article
  * @param id
  * @return JSON article
  */
 public function getNewsArticle(Request $request)
 {
     try {
         $path = explode("/", $request->path());
         $id = $path[count($path) - 1];
         $article = \App\News::findOrFail($id);
         return $article->first();
     } catch (ModelNotFoundException $e) {
         return response()->json(['error' => 'invalid_id'], 401);
     }
 }
开发者ID:greenelfx,项目名称:stormcaster,代码行数:16,代码来源:PageController.php

示例8: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     //
     parent::boot($router);
     $router->bind('link', function ($value) {
         return Link::findOrFail($value);
     });
     $router->bind('news', function ($value) {
         //news is name of wildcard
         return News::findOrFail($value);
     });
 }
开发者ID:slifer2015,项目名称:tarabar,代码行数:18,代码来源:RouteServiceProvider.php

示例9: updateData

 /**
  * Helper untuk melakukan Update new Data ke dalam database
  * @param int $id
  */
 private function updateData($id = 0)
 {
     $data = News::findOrFail($id);
     $data->judul = Input::get('judul');
     $data->isi = Input::get('isi');
     $file = Input::file('berita');
     $image_name = time() . "-news-" . $file->getClientOriginalName();
     $file->move(public_path() . '/upload', $image_name);
     $data->image = $image_name;
     $data->save();
     return true;
 }
开发者ID:semmiverian,项目名称:webJok,代码行数:16,代码来源:newsController.php

示例10: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->bind('articles', function ($slug) {
         return \Route::currentRouteName() == "articles.edit" ? \App\Article::findOrFail($slug) : \App\Article::published()->findOrFail($slug);
     });
     $router->bind('news', function ($id) {
         return \Route::currentRouteName() == "news.edit" ? \App\News::findOrFail($id) : \App\News::published()->findOrFail($id);
     });
     $router->bind('tags', function ($name) {
         return \App\Tag::where('name', $name)->firstOrFail();
     });
     $router->bind('users', function ($id) {
         return \App\User::where('id', $id)->firstOrFail();
     });
     $router->bind('messages', function ($id) {
         return \App\Message::where('id', $id)->firstOrFail();
     });
     $router->bind('registrants', function ($id) {
         return \App\Registrant::where('id', $id)->firstOrFail();
     });
     $router->model('image', Image::class);
 }
开发者ID:kobeuu,项目名称:bpb-sf,代码行数:29,代码来源:RouteServiceProvider.php

示例11: update

 /**
  * Update the news item in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update($id, NewsRequest $request)
 {
     $news = News::findOrFail($id);
     $news->update($request->all());
     flash()->success('Your news item has been updated');
     return redirect()->action('NewsController@edit', $news->id);
 }
开发者ID:vowsdesrat,项目名称:laravel,代码行数:14,代码来源:NewsController.php

示例12: delete

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     $news = News::findOrFail($id);
     $news->delete();
     return Redirect::to('admin/newsList');
 }
开发者ID:klokand,项目名称:JulySite,代码行数:12,代码来源:NewsController.php

示例13: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $news = News::findOrFail($id);
     try {
         File::delete(public_path() . '/uploads/news/' . $news->image);
         $news->destroy($id);
     } catch (Exception $e) {
         App::abort(404);
     }
     return Redirect::route('admin.index');
 }
开发者ID:nikajorjika,项目名称:gamoiwere.ge,代码行数:17,代码来源:NewsController.php

示例14: show

 public function show($id)
 {
     $news = News::findOrFail($id);
     return view('news.show')->with('news', $news);
 }
开发者ID:sashacitylight,项目名称:sashasite,代码行数:5,代码来源:NewsController.php

示例15: postDeleteNews

 public function postDeleteNews($id)
 {
     $news = News::findOrFail($id);
     $news->delete(News::all());
     return redirect('nieuws');
 }
开发者ID:omarzoundri,项目名称:outdoorxl-cloud,代码行数:6,代码来源:HomeController.php


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