HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/zuiderbos.komma.pro/Komma/Faq/Composers/FaqComposer.php
<?php


namespace Komma\Faq\Composers;


use Komma\Faq\Models\Faq;

class FaqComposer
{

    /**
     * Provide footer with navigation
     *
     * @param $view
     */
    public function compose($view)
    {

        $faq = Faq::where('lft', '!=', 1)
            ->with('translation')
            ->with('schools')
            ->where('active', 1)
            ->orderBy('lft')
            ->get();

        $homeFaq = [];


        foreach($faq as $item){

            //Check if school or global isset
            if(! isset($item->schools)) continue;

            $global = false;

            foreach ($item->schools as $faqSchool){
                if( $faqSchool->id == 6 ) $global = true;
            }

            if($global) $homeFaq[] = $item;
        }

        $view->with(['faq'=> $homeFaq]);
    }

}