jeudi 19 mai 2016

Bulk Insert or Update Laravel Eloquent without Foreach Loop

Data structure is as follows:

referral_statistics

id | registered_user_id | date | promoter_ref_revenue | writer_ref_revenue

Now for this Table I want to insert two arrays, first one will is successfully getting inserted as follows:

$referralStats = ReferralStatistic::insert($userReferralStatsArray);
$referralStats = ReferralStatistic::insert($userWriterReferralStatsArray);

Now second array is $userWriterReferralStatsArray, while inserting this array I want to check if same date and same id is repeated then it should update not insert the new row. How can I do it, or please suggest me if there is any other good way to implement it because there are large number of rows.

Thanks in advance



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire