本文整理汇总了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');
}
示例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'));
}
示例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');
}
示例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');
}
示例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('/');
}
示例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');
}
示例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');
}