Total Complexity | 11 |
Total Lines | 96 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | class Round extends Base |
||
8 | { |
||
9 | use Traits\HasProperty; |
||
|
|||
10 | |||
11 | /** |
||
12 | * @const |
||
13 | */ |
||
14 | const STATUS_PENDING = 0; |
||
15 | |||
16 | /** |
||
17 | * @const |
||
18 | */ |
||
19 | const STATUS_OPENED = 1; |
||
20 | |||
21 | /** |
||
22 | * @const |
||
23 | */ |
||
24 | const STATUS_CLOSED = 2; |
||
25 | |||
26 | /** |
||
27 | * Indicates if the model should be timestamped. |
||
28 | * |
||
29 | * @var bool |
||
30 | */ |
||
31 | public $timestamps = false; |
||
32 | |||
33 | /** |
||
34 | * The attributes that are mass assignable. |
||
35 | * |
||
36 | * @var array |
||
37 | */ |
||
38 | protected $fillable = [ |
||
39 | 'title', |
||
40 | 'status', |
||
41 | 'notes', |
||
42 | ]; |
||
43 | |||
44 | public function startAt(): Attribute |
||
45 | { |
||
46 | return Attribute::make( |
||
47 | get: function() { |
||
48 | $startSession = $this->sessions()->orderBy('start_at')->first(); |
||
49 | return !$startSession ? null : $startSession->start_at; |
||
50 | }, |
||
51 | ); |
||
52 | } |
||
53 | |||
54 | public function endAt(): Attribute |
||
55 | { |
||
56 | return Attribute::make( |
||
57 | get: function() { |
||
58 | $endSession = $this->sessions()->orderByDesc('start_at')->first(); |
||
59 | return !$endSession ? null : $endSession->start_at; |
||
60 | }, |
||
61 | ); |
||
62 | } |
||
63 | |||
64 | public function pending(): Attribute |
||
65 | { |
||
66 | return Attribute::make( |
||
67 | get: fn() => $this->status === self::STATUS_PENDING, |
||
68 | ); |
||
69 | } |
||
70 | |||
71 | public function opened(): Attribute |
||
75 | ); |
||
76 | } |
||
77 | |||
78 | public function closed(): Attribute |
||
79 | { |
||
80 | return Attribute::make( |
||
81 | get: fn() => $this->status === self::STATUS_CLOSED, |
||
82 | ); |
||
83 | } |
||
84 | |||
85 | public function tontine() |
||
86 | { |
||
87 | return $this->belongsTo(Tontine::class); |
||
88 | } |
||
89 | |||
90 | public function pools() |
||
91 | { |
||
92 | return $this->hasMany(Pool::class); |
||
93 | } |
||
94 | |||
95 | public function sessions() |
||
98 | } |
||
99 | |||
100 | public function bills() |
||
101 | { |
||
102 | return $this->hasMany(RoundBill::class); |
||
103 | } |
||
104 | } |
||
105 |