FormResponse::downloadAll()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace App\Models;
4
5
use Excel;
6
use Illuminate\Database\Eloquent\Model;
7
8
class FormResponse extends Model
9
{
10
    protected $guarded = ['id'];
11
12
    public static function downloadAll()
13
    {
14
        Excel::create('Responses '.date('Y-m-d'), function ($excel) {
15
            $excel->sheet('Responses', function ($sheet) {
16
                $sheet->freezeFirstRow();
17
18
                $sheet->cells('A1:Z1', function ($cells) {
19
                    $cells->setFontWeight('bold');
20
                    $cells->setBorder('node', 'none', 'solid', 'none');
21
                });
22
23
                $sheet->fromModel(self::all());
24
            });
25
        })->download('xlsx');
26
    }
27
}
28