本文整理汇总了PHP中App\Http\Requests\UserRequest::ajax方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRequest::ajax方法的具体用法?PHP UserRequest::ajax怎么用?PHP UserRequest::ajax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Requests\UserRequest
的用法示例。
在下文中一共展示了UserRequest::ajax方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addUser
public function addUser(Requests\UserRequest $request, User $user)
{
if ($request->ajax()) {
$user->name = $request->name;
$user->email = $request->email;
$user->password = $request->password;
$user->type = $request->type;
$user->save();
}
}
示例2: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(UserRequest $request, User $user)
{
$input = $request->all();
$user->update(['name' => $input['name'], 'password' => bcrypt($input['password'])]);
if ($request->ajax() || $request->wantsJson()) {
return new JsonResponse($user);
}
flash()->success('aggiornato con successo!');
return redirect('users');
}
示例3: update
public function update($id, UserRequest $request)
{
$data = $request->has('password') ? $request->all() : $request->except('password');
$this->user->save($id, $data);
if ($request->ajax()) {
return response()->json(['status' => trans('messages.saved'), 'type' => 'success']);
}
$route = $request->get('task') == 'apply' ? route('admin.users.edit', $id) : route('admin.users.index');
return redirect($route)->with(['status' => trans('messages.saved'), 'type' => 'success']);
}