i having code in controller
foreach($blogtags $blogtagsdata) { $data[] = array( 'blog_id' => $postblog->id, 'user_id' => '1', 'tag_id' => $blogtagsdata[0]); } blogtag::insert($data);
where $blogtags have 1,2,3 that.
but when insert
not inserting timestamps in created_at field , updated_at field..
even have inside model
public $timestamps = true;
what mistake doing,,,
is doing following way option ?
$data['created_at']= \carbon\carbon::now()->todatetimestring(); $data['updated_at']= \carbon\carbon::now()->todatetimestring();
or there better way include laravel default timestamp insertion ..
try
foreach ($blogtags $blogtagsdata) { blogtag::create([ 'blog_id' => $postblog->id, 'user_id' => '1', 'tag_id' => $blogtagsdata[0] ]); }
Comments
Post a Comment