MethodDeliveryPayment::getImageAttribute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
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