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


PHP ArticleRequest::hasFile方法代码示例

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


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

示例1: 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

示例2: update

 /**
  * Cập nhật bài viết
  *
  * @param  Article  $article
  * @return Response
  */
 public function update(Article $article, ArticleRequest $request, ImageInterface $image)
 {
     $data = $request->all();
     if ($request->hasFile('image')) {
         // Trước hết cần xóa các file ảnh cũ nếu có
         if ($article->image) {
             \File::delete(public_path(config("image.paths") . 'articles/large' . $article->image));
             \File::delete(public_path(config("image.paths") . 'articles/medium' . $article->image));
             \File::delete(public_path(config("image.paths") . 'articles/small' . $article->image));
         }
         $image->init($request, 'articles')->save('large')->save('medium')->save('small');
         $data = array_replace($data, ['image' => $image->name]);
     }
     $article->update($data);
     $article->syncTags($request->input('tag_list', []));
     return redirect('admin/article')->with('flash_message', config('blog.message.updated'));
 }
开发者ID:khanhpnk,项目名称:hocvet,代码行数:23,代码来源:ArticleController.php

示例3: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(ArticleRequest $request, $id)
 {
     $article = Article::find($id);
     //Check fileImage
     if ($request->hasFile('image')) {
         $image = $request->file('image');
         $imagename = time() . '-' . $image->getClientOriginalName();
         $image->move(public_path() . '/image', $imagename);
     } else {
         $imagename = $article->image;
     }
     //Status
     if ($request->Input('status') == false) {
         $status = 0;
     } else {
         $status = 1;
     }
     //data
     $data = ['name' => $request->get('name'), 'summary' => $request->get('summary'), 'content' => $request->get('content'), 'image' => $imagename, 'status' => $status];
     //update
     //dd($data);
     $article->update($data);
     return redirect()->route('article.index');
 }
开发者ID:hoangvu2015,项目名称:laravel_totnghiep,代码行数:30,代码来源:ArticleController.php

示例4: update

 /**
  * update an existing article
  *
  * @param  integer $id
  * @param  ArticleRequest $request
  * @return Response
  */
 public function update(Article $article, ArticleRequest $request)
 {
     $article->update($request->except('image'));
     $article->slug = str_slug($request->title, '-');
     if ($request->hasFile('image')) {
         $file = $request->file('image');
         $filename = $file->getClientOriginalName();
         $extension = $file->getClientOriginalExtension();
         $image = sha1($filename . time()) . '.' . $extension;
         $destinationPath = public_path('/uploads/images/');
         $request->file('image')->move($destinationPath, $image);
         $article->image = $image;
     }
     $article->update();
     $this->syncTags($article, $request->input('tag_list'));
     flash()->info('Artikel telah diperbarui!');
     return redirect('/dashboard/articles');
 }
开发者ID:kobeuu,项目名称:bpb-sf,代码行数:25,代码来源:ArticlesController.php

示例5: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(ArticleRequest $request, $id)
 {
     $article = Article::find($id);
     if ($request->hasFile('image')) {
         $path = base_path() . '/public/images';
         $file = $request->input('image');
         // $file->fit(120,90);
         $fileName = $request->file('image')->getClientOriginalName();
         $request->file('image')->move($path, $fileName);
         $article->image = $fileName;
     }
     $article->update($request->all());
     for ($i = 0; $i < sizeof($request->input('dealname')); $i++) {
         $deal = $article->deals()->where('dayID', $i + 1)->first();
         $deal->dealname = $request->input('dealname')[$i];
         $deal->save();
     }
     // TO UPDATE CATEGORIES
     $categoriesId = $request->input('categoryList');
     $article->categories()->sync($categoriesId);
     $daysId = $request->input('dayList');
     $article->days()->sync($daysId);
     return redirect('/');
 }
开发者ID:lakemck,项目名称:gethappy,代码行数:31,代码来源:ArticlesController.php

示例6: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, ArticleRequest $request)
 {
     $article = Article::findOrFail($id);
     $article->update($request->all());
     // update image
     if ($request->hasFile('image')) {
         $image_filename = $request->file('image')->getClientOriginalName();
         $image_name = date("Ymd-His-") . $image_filename;
         $public_path = 'images/articles/';
         $destination = base_path() . $public_path;
         $request->file('image')->move($destination, $image_name);
         $article->image = $public_path . $image_name;
         $article->save();
     }
     $tagsId = $request->input('tag_list');
     if (!empty($tagsId)) {
         /* select */
         $article->tags()->sync($tagsId);
     } else {
         /* Not select */
         $article->tags()->detach();
     }
     session()->flash('flash_message', 'Edit completed');
     return redirect('articles');
 }
开发者ID:tiscomsci29,项目名称:Laravel_2,代码行数:31,代码来源:ArticleController.php

示例7: update

 public function update($id, ArticleRequest $request)
 {
     $request_data = $request->all();
     $article = Auth::user()->articles()->findOrFail($id);
     if ($request->hasFile('image_file')) {
         $image_file = $request_data['image_file'];
         unset($request_data['image_file']);
         $path = storage_path("app/articles/" . $article->id . "/");
         $request_data['image_name'] = $this->generateImageName($image_file->getClientOriginalExtension());
         $request_data['mime_type'] = $image_file->getClientMimeType();
         $this->saveImage($path, $image_file, $request_data['image_name']);
     }
     //$article = Article::findOrFail($id);
     $article->update($request_data);
     return redirect('articles');
 }
开发者ID:jjmmarquez,项目名称:SCCAlumniPortal,代码行数:16,代码来源:ArticlesController.php


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