/** * Set the distribution if applicable. * * @param Product $product * @param array $data */ protected function createDistribution(sosProduct $product, array $data) { if (isset($data['custom']) && $data['custom'] == 'on') { $product->groep_flag = 1; $product->distributies()->attach(static::DISTRIBUTION_ID, array('custom_prod' => '1')); //saving happens at the end of the creation process } }