/**
  * view method
  *
  * @access public
  * @return void
  * @author ida
  */
 public function view()
 {
     $this->entry_styles = \Config::get('master.entry_styles');
     $this->item_categories = \Model_Entry::getItemCategories();
     $this->entry_statuses = \Model_Entry::getEntryStatuses();
     $this->devices = \Model_Entry::getDevices();
 }
<?php

use Model_Entry;
use Model_Fleamarket;
use Model_Fleamarket_Entry_Style;
use Model_User;
$item_categories = array('1' => 'リサイクル品', '2' => '手作り品');
$item_genres = \Model_Entry::getItemGenres();
$link_from_list = \Model_Entry::getLinkFromList();
$entry_statuses = \Model_Entry::getEntryStatuses();
$fleamarkets = \Model_Fleamarket::find('all', array('select' => array('fleamarket_id')));
$users = \Model_User::find('all', array('select' => array('user_id')));
for ($i = 1; $i < 1000; $i++) {
    $item_category = array_rand($item_categories);
    $item_genre = array_rand($item_genres);
    $link_from = array_rand($link_from_list);
    $entry_status = array_rand($entry_statuses);
    while (true) {
        $fleamarket_key = array_rand($fleamarkets);
        $fleamarket = $fleamarkets[$fleamarket_key];
        $fleamarket_entry_styles = \Model_Fleamarket_Entry_Style::find('all', array('select' => array('fleamarket_entry_style_id'), 'where' => array(array('fleamarket_id', $fleamarket->fleamarket_id))));
        if ($fleamarket_entry_styles) {
            $fleamarket_entry_style_key = array_rand($fleamarket_entry_styles);
            $fleamarket_entry_style = $fleamarket_entry_styles[$fleamarket_entry_style_key];
            break;
        }
    }
    $user_key = array_rand($users);
    $user = $users[$user_key];
    $data = array('user_id' => $user->user_id, 'fleamarket_id' => $fleamarket->fleamarket_id, 'fleamarket_entry_style_id' => $fleamarket_entry_style->fleamarket_entry_style_id, 'reservation_number' => str_pad($fleamarket->fleamarket_id, 5, "0", STR_PAD_LEFT) . '-' . str_pad($i, 5, "0", STR_PAD_LEFT), 'item_category' => $item_category, 'item_genres' => $item_genres[$item_genre], 'reserved_booth' => mt_rand(1, 3), 'link_from' => $link_from_list[$link_from], 'remarks' => '初めてフリマを予約します' . $i, 'entry_status' => $entry_status, 'created_user' => 0);
    $entry = \Model_Entry::forge($data);
 /**
  * 予約履歴CSV出力
  *
  * @access public
  * @param
  * @return void
  * @author kobayashi
  * @author ida
  */
 public function action_csv()
 {
     $fleamarket = Model_Fleamarket::find(Input::param('fleamarket_id'));
     $csv = Lang::load('admin/csv');
     $data = array($csv['header']);
     $prefectures = \Config::get('master.prefectures');
     $entry_styles = \Config::get('master.entry_styles');
     $entry_statuses = \Model_Entry::getEntryStatuses();
     $gender_list = \Model_User::getGenderList();
     foreach ($fleamarket->entries as $entry) {
         if ($entry->user && $entry->fleamarket_entry_style) {
             $prefecture_id = $entry->user->prefecture_id;
             if (!isset($prefectures[$prefecture_id])) {
                 $prefecture_name = '-';
             } else {
                 $prefecture_name = $prefectures[$prefecture_id];
             }
             $data[] = array($entry->created_at, $fleamarket->event_date, $fleamarket->name, $entry->user->user_id, $entry->reservation_number, $entry_styles[$entry->fleamarket_entry_style->entry_style_id], $entry->reserved_booth, $entry->user->last_name . $entry->user->first_name, $entry->user->zip, $prefecture_name, $entry->user->address, $entry->user->tel, @$gender_list[$entry->user->gender], $entry->user->email, $entry_statuses[$entry->entry_status]);
         }
     }
     return $this->response_csv($data, $fleamarket->name);
 }