|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\ServiceProvider; |
|
4
|
|
|
|
|
5
|
|
|
use App\Http\Controllers\Controller; |
|
6
|
|
|
use App\Model\licence\Licence; |
|
7
|
|
|
use App\Model\Licence\LicencedOrganization; |
|
8
|
|
|
use App\Model\licence\Sla; |
|
9
|
|
|
use App\Model\licence\SlaServiceRelation; |
|
10
|
|
|
use App\Model\Product\Service; |
|
11
|
|
|
use App\Organization; |
|
12
|
|
|
use Illuminate\Http\Request; |
|
13
|
|
|
|
|
14
|
|
|
class ServiceProviderController extends Controller |
|
15
|
|
|
{ |
|
16
|
|
|
public $slaServiceRelation; |
|
17
|
|
|
public $service; |
|
18
|
|
|
public $licence; |
|
19
|
|
|
|
|
20
|
|
|
public function __construct() |
|
21
|
|
|
{ |
|
22
|
|
|
$this->middleware('auth'); |
|
23
|
|
|
$this->middleware('service.provider'); |
|
24
|
|
|
|
|
25
|
|
|
$cart = new \App\Http\Controllers\Front\CheckoutController(); |
|
26
|
|
|
$auth = $cart->GetXdeskAuthOrganization(); |
|
|
|
|
|
|
27
|
|
|
$this->org = $auth; |
|
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
$sla = new Sla(); |
|
30
|
|
|
$this->sla = $sla; |
|
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
$LicencedOrg = new LicencedOrganization(); |
|
33
|
|
|
$this->LicencedOrg = $LicencedOrg; |
|
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
$slaServiceRelation = new SlaServiceRelation(); |
|
36
|
|
|
$this->slaServiceRelation = $slaServiceRelation; |
|
37
|
|
|
|
|
38
|
|
|
$service = new Service(); |
|
39
|
|
|
$this->service = $service; |
|
40
|
|
|
|
|
41
|
|
|
$organization = new Organization(); |
|
42
|
|
|
$this->organization = $organization; |
|
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
$licence = new Licence(); |
|
45
|
|
|
$this->licence = $licence; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function Orders() |
|
49
|
|
|
{ |
|
50
|
|
|
try { |
|
51
|
|
|
return view('themes.default1.serviceprovider.orders'); |
|
52
|
|
|
} catch (\Exception $ex) { |
|
53
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function Sla() |
|
58
|
|
|
{ |
|
59
|
|
|
try { |
|
60
|
|
|
return view('themes.default1.serviceprovider.sla'); |
|
61
|
|
|
} catch (\Exception $ex) { |
|
62
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function Pricing() |
|
67
|
|
|
{ |
|
68
|
|
|
try { |
|
69
|
|
|
$licence = new \App\Model\licence\Licence(); |
|
70
|
|
|
$licences = $licence->get(); |
|
|
|
|
|
|
71
|
|
|
|
|
72
|
|
|
return view('themes.default1.serviceprovider.pricing', compact('licences')); |
|
73
|
|
|
} catch (\Exception $ex) { |
|
74
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function GetOrders() |
|
79
|
|
|
{ |
|
80
|
|
|
return \Datatable::collection($this->LicencedOrg->where('organization_id', $this->org->id)->get()) |
|
|
|
|
|
|
81
|
|
|
|
|
82
|
|
|
->showColumns('licence_name', 'licence_description', 'number_of_slas', 'price', 'payment_status') |
|
83
|
|
|
->searchColumns('licence_name') |
|
84
|
|
|
->orderColumns('licence_name') |
|
85
|
|
|
->make(); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function GetSlas() |
|
89
|
|
|
{ |
|
90
|
|
|
return \Datatable::collection($this->sla->where('service_provider_id', $this->org->id)->get()) |
|
91
|
|
|
->addColumn('licence_id', function ($model) { |
|
92
|
|
|
$licence_name = $this->licence->where('id', $model->licence_id)->first()->name; |
|
|
|
|
|
|
93
|
|
|
|
|
94
|
|
|
return $licence_name; |
|
95
|
|
|
}) |
|
96
|
|
|
->showColumns('name', 'description') |
|
97
|
|
View Code Duplication |
->addColumn('service', function ($model) { |
|
|
|
|
|
|
98
|
|
|
$serviceid = $this->slaServiceRelation->where('sla_id', $model->id)->first()->service_id; |
|
|
|
|
|
|
99
|
|
|
|
|
100
|
|
|
return $this->service->where('id', $serviceid)->first()->name; |
|
|
|
|
|
|
101
|
|
|
}) |
|
102
|
|
View Code Duplication |
->addColumn('organization_id', function ($model) { |
|
|
|
|
|
|
103
|
|
|
$name = $this->organization->where('id', $model->organization_id)->where('type', 'client')->first()->name; |
|
104
|
|
|
|
|
105
|
|
|
return $name; |
|
106
|
|
|
}) |
|
107
|
|
|
|
|
108
|
|
|
->showColumns('start_date', 'end_date', 'grace_period') |
|
109
|
|
|
->addColumn('action', function ($model) { |
|
110
|
|
|
return '<a href='.url('slas/'.$model->id.'/edit')." class='btn btn-sm btn-primary'>Edit</a>"; |
|
111
|
|
|
}) |
|
112
|
|
|
->searchColumns('name') |
|
113
|
|
|
->orderColumns('name') |
|
114
|
|
|
->make(); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
public function AddtoCart($id, Request $request) |
|
118
|
|
|
{ |
|
119
|
|
|
try { |
|
120
|
|
|
$licence = new \App\Model\licence\Licence(); |
|
121
|
|
|
$item = $licence->where('id', $id)->first(); |
|
|
|
|
|
|
122
|
|
|
//dd($item); |
|
123
|
|
|
$order = $this->LicencedOrg->create([ |
|
|
|
|
|
|
124
|
|
|
'organization_id' => $this->org->id, |
|
125
|
|
|
'licence_name' => $item->name, |
|
126
|
|
|
'licence_description' => $item->description, |
|
127
|
|
|
'number_of_slas' => $item->number_of_sla, |
|
128
|
|
|
'price' => $item->price, |
|
129
|
|
|
|
|
130
|
|
|
]); |
|
131
|
|
|
|
|
132
|
|
|
//dd($request); |
|
133
|
|
|
\Event::fire(new \App\Events\SmsIntegration($request)); |
|
134
|
|
|
//\Event::fire(new \App\Events\PaymentGateway(['request' => $request, 'cart' => [], 'order' => $order])); |
|
|
|
|
|
|
135
|
|
|
} catch (\Exception $ex) { |
|
136
|
|
|
return redirect()->back()->with('fails', $ex->getMessage()); |
|
137
|
|
|
} |
|
138
|
|
|
} |
|
139
|
|
|
} |
|
140
|
|
|
|
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: