app/app/Repositories/Eloquent/TicketRepository.php
/**
	 * Update ticket by a reply ticket action
	 * 
	 * @param  array App\TicketAction::toArray() + $action['status']
	 * @return array App\Ticket::toArray() + $['old_status']
	 */
Update ticket by a reply ticket action


Update ticket by a reply ticket action
public function updateByReply(array $action) {
		$ticket = $this->model->find($action['ticket_id']);
		$ticket_array['old_status'] = $ticket->status;
		$ticket->last_action_at = $action['created_at'];
		$ticket->time_spent += $action['time_spent'];
		$ticket->status = $action['status'];
		if ($action['status'] == 'open') {
			$ticket->closed_at = null;
		} else {
			$ticket->closed_at = $action['created_at'];
		}
		$ticket->save();
		return array_merge($ticket->toArray(), $ticket_array);
	}
public function updateByReply ( array $ action ) { $ ticket = $ this -> model -> find ( $ action [ 'ticket_id' ] ) ; $ ticket_array [ 'old_status' ] = $ ticket -> status ; $ ticket -> last_action_at = $ action [ 'created_at' ] ; $ ticket -> time_spent += $ action [ 'time_spent' ] ; $ ticket -> status = $ action [ 'status' ] ; if ( $ action [ 'status' ] == 'open' ) { $ ticket -> closed_at = null ; } else { $ ticket -> closed_at = $ action [ 'created_at' ] ; } $ ticket -> save ( ) ; return array_merge ( $ ticket -> toArray ( ) , $ ticket_array ) ; }
Update ticket by a reply ticket action
Update ticket by a reply ticket action