Passed
Push — main ( 847231...5f2f7c )
by Richard
05:35
created

HouseAd::getUrlImagePortraitAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Furic\HouseAds\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Furic\GameEssentials\Models\Game;
7
8
class HouseAd extends Model
9
{
10
11
    protected $guarded = [];
12
13
    protected $hidden = ['game_id', 'media_portrait', 'media_landscape', 'confirmed_count', 'cancelled_count', 'start_at', 'end_at', 'created_at', 'updated_at'];
14
15
    protected $appends = ['url_media_portrait', 'url_media_landscape', 'game'];
16
17
    public function getUrlMediaPortraitAttribute()
18
    {
19
        return url('/media/'.$this->media_portrait);
20
    }
21
22
    public function getUrlMediaLandscapeAttribute()
23
    {
24
        return url('/media/'.$this->media_landscape);
25
    }
26
27
    public function game()
28
    {
29
        return $this->belongsTo(Game::class);
30
    }
31
32
    public function getGameAttribute()
33
    {
34
        return $this->game()->first();
35
    }
36
37
}
38