Completed
Push — development ( 98c85a...de3a5b )
by Claudio
03:47
created

Ban::getBanExpireAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace App\Models;
4
5
/**
6
 * Class Ban
7
 * @package App\Models
8
 */
9
class Ban extends ChocolateyModel
10
{
11
    /**
12
     * Disable Timestamps
13
     *
14
     * @var bool
15
     */
16
    public $timestamps = false;
17
18
    /**
19
     * The table associated with the model.
20
     *
21
     * @var string
22
     */
23
    protected $table = 'bans';
24
25
    /**
26
     * Primary Key of the Table
27
     *
28
     * @var string
29
     */
30
    protected $primaryKey = 'id';
31
32
    /**
33
     * Store an User Ban
34
     *
35
     * @param int $userId
36
     * @param int $userStaffId
37
     * @param string $banReason
38
     * @param string $banType (Account, IP, Machine, Super)
39
     * @param int $banExpire
40
     * @param string $ipAddress
41
     * @param string $machineId
42
     * @return Ban
43
     */
44
    public function store(int $userId, int $userStaffId, string $banReason, $banType = 'account', $banExpire = 0, $ipAddress = '', $machineId = ''): Ban
45
    {
46
        $this->attributes['user_id'] = $userId;
47
        $this->attributes['user_staff_id'] = $userStaffId;
48
        $this->attributes['ban_reason'] = $banReason;
49
        $this->attributes['ban_expire'] = $banExpire;
50
        $this->attributes['timestamp'] = time();
51
        $this->attributes['ip'] = $ipAddress;
52
        $this->attributes['type'] = $banType;
53
        $this->attributes['machine_id'] = $machineId;
54
55
        return $this;
56
    }
57
58
    /**
59
     * Get Ban Expire Attribute
60
     *
61
     * @return string
62
     */
63
    public function getBanExpireAttribute(): string
64
    {
65
        return date('M/d/Y h:m A', $this->attributes['ban_expire']);
66
    }
67
}
68