当前位置: 首页>>代码示例>>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;未经允许,请勿转载。