Skip to content

Commit

Permalink
Improved code on preparing <x-ts-table />
Browse files Browse the repository at this point in the history
  • Loading branch information
MGeurts committed Dec 8, 2024
1 parent bf3c345 commit c99b69a
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 71 deletions.
18 changes: 9 additions & 9 deletions resources/views/livewire/people/history.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ class="print:break-before-page flex flex-col rounded bg-white shadow-[0_2px_15px
@php
$headers = [['index' => 'attribute', 'label' => __('app.attribute')], ['index' => 'old', 'label' => __('app.old')], ['index' => 'new', 'label' => __('app.new')]];
$rows = [];
foreach ($activity['new'] as $key => $value) {
array_push($rows, [
'attribute' => $key,
'old' => $activity['old'] ? $activity['old'][$key] : null,
'new' => $value,
]);
}
$rows = collect($activity['new'])
->map(function ($value, $key) use ($activity) {
return [
'attribute' => $key,
'old' => $activity['old'][$key] ?? null,
'new' => $value,
];
})
->toArray();
@endphp

<x-ts-table :$headers :$rows />
Expand Down
30 changes: 16 additions & 14 deletions resources/views/livewire/peoplelog.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
@php
$headers = [['index' => 'key', 'label' => 'Key'], ['index' => 'value', 'label' => __('app.old')]];
$rows = [];
foreach ($log['properties_old'] as $key => $value) {
array_push($rows, [
'key' => $key,
'value' => $value,
]);
}
$rows = collect($log['properties_old'])
->map(function ($value, $key) {
return [
'key' => $key,
'value' => $value,
];
})
->toArray();
@endphp

<x-ts-table :$headers :$rows />
Expand All @@ -55,12 +55,14 @@
$rows = [];
foreach ($log['properties_new'] as $key => $value) {
array_push($rows, [
'key' => $key,
'value' => $value,
]);
}
$rows = collect($log['properties_new'])
->map(function ($value, $key) {
return [
'key' => $key,
'value' => $value,
];
})
->toArray();
@endphp

<x-ts-table :$headers :$rows />
Expand Down
46 changes: 24 additions & 22 deletions resources/views/livewire/teamlog.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@
$rows = [];
foreach ($log['properties_old'] as $key => $value) {
array_push($rows, [
'key' => $key,
'value' => $value,
]);
}
$rows = collect($log['properties_old'])
->map(function ($value, $key) {
return [
'key' => $key,
'value' => $value,
];
})
->toArray();
@endphp

<x-ts-table :$headers :$rows />
Expand All @@ -47,14 +49,14 @@
@php
$headers = [['index' => 'key', 'label' => 'Key'], ['index' => 'value', 'label' => __('app.new')]];
$rows = [];
foreach ($log['properties_new'] as $key => $value) {
array_push($rows, [
'key' => $key,
'value' => $value,
]);
}
$rows = collect($log['properties_new'])
->map(function ($value, $key) {
return [
'key' => $key,
'value' => $value,
];
})
->toArray();
@endphp

<x-ts-table :$headers :$rows />
Expand All @@ -63,14 +65,14 @@
@php
$headers = [['index' => 'key', 'label' => 'Key'], ['index' => 'value', 'label' => __('value')]];
$rows = [];
foreach ($log['properties'] as $key => $value) {
array_push($rows, [
'key' => $key,
'value' => $value,
]);
}
$rows = collect($log['properties'])
->map(function ($value, $key) {
return [
'key' => $key,
'value' => $value,
];
})
->toArray();
@endphp

<x-ts-table :$headers :$rows />
Expand Down
24 changes: 11 additions & 13 deletions resources/views/profile/delete-user-form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,17 @@
['index' => 'personal', 'label' => __('team.team_personal') . '?'],
];
$rows = [];
$teams = auth()->user()->teamsStatistics();
foreach ($teams as $team) {
array_push($rows, [
'team' => $team->name,
'users' => $team->users_count > 0 ? $team->users_count : '',
'persons' => $team->persons_count > 0 ? $team->persons_count : '',
'couples' => $team->couples_count > 0 ? $team->couples_count : '',
'personal' => $team->personal_team,
]);
}
$rows = collect(auth()->user()->teamsStatistics())
->map(function ($team) {
return [
'team' => $team->name,
'users' => $team->users_count > 0 ? $team->users_count : '',
'persons' => $team->persons_count > 0 ? $team->persons_count : '',
'couples' => $team->couples_count > 0 ? $team->couples_count : '',
'personal' => $team->personal_team,
];
})
->toArray();
@endphp

<x-ts-table :$headers :$rows>
Expand Down
14 changes: 1 addition & 13 deletions resources/views/teams/delete-team-form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,7 @@
</x-slot>

<x-slot name="content">
@php
$headers = [['index' => 'object', 'label' => $team->name], ['index' => 'count', 'label' => '#']];
$rows = [
['object' => __('team.users'), 'count' => count($team->users)],
['object' => __('team.persons'), 'count' => count($team->persons)],
['object' => __('team.couples'), 'count' => count($team->couples)],
];
@endphp

<x-ts-table :$headers :$rows />

<x-hr.normal />
@livewire('team.status', ['team' => $team])

@if ($team->isDeletable())
<div class="max-w-xl text-sm text-gray-600">
Expand Down

0 comments on commit c99b69a

Please sign in to comment.