本文整理匯總了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);
}