I have an activities log tables, And I want to batch write to log tables each time system collected more than 100 records. How to do that with Laravel ?
Thank you!
I have an activities log tables, And I want to batch write to log tables each time system collected more than 100 records. How to do that with Laravel ?
Thank you!
You can do that as below...
$data = array(
array(
'log_name'=>'Syntax',
'type'=>'Error',
'created_at'=>date('Y-m-d H:i:s'),
'modified_at'=> date('Y-m-d H:i:s')
),
array(
'log_name'=>'Logical',
'type'=>'Warning',
'created_at'=>date('Y-m-d H:i:s'),
'modified_at'=> date('Y-m-d H:i:s')
),
//...
);
Log::insert($data);
Or using query builder as
DB::table('log')->insert($data);