Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

dont insert duplicate data in laravel

$harmFlag = HarmFlag::firstOrNew(['post_id' => $postId, 'harm_id' => $harm_id]);
$harmFlag->gif_flag = $gif_flag;
$harmFlag->save();
or

$harmFlag = HarmFlag::updateOrCreate(['post_id' => $postId, 'harm_id' => $harm_id]);
$harmFlag->gif_flag = $gif_flag;
$harmFlag->save();
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #dont #insert #duplicate #data #laravel
ADD COMMENT
Topic
Name
7+7 =