if ($entry_style_rand > 0) { $entry_style_list = array_rand($entry_styles, $entry_style_rand); if (!is_array($entry_style_list)) { $entry_style_list = (array) $entry_style_list; } foreach ($entry_style_list as $entry_style_id) { if ($shop_fee_list[$shop_fee] == \Model_Fleamarket::SHOP_FEE_FLAG_FREE) { $booth_fee = 0; } else { $booth_fee_key = array_rand($booth_fee_list); $booth_fee = $booth_fee_list[$booth_fee_key]; } $max_booth = mt_rand(20, 100); $reservation_booth_limit = mt_rand(1, 10); $entry_style_line = array('fleamarket_id' => $fleamarket_id, 'entry_style_id' => $entry_style_id, 'booth_fee' => $booth_fee, 'max_booth' => $max_booth, 'reservation_booth_limit' => $reservation_booth_limit, 'created_user' => 0, 'updated_user' => null, 'created_at' => \Date::forge()->format('mysql')); \Model_Fleamarket_Entry_Style::forge($entry_style_line)->save(); } } // フリマ説明情報 $about_rand = mt_rand(0, 7); if ($about_rand > 0) { $about_list = array_rand($about_titles, $about_rand); if (!is_array($about_list)) { $about_list = (array) $about_list; } foreach ($about_list as $about_id) { $about_line = array('fleamarket_id' => $fleamarket_id, 'about_id' => $about_id, 'title' => $about_titles[$about_id], 'description' => $abouts[$about_id], 'created_user' => 0, 'updated_user' => null, 'created_at' => \Date::forge()->format('mysql')); \Model_Fleamarket_About::forge($about_line)->save(); } } }
/** * フリマ出店形態情報を登録する * * @access private * @param object フリマ情報 * @return void * @author kobayashi * @author ida */ private function registerFleamarketEntryStyle($fleamarket) { $entry_styles = \Config::get('master.entry_styles'); $fieldsets = $this->getFieldsets(); foreach ($entry_styles as $id => $entry_style) { $fieldset = $fieldsets['fleamarket_entry_styles'][$id]; $input = $fieldset->input(); $fleamarket_entry_style = \Model_Fleamarket_Entry_Style::find('first', array('where' => array('fleamarket_id' => $fleamarket->fleamarket_id, 'entry_style_id' => $id))); $data = array('booth_fee' => $input['booth_fee'], 'max_booth' => $input['max_booth'], 'reservation_booth_limit' => $input['reservation_booth_limit']); if (strlen($input['booth_fee'])) { $administrator_id = $this->administrator->administrator_id; if ($fleamarket_entry_style) { $data['updated_user'] = $administrator_id; } else { $fleamarket_entry_style = \Model_Fleamarket_Entry_Style::forge(array('fleamarket_id' => $fleamarket->fleamarket_id, 'entry_style_id' => $id)); $data['created_user'] = $administrator_id; } $fleamarket_entry_style->set($data)->save(); } else { if ($fleamarket_entry_style) { $fleamarket_entry_style->delete(); } } } }
<?php use Model_FleamarketEntryStyle; $seeds = array(array('fleamarket_entry_style_id' => 1, 'fleamarket_id' => 1, 'entry_style_id' => 1, 'booth_fee' => 100, 'max_booth' => 100, 'reservation_booth_limit' => 10, 'created_user' => 1, 'updated_user' => 1), array('fleamarket_entry_style_id' => 2, 'fleamarket_id' => 1, 'entry_style_id' => 2, 'booth_fee' => 100, 'max_booth' => 100, 'reservation_booth_limit' => 5, 'created_user' => 1, 'updated_user' => 1)); foreach ($seeds as $line) { $model = Model_Fleamarket_Entry_Style::forge($line); $model->save(); }