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