1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Console\Commands; |
4
|
|
|
|
5
|
|
|
use App\Http\Controllers\Agent\helpdesk\MailController; |
6
|
|
|
use App\Http\Controllers\Agent\helpdesk\TicketWorkflowController; |
7
|
|
|
use Event; |
8
|
|
|
use Illuminate\Console\Command; |
9
|
|
|
|
10
|
|
|
class TicketFetch extends Command |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* The name and signature of the console command. |
14
|
|
|
* |
15
|
|
|
* @var string |
16
|
|
|
*/ |
17
|
|
|
protected $signature = 'ticket:fetch'; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* The console command description. |
21
|
|
|
* |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
protected $description = 'Fetching the tickets from service provider'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Create a new command instance. |
28
|
|
|
* |
29
|
|
|
* @return void |
|
|
|
|
30
|
|
|
*/ |
31
|
|
|
public function __construct() |
32
|
|
|
{ |
33
|
|
|
parent::__construct(); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Execute the console command. |
38
|
|
|
* |
39
|
|
|
* @return mixed |
40
|
|
|
*/ |
41
|
|
|
public function handle() |
42
|
|
|
{ |
43
|
|
|
if (env('DB_INSTALL') == 1) { |
44
|
|
|
$controller = $this->mailController(); |
45
|
|
|
$emails = new \App\Model\helpdesk\Email\Emails(); |
46
|
|
|
$settings_email = new \App\Model\helpdesk\Settings\Email(); |
47
|
|
|
$system = new \App\Model\helpdesk\Settings\System(); |
48
|
|
|
$ticket = new \App\Model\helpdesk\Settings\Ticket(); |
49
|
|
|
$controller->readmails($emails, $settings_email, $system, $ticket); |
50
|
|
|
Event::fire('ticket.fetch', ['event' => '']); |
51
|
|
|
loging('fetching-ticket', 'Ticket has read', 'info'); |
52
|
|
|
//\Log::info('Ticket has read'); |
|
|
|
|
53
|
|
|
$this->info('Ticket has read'); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
57
|
|
View Code Duplication |
public function mailController() |
|
|
|
|
58
|
|
|
{ |
59
|
|
|
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController(); |
60
|
|
|
$NotificationController = new \App\Http\Controllers\Common\NotificationController(); |
61
|
|
|
$ticket = new \App\Http\Controllers\Agent\helpdesk\TicketController($PhpMailController, $NotificationController); |
62
|
|
|
$work = new TicketWorkflowController($ticket); |
63
|
|
|
$controller = new MailController($work); |
64
|
|
|
|
65
|
|
|
return $controller; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.