MethodDeliveryPayment   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 4
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getImageAttribute() 0 7 2
A delete() 0 9 3
1
<?php
2
namespace App;
3
use Keyhunter\Administrator\Repository;
4
use Keyhunter\Translatable\HasTranslations;
5
use App\Traits\ActivateableTrait;
6
class MethodDeliveryPayment extends Repository
7
{
8
    use HasTranslations,ActivateableTrait;
9
10
    public $translationModel = MethodDeliveryPaymentTransaltion::class;
11
    /**
12
     * @var string
13
     */
14
    protected $table = 'method_delivery_payment';
15
16
    /**
17
     * @var array
18
     */
19
20
    protected $fillable = ['active','type','ico'];
21
22
    /**
23
     * @var array
24
     */
25
    public $translatedAttributes = ['name'];
26
    
27
    public function getImageAttribute($value)
28
    {
29
        //add full path to image
30
      if (!empty($value)) {
31
        return str_replace('\\', '/', $value);
32
      }
33
    }
34
35
    public function delete(){
36
        if($this->attributes['ico']){
37
            $file = $this->attributes['ico'];
38
            if(File::exists(public_path($file))){
39
                \File::delete(public_path($file));
40
            }
41
        }
42
        parent::delete();
43
    }
44
}
45