Implementacion de modulo de pedidos
This commit is contained in:
58
app/exports/PedidosExport.php
Normal file
58
app/exports/PedidosExport.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Invoice;
|
||||
use App\Models\Movimiento;
|
||||
use App\Models\Pedido;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
|
||||
class PedidosExport implements FromView{
|
||||
|
||||
public $fecha_inicio, $fecha_final;
|
||||
public $is_venta_cerrada, $is_venta_entregada;
|
||||
|
||||
public function __construct($fecha_inicio, $fecha_final, $is_venta_cerrada, $is_venta_entregada)
|
||||
{
|
||||
$this->fecha_inicio = $fecha_inicio;
|
||||
$this->fecha_final = $fecha_final;
|
||||
$this->is_venta_cerrada = $is_venta_cerrada;
|
||||
$this->is_venta_entregada = $is_venta_entregada;
|
||||
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return Pedido::select(
|
||||
'pedido',
|
||||
'cuenta',
|
||||
'telefono',
|
||||
'year',
|
||||
'marca',
|
||||
'modelo',
|
||||
'motor',
|
||||
)->get();
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$query = Pedido::query();
|
||||
|
||||
$query->when($this->is_venta_entregada, function ($query) {
|
||||
return $query->where('is_venta_entregada',"=",$this->is_venta_entregada);
|
||||
});
|
||||
$query->when($this->is_venta_cerrada, function ($query) {
|
||||
return $query->where('is_venta_cerrada',"=",$this->is_venta_cerrada);
|
||||
});
|
||||
|
||||
$query->when(($this->fecha_inicio && $this->fecha_final), function ($query) {
|
||||
return $query->whereBetween('created_at', [$this->fecha_inicio, $this->fecha_final]);
|
||||
});
|
||||
|
||||
return view('export.reportePedidoExport',[
|
||||
// 'pedidos' => Pedido::whereBetween('created_at',[$this->fecha_inicio,$this->fecha_final])->get(),
|
||||
'pedidos' => $query->get(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user