@@ 7-29 (lines=23) @@ | ||
4 | ||
5 | use Illuminate\Database\Eloquent\Model; |
|
6 | ||
7 | class Experiment extends Model |
|
8 | { |
|
9 | protected $table = 'ab_experiments'; |
|
10 | ||
11 | protected $fillable = [ |
|
12 | 'name', |
|
13 | 'visitors', |
|
14 | ]; |
|
15 | ||
16 | protected $casts = [ |
|
17 | 'visitors' => 'integer', |
|
18 | ]; |
|
19 | ||
20 | public function goals() |
|
21 | { |
|
22 | return $this->hasMany(Goal::class); |
|
23 | } |
|
24 | ||
25 | public function incrementVisitor() |
|
26 | { |
|
27 | $this->increment('visitors'); |
|
28 | } |
|
29 | } |
|
30 |
@@ 7-29 (lines=23) @@ | ||
4 | ||
5 | use Illuminate\Database\Eloquent\Model; |
|
6 | ||
7 | class Goal extends Model |
|
8 | { |
|
9 | protected $table = 'ab_goals'; |
|
10 | ||
11 | protected $fillable = [ |
|
12 | 'name', |
|
13 | 'hit', |
|
14 | ]; |
|
15 | ||
16 | protected $casts = [ |
|
17 | 'hit' => 'integer', |
|
18 | ]; |
|
19 | ||
20 | public function experiment() |
|
21 | { |
|
22 | return $this->belongsTo(Experiment::class); |
|
23 | } |
|
24 | ||
25 | public function incrementHit() |
|
26 | { |
|
27 | $this->increment('hit'); |
|
28 | } |
|
29 | } |
|
30 |