Skip to content

Commit fca63b9

Browse files
authored
PSR12 (#156)
* PSR12 - app/models/ * PSR12 * PSR12 * Remove stupid comments * PSR12
1 parent 7f253f2 commit fca63b9

File tree

6 files changed

+91
-91
lines changed

6 files changed

+91
-91
lines changed

app/Livewire/CustomFieldSetDefaultValuesForModel.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use App\Models\CustomField;
66
use Livewire\Attributes\Computed;
77
use Livewire\Component;
8-
98
use App\Models\CustomFieldset;
109
use App\Models\AssetModel;
1110

app/Livewire/Importer.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public function generate_field_map()
6969
$tmp = array_filter($tmp);
7070
}
7171
return json_encode($tmp);
72-
7372
}
7473

7574
private function getColumns($type)
@@ -327,7 +326,7 @@ public function mount()
327326
$this->manufacturers_fields = [
328327
'name' => trans('general.name'),
329328
'url' => trans('general.url'),
330-
'support_url' =>trans('admin/manufacturers/table.support_url'),
329+
'support_url' => trans('admin/manufacturers/table.support_url'),
331330
'support_email' => trans('admin/manufacturers/table.support_email'),
332331
'warranty_lookup_url' => trans('admin/manufacturers/table.warranty_lookup_url'),
333332
'wikidata' => "Wikidata",
@@ -641,7 +640,6 @@ public function selectFile($id)
641640
$this->file_id = $id;
642641
$this->import_errors = null;
643642
$this->statusText = null;
644-
645643
}
646644

647645
public function destroy($id)

app/Livewire/LocationScopeCheck.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public function check_locations()
1616
$this->mismatched = Helper::test_locations_fmcs(false);
1717
}
1818

19-
public function mount() {
19+
public function mount()
20+
{
2021
$this->setting = Setting::getSettings();
2122
$this->mismatched = Helper::test_locations_fmcs(false);
2223
}

app/Livewire/OauthClients.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,5 @@ public function updateClient(Client $editClientId): void
9494
}
9595

9696
$this->dispatch('clientUpdated');
97-
9897
}
9998
}

app/Livewire/PersonalAccessTokens.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ public function rules(): array
3636

3737
public function createToken(): void
3838
{
39-
$this->validate();
39+
$this->validate();
4040

41-
$newToken = auth()->user()->createToken($this->name);
41+
$newToken = auth()->user()->createToken($this->name);
4242

43-
$this->newTokenString = $newToken->accessToken;
43+
$this->newTokenString = $newToken->accessToken;
4444

4545
$this->dispatch('tokenCreated', token: $newToken->accessToken);
4646
}

app/Livewire/SlackSettingsForm.php

Lines changed: 85 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
use App\Models\Setting;
1010
use App\Helpers\Helper;
1111
use Osama\LaravelTeamsNotification\TeamsNotification;
12+
1213
class SlackSettingsForm extends Component
1314
{
1415
public $webhook_endpoint;
1516
public $webhook_channel;
1617
public $webhook_botname;
17-
public $isDisabled ='disabled' ;
18+
public $isDisabled = 'disabled' ;
1819
public $webhook_name;
1920
public $webhook_link;
2021
public $webhook_placeholder;
@@ -37,36 +38,37 @@ class SlackSettingsForm extends Component
3738
];
3839

3940

40-
public function mount() {
41-
$this->webhook_text= [
41+
public function mount()
42+
{
43+
$this->webhook_text = [
4244
"slack" => array(
4345
"name" => trans('admin/settings/general.slack') ,
4446
"icon" => 'fab fa-slack',
4547
"placeholder" => "https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX",
4648
"link" => 'https://api.slack.com/messaging/webhooks',
4749
"test" => "testWebhook"
48-
),
49-
"general"=> array(
50+
),
51+
"general" => array(
5052
"name" => trans('admin/settings/general.general_webhook'),
5153
"icon" => "fab fa-hashtag",
5254
"placeholder" => trans('general.url'),
5355
"link" => "",
5456
"test" => "testWebhook"
55-
),
56-
"google" => array(
57+
),
58+
"google" => array(
5759
"name" => trans('admin/settings/general.google_workspaces'),
5860
"icon" => "fa-brands fa-google",
5961
"placeholder" => "https://chat.googleapis.com/v1/spaces/xxxxxxxx/messages?key=xxxxxx",
6062
"link" => "https://developers.google.com/chat/how-tos/webhooks#register_the_incoming_webhook",
6163
"test" => "googleWebhookTest"
62-
),
63-
"microsoft" => array(
64+
),
65+
"microsoft" => array(
6466
"name" => trans('admin/settings/general.ms_teams'),
6567
"icon" => "fa-brands fa-microsoft",
6668
"placeholder" => "https://abcd.webhook.office.com/webhookb2/XXXXXXX",
6769
"link" => "https://support.microsoft.com/en-us/office/create-incoming-webhooks-with-workflows-for-microsoft-teams-8ae491c7-0394-4861-ba59-055e33f75498",
6870
"test" => "msTeamTestWebhook"
69-
),
71+
),
7072
];
7173

7274
$this->setting = Setting::getSettings();
@@ -87,27 +89,29 @@ public function mount() {
8789
}
8890

8991
if ($this->setting->webhook_endpoint != null && $this->setting->webhook_channel != null) {
90-
$this->isDisabled= '';
92+
$this->isDisabled = '';
9193
}
9294
if ($this->webhook_selected === 'microsoft' && $this->teams_webhook_deprecated) {
9395
session()->flash('warning', trans('admin/settings/message.webhook.ms_teams_deprecation'));
9496
}
9597
}
96-
public function updated($field) {
98+
public function updated($field)
99+
{
97100

98101
$this->validateOnly($field, $this->rules);
99-
100102
}
101103

102-
public function updatedWebhookSelected() {
104+
public function updatedWebhookSelected()
105+
{
103106
$this->webhook_name = $this->webhook_text[$this->webhook_selected]['name'];
104-
$this->webhook_icon = $this->webhook_text[$this->webhook_selected]["icon"]; ;
107+
$this->webhook_icon = $this->webhook_text[$this->webhook_selected]["icon"];
108+
;
105109
$this->webhook_placeholder = $this->webhook_text[$this->webhook_selected]["placeholder"];
106110
$this->webhook_endpoint = null;
107111
$this->webhook_link = $this->webhook_text[$this->webhook_selected]["link"];
108112
$this->webhook_test = $this->webhook_text[$this->webhook_selected]["test"];
109113
if ($this->webhook_selected != 'slack') {
110-
$this->isDisabled= '';
114+
$this->isDisabled = '';
111115
$this->save_button = trans('general.save');
112116
}
113117
if ($this->webhook_selected == 'microsoft' || $this->webhook_selected == 'google') {
@@ -120,26 +124,27 @@ public function updatedwebhookEndpoint()
120124
$this->teams_webhook_deprecated = !Str::contains($this->webhook_endpoint, 'workflows');
121125
}
122126

123-
private function isButtonDisabled() {
124-
if (empty($this->webhook_endpoint)) {
125-
$this->isDisabled = 'disabled';
126-
$this->save_button = trans('admin/settings/general.webhook_presave');
127-
}
128-
if (empty($this->webhook_channel)) {
129-
$this->isDisabled = 'disabled';
130-
$this->save_button = trans('admin/settings/general.webhook_presave');
131-
}
127+
private function isButtonDisabled()
128+
{
129+
if (empty($this->webhook_endpoint)) {
130+
$this->isDisabled = 'disabled';
131+
$this->save_button = trans('admin/settings/general.webhook_presave');
132+
}
133+
if (empty($this->webhook_channel)) {
134+
$this->isDisabled = 'disabled';
135+
$this->save_button = trans('admin/settings/general.webhook_presave');
136+
}
132137
}
133138

134139
public function render()
135140
{
136141
$this->isButtonDisabled();
137142

138143
return view('livewire.slack-settings-form');
139-
140144
}
141145

142-
public function testWebhook() {
146+
public function testWebhook()
147+
{
143148

144149
$webhook = new Client([
145150
'base_url' => e($this->webhook_endpoint),
@@ -156,34 +161,33 @@ public function testWebhook() {
156161
'username' => e($this->webhook_botname),
157162
'icon_emoji' => ':heart:',
158163

159-
]);
164+
]
165+
);
160166

161167
try {
162168
$test = $webhook->post($this->webhook_endpoint, ['body' => $payload, ['headers' => ['Content-Type' => 'application/json']]]);
163169

164-
if (($test->getStatusCode() == 302)||($test->getStatusCode() == 301)) {
165-
return session()->flash('error' , trans('admin/settings/message.webhook.error_redirect', ['endpoint' => $this->webhook_endpoint]));
170+
if (($test->getStatusCode() == 302) || ($test->getStatusCode() == 301)) {
171+
return session()->flash('error', trans('admin/settings/message.webhook.error_redirect', ['endpoint' => $this->webhook_endpoint]));
166172
}
167-
$this->isDisabled='';
173+
$this->isDisabled = '';
168174
$this->save_button = trans('general.save');
169-
return session()->flash('success' , trans('admin/settings/message.webhook.success', ['webhook_name' => $this->webhook_name]));
170-
175+
return session()->flash('success', trans('admin/settings/message.webhook.success', ['webhook_name' => $this->webhook_name]));
171176
} catch (\Exception $e) {
172-
173-
$this->isDisabled='disabled';
177+
$this->isDisabled = 'disabled';
174178
$this->save_button = trans('admin/settings/general.webhook_presave');
175-
return session()->flash('error' , trans('admin/settings/message.webhook.error', ['error_message' => $e->getMessage(), 'app' => $this->webhook_name]));
179+
return session()->flash('error', trans('admin/settings/message.webhook.error', ['error_message' => $e->getMessage(), 'app' => $this->webhook_name]));
176180
}
177181

178-
return session()->flash('error' , trans('admin/settings/message.webhook.error_misc'));
179-
182+
return session()->flash('error', trans('admin/settings/message.webhook.error_misc'));
180183
}
181184

182185

183-
public function clearSettings() {
186+
public function clearSettings()
187+
{
184188

185189
if (Helper::isDemoMode()) {
186-
session()->flash('error',trans('general.feature_disabled'));
190+
session()->flash('error', trans('general.feature_disabled'));
187191
} else {
188192
$this->webhook_endpoint = '';
189193
$this->webhook_channel = '';
@@ -201,7 +205,7 @@ public function clearSettings() {
201205
public function submit()
202206
{
203207
if (Helper::isDemoMode()) {
204-
session()->flash('error',trans('general.feature_disabled'));
208+
session()->flash('error', trans('general.feature_disabled'));
205209
} else {
206210
$this->validate($this->rules);
207211

@@ -212,11 +216,11 @@ public function submit()
212216

213217
$this->setting->save();
214218

215-
session()->flash('success',trans('admin/settings/message.update.success'));
219+
session()->flash('success', trans('admin/settings/message.update.success'));
216220
}
217-
218221
}
219-
public function googleWebhookTest() {
222+
public function googleWebhookTest()
223+
{
220224

221225
$payload = [
222226
"text" => trans('general.webhook_test_msg', ['app' => $this->webhook_name]),
@@ -225,29 +229,29 @@ public function googleWebhookTest() {
225229
try {
226230
$response = Http::withHeaders([
227231
'content-type' => 'application/json',
228-
])->post($this->webhook_endpoint,
229-
$payload)->throw();
232+
])->post(
233+
$this->webhook_endpoint,
234+
$payload
235+
)->throw();
230236

231237

232238
if (($response->getStatusCode() == 302) || ($response->getStatusCode() == 301)) {
233239
return session()->flash('error', trans('admin/settings/message.webhook.error_redirect', ['endpoint' => $this->webhook_endpoint]));
234240
}
235241

236-
$this->isDisabled='';
242+
$this->isDisabled = '';
237243
$this->save_button = trans('general.save');
238-
return session()->flash('success' , trans('admin/settings/message.webhook.success', ['webhook_name' => $this->webhook_name]));
239-
244+
return session()->flash('success', trans('admin/settings/message.webhook.success', ['webhook_name' => $this->webhook_name]));
240245
} catch (\Exception $e) {
241-
242-
$this->isDisabled='disabled';
246+
$this->isDisabled = 'disabled';
243247
$this->save_button = trans('admin/settings/general.webhook_presave');
244-
return session()->flash('error' , trans('admin/settings/message.webhook.error', ['error_message' => $e->getMessage(), 'app' => $this->webhook_name]));
248+
return session()->flash('error', trans('admin/settings/message.webhook.error', ['error_message' => $e->getMessage(), 'app' => $this->webhook_name]));
245249
}
246250
}
247-
public function msTeamTestWebhook() {
251+
public function msTeamTestWebhook()
252+
{
248253

249254
try {
250-
251255
if ($this->teams_webhook_deprecated) {
252256
//will use the deprecated webhook format
253257
$payload =
@@ -260,33 +264,32 @@ public function msTeamTestWebhook() {
260264
];
261265
$response = Http::withHeaders([
262266
'content-type' => 'application/json',
263-
])->post($this->webhook_endpoint,
264-
$payload)->throw();
267+
])->post(
268+
$this->webhook_endpoint,
269+
$payload
270+
)->throw();
271+
} else {
272+
$notification = new TeamsNotification($this->webhook_endpoint);
273+
$message = trans('general.webhook_test_msg', ['app' => $this->webhook_name]);
274+
$notification->success()->sendMessage($message);
275+
276+
$response = Http::withHeaders([
277+
'content-type' => 'application/json',
278+
])->post($this->webhook_endpoint);
265279
}
266-
else {
267-
$notification = new TeamsNotification($this->webhook_endpoint);
268-
$message = trans('general.webhook_test_msg', ['app' => $this->webhook_name]);
269-
$notification->success()->sendMessage($message);
270-
271-
$response = Http::withHeaders([
272-
'content-type' => 'application/json',
273-
])->post($this->webhook_endpoint);
274-
}
275-
276-
if (($response->getStatusCode() == 302)||($response->getStatusCode() == 301)) {
277-
return session()->flash('error' , trans('admin/settings/message.webhook.error_redirect', ['endpoint' => $this->webhook_endpoint]));
278-
}
279-
$this->isDisabled='';
280-
$this->save_button = trans('general.save');
281-
return session()->flash('success' , trans('admin/settings/message.webhook.success', ['webhook_name' => $this->webhook_name]));
282-
283-
} catch (\Exception $e) {
284-
285-
$this->isDisabled='disabled';
286-
$this->save_button = trans('admin/settings/general.webhook_presave');
287-
return session()->flash('error' , trans('admin/settings/message.webhook.error', ['error_message' => $e->getMessage(), 'app' => $this->webhook_name]));
288-
}
289-
290-
return session()->flash('error' , trans('admin/settings/message.webhook.error_misc'));
291-
}
280+
281+
if (($response->getStatusCode() == 302) || ($response->getStatusCode() == 301)) {
282+
return session()->flash('error', trans('admin/settings/message.webhook.error_redirect', ['endpoint' => $this->webhook_endpoint]));
283+
}
284+
$this->isDisabled = '';
285+
$this->save_button = trans('general.save');
286+
return session()->flash('success', trans('admin/settings/message.webhook.success', ['webhook_name' => $this->webhook_name]));
287+
} catch (\Exception $e) {
288+
$this->isDisabled = 'disabled';
289+
$this->save_button = trans('admin/settings/general.webhook_presave');
290+
return session()->flash('error', trans('admin/settings/message.webhook.error', ['error_message' => $e->getMessage(), 'app' => $this->webhook_name]));
291+
}
292+
293+
return session()->flash('error', trans('admin/settings/message.webhook.error_misc'));
294+
}
292295
}

0 commit comments

Comments
 (0)