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


PHP Profile::firstOrCreate方法代码示例

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


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

示例1: getIndex

 public function getIndex()
 {
     $profile = Profile::firstOrCreate(['user_id' => Auth::id()]);
     if ($profile && $profile->isActive == 1) {
         return redirect('/profile/index/' . $profile->id);
     }
     return redirect()->action('HomeController@getGameOver');
     if ($profile->shortLink == "") {
         $profile->user_id = Auth::id();
         $profile->shortLink = shortenUrl($_ENV['BASE_FB_URL'] . 'profile/index/' . $profile->id);
     }
     $profile->save();
     $data = array('selectedPage' => 2);
     return view('register.index', $data);
 }
开发者ID:ElasticOrange,项目名称:canon-orasul-respira-foto,代码行数:15,代码来源:RegistrationController.php

示例2: postRemove

 public function postRemove(Request $request)
 {
     if (!Auth::id()) {
         return response()->json(['message' => 'user not found'], 400);
     }
     $imageId = $request->input("imageId");
     if ($imageId < 1 || $imageId > 5) {
         return response()->json(['message' => 'resource not found'], 400);
     }
     $profile = Profile::firstOrCreate(['user_id' => Auth::id()]);
     $profile->user_id = Auth::id();
     switch ($request->input("imageId")) {
         case 1:
             unlink(public_path() . generatePhotoURL('full', $profile->photo1));
             unlink(public_path() . generatePhotoURL('thumb_80', $profile->photo1));
             unlink(public_path() . generatePhotoURL('thumb_180', $profile->photo1));
             $profile->photo1 = '';
             break;
         case 2:
             unlink(public_path() . generatePhotoURL('full', $profile->photo2));
             unlink(public_path() . generatePhotoURL('thumb_80', $profile->photo2));
             unlink(public_path() . generatePhotoURL('thumb_180', $profile->photo2));
             $profile->photo2 = '';
             break;
         case 3:
             unlink(public_path() . generatePhotoURL('full', $profile->photo3));
             unlink(public_path() . generatePhotoURL('thumb_80', $profile->photo3));
             unlink(public_path() . generatePhotoURL('thumb_180', $profile->photo3));
             $profile->photo3 = '';
             break;
         case 4:
             unlink(public_path() . generatePhotoURL('full', $profile->photo4));
             unlink(public_path() . generatePhotoURL('thumb_80', $profile->photo4));
             unlink(public_path() . generatePhotoURL('thumb_180', $profile->photo4));
             $profile->photo4 = '';
             break;
         case 5:
             unlink(public_path() . generatePhotoURL('full', $profile->photo5));
             unlink(public_path() . generatePhotoURL('thumb_80', $profile->photo5));
             unlink(public_path() . generatePhotoURL('thumb_180', $profile->photo5));
             $profile->photo5 = '';
             break;
     }
     $profile->save();
     //$request->session()->push('uploaded_images', $image->id);
     return response()->json(['message' => 'removed', 'imageId' => $imageId], 201);
 }
开发者ID:ElasticOrange,项目名称:canon-orasul-respira-foto,代码行数:47,代码来源:UploadImageController.php


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