Files
backend/app/Exports/AxisReport/AllSheet.php
2024-02-01 09:53:53 +00:00

49 lines
1.5 KiB
PHP

<?php
namespace App\Exports\AxisReport;
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
use App\Exports\AxisReport\ActivityReports;
use App\Exports\AxisReport\Projects;
use App\Exports\AxisReport\RoadObserved;
use App\Exports\AxisReport\RoadPatrol;
class AllSheet implements WithMultipleSheets
{
public function __construct($patrols, $activities, $projects, $observeds, $date_to, $date_from)
{
$this->patrols = $patrols;
$this->activities = $activities;
$this->projects = $projects;
$this->observeds = $observeds;
$this->date_to = $date_to;
$this->date_from = $date_from;
}
public function sheets(): array
{
$result = null;
if ($this->activities != null) {
$result[] = new ActivityReports($this->activities, $this->date_to, $this->date_from);
}
if ($this->patrols != null) {
$result[] = new RoadPatrol($this->patrols, $this->date_to, $this->date_from);
}
if ($this->observeds != null) {
$result[] = new RoadObserved($this->observeds, $this->date_to, $this->date_from);
}
if ($this->projects != null) {
$result[] = new Projects($this->projects, $this->date_to, $this->date_from);
}
if ($result) {
return $result;
} else {
dd("داده ای برای گزارش گیری وجود ندارد لطفا بعد از بررسی مقادیر فیلتر شده، مجدد اقدام نمایید.");
}
return $result;
}
}