Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| CollectionProducts | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
5 | |
100.00% |
1 / 1 |
| label | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
| icon | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| description | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| fields | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| collection | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace App\Widgets\Types; |
| 3 | use App\Models\ProductCollection; |
| 4 | use App\Widgets\AbstractWidget; |
| 5 | class CollectionProducts extends AbstractWidget { |
| 6 | protected string $view='widgets.collection-products'; |
| 7 | public function label():string{return 'Product collection';} public function icon():string{return 'fas fa-layer-group';} |
| 8 | public function description():string{return 'Products selected in one of your collections.';} |
| 9 | public function fields():array{return ['collection_id'=>['type'=>'select','label'=>'Collection','default'=>'','options'=>[''=>'Choose collection']+ProductCollection::where('is_active',true)->orderBy('name')->pluck('name','id')->all()],'title'=>['type'=>'text','label'=>'Custom heading (optional)','default'=>''],'layout'=>['type'=>'select','label'=>'Layout','default'=>'carousel','options'=>['carousel'=>'Sliding carousel','grid'=>'Grid']],'limit'=>['type'=>'number','label'=>'How many products','default'=>8]];} |
| 10 | public function collection(array $s){return ProductCollection::where('is_active',true)->find($s['collection_id']??null);} |
| 11 | } |