當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ArticleRequest::has方法代碼示例

本文整理匯總了PHP中App\Http\Requests\ArticleRequest::has方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArticleRequest::has方法的具體用法?PHP ArticleRequest::has怎麽用?PHP ArticleRequest::has使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在App\Http\Requests\ArticleRequest的用法示例。


在下文中一共展示了ArticleRequest::has方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: store

 /**
  * Function for storing a new blog article.
  *
  * @param $request
  * @param ArticleRequest $request
  * @return Redirect
  */
 public function store(ArticleRequest $request)
 {
     if ($request->has('slug')) {
         $request['slug'] = str_slug($request['slug'], "_");
     } else {
         $request['slug'] = str_slug($request['title'], "_");
     }
     $today = Carbon::today()->format('Y') . '/' . Carbon::today()->format('M') . '/' . Carbon::today()->format('d');
     $uploadPath = base_path() . '/public/img/uploads/' . $today;
     $article = Article::create($request->all());
     // TODO: Refine into two seperate actions //
     if (!empty($request['cover-image']) || !empty($request['cover-image'])) {
         $SmallImageName = '/img/uploads/' . $today . '/' . $request['slug'] . '_sml' . '.' . $request->file('listing-image')->getClientOriginalExtension();
         $coverImageName = '/img/uploads/' . $today . '/' . $request['slug'] . '_cover' . '.' . $request->file('cover-image')->getClientOriginalExtension();
         $article['imgfull'] = $coverImageName;
         $article['imgsml'] = $SmallImageName;
     }
     $article['page_code'] = str_random(16);
     $article['author'] = Auth::user()->id;
     $article['category'] = $request['category'];
     // TODO:: Preform a check to see if this Category Exists //
     $article['published'] = Carbon::parse($request['published']);
     // TODO:: Add a time to publish field //
     $article->save();
     if (!empty($request['cover-image']) || !empty($request['cover-image'])) {
         $request->file('listing-image')->move($uploadPath, $SmallImageName);
         $request->file('cover-image')->move($uploadPath, $coverImageName);
     }
     return redirect('blog/' . $request->slug);
 }
開發者ID:JBird608,項目名稱:JoeCurran_Codes,代碼行數:37,代碼來源:BlogController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(ArticleRequest $request)
 {
     $article = Auth::user()->articles()->create($request->all());
     $this->syncTags($article, $request->input('tag_list'));
     if ($request->hasFile('cover')) {
         $this->uploadFile($article, $request->file('cover'));
     }
     if ($request->has('twitter')) {
         $this->tweet($article);
     }
     session()->flash('flash_message', 'Se ha publicado tu artículo');
     return redirect('admin/articles');
 }
開發者ID:realnerdo,項目名稱:blog,代碼行數:19,代碼來源:ArticlesController.php


注:本文中的App\Http\Requests\ArticleRequest::has方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。