當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。