Skip to content

Instantly share code, notes, and snippets.

@syossan27
Created January 17, 2015 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syossan27/46596bfd15c0f6c4d8f6 to your computer and use it in GitHub Desktop.
Save syossan27/46596bfd15c0f6c4d8f6 to your computer and use it in GitHub Desktop.
if ( count(User::firstByAttributes('id', '=', '1')) == 0 ) {
// 新規作成処理
$user = new User;
$user['hoge'] = 1;
$user->save();
} else {
// アップデート処理
User::where('id', '=', '1')->update(['hoge' => 1]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment