Example #1
0
$mat_1->save();
$mat_2 = new Material();
$mat_2->belongs_to($company);
$mat_2->name = 'Drewno brzozowe';
$mat_2->save();
/** 1.6. Check if materials successfully created */
debug($mat_1->load());
debug($mat_2->load());
/** 1.7. Create a new material combination */
$comb = new Combination();
$comb->belongs_to($product);
$comb->has_multiple($mat_1, $mat_2);
$comb->price = '12.34';
$comb->save();
/** 1.8. Check if combination successfully created */
debug($comb->load());
/*
CREATE TABLE `product` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `company_id` int(10) unsigned NOT NULL,
  `name` text collate utf8_polish_ci NOT NULL,
  `elem_1` text collate utf8_polish_ci NOT NULL,
  `elem_2` text collate utf8_polish_ci NOT NULL,
  `elem_3` text collate utf8_polish_ci NOT NULL,
  `elem_4` text collate utf8_polish_ci NOT NULL,
  PRIMARY KEY  (`id`)
);
CREATE TABLE `combination` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `product_id` int(10) unsigned NOT NULL,
  `mat_id` int(10) unsigned default NULL,