本文整理匯總了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("'Новину відредаговано'");
}