本文整理汇总了PHP中app\User::findOrNew方法的典型用法代码示例。如果您正苦于以下问题:PHP User::findOrNew方法的具体用法?PHP User::findOrNew怎么用?PHP User::findOrNew使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\User
的用法示例。
在下文中一共展示了User::findOrNew方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Execute the job.
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handle()
{
// Language.
$language = Language::findOrNew(1);
if (!$language->id) {
$language->id = 1;
$language->name = 'english';
$language->prefix = 'en';
$language->save();
}
// Country.
$country = Country::findOrNew(1);
if (!$country->id) {
$country->id = 1;
$country->name = 'spain';
$country->prefix = 'spa';
$country->save();
}
// User.
$user = User::findOrNew(1);
if (!$user->id) {
$user->id = 1;
$user->name = 'Test';
$user->surname = 'Test';
$user->email = 'test@test.com';
$user->direction = 'this should be called address lol';
$user->birthday = '2000-01-01';
$user->language_id = $language->id;
$user->country_id = $country->id;
$user->save();
}
$created = $user->tasks()->create($this->requestParams);
return response()->json($created);
}
示例2: viewUserProfile
/**
* show users profile
* @param $userId
* @return \Illuminate\View\View
*/
public function viewUserProfile($userId)
{
$userProfile = $this->user->findOrNew($userId);
if (!in_array($userId, $this->organizationManager->getOrganizationUsers($this->org_id))) {
return redirect()->back()->withResponse($this->getNoPrivilegesMessage());
}
return view('admin.viewUserProfile', compact('userProfile'));
}
示例3: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy()
{
$user_id = Route::input('user_id');
//dd('this is dengun');
$user = User::findOrNew($user_id);
$first_name = $user->first_name;
$user->delete();
return \redirect('admin/dashboard/showuser/selectuser')->with('delete', 'user with first name ' . $first_name . ' deleted successfully');
}
示例4: postModificar
public function postModificar(Request $req)
{
$usuario = User::findOrNew($req->get('id', 0));
$usuario->fill($req->all());
if ($req->get('password') != "") {
$usuario->password = $req->get('password');
}
if ($usuario->save()) {
return redirect('usuarios')->with('mensaje', 'Se actualizó el usuario correctamente');
}
return redirect()->back()->withInput()->withErrors($usuario->getErrors());
}
示例5: createOrUpdate
public function createOrUpdate($profile, $token)
{
if (!isset($profile->id)) {
throw new \InvalidArgumentException('There must be an ID field');
}
$user = User::findOrNew($profile->id);
if (is_null($user->id)) {
$user->id = $profile->id;
}
$user = $user->fill(['name' => $profile->name, 'email' => $profile->email, 'picture' => $profile->picture, 'access_token' => $token]);
$user->save();
return $user;
}
示例6: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
if ($request->type == 1) {
$person = \App\Dosen::findOrFail($request->id);
} else {
$person = \App\Mahasiswa::findOrFail($request->id);
}
$user = \App\User::findOrNew($request->id);
$user->id = $request->id;
$user->name = $person->nama;
$user->email = $request->email;
$user->password = bcrypt($request->password);
$user->save();
if ($request->type == '1') {
return redirect('/dosen');
} else {
return redirect('/mahasiswa');
}
}
示例7: postIndex
/**
* Store a newly created resource in storage.
* Or
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function postIndex(Request $request)
{
$usuario = User::findOrNew($request->input('id'));
$usuario->fill($request->all());
$validacion = $usuario->validate();
if ($validacion) {
if ($usuario->save()) {
$usuario->roles()->sync($request->input('roles', []));
if ($request->ajax()) {
return response()->json(['mensaje' => 'Se guardo el usuario correctamente']);
} else {
return redirect('admin/seguridad/usuarios')->with('mensaje', 'Se guardo el usuario correctamente.');
}
} else {
return back()->withInput()->withErrors($usuario->getErrors());
}
} else {
return back()->withInput()->withErrors($usuario->getErrors());
}
}
示例8: getCallback
/**
* 社交登录回调
*/
public function getCallback()
{
$platform = Input::get('platform');
$info = Socialite::driver($platform)->user();
$socialAccount = SocialAccount::whereId($info->id)->wherePlatform($platform)->first();
if (!$socialAccount) {
$socialAccount = SocialAccount::from($info, $platform);
if (Auth::guest()) {
$user = User::create();
$user->nickname = $socialAccount->nickname;
$user->avatar = $socialAccount->avatar;
if ($platform == 'github') {
$user->email = $socialAccount->email;
}
} else {
$user = User::findOrNew(Auth::id());
}
$user->social()->save($socialAccount);
$user->save();
}
Auth::loginUsingId($socialAccount->user_id, true);
return Redirect::to('/');
}
示例9: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
error_log(print_r('UserController.destroy(' . $id . ')', TRUE));
$user = User::findOrFail($id);
$user->delete();
$params = ['title' => 'Deleted User', 'user' => User::findOrNew($id)];
return view('blog.user.destroy', $params);
}
示例10: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$user = User::findOrNew($id);
return view('user.edit', compact('user'));
}
示例11: index
/**
* Get all tasks assigned to the current user.
*
* @return \Symfony\Component\HttpFoundation\Response Returns the tasks list.
*/
public function index()
{
$tasks = User::findOrNew($this->user)->tasks;
return response()->json($tasks);
}
示例12: getAdmin
public function getAdmin(Route $route)
{
$this->administador = User::findOrNew($route->getParameter('administrador'));
}