本文整理汇总了PHP中app\News::fill方法的典型用法代码示例。如果您正苦于以下问题:PHP News::fill方法的具体用法?PHP News::fill怎么用?PHP News::fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\News
的用法示例。
在下文中一共展示了News::fill方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$object = new Model();
$params = $request->only('img', 'ru_title', 'ua_title', 'en_title', 'en_description', 'ua_description', 'ru_description', 'en_text', 'ru_text', 'ua_text', 'ru_seo_keywords', 'en_seo_keywords', 'ua_seo_keywords', 'ru_seo_description', 'en_seo_description', 'ua_seo_description');
$filter = $object->validator($params);
if ($filter->fails()) {
$error = $filter->errors()->toArray();
return view('admin.news.create', ['input' => $params, 'error' => $error]);
}
if ($request->hasFile('img')) {
$params['img'] = $this->upload('img');
}
$object->fill($params);
$object->save();
return redirect('admin/news/' . $object->id);
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$news = new News();
$news->fill($request->all());
$slug = Helpers::makeSlug($request->input('title_geo'), 'news');
if ($slug == "") {
return Redirect::route('admin.index');
}
$news->slug = $slug;
$image = $request->file('image');
$fileName = "";
if ($image->isValid()) {
$path = public_path() . '/uploads/news/';
$fileName = str_random(32) . '.' . $image->getClientOriginalExtension();
$image->move($path, $fileName);
} else {
App::abort(404);
}
$news->image = $fileName;
$news->save();
return Redirect::route('admin.index');
}
示例3: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update(News $news, Request $request)
{
$data = $request->all();
if (!$data['published_at']) {
$data['published_at'] = Carbon::now();
}
$news->fill($data);
$news->save();
return back()->withSuccess("'Новину відредаговано'");
}