Inheritance: implements Bosnadev\Repositories\Contracts\RepositoryInterface, implements Bosnadev\Repositories\Contracts\CriteriaInterface
Exemplo n.º 1
0
 public function update(array $data, $id, $attribute = 'id')
 {
     if (isset($data['password'])) {
         $data['password'] = bcrypt($data['password']);
     }
     parent::update($data, $id, $attribute);
 }
 /**
  * Create Action and update ticket
  *
  * @param  array $attrs [ticket_id, user_id, type, body, [title, assigned_id, transfer_id, hours, status]]
  * @return App\TicketAction
  */
 public function create(array $data)
 {
     // create action
     $action = parent::create(array_except($data, ['hours', 'time_at', 'status']));
     //update timelog
     if (isset($data['hours']) && $data['hours'] > 0) {
         $this->updateTimeLog($action->id, $action->user_id, $data['hours'], $data['time_at']);
     }
     // update ticket
     $ticket = $this->updateTicket($data);
     if (isset($ticket['old_status']) && $ticket['old_status'] != $ticket['status']) {
         $action->type = $ticket['status'];
     }
     $action->save();
     return $action;
 }
Exemplo n.º 3
0
 public function paginateByRequest($perPage = 1, $columns = ['*'])
 {
     $this->model = $this->model->select('tickets.*', 'ticket_actions.title as title', 'users.display_name as user_display_name', 'su.display_name as staff_display_name')->join('users', 'users.id', '=', 'tickets.user_id')->join('staff', 'staff.id', '=', 'tickets.staff_id')->join('users as su', 'su.id', '=', 'staff.user_id')->join('ticket_actions', 'ticket_actions.ticket_id', '=', 'tickets.id')->where('ticket_actions.type', 'create');
     $this->pushCriteria(new Criteria\RequestSort())->pushCriteria(new Criteria\RequestCreatedAtRange())->pushCriteria(new Criteria\RequestSearchTickets())->pushCriteria(new Criteria\Request('status'))->pushCriteria(new Criteria\Request('priority'))->pushCriteria(new Criteria\Request('dept_id'))->pushCriteria(new Criteria\Request('staff_id'));
     return parent::paginate($perPage);
 }
Exemplo n.º 4
0
 public function paginateByRequest(TicketIndexRequest $request)
 {
     $this->model = $this->model->with('user', 'assigned');
     $this->pushCriteria(new Criteria\Request\RequestOrderBy($request))->pushCriteria(new Criteria\Request\RequestWhereCreatedAtBetween($request))->pushCriteria(new Criteria\Tickets\RequestWhereInStatus($request))->pushCriteria(new Criteria\Tickets\RequestWhereInPriority($request))->pushCriteria(new Criteria\Request\RequestWhereInDeptId($request))->pushCriteria(new Criteria\Request\RequestWhereInOrgId($request))->pushCriteria(new Criteria\Tickets\RequestWhereInAssignedId($request))->pushCriteria(new Criteria\Tickets\RequestSearch($request));
     return parent::paginate($request->get('per_page', config('system.page_size')));
 }
Exemplo n.º 5
0
 /**
  * @param int $perPage
  * @param array $columns
  * @return mixed
  */
 public function paginate($perPage = 20, $columns = array('*'))
 {
     return parent::paginate($perPage, $columns);
 }
Exemplo n.º 6
0
 /**
  * @param  array $data
  * @param  $id
  * @return mixed
  */
 public function updateRich(array $data, $id)
 {
     $data = $this->_clearFromFormHelpers($data);
     list($data, $relation_data) = $this->_prepareRelationsData($data);
     $ret = parent::updateRich($data, $id);
     $this->_saveRelations($relation_data, $id);
     $this->flushCache();
     return $ret;
 }
Exemplo n.º 7
0
 /**
  * Render response to display list of $data
  *
  * @param Repository|Model $data
  * @param string $view
  * @return Response
  */
 protected function defaultIndex($data, $view)
 {
     $var = camel_case(explode('.', $view)[1] . 's');
     ${$var} = $data->paginate(15);
     return view($view, compact($var));
 }