Completed
Push — master ( dab270...a45a25 )
by Abhishek Kumar
08:02
created

Import   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 60
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A importLogs() 0 3 1
A setModelMapAttribute() 0 3 1
A getDbColsAttribute() 0 3 1
A getModelMapAttribute() 0 3 1
A setDbColsAttribute() 0 3 1
1
<?php
2
3
namespace Ladybirdweb\ImportExport\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Import extends Model
8
{
9
    protected $fillable = ['file', 'file_rows', 'db_cols', 'row_processed'];
10
11
    /**
12
     * Relationship with import export log model.
13
     *
14
     * @return void
15
     */
16
    public function importLogs()
17
    {
18
        return $this->hasMany(\Ladybirdweb\ImportExport\Models\ImportExportLog::class, 'op_id');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->hasMany(La...ortLog::class, 'op_id') returns the type Illuminate\Database\Eloquent\Relations\HasMany which is incompatible with the documented return type void.
Loading history...
19
    }
20
21
    /**
22
     * Model Map accessor.
23
     *
24
     * Unserialize model map while retriving.
25
     * @param $value
26
     * @return string
27
     */
28
    public function getModelMapAttribute($value)
29
    {
30
        return unserialize($value);
31
    }
32
33
    /**
34
     * Model Map mulator.
35
     *
36
     * Serialize model map while storing.
37
     * @param $value
38
     * @return void
39
     */
40
    public function setModelMapAttribute($value)
41
    {
42
        $this->attributes['model_map'] = serialize($value);
43
    }
44
45
    /**
46
     * DB cols accessor.
47
     *
48
     * Unserialize model map while retriving.
49
     * @param $value
50
     * @return string
51
     */
52
    public function getDbColsAttribute($value)
53
    {
54
        return unserialize($value);
55
    }
56
57
    /**
58
     * Model Map mulator.
59
     *
60
     * Serialize model map while storing.
61
     * @param $value
62
     * @return void
63
     */
64
    public function setDbColsAttribute($value)
65
    {
66
        $this->attributes['db_cols'] = serialize($value);
67
    }
68
}
69