<?php

class StorageController extends BaseController {

	/**
	 * Constructor
	 */
	public function __construct() {
		// Establish Filters
		$this->beforeFilter('auth');
		$this->beforeFilter('hasRole:' . Role::ROLE_LOGISTICS, array('except' => 'getRefrenceStat'));

		if (Auth::check()) {
			$this->user			 = Auth::user();
			$this->projects	 = $this->user->projects()->whereUsestorage(1)->get();
		}
		$this->projectPrefix = 'storage';
		parent::__construct();

		if ($this->user && !$this->user->hasAnyRole(array(Role::ROLE_LOGISTICS, Role::ROLE_PROJECT_MANAGER))) {
			$this->beforeFilter('hasRole:' . Role::ROLE_LOGISTICS);
			$this->beforeFilter('hasRole:' . Role::ROLE_PROJECT_MANAGER);
		}
	}

	public function index() {
		return $this->setupLayout('storage.index');
	}

}
