本文整理汇总了PHP中app\Company::fill方法的典型用法代码示例。如果您正苦于以下问题:PHP Company::fill方法的具体用法?PHP Company::fill怎么用?PHP Company::fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Company
的用法示例。
在下文中一共展示了Company::fill方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$this->middleware('isMember');
$a = new Company();
if (!$a->validate(Input::all())) {
return redirect('company/create')->withErrors($a->errors())->withInput();
}
$a->fill(Input::all());
$a->save();
Flash::success('New company is created');
return Redirect::to('company');
}
示例2: store
public function store(Request $request)
{
$data = $request->all();
$company = new Company();
$validator = Validator::make($data, ['name' => 'required|max:100', 'email' => 'required|email|unique:companies', 'password' => 'required']);
if ($validator->fails()) {
return response()->json(['message' => 'Validation Failed', 'errors' => $validator->errors()->all()], 422);
}
$company->fill($data);
$password = $request->only('password')["password"];
$company->password = Hash::make($password);
$company->save();
return response()->json($company, 201);
}