예제 #1
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Expense::create([]);
     }
 }
예제 #2
0
 /**
  * Store a newly created expense in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Expense::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     Expense::create($data);
     return Redirect::route('expenses.index');
 }
예제 #3
0
 public function post_index()
 {
     if (!ExpenseForm::is_valid()) {
         return Redirect::back()->with_input()->with_errors(ExpenseForm::$validation);
     }
     $new_expense = Expense::create(Input::get());
     if ($new_expense) {
         return Redirect::to_action('expenses');
     }
 }
예제 #4
0
 /**
  * create
  */
 public function create()
 {
     $res = new Response();
     $rec = Expense::create($this->params);
     echo "{\"items\": []}";
     return;
     $rec = Expense::create($this->params);
     if ($rec) {
         $res->success = true;
         $res->message = "Created new User" . $rec->id;
         $res->data = $rec->to_hash();
     } else {
         $res->message = "Failed to create User";
     }
     return $res->to_json();
 }
예제 #5
0
 function create()
 {
     if ($_POST) {
         unset($_POST['send']);
         unset($_POST['_wysihtml5_mode']);
         unset($_POST['files']);
         $config['upload_path'] = './files/media/';
         $config['encrypt_name'] = TRUE;
         $config['allowed_types'] = '*';
         $this->load->library('upload', $config);
         if ($this->upload->do_upload()) {
             $data = array('upload_data' => $this->upload->data());
             if ($_POST['attachment_description'] == "") {
                 $_POST['attachment_description'] = $data['upload_data']['orig_name'];
             }
             $_POST['attachment'] = $data['upload_data']['file_name'];
         }
         $expense = Expense::create($_POST);
         if (!$expense) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_create_expense_error'));
         } else {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_create_expense_success'));
         }
         redirect('expenses');
     } else {
         $this->view_data['expenses'] = Expense::all();
         $this->view_data['next_reference'] = Expense::last();
         $this->view_data['projects'] = Project::all();
         $this->view_data['core_settings'] = Setting::first();
         $this->view_data['companies'] = Company::find('all', array('conditions' => array('inactive=?', '0')));
         $this->theme_view = 'modal';
         $this->view_data['categories'] = Expense::find_by_sql("select category from expenses group by category");
         $this->view_data['title'] = $this->lang->line('application_create_expense');
         $this->view_data['form_action'] = 'expenses/create';
         $this->content_view = 'expenses/_expense';
     }
 }