@@ 43-55 (lines=13) @@ | ||
40 | $model->delete(); |
|
41 | } |
|
42 | ||
43 | public function findByName($featureName) |
|
44 | { |
|
45 | /** @var Model $model */ |
|
46 | $model = Model::where('name', '=', $featureName)->first(); |
|
47 | if (!$model) { |
|
48 | throw new FeatureException('Unable to find the feature.'); |
|
49 | } |
|
50 | ||
51 | return Feature::fromNameAndStatus( |
|
52 | $model->name, |
|
53 | $model->is_enabled |
|
54 | ); |
|
55 | } |
|
56 | ||
57 | public function enableFor($featureName, FeaturableInterface $featurable) |
|
58 | { |
|
@@ 87-96 (lines=10) @@ | ||
84 | $featurable->features()->detach($model->id); |
|
85 | } |
|
86 | ||
87 | public function isEnabledFor($featureName, FeaturableInterface $featurable) |
|
88 | { |
|
89 | /** @var Model $model */ |
|
90 | $model = Model::where('name', '=', $featureName)->first(); |
|
91 | if (!$model) { |
|
92 | throw new FeatureException('Unable to find the feature.'); |
|
93 | } |
|
94 | ||
95 | return ($model->is_enabled) ? true : $featurable->hasFeature($featureName); |
|
96 | } |
|
97 | } |
|
98 |