# если $allSpecCat - ассоциативный массив
$data['blog_cat_id'] = $allSpecCat['blog_cat_id']
array(1) { ["blog_cat_id"]=> int(3) }
array(1) { ["blog_cat_id"]=> int(334) }
array(1) { ["blog_cat_id"]=> int(335) }
array(1) { ["blog_cat_id"]=> int(336) }
array(1) { ["blog_cat_id"]=> int(337) }
array(1) { ["blog_cat_id"]=> int(338) }
private function SaveSpec($name,$idspec = "")
{
$url = $this->createUrl($name);
$specsCatId = DB::table('eyalovoy_createdocs_specs')->leftJoin('rainlab_blog_categories', 'rainlab_blog_categories.name', '=', 'eyalovoy_createdocs_specs.name')->select('rainlab_blog_categories.id')->get();
//echo $specsCatId;
$allSpecCat = [];
foreach($specsCatId as $sci)
{
$allSpecCat = [
'blog_cat_id' => $sci->id,
];
var_dump($allSpecCat);
}
$data = [
'name' => $name,
'guid' => $idspec,
'blog_cat_id' => '',
'created_at' => date("Y-m-d H:i:s"),
'updated_at' => date("Y-m-d H:i:s"),
];
$specName = $data['name'];
$checkSpec = DB::table('eyalovoy_createdocs_specs')->where('eyalovoy_createdocs_specs.name', $specName)->value('name');
if($checkSpec == $data['name'])
{
$data['updated_at'] = date("Y-m-d H:i:s");
$goToDb = \Db::table('eyalovoy_createdocs_specs')->where('name', $specName)->update($data);
}
else
{
$goToDb = DB::table('eyalovoy_createdocs_specs')->insertGetId($data);
}
}