當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Location::firstOrNew方法代碼示例

本文整理匯總了PHP中app\Location::firstOrNew方法的典型用法代碼示例。如果您正苦於以下問題:PHP Location::firstOrNew方法的具體用法?PHP Location::firstOrNew怎麽用?PHP Location::firstOrNew使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Location的用法示例。


在下文中一共展示了Location::firstOrNew方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: storeReferee

 public function storeReferee($data, $season, $type, $country)
 {
     $location = Location::firstOrNew(['name' => $data['location'], 'country_id' => $country->id]);
     if ($country->locations()->where(['id' => $location->id])->get()->count() == 0) {
         $country->locations()->save($location);
     }
     $ref = Person::firstOrNew(['first_name' => $data['name'], 'last_name' => $data['lname'], 'location_id' => $location->id]);
     $ref->parent_league = $data['league'];
     $ref->save();
     if ($this->referees()->where('id', '=', $ref->id)->wherePivot('season_id', '=', $season->id)->wherePivot('type', '=', $type)->get()->count() == 0) {
         $this->referees()->attach($ref->id, ['pair_number' => $data['pivot']['pair_number'], 'season_id' => $season->id, 'type' => $type]);
     }
     if ($data['pivot']['pair_number'] != null) {
         $pair = $this->storePair($ref->id, $data['pivot']['pair_number'], $season->id, 1);
         $pair->active = 1;
         $pair->save();
     }
     return $ref;
 }
開發者ID:dinocata,項目名稱:Delegiranje,代碼行數:19,代碼來源:Competition.php

示例2: saveLocation

 /**
  * @param $data
  */
 public function saveLocation($data)
 {
     $location = Location::firstOrNew(['add1' => $data['add1'], 'city' => $data['city'], 'county' => $data['county'], 'postcode' => $data['postcode']]);
     $location->add2 = $data['add2'];
 }
開發者ID:bencarter78,項目名稱:ptbx,代碼行數:8,代碼來源:VacancyParser.php

示例3: create

 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $country = Country::firstOrNew(['name' => $data['country']]);
     $country->save();
     $location = Location::firstOrNew(['name' => $data['location'], 'country_id' => $country->id]);
     if ($country->locations()->where(['id' => $location->id])->get()->count() == 0) {
         $country->locations()->save($location);
     }
     $person = Person::firstOrNew(['first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'location_id' => $location->id]);
     if ($location->person()->where(['id' => $person->id])->get()->count() == 0) {
         $location->person()->save($person);
     }
     return User::create(['person_id' => $person->id, 'email' => $data['email'], 'password' => bcrypt($data['password']), 'type' => 'member']);
 }
開發者ID:dinocata,項目名稱:Delegiranje,代碼行數:20,代碼來源:AuthController.php


注:本文中的app\Location::firstOrNew方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。