Passed
Push — master ( 336a24...a4f66d )
by Mihail
14:10
created

FormContentGlobDelete::before()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 11
rs 9.4286
cc 2
eloc 6
nc 2
nop 0
1
<?php
2
3
namespace Apps\Model\Admin\Content;
4
5
6
use Ffcms\Core\Arch\Model;
7
use Ffcms\Core\Helper\Date;
8
use Ffcms\Core\Helper\Serialize;
9
10
class FormContentGlobDelete extends Model
11
{
12
    private $_records;
13
14
    public $data = [];
15
16
    public function __construct($records)
17
    {
18
        $this->_records = $records;
19
        parent::__construct();
20
    }
21
22
    public function before()
23
    {
24
        // set data to display in view
25
        foreach ($this->_records as $row) {
26
            $this->data[] = [
27
                'id' => $row->id,
28
                'title' => Serialize::getDecodeLocale($row->title),
29
                'date' => Date::convertToDatetime($row->created_at, Date::FORMAT_TO_HOUR)
30
            ];
31
        }
32
    }
33
34
    public function make()
35
    {
36
        foreach ($this->_records as $record) {
37
            $record->delete();
38
        }
39
    }
40
41
42
}