<?php namespace App\Libs\Composers\CF;

use Cobenefit;
use Technology;
use Standard;
use stdClass;
use Lang;

class CfProjectsComposer
{

    public function compose($view)
    {
        $australianProjects = (request()->get('australian_projects') == '1' ? true : false);
        $globalProjects = (request()->get('global_projects') == '1' ? true : false);
        $goldPowerProjects = (request()->get('goldpower_projects') == '1' ? true : false);

        if (!$australianProjects && !$globalProjects && !$goldPowerProjects) {
            $australianProjects = $globalProjects = $goldPowerProjects = true;
        }

        $cobenefits = Cobenefit::full()
            ->with('iconDark')
            ->orderBy('website_objects.position', 'asc')
            ->get();

        $technologies = Technology::full()
            ->where('show_cf', 1)
            ->orderBy('website_objects.position', 'asc')
            ->get();

        $standards = Standard::full()
            ->where('show_cf', 1)
            ->orderBy('website_objects.position', 'asc')
            ->get();

        $location = new stdClass();
        $location->id = 'africa';
        $location->title = Lang::get('frontend.africa');
        $locations[] = $location;

        $location = new stdClass();
        $location->id = 'asia';
        $location->title = Lang::get('frontend.asia');;
        $locations[] = $location;

        $location = new stdClass();
        $location->id = 'europe';
        $location->title = Lang::get('frontend.europe');;
        $locations[] = $location;

        $location = new stdClass();
        $location->id = 'north_america';
        $location->title = Lang::get('frontend.north_america');;
        $locations[] = $location;

        $location = new stdClass();
        $location->id = 'oceania';
        $location->title = Lang::get('frontend.oceania');;
        $locations[] = $location;

        $location = new stdClass();
        $location->id = 'south_america';
        $location->title = Lang::get('frontend.south_america');;
        $locations[] = $location;


        $view->with(array(
            'cobenefits' => $cobenefits,
            'technologies' => $technologies,
            'standards' => $standards,
            'locations' => $locations,
            'australianProjects' => $australianProjects,
            'globalProjects' => $globalProjects,
            'goldPowerProjects' => $goldPowerProjects
        ));
    }
}
