Step::flow()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Hechoenlaravel\JarvisFoundation\Flows;
4
5
use Hechoenlaravel\JarvisFoundation\Flows\Transformers\StepTransformer;
6
use Illuminate\Database\Eloquent\Model;
7
use League\Fractal\Manager;
8
use League\Fractal\Resource\Item;
9
10
/**
11
 * Class Step
12
 * @package Modules\Flows\Entities
13
 */
14
class Step extends Model
15
{
16
    /**
17
     * @var string
18
     */
19
    public $table = "fl_flows_steps";
20
21
    /**
22
     * @var array
23
     */
24
    protected $fillable = ['name', 'description', 'order', 'is_last'];
25
26
    /**
27
     * The flow this step belongs to
28
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
29
     */
30
    public function flow()
31
    {
32
        return $this->belongsTo(Flow::class);
33
    }
34
35
    /**
36
     * The possible transitions from this step
37
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
38
     */
39
    public function transitions()
40
    {
41
        return $this->hasMany(Transition::class, 'step_from_id');
42
    }
43
44
    /**
45
     * Model Transformed
46
     * @return \League\Fractal\Scope
47
     */
48
    public function transformed()
49
    {
50
        $manager = new Manager();
51
        $resource = new Item($this, new StepTransformer());
52
        return $manager->createData($resource);
53
    }
54
}
55