Skip to content

Commit d84577f

Browse files
authored
Merge pull request #109 from devaslanphp/dev
Resolve Sonar issues
2 parents 298f942 + 00aada3 commit d84577f

77 files changed

Lines changed: 1334 additions & 398 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/Core/LogsActivity.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,18 @@ public function getActivitylogOptions(): LogOptions
2222
->logOnly($this->getFillable())
2323
->setDescriptionForEvent(fn(string $eventName) => new HtmlString(
2424
'<div class="flex flex-col gap-1">'
25-
. (auth()->user()->name ?? '') . " " . $eventName . " " . $this->fromCamelCase((new \ReflectionClass($this))->getShortName()) . " " . $this
26-
. ' <a class="text-primary-500 hover:underline hover:cursor-pointer" target="_blank" href="' . $this->activityLogLink() . '">' . __('See details') . '</a>'
25+
. (auth()->user()->name ?? '')
26+
. " "
27+
. $eventName
28+
. " "
29+
. $this->fromCamelCase((new \ReflectionClass($this))->getShortName())
30+
. " "
31+
. $this
32+
. ' <a class="text-primary-500 hover:underline hover:cursor-pointer"
33+
target="_blank"
34+
href="' . $this->activityLogLink() . '">
35+
' . __('See details')
36+
. '</a>'
2737
. '</div>'
2838
));
2939
}

app/Http/Controllers/Auth/LogoutController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class LogoutController extends Controller
1212
public function __invoke(Request $request)
1313
{
1414
Auth::logout();
15-
// $request->session()->invalidate();
1615
$request->session()->regenerateToken();
1716
return redirect('/');
1817
}

app/Http/Controllers/TicketNumberController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ class TicketNumberController extends Controller
1717
*/
1818
public function __invoke(string $number)
1919
{
20-
$ticket_prefix = substr($number, 0, 4);
21-
$ticket_number = str_replace($ticket_prefix, "", $number);
22-
$ticket = Ticket::where('number', $ticket_number)
23-
->whereHas('project', fn($query) => $query->where('ticket_prefix', $ticket_prefix))
20+
$ticketPrefix = substr($number, 0, 4);
21+
$ticketNumber = str_replace($ticketPrefix, "", $number);
22+
$ticket = Ticket::where('number', $ticketNumber)
23+
->whereHas('project', fn($query) => $query->where('ticket_prefix', $ticketPrefix))
2424
->first();
2525
if ($ticket) {
2626
return redirect()->route('tickets.details', [

app/Http/Livewire/Administration/CompaniesDialog.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,12 @@ protected function getFormSchema(): array
8080
TextInput::make('name')
8181
->label(__('Company name'))
8282
->maxLength(255)
83-
->unique(table: Company::class, column: 'name', ignorable: fn() => $this->company, callback: function (Unique $rule) {
84-
return $rule->withoutTrashed();
85-
})
83+
->unique(
84+
table: Company::class,
85+
column: 'name',
86+
ignorable: fn() => $this->company,
87+
callback: fn (Unique $rule) => $rule->withoutTrashed()
88+
)
8689
->required(),
8790

8891
Select::make('responsible_id')

app/Http/Livewire/Administration/TicketPriorities.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ protected function getTableColumns(): array
4848
->searchable()
4949
->sortable()
5050
->formatStateUsing(fn(TicketPriority $record) => new HtmlString('
51-
<span class="px-2 py-1 rounded-full text-sm flex items-center gap-2" style="color: ' . $record->text_color . '; background-color: ' . $record->bg_color . '">
51+
<span
52+
class="px-2 py-1 rounded-full text-sm flex items-center gap-2"
53+
style="color: ' . $record->text_color . '; background-color: ' . $record->bg_color . '"
54+
>
5255
<i class="fa ' . $record->icon . '"></i>' . $record->title . '
5356
</span>
5457
')),

app/Http/Livewire/Administration/TicketPrioritiesDialog.php

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,15 @@ protected function getFormSchema(): array
5454
TextInput::make('title')
5555
->label(__('Title'))
5656
->maxLength(255)
57-
->unique(table: TicketPriority::class, column: 'title', ignorable: fn () => $this->priority, callback: function (Unique $rule) {
58-
return $rule->withoutTrashed();
59-
})
57+
->unique(
58+
table: TicketPriority::class,
59+
column: 'title',
60+
ignorable: fn () => $this->priority,
61+
callback: function (Unique $rule)
62+
{
63+
return $rule->withoutTrashed();
64+
}
65+
)
6066
->required(),
6167

6268
ColorPicker::make('text_color')
@@ -72,10 +78,34 @@ protected function getFormSchema(): array
7278
->reactive()
7379
->searchable()
7480
->required()
75-
->getSearchResultsUsing(fn (string $search) => Icon::where('icon', 'like', "%{$search}%")->limit(50)->pluck('icon', 'icon'))
81+
->getSearchResultsUsing(
82+
fn (string $search) =>
83+
Icon::where('icon', 'like', "%{$search}%")
84+
->limit(50)
85+
->pluck('icon', 'icon')
86+
)
7687
->getOptionLabelUsing(fn ($value): ?string => Icon::where('icon', $value)->first()?->icon)
77-
->hint(fn (Closure $get) => $get('icon') ? new HtmlString(__('Selected icon:') . ' <i class="fa fa-2x ' . $get('icon') . '"></i>') : '')
78-
->helperText(new HtmlString(__("Check the <a href='https://fontawesome.com/icons' target='_blank' class='text-blue-500 underline'>fontawesome icons here</a> to choose your right icon"))),
88+
->hint(
89+
fn (Closure $get) =>
90+
$get('icon') ?
91+
new HtmlString(
92+
__('Selected icon:')
93+
. ' <i class="fa fa-2x '
94+
. $get('icon')
95+
. '"></i>'
96+
)
97+
:
98+
''
99+
)
100+
->helperText(
101+
new HtmlString(
102+
__("Check the <a href='https://fontawesome.com/icons'
103+
target='_blank' class='text-blue-500 underline'>
104+
fontawesome icons here
105+
</a> to choose your right icon"
106+
)
107+
)
108+
),
79109
];
80110
}
81111

@@ -88,7 +118,7 @@ public function save(): void
88118
{
89119
$data = $this->form->getState();
90120
if (!$this->priority?->id) {
91-
$priority = TicketPriority::create([
121+
TicketPriority::create([
92122
'title' => $data['title'],
93123
'text_color' => $data['text_color'],
94124
'bg_color' => $data['bg_color'],

app/Http/Livewire/Administration/TicketStatuses.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@
33
namespace App\Http\Livewire\Administration;
44

55
use App\Models\TicketStatus;
6-
use App\Models\User;
7-
use Filament\Forms\Components\Grid;
8-
use Filament\Forms\Components\TextInput;
9-
use Filament\Forms\Concerns\InteractsWithForms;
10-
use Filament\Forms\Contracts\HasForms;
116
use Filament\Tables\Actions\Action;
12-
use Filament\Tables\Columns\BadgeColumn;
137
use Filament\Tables\Columns\BooleanColumn;
148
use Filament\Tables\Columns\TextColumn;
159
use Filament\Tables\Concerns\InteractsWithTable;
@@ -54,8 +48,11 @@ protected function getTableColumns(): array
5448
->label(__('Title'))
5549
->searchable()
5650
->sortable()
57-
->formatStateUsing(fn (TicketStatus $record) => new HtmlString('
58-
<span class="px-2 py-1 rounded-full text-sm" style="color: ' . $record->text_color . '; background-color: ' . $record->bg_color . '">' . $record->title . '</span>
51+
->formatStateUsing(fn(TicketStatus $record) => new HtmlString('
52+
<span class="px-2 py-1 rounded-full text-sm"
53+
style="color: ' . $record->text_color . '; background-color: ' . $record->bg_color . '">
54+
' . $record->title . '
55+
</span>
5956
')),
6057

6158
BooleanColumn::make('default')
@@ -146,7 +143,8 @@ public function cancelStatus()
146143
*
147144
* @return void
148145
*/
149-
public function statusSaved() {
146+
public function statusSaved()
147+
{
150148
$this->cancelStatus();
151149
}
152150

@@ -155,7 +153,8 @@ public function statusSaved() {
155153
*
156154
* @return void
157155
*/
158-
public function statusDeleted() {
156+
public function statusDeleted()
157+
{
159158
$this->statusSaved();
160159
}
161160
}

app/Http/Livewire/Administration/TicketStatusesDialog.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class TicketStatusesDialog extends Component implements HasForms
2323

2424
protected $listeners = ['doDeleteStatus', 'cancelDeleteStatus'];
2525

26-
public function mount(): void {
26+
public function mount(): void
27+
{
2728
$this->form->fill([
2829
'title' => $this->status->title,
2930
'text_color' => $this->status->text_color,
@@ -49,9 +50,14 @@ protected function getFormSchema(): array
4950
TextInput::make('title')
5051
->label(__('Title'))
5152
->maxLength(255)
52-
->unique(table: TicketStatus::class, column: 'title', ignorable: fn () => $this->status, callback: function (Unique $rule) {
53-
return $rule->withoutTrashed();
54-
})
53+
->unique(
54+
table: TicketStatus::class,
55+
column: 'title',
56+
ignorable: fn() => $this->status,
57+
callback: function (Unique $rule) {
58+
return $rule->withoutTrashed();
59+
}
60+
)
5561
->required(),
5662

5763
ColorPicker::make('text_color')
@@ -73,7 +79,8 @@ protected function getFormSchema(): array
7379
*
7480
* @return void
7581
*/
76-
public function save(): void {
82+
public function save(): void
83+
{
7784
$data = $this->form->getState();
7885
if (!$this->status?->id) {
7986
$status = TicketStatus::create([
@@ -89,7 +96,7 @@ public function save(): void {
8996
->body(__('The status has been created'))
9097
->send();
9198
if ($status->default) {
92-
TicketStatus::where('id', '<>',$status->id)->update(['default' => false]);
99+
TicketStatus::where('id', '<>', $status->id)->update(['default' => false]);
93100
}
94101
} else {
95102
$this->status->title = $data['title'];
@@ -103,7 +110,7 @@ public function save(): void {
103110
->title(__('Status updated'))
104111
->body(__('The status\'s details has been updated'))
105112
->send();
106-
TicketStatus::where('id', '<>',$this->status->id)->update(['default' => false]);
113+
TicketStatus::where('id', '<>', $this->status->id)->update(['default' => false]);
107114
}
108115
if (TicketStatus::where('default', true)->count() === 0) {
109116
$first = TicketStatus::first();
@@ -118,7 +125,8 @@ public function save(): void {
118125
*
119126
* @return void
120127
*/
121-
public function doDeleteStatus(): void {
128+
public function doDeleteStatus(): void
129+
{
122130
$this->status->delete();
123131
$this->deleteConfirmationOpened = false;
124132
$this->emit('statusDeleted');
@@ -134,7 +142,8 @@ public function doDeleteStatus(): void {
134142
*
135143
* @return void
136144
*/
137-
public function cancelDeleteStatus(): void {
145+
public function cancelDeleteStatus(): void
146+
{
138147
$this->deleteConfirmationOpened = false;
139148
}
140149

@@ -144,7 +153,8 @@ public function cancelDeleteStatus(): void {
144153
* @return void
145154
* @throws \Exception
146155
*/
147-
public function deleteStatus(): void {
156+
public function deleteStatus(): void
157+
{
148158
$this->deleteConfirmationOpened = true;
149159
Notification::make()
150160
->warning()

app/Http/Livewire/Administration/TicketTypes.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@
22

33
namespace App\Http\Livewire\Administration;
44

5-
use App\Models\TicketStatus;
65
use App\Models\TicketType;
7-
use Filament\Forms\Components\Grid;
8-
use Filament\Forms\Components\TextInput;
9-
use Filament\Forms\Concerns\InteractsWithForms;
10-
use Filament\Forms\Contracts\HasForms;
116
use Filament\Tables\Actions\Action;
12-
use Filament\Tables\Columns\BooleanColumn;
137
use Filament\Tables\Columns\TextColumn;
148
use Filament\Tables\Concerns\InteractsWithTable;
159
use Filament\Tables\Contracts\HasTable;
@@ -53,8 +47,11 @@ protected function getTableColumns(): array
5347
->label(__('Title'))
5448
->searchable()
5549
->sortable()
56-
->formatStateUsing(fn (TicketType $record) => new HtmlString('
57-
<span class="px-2 py-1 rounded-full text-sm flex items-center gap-2" style="color: ' . $record->text_color . '; background-color: ' . $record->bg_color . '">
50+
->formatStateUsing(fn(TicketType $record) => new HtmlString('
51+
<span
52+
class="px-2 py-1 rounded-full text-sm flex items-center gap-2"
53+
style="color: ' . $record->text_color . '; background-color: ' . $record->bg_color . '"
54+
>
5855
<i class="fa ' . $record->icon . '"></i>' . $record->title . '
5956
</span>
6057
')),
@@ -142,7 +139,8 @@ public function cancelType()
142139
*
143140
* @return void
144141
*/
145-
public function typeSaved() {
142+
public function typeSaved()
143+
{
146144
$this->cancelType();
147145
}
148146

@@ -151,7 +149,8 @@ public function typeSaved() {
151149
*
152150
* @return void
153151
*/
154-
public function typeDeleted() {
152+
public function typeDeleted()
153+
{
155154
$this->typeSaved();
156155
}
157156
}

0 commit comments

Comments
 (0)