當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。