Conditions | 3 |
Paths | 2 |
Total Lines | 14 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
17 | public function categories() |
||
18 | { |
||
19 | if (!$this->get('category') || !is_array($this->get('category'))) { |
||
|
|||
20 | return []; |
||
21 | } |
||
22 | |||
23 | //$this->get("category") is an array of category SLUGs and we need IDs |
||
24 | |||
25 | // check they are valid, return the IDs |
||
26 | // limit to 1000 ... just in case someone submits with too many for the web server. No error is given if they submit more than 1k. |
||
27 | $vals = Category::whereIn('id', array_keys($this->get('category')))->select('id')->limit(1000)->get(); |
||
28 | $vals = array_values($vals->pluck('id')->toArray()); |
||
29 | |||
30 | return $vals; |
||
31 | } |
||
33 |