Skip to content

Commit 3a4ccc3

Browse files
committed
feature: reorganized some table columns and changed some data inside them
1 parent 583bdac commit 3a4ccc3

File tree

8 files changed

+20
-16
lines changed

8 files changed

+20
-16
lines changed

app/Http/Controllers/RepairController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class RepairController extends Controller
99
public function index()
1010
{
1111
return Inertia::render('Repairs', [
12-
'repairs' => Repair::all()
12+
'repairs' => Repair::with(['repairType', 'vehicle.client'])->get()
1313
]);
1414
}
1515
}

app/Http/Controllers/VehicleController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class VehicleController extends Controller
99
public function index()
1010
{
1111
return Inertia::render('Vehicles', [
12-
'vehicles' => Vehicle::all()
12+
'vehicles' => Vehicle::with('client')->get()
1313
]);
1414
}
1515
}

app/Models/Vehicle.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Vehicle extends Model
99
{
1010
use HasFactory;
1111

12-
public function clients()
12+
public function client()
1313
{
1414
return $this->belongsTo(Client::class);
1515
}

resources/js/Components/DataTable.vue

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ const totalPages = computed(() => Math.ceil(totalItems.value / props.itemsPerPag
2424
const startIndex = computed(() => (currentPage.value - 1) * props.itemsPerPage);
2525
const endIndex = computed(() => Math.min(startIndex.value + props.itemsPerPage, totalItems.value));
2626
27+
const getNestedValue = (obj, path) => {
28+
return path.split('.').reduce((current, key) =>
29+
current ? current[key] : undefined, obj
30+
);
31+
};
32+
2733
const paginatedData = computed(() => {
2834
return props.data.slice(startIndex.value, endIndex.value);
2935
});
@@ -98,7 +104,7 @@ watch(() => props.data, () => {
98104
<td v-for="column in columns"
99105
:key="column.key"
100106
class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
101-
{{ item[column.key] }}
107+
{{ getNestedValue(item, column.key) }}
102108
</td>
103109
</tr>
104110
</tbody>

resources/js/Pages/Clients.vue

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ const props = defineProps({
1111
1212
const columns = [
1313
{ key: 'id', label: 'ID' },
14+
{ key: 'DNI', label: 'DNI' },
1415
{ key: 'name', label: 'Nombre' },
1516
{ key: 'email', label: 'Email' },
1617
{ key: 'telephone', label: 'Teléfono' },
1718
{ key: 'city', label: 'Ciudad' },
1819
{ key: 'postal_code', label: 'Código Postal' },
19-
{ key: 'DNI', label: 'DNI' },
20-
{ key: 'registered_at', label: 'Fecha de Registro' },
21-
{ key: 'created_at', label: 'Fecha de Creación' }
20+
{ key: 'registered_at', label: 'Fecha de Registro' }
2221
];
2322
</script>
2423

resources/js/Pages/DeliveryNotes/Show.vue

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ const columns = [
1818
{ key: 'cost', label: 'Coste' },
1919
{ key: 'margin', label: 'Margen' },
2020
{ key: 'profit', label: 'Beneficio' },
21-
{ key: 'added_at', label: 'Fecha de Alta' },
22-
{ key: 'created_at', label: 'Fecha de Creación' }
21+
{ key: 'added_at', label: 'Fecha de Alta' }
2322
];
2423
</script>
2524

resources/js/Pages/Repairs.vue

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ const props = defineProps({
1111
1212
const columns = [
1313
{ key: 'id', label: 'ID' },
14-
{ key: 'repair_type_id', label: 'Tipo de Reparación' },
15-
{ key: 'vehicle_id', label: 'ID Vehículo' },
14+
{ key: 'vehicle.client.name', label: 'Cliente' },
15+
{ key: 'vehicle.brand', label: 'Marca' },
16+
{ key: 'vehicle.plate_number', label: 'Matrícula' },
17+
{ key: 'repair_type.name', label: 'Tipo de Reparación' },
1618
{ key: 'observations', label: 'Observaciones' },
1719
{ key: 'status', label: 'Estado' },
18-
{ key: 'started_at', label: 'Fecha de Inicio' },
19-
{ key: 'created_at', label: 'Fecha de Creación' }
20+
{ key: 'started_at', label: 'Fecha de Inicio' }
2021
];
2122
</script>
2223

resources/js/Pages/Vehicles.vue

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ const props = defineProps({
1111
1212
const columns = [
1313
{ key: 'id', label: 'ID' },
14-
{ key: 'client_id', label: 'ID Cliente' },
14+
{ key: 'client.name', label: 'Cliente' },
1515
{ key: 'plate_number', label: 'Matrícula' },
1616
{ key: 'brand', label: 'Marca' },
1717
{ key: 'model', label: 'Modelo' },
1818
{ key: 'VIN', label: 'VIN' },
1919
{ key: 'motor_type', label: 'Tipo de Motor' },
20-
{ key: 'added_at', label: 'Fecha de Alta' },
21-
{ key: 'created_at', label: 'Fecha de Creación' }
20+
{ key: 'added_at', label: 'Fecha de Alta' }
2221
];
2322
</script>
2423

0 commit comments

Comments
 (0)