Libraries\PError\PError->handleError():19 PHP 8.1.19

Undefined array key "guides"

/home/filepedia/public_html/framework/functions/theme.php:19

7
8
function generate_categories(array $config)
9
{
10
    $categories Category::select('p.id, t1.title, t1.slug')
11
        ->join(CategoryMetadata::class, 't1.category = p.id AND t1.language = "' $config['language'] . '"')
12
        ->where('p.parent is NULL')
13
        ->fetch(\PDO::FETCH_ASSOC)
14
        ->get();
15
16
    if (!$categories->isEmpty()) {
17
        $sql = [];
18
        foreach ($categories->all() as $category) {
19
            $sql[] = '(SELECT DISTINCT p.id, t2.title, t2.slug, p.parent FROM ' Category::tableName() . ' as p JOIN ' Product::tableName() . ' as t1 ON t1.category = p.id ' . (isset($config['platform']) ? ' AND t1.platform = ' Product::PLATFORM[$config['platform']] : '') . ' JOIN ' ProductMetadata::tableName() . ' as mt ON mt.product = t1.id AND mt.language = "' $config['language'] . '" JOIN ' CategoryMetadata::tableName() . ' as t2 ON t2.category = p.id AND t2.language = "' $config['language'] . '" WHERE p.parent = ' $category['id'] . ' LIMIT ' . ($config['subcat_limit'] ?? 10) . ')';
20
        }
21
        $sql database()->prepare(join(' UNION '$sql));
22
        $sql->execute();
23
        foreach ($sql->fetchAll(\PDO::FETCH_ASSOC) as $category) {
24
            $categories->findAndPush(['id' => $category['parent']], ['subcategories' => $category]);
25
        }
26
    }
27
28
    $empty_sql = [];
29
    foreach ($categories->all() as $cat) {
30
        if (!isset($cat['subcategories']) || (isset($cat['subcategories']) && empty($cat['subcategories']))) {
31
            $empty_sql[] = '(SELECT p.category FROM ' Product::tableName() . ' as p JOIN ' ProductMetadata::tableName() . ' as mt ON mt.product = p.id AND mt.language = "' $config['language'] . '" JOIN ' CategoryMetadata::tableName() . ' as ct ON ct.category = p.category AND ct.language = "' $config['language'] . '" WHERE p.category = ' $cat['id'] . (isset($config['platform']) ? ' AND p.platform = ' Product::PLATFORM[$config['platform']] : '') . ' LIMIT 1)';
32
        }