Sindbad~EG File Manager

Current Path : /var/www/html/votacao.camarasap.rs.gov.br/src/Controller/
Upload File :
Current File : /var/www/html/votacao.camarasap.rs.gov.br/src/Controller/DashboardController.php

<?php
declare(strict_types=1);

namespace App\Controller;

/**
 * Dashboard Controller
 *
 * @method \App\Model\Entity\Dashboard[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = [])
 */
class DashboardController extends AppController
{
    /**
     * Index method
     *
     * @return \Cake\Http\Response|null|void Renders view
     */
    public function index()
    {

    	$this->loadModel('Votings');
    	$this->loadModel('Councilors');
    	$this->loadModel('PoliticalParties');
    	$this->loadModel('Meetings');

		$user = $this->Authentication->getIdentity();

		if ($this->checkCouncilorRecord($user->id)) {
			return $this->redirect(['controller' => 'CouncilorsVotings', 'action' => 'view']);
		}

    	$votingsTotal = $this->Votings->find('all')->count();
    	$councilorsTotal = $this->Councilors->find('all')->count();
    	$politicalPartiesTotal = $this->PoliticalParties->find('all')->count();
    	$meetingsTotal = $this->Meetings->find('all')->count();

    	$activeMeetings = $this->Meetings->find('all')->where(['Meetings.active' => 1]);
    	$activeVotings = $this->Votings->find('all')->contain(['VotingVotes'])->where(['Votings.active' => 1]);

    	$this->set(compact('votingsTotal', 'councilorsTotal', 'politicalPartiesTotal', 'meetingsTotal', 'activeMeetings', 'activeVotings'));

    }

	protected function checkCouncilorRecord($userId)
    {
        $this->loadModel('Councilors');
        return $this->Councilors->exists(['user_id' => $userId]);
    }

}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists