I need to know how to create a dropdown list with maatwebsite/excel. The thing would be to eliminate from the table Term 1, 2, 3... and leave 2 drop-down lists, one with the amounts of the deadlines and the other with the statuses of the deadlines.
This is my export class.
<?php
namespace App\Exports;
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
class InformeExport implements WithMultipleSheets
{
protected $lista;
public function __construct($lista)
{
$this->lista = $lista;
}
public function sheets(): array
{
$sheets = [];
$sheets[] = new InformePlazosSheet($this->lista, 'Plazos');
return $sheets;
}
}
This is the InformePlazosSheet file.
<?php
namespace App\Exports;
use App\Models\Abonado;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\WithTitle;
class InformePlazosSheet implements FromView, WithTitle
{
private $lista;
private $nombre;
public function __construct($lista, $nombre)
{
$this->lista = $lista;
$this->nombre = $nombre;
}
/**
* @return Builder
*/
public function view(): View
{
$abonados = Abonado::join('abonado_lista_abonado_plazos', 'abonado_lista_abonado.id', '=', 'abonado_lista_abonado_plazos.abonado_lista_abonado_id')
->where('abonado_lista_abonado.lista_id', $this->lista->id)
->select('abonado_lista_abonado.*')
->groupBy('abonado_lista_abonado.id')
->with('plazos')
->get();
return view('exports.taquilla_plazos', [
'abonados' => $abonados
]);
}
/**
* @return string
*/
public function title(): string
{
return $this->nombre;
}
}
?>
And this is the view file.
<table>
<thead>
<tr>
<th>Abonado</th>
<th>DNI</th>
<th>Email</th>
<th>Método de pago</th>
<th>Titular de la cuenta</th>
<th>Iban</th>
<th>Plazo 1 - importe</th>
<th>Plazo 1 - estado</th>
<th>Plazo 2 - importe</th>
<th>Plazo 2 - estado</th>
<th>Plazo 3 - importe</th>
<th>Plazo 3 - estado</th>
</tr>
</thead>
<tbody>
@foreach($abonados as $abonado)
<tr>
<td>{{ $abonado->getNombreCompleto() }}</td>
<td>{{ $abonado->dni }}</td>
<td>{{ $abonado->email }}</td>
<td>{{ $abonado->metodoDePagoTostring() }}</td>
<td>{{ $abonado->titular_cuenta }}</td>
<td>{{ $abonado->iban }}</td>
@foreach($abonado->plazos as $plazo)
<td>
{{ App\Libraries\Utils::formatearPrecio($plazo->getImporteTotal()) }}
</td>
<td>
{{ $plazo->pagado ? 'Pagado (' . $plazo->getFechaPago() . ')' : 'Pago pendiente' }}
</td>
@endforeach
</tr>
@endforeach
</tbody>
</table>
I have looked at the documentation, laravel cast, tried many things and I can't get it. I am using Laravel 6 and php 7.4. Please help me if you can.