本文整理匯總了PHP中App\Http\Requests\ArticleRequest::user方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArticleRequest::user方法的具體用法?PHP ArticleRequest::user怎麽用?PHP ArticleRequest::user使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類App\Http\Requests\ArticleRequest
的用法示例。
在下文中一共展示了ArticleRequest::user方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: store
public function store(ArticleRequest $request)
{
$article = new Article($request->except('images'));
$article->user_id = $request->user()->id;
$article->save();
$files = Input::file('images');
$uploads = '/uploads/';
$path = public_path() . $uploads;
foreach ($files as $file) {
if (empty($file)) {
continue;
}
$fileName = $file->getClientOriginalName();
$file->move($path, $fileName);
(new Image(['image' => $uploads . $fileName, 'article_id' => $article->id]))->save();
}
return redirect('articles');
}
示例2: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(ArticleRequest $request, Article $article)
{
//if($this->authorize('edit-article', $article))
if ($request->user()->cannot('edit', $article)) {
return redirect('article');
}
//$article = Article::findOrFail($id);
$article->update($request->all());
//$article->tags()->sync($request->input('tag_list'));
$this->syncTags($article, $request->input('tag_list'));
return redirect('article');
}