public function parseMaterial($content, $userid, $alpha, $core = 0) { /* * always purge all existing core materials first * */ Material::truncate(); $processed = 0; foreach ($content['material'] as $item) { $name = $item['@attributes']['id']; if ($name != '') { $record = array("name" => $name); foreach ($item['property'] as $prop) { $prop = $prop['@attributes']; $record[$prop['name']] = $prop['value']; } $record = array_merge($record, array('user_id' => $userid, 'core' => 1, 'mod_id' => 1, 'alpha' => $alpha)); Material::create($record); $processed++; } } }