Пример #1
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Despesa::create([]);
     }
 }
Пример #2
0
 public function get_despesas()
 {
     //return $this->hasMany('Despesa', 'ids');
     $despesas = explode(',', $this->ids);
     $despesas = Despesa::whereIn('id', $despesas)->get();
     return $despesas;
 }
 /**
  * Status atual dos itens
  *
  * @param  string $resource_name
  * @return Response
  */
 public function status($resource_name = NULL)
 {
     // TIPO DE RELATÓRIO
     switch ($resource_name) {
         /*
         	DESPESAS
         */
         case 'despesas':
             $items = Despesa::all();
             break;
             /*
             	CONVERSAS
             */
         /*
         	CONVERSAS
         */
         case 'conversas':
             $items = Conversa::all();
             break;
         default:
             return $items = array();
             break;
     }
     // STATUS
     $status['total'] = count($items);
     $status['nao_enviadas'] = $items->filter(function ($item) {
         if (isset($item->relatorio_id) and $item->relatorio_id < 1) {
             return $item;
         }
     });
     $status['nao_enviadas'] = count($status['nao_enviadas']);
     // RETURN
     return $status;
 }
Пример #4
0
 /**
  * Remove the specified despesa from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if (Despesa::destroy($id)) {
         // Alert
         $alert[] = ['class' => 'alert-success', 'message' => '<strong><i class="fa fa-check"></i></strong> Despesa excluída com sucesso'];
     } else {
         // Alert
         $alert[] = ['class' => 'alert-danger', 'message' => '<strong><i class="fa fa-check"></i></strong> Erro! Não foi possível excluir a despesa.'];
     }
     Session::flash('alerts', $alert);
     return Redirect::to(URL::previous());
 }
Пример #5
0
 /**
  * Busca todas as despesas de um determinado m�s
  *
  * @param long $mes
  * @param long $ano
  * 
  * @return array
  */
 function busca_mes($mes, $ano, $id_estudio = NULL)
 {
     $timestamp_inicio = mktime(0, 0, 1, $mes, 1, $ano);
     $timestamp_fim = mktime(23, 59, 59, $mes + 1, 0, $ano);
     $data_inicio = date(FORMATO_DATA_MYSQL, $timestamp_inicio);
     $data_fim = date(FORMATO_DATA_MYSQL, $timestamp_fim);
     $this->db->from($this->get_table_name());
     $this->db->where('data >=', $data_inicio);
     $this->db->where('data <=', $data_fim);
     if (NULL !== $id_estudio) {
         $this->db->where('id_estudio', $id_estudio);
     }
     $query = $this->db->get();
     $colecao = array();
     if ($query->num_rows() > 0) {
         foreach ($query->result_array() as $row) {
             $despesa = new Despesa();
             $despesa->populate($row);
             array_push($colecao, $despesa);
         }
     }
     return $colecao;
 }
Пример #6
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Despesa the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Despesa::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }