Passed
Pull Request — dev (#47)
by Stone
04:17 queued 01:57
created

IncludesModel::getMenu()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 0
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Models;
4
5
use Core\Model;
6
7
/**
8
 * Class IncludesModel
9
 * All the included views data (menu, jumbotron, ...)
10
 * the returned data should then be stored in a $data['var'] and the view will check if var is set
11
 * @package App\Models
12
 */
13
class IncludesModel extends Model
14
{
15
    /**
16
     * get all the menu elements from the database
17
     * @return array the categories and access URL
18
     * @throws \ReflectionException
19
     */
20
    public function getMenu(): array
21
    {
22
        $data = [];
23
        //get the categories from database
24
        $categories = $this->getResultSet('categories');
25
        foreach ($categories as $category) {
26
            $data += [
27
                $category->category_name => '/category/' . $category->categories_slug
28
            ];
29
        }
30
        return $data;
31
    }
32
}