7 changed files with 1160 additions and 202 deletions
@ -0,0 +1,35 @@ |
|||
<?php |
|||
|
|||
namespace App\Exports; |
|||
|
|||
use App\Models\Marca; |
|||
use Maatwebsite\Excel\Concerns\FromCollection; |
|||
use Maatwebsite\Excel\Concerns\WithHeadings; |
|||
|
|||
class MarcasExport implements FromCollection, WithHeadings |
|||
{ |
|||
/** |
|||
* Método que devuelve la colección de datos a exportar. |
|||
* |
|||
* @return \Illuminate\Support\Collection |
|||
*/ |
|||
public function collection() |
|||
{ |
|||
return Marca::where('eliminado', 0) // Solo marcas activas |
|||
->select('id', 'marca') // Selecciona los campos que deseas exportar |
|||
->get(); |
|||
} |
|||
|
|||
/** |
|||
* Método que define los encabezados de las columnas en el archivo Excel. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function headings(): array |
|||
{ |
|||
return [ |
|||
'ID', // Encabezado para la columna ID |
|||
'Marca', // Encabezado para la columna Marca |
|||
]; |
|||
} |
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,44 @@ |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<title>Lista de Marcas</title> |
|||
<style> |
|||
table { |
|||
width: 100%; |
|||
border-collapse: collapse; |
|||
margin-bottom: 20px; |
|||
} |
|||
th, td { |
|||
border: 1px solid #ddd; |
|||
padding: 8px; |
|||
text-align: left; |
|||
} |
|||
th { |
|||
background-color: #f2f2f2; |
|||
} |
|||
h2 { |
|||
color: #333; |
|||
margin-bottom: 20px; |
|||
} |
|||
</style> |
|||
</head> |
|||
<body> |
|||
<h2>Lista de Marcas</h2> |
|||
<table> |
|||
<thead> |
|||
<tr> |
|||
<th>ID</th> |
|||
<th>Marca</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
@foreach($marcas as $marca) |
|||
<tr> |
|||
<td>{{ $marca->id }}</td> |
|||
<td>{{ $marca->marca }}</td> |
|||
</tr> |
|||
@endforeach |
|||
</tbody> |
|||
</table> |
|||
</body> |
|||
</html> |
Loading…
Reference in new issue