当前位置: 首页>>代码示例>>PHP>>正文


PHP Address::retrieveOrCreate方法代码示例

本文整理汇总了PHP中app\Address::retrieveOrCreate方法的典型用法代码示例。如果您正苦于以下问题:PHP Address::retrieveOrCreate方法的具体用法?PHP Address::retrieveOrCreate怎么用?PHP Address::retrieveOrCreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Address的用法示例。


在下文中一共展示了Address::retrieveOrCreate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validateAndSaveConsumer

 private function validateAndSaveConsumer(Request $request, Consumer $consumer)
 {
     $this->validate($request, array_merge(['first_name' => 'required', 'last_name' => 'required', 'description' => 'required'], Address::rules()));
     // TODO: check to see if logged in user is a caregiver for this consumer
     $consumer->first_name = $request->first_name;
     $consumer->last_name = $request->last_name;
     $consumer->description = $request->description;
     $consumer->address_id = Address::retrieveOrCreate(['street' => $request->street, 'city' => $request->city, 'state' => $request->state, 'zip1' => $request->zip1])->id;
     $consumer->save();
     return Redirect::to('/caregiver');
 }
开发者ID:kevjava,项目名称:Safe-Assist,代码行数:11,代码来源:ConsumerController.php

示例2: postUpdate

 /**
  * update the given user's profile info.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postUpdate(Request $request)
 {
     $this->validate($request, ['id' => 'required|exists:users']);
     $user = User::find($request->id);
     $user->email = $request->email;
     $this->validate($request, array_merge(['id' => 'required|exists:users', 'email' => 'email|max:255' . ($user->isDirty('email') ? '|unique:users,email' : '')], Address::rules()));
     if (Auth::user()->id != $request->id && !Auth::user()->administrator) {
         //todo: access denied (handle w/ middleware instead of controller?)
     } else {
         $user->first_name = $request->first_name;
         $user->last_name = $request->last_name;
         $user->address_id = Address::retrieveOrCreate(['street' => $request->street, 'city' => $request->city, 'state' => $request->state, 'zip1' => $request->zip1])->id;
         $user->save();
         return Redirect::to('/profile/' . $request->id);
     }
 }
开发者ID:kevjava,项目名称:Safe-Assist,代码行数:22,代码来源:UserController.php

示例3: create

 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $address = Address::retrieveOrCreate(['street' => $data['street'], 'city' => $data['city'], 'state' => $data['state'], 'zip1' => $data['zip1']]);
     return User::create(['address_id' => $address->id, 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
 }
开发者ID:kevjava,项目名称:Safe-Assist,代码行数:11,代码来源:AuthController.php


注:本文中的app\Address::retrieveOrCreate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。