Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 4 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
ShortcutSubCategoryLv2 | |
0.00% |
0 / 4 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
boot | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
subCategoryLv1 | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
shortcuts | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getShortcutsCountAttribute | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace App\Http\Models; |
4 | |
5 | use App\Observers\ShortcutSubCategoryLv2Observer; |
6 | use Illuminate\Database\Eloquent\Attributes\ObservedBy; |
7 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
8 | use Illuminate\Notifications\Notifiable; |
9 | |
10 | #[ObservedBy([ShortcutSubCategoryLv2Observer::class])] |
11 | class ShortcutSubCategoryLv2 extends Moloquent |
12 | { |
13 | use HasFactory, Notifiable; |
14 | |
15 | protected $table = 'shortcut_sub_categories_lv2'; |
16 | |
17 | protected $fillable = [ |
18 | 'name', |
19 | 'user_id', |
20 | 'seq_id', |
21 | 'sub_categories_lv1' |
22 | ]; |
23 | |
24 | protected $appends = ['shortcuts_count']; |
25 | |
26 | protected static function boot() |
27 | { |
28 | parent::boot(); |
29 | } |
30 | |
31 | public function subCategoryLv1() |
32 | { |
33 | return $this->belongsTo(ShortcutSubCategoryLv1::class, 'sub_categories_lv1'); |
34 | } |
35 | |
36 | public function shortcuts() |
37 | { |
38 | return $this->hasMany(Shortcut::class, 'sub_categories_lv2_id'); |
39 | } |
40 | |
41 | public function getShortcutsCountAttribute() |
42 | { |
43 | return $this->shortcuts()->count(); |
44 | } |
45 | } |