# fluent-support/1.4.6/app/Services/Tickets/TicketService.php

Fluent Support – Helpdesk &amp; Customer Support Ticket System, version 1.4.6. 68 lines.

- Page: https://pluginprobe.com/plugins/fluent-support/1.4.6/code/app/Services/Tickets/TicketService.php
- Raw: https://pluginprobe.com/plugins/fluent-support/1.4.6/raw/app/Services/Tickets/TicketService.php
- Modified: 2021-11-12T14:57:38+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-support/1.4.6/code/app/Services/Tickets/TicketService.php#L10-L20`.

```php
<?php

namespace FluentSupport\App\Services\Tickets;

use FluentSupport\App\Models\Conversation;

class TicketService
{
    public function close($ticket, $person, $internalNote = '')
    {
        if ($ticket->status != 'closed') {
            $ticket->status = 'closed';
            $ticket->resolved_at = current_time('mysql');
            $ticket->closed_by = $person->id;
            $ticket->total_close_time = current_time('timestamp') - strtotime($ticket->created_at);
            $ticket->save();
            do_action('fluent_support/ticket_closed', $ticket, $person);
            do_action('fluent_support/ticket_closed_by_' . $person->person_type, $ticket, $person);

            if(!$internalNote) {
                $internalNote = __('Ticket has been closed', 'fluent-support');
            }

            Conversation::create([
                'ticket_id' => $ticket->id,
                'person_id' => $person->id,
                'conversation_type' => 'internal_info',
                'content' => $internalNote
            ]);

        }

        return $ticket;
    }

    public function reopen($ticket, $person)
    {
        if ($ticket->status == 'closed') {
            $ticket->status = 'active';
            $ticket->waiting_since = current_time('mysql');
            $ticket->save();
            do_action('fluent_support/ticket_reopen', $ticket, $person);
            do_action('fluent_support/ticket_reopen_by_' . $person->person_type, $ticket, $person);
            Conversation::create([
                'ticket_id' => $ticket->id,
                'person_id' => $person->id,
                'conversation_type' => 'internal_info',
                'content' => __('Ticket has been reopened', 'fluent-support')
            ]);
        }

        return $person;
    }

    public function onAgentChange($ticket, $person){
        Conversation::create([
            'ticket_id' => $ticket->id,
            'person_id' => $person->id,
            'conversation_type' => 'internal_info',
            'content' => $ticket->agent->full_name !== $person->full_name ?
                         __($person->full_name .' assign '. $ticket->agent->full_name .' in this ticket' , 'fluent-support') :
                         __($person->full_name. ' assign this ticket to self', 'fluent-support')
        ]);

        return $person;
    }
}

```
