|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Cortex\Contacts\Http\Controllers\Managerarea; |
|
6
|
|
|
|
|
7
|
|
|
use Illuminate\Http\Request; |
|
8
|
|
|
use Rinvex\Contacts\Contracts\ContactContract; |
|
9
|
|
|
use Cortex\Foundation\DataTables\LogsDataTable; |
|
10
|
|
|
use Cortex\Contacts\DataTables\Managerarea\ContactsDataTable; |
|
11
|
|
|
use Cortex\Foundation\Http\Controllers\AuthorizedController; |
|
12
|
|
|
use Cortex\Contacts\Http\Requests\Managerarea\ContactFormRequest; |
|
13
|
|
|
|
|
14
|
|
|
class ContactsController extends AuthorizedController |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* {@inheritdoc} |
|
18
|
|
|
*/ |
|
19
|
|
|
protected $resource = 'contacts'; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Display a listing of the resource. |
|
23
|
|
|
* |
|
24
|
|
|
* @param \Cortex\Contacts\DataTables\Managerarea\ContactsDataTable $contactsDataTable |
|
25
|
|
|
* |
|
26
|
|
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\View\View |
|
27
|
|
|
*/ |
|
28
|
|
|
public function index(ContactsDataTable $contactsDataTable) |
|
29
|
|
|
{ |
|
30
|
|
|
return $contactsDataTable->with([ |
|
31
|
|
|
'id' => 'cortex-contacts', |
|
32
|
|
|
'phrase' => trans('cortex/contacts::common.contacts'), |
|
33
|
|
|
])->render('cortex/tenants::managerarea.pages.datatable'); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Display a listing of the resource logs. |
|
38
|
|
|
* |
|
39
|
|
|
* @param \Rinvex\Contacts\Contracts\ContactContract $category |
|
|
|
|
|
|
40
|
|
|
* @param \Cortex\Foundation\DataTables\LogsDataTable $logsDataTable |
|
41
|
|
|
* |
|
42
|
|
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\View\View |
|
43
|
|
|
*/ |
|
44
|
|
|
public function logs(ContactContract $contact, LogsDataTable $logsDataTable) |
|
45
|
|
|
{ |
|
46
|
|
|
return $logsDataTable->with([ |
|
47
|
|
|
'tab' => 'logs', |
|
48
|
|
|
'type' => 'contacts', |
|
49
|
|
|
'resource' => $contact, |
|
50
|
|
|
'id' => 'cortex-contacts-logs', |
|
51
|
|
|
'phrase' => trans('cortex/contacts::common.contacts'), |
|
52
|
|
|
])->render('cortex/tenants::managerarea.pages.datatable-tab'); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Store a newly created resource in storage. |
|
57
|
|
|
* |
|
58
|
|
|
* @param \Cortex\Contacts\Http\Requests\Managerarea\ContactFormRequest $request |
|
59
|
|
|
* |
|
60
|
|
|
* @return \Illuminate\Http\Response |
|
|
|
|
|
|
61
|
|
|
*/ |
|
62
|
|
|
public function store(ContactFormRequest $request) |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->process($request, app('rinvex.contacts.contact')); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Update the given resource in storage. |
|
69
|
|
|
* |
|
70
|
|
|
* @param \Cortex\Contacts\Http\Requests\Managerarea\ContactFormRequest $request |
|
71
|
|
|
* @param \Rinvex\Contacts\Contracts\ContactContract $contact |
|
72
|
|
|
* |
|
73
|
|
|
* @return \Illuminate\Http\Response |
|
|
|
|
|
|
74
|
|
|
*/ |
|
75
|
|
|
public function update(ContactFormRequest $request, ContactContract $contact) |
|
76
|
|
|
{ |
|
77
|
|
|
return $this->process($request, $contact); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Delete the given resource from storage. |
|
82
|
|
|
* |
|
83
|
|
|
* @param \Rinvex\Contacts\Contracts\ContactContract $contact |
|
84
|
|
|
* |
|
85
|
|
|
* @return \Illuminate\Http\Response |
|
|
|
|
|
|
86
|
|
|
*/ |
|
87
|
|
|
public function delete(ContactContract $contact) |
|
88
|
|
|
{ |
|
89
|
|
|
$contact->delete(); |
|
90
|
|
|
|
|
91
|
|
|
return intend([ |
|
92
|
|
|
'url' => route('managerarea.contacts.index'), |
|
93
|
|
|
'with' => ['warning' => trans('cortex/contacts::messages.contact.deleted', ['slug' => $contact->slug])], |
|
|
|
|
|
|
94
|
|
|
]); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Show the form for create/update of the given resource. |
|
99
|
|
|
* |
|
100
|
|
|
* @param \Rinvex\Contacts\Contracts\ContactContract $contact |
|
101
|
|
|
* |
|
102
|
|
|
* @return \Illuminate\Http\Response |
|
|
|
|
|
|
103
|
|
|
*/ |
|
104
|
|
|
public function form(ContactContract $contact) |
|
105
|
|
|
{ |
|
106
|
|
|
$countries = countries(); |
|
107
|
|
|
$languages = collect(languages())->pluck('name', 'iso_639_1'); |
|
108
|
|
|
$sources = app('rinvex.contacts.contact')->distinct()->get(['source'])->pluck('source', 'source')->toArray(); |
|
109
|
|
|
$methods = app('rinvex.contacts.contact')->distinct()->get(['method'])->pluck('method', 'method')->toArray(); |
|
110
|
|
|
$genders = ['m' => trans('cortex/contacts::common.male'), 'f' => trans('cortex/contacts::common.female')]; |
|
111
|
|
|
|
|
112
|
|
|
return view('cortex/contacts::managerarea.forms.contact', compact('contact', 'genders', 'countries', 'languages', 'sources', 'methods')); |
|
|
|
|
|
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* Process the form for store/update of the given resource. |
|
117
|
|
|
* |
|
118
|
|
|
* @param \Illuminate\Http\Request $request |
|
119
|
|
|
* @param \Rinvex\Contacts\Contracts\ContactContract $contact |
|
120
|
|
|
* |
|
121
|
|
|
* @return \Illuminate\Http\Response |
|
|
|
|
|
|
122
|
|
|
*/ |
|
123
|
|
|
protected function process(Request $request, ContactContract $contact) |
|
124
|
|
|
{ |
|
125
|
|
|
// Prepare required input fields |
|
126
|
|
|
$data = $request->all(); |
|
127
|
|
|
|
|
128
|
|
|
// Save contact |
|
129
|
|
|
$contact->fill($data)->save(); |
|
130
|
|
|
|
|
131
|
|
|
return intend([ |
|
132
|
|
|
'url' => route('managerarea.contacts.index'), |
|
133
|
|
|
'with' => ['success' => trans('cortex/contacts::messages.contact.saved', ['slug' => $contact->slug])], |
|
|
|
|
|
|
134
|
|
|
]); |
|
135
|
|
|
} |
|
136
|
|
|
} |
|
137
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.