2019-12-14 22:03:41 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Exports;
|
|
|
|
|
|
|
|
use App\Subject;
|
|
|
|
use App\Classes;
|
|
|
|
use Maatwebsite\Excel\Concerns\FromView;
|
|
|
|
use Illuminate\Contracts\View\View;
|
|
|
|
use Maatwebsite\Excel\Concerns\WithTitle;
|
|
|
|
|
|
|
|
class AttendanceGroupedExportSingleView implements FromView, WithTitle
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Support\Collection
|
|
|
|
*/
|
|
|
|
|
|
|
|
private $attendances;
|
|
|
|
private $groupBy;
|
|
|
|
private $groupedValue;
|
|
|
|
|
|
|
|
public function __construct($attendances, $groupBy, $groupedValue)
|
|
|
|
{
|
|
|
|
$this->attendances = $attendances;
|
|
|
|
$this->groupBy = $groupBy;
|
|
|
|
$this->groupedValue = $groupedValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function view(): View
|
|
|
|
{
|
|
|
|
return view('user.attendances_table', ['attendances_list' => $this->attendances, 'export' => 1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function title(): string
|
|
|
|
{
|
|
|
|
if($this->groupBy == 'classes_id') {
|
|
|
|
|
2020-03-06 18:33:03 +01:00
|
|
|
$subject = Subject::findOrFail(Classes::find($this->groupedValue)->subject_id)->name;
|
|
|
|
$date = Classes::findOrFail($this->groupedValue)->date;
|
2019-12-14 22:03:41 +01:00
|
|
|
|
2019-12-14 22:41:09 +01:00
|
|
|
$this->groupedValue = "{$date} {$subject}";
|
2020-03-03 15:24:09 +01:00
|
|
|
} else if($this->groupBy == 'seat_number') {
|
|
|
|
$this->groupedValue = "{$this->groupedValue}";
|
2019-12-14 22:03:41 +01:00
|
|
|
}
|
2019-12-14 22:38:00 +01:00
|
|
|
return substr(str_replace(":", "-", "{$this->groupedValue}"), 0, 30);
|
2019-12-14 22:03:41 +01:00
|
|
|
}
|
|
|
|
}
|