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


PHP Profile::firstOrNew方法代码示例

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


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

示例1: store

 /**
  * Store a newly created profile in storage.
  *
  * @return Response
  */
 public function store(CreateProfileRequest $request)
 {
     $profile = Profile::firstOrNew(['user_id' => \Auth::id()]);
     if ($request->id) {
         $placeliving = Place::where('id', '=', $request->id)->first();
         if (!$placeliving) {
             $placeliving = new Place($request->only(['id', 'place_lat', 'place_lng', 'country', 'state', 'city']));
             $placeliving->save();
         }
         $profile->place_living_id = $request->id;
     }
     if ($request->id2) {
         $placefrom = Place::where('id', '=', $request->id2)->first();
         if (!$placefrom) {
             $placefrom = new Place();
             $placefrom->id = $request->id2;
             $placefrom->place_lat = $request->place_lat2;
             $placefrom->place_lng = $request->place_lng2;
             $placefrom->country = $request->country2;
             $placefrom->state = $request->state2;
             $placefrom->city = $request->city2;
             $placefrom->save();
         }
         $profile->place_from_id = $request->id2;
     }
     if ($request->about) {
         $profile->about = $request->about;
     }
     if ($request->occupation) {
         $profile->occupation = $request->occupation;
     }
     if ($request->studies) {
         $profile->studies = $request->studies;
     }
     if ($request->transport) {
         $profile->transport = $request->transport;
     }
     $profile->save();
     \Session::flash('message', 'Profile updated successfully');
     return redirect()->route('index');
 }
开发者ID:charlieboo,项目名称:creatrip,代码行数:46,代码来源:ProfileController.php

示例2: normalize

 /**
  * @param $reviewData
  * @return \App\Review
  */
 public static function normalize(&$reviewData)
 {
     $review = ReviewModel::firstOrNew(['external_id' => $reviewData['id']]);
     $review->external_id = $reviewData['id'];
     $review->text = $reviewData['text'];
     $review->date = Carbon::createFromTimestamp($reviewData['date']);
     $profileData = $reviewData['profile'];
     $profile = ProfileModel::firstOrNew(['external_id' => $reviewData['profile']['uid']]);
     $profile->first_name = $profileData['first_name'];
     $profile->last_name = $profileData['last_name'];
     $profile->domain = $profileData['domain'];
     if (isset($profileData['photo_200_orig'])) {
         $profile->photo = $profileData['photo_200_orig'];
     }
     if (isset($profileData['photo_400_orig'])) {
         $profile->photo_big = $profileData['photo_400_orig'];
     }
     $profile->save();
     $profile->reviews()->save($review);
     return $review;
 }
开发者ID:stcoder,项目名称:uf-vova,代码行数:25,代码来源:Review.php


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