public static function create($title, $content, $label_ids){
self::$db->action(function($db){
$db->insert("articles", [
"title" => $title,
"content" => $content,
"created_at" => self::$t,
"updated_at" => self::$t,
"created_date" => self::$t_date,
"updated_date" => self::$t_date,
]);
$article_id = $db->id();
$data = [];
foreach(explode(",", $label_ids) as $id){
$data[] = [
"article_id" => $article_id,
"label_id" => $id,
"created_at" => self::$t,
"updated_at" => self::$t,
"created_date" => self::$t_date,
"updated_date" => self::$t_date,
];
}
$db->insert("article_labels", $data);
});
}
how to pass variables outside action