本文整理汇总了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);
}
示例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);
}