Completed
Push — master ( 5e49b6...2ab591 )
by David Martínez
07:18
created

Lesson::validateStep1step2()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 9.4285
cc 2
eloc 3
nc 2
nop 0
crap 6
1
<?php
2
3
namespace Scool\Timetables\Models;
4
5
use Acacha\Stateful\Contracts\Stateful;
6
use Acacha\Stateful\Traits\StatefulTrait;
7
use Illuminate\Database\Eloquent\Model;
8
use Prettus\Repository\Contracts\Transformable;
9
use Prettus\Repository\Traits\TransformableTrait;
10
11
/**
12
 * Class Lesson
13
 * @package Scool\Timetables\Models
14
 */
15
class Lesson extends Model implements Transformable, Stateful
16
{
17
    use TransformableTrait, StatefulTrait;
18
19
    protected $fillable = ['id','location_id','day_id','timeslot_id','classroom_id', 'state'];
20
21
    /**
22
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
23
     */
24
    public function locations()
25
    {
26
        return $this->belongsTo(\Scool\Timetables\Models\Location::class);
27
    }
28
29
    /**
30
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
31
     */
32
    public function days()
33
    {
34
        return $this->belongsTo(\Scool\Timetables\Models\Day::class);
35
    }
36
37
    /**
38
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
39
     */
40
    public function timeslots()
41
    {
42
        return $this->belongsTo(\Scool\Timetables\Models\Timeslot::class);
43
    }
44
45
    /**
46
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
47
     */
48
    public function classrooms()
49
    {
50
        return $this->belongsTo(\Scool\Timetables\Models\Classroom::class);
51
    }
52
53
    /**
54
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
55
     */
56
    public function users()
57
    {
58
        return $this->belongsToMany(\App\User::class);
59
    }
60
61
    /**
62
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
63
     */
64
    public function submodules()
65
    {
66
        return $this->belongsToMany(\Submodule::class); //TODO
67
    }
68
69
    /**
70
     * States.
71
     *
72
     * @var array
73
     */
74
    protected $states = [
75
        'step1' => ['initial' => true],
76
        'step2' => ['final' => true]
77
    ];
78
    /**
79
     * Transaction State Transitions
80
     *
81
     * @var array
82
     */
83
    protected $transitions = [
84
        'step1step2' => [
85
            'from' => 'step1',
86
            'to' => 'step2'
87
        ],
88
        'step2step1' => [
89
            'from' => 'step2',
90
            'to' => 'step1'
91
        ]
92
    ];
93
    /**
94
     * @return bool
95
     */
96
    protected function validateStep1step2()
97
    {
98
        if ($this->location_id != null) return true;
99
        return false;
100
    }
101
    /**
102
     * @return bool
103
     */
104
    protected function validateStep2step1()
105
    {
106
        return false;
107
    }
108
109
}
110