Exemple #1
0
 /**
  * Initializer.
  *
  * @access   public
  * @return BaseController
  */
 public function __construct()
 {
     $is_admin = Request::is('admin*');
     $is_backend = Request::is('backend*');
     /* Set middleware(s) based on route URLs */
     if ($is_admin || $is_backend) {
         $this->middleware('auth');
         if ($is_backend) {
             // Backend specific middleware
             $this->middleware('auth.backend');
         }
         $this->middleware('auth.permissions');
         if (!Request::is('*users/change-password')) {
             // No validation for stale password if password is being changed
             $this->middleware('auth.pw_6_months');
         }
     }
     list($this->link_type, $this->link, $this->layout, $this->current_theme) = current_section();
     View::share('link_type', $this->link_type);
     View::share('current_theme', $this->current_theme);
     $website_settings = Setting::lists('value', 'name')->all();
     View::share('website_settings', $website_settings);
     $locale = Setting::value('language');
     App::setLocale($locale);
     Lang::setLocale($locale);
     $this->user = current_user();
     View::share('current_user', $this->user);
     View::share('current_user_companies', current_user_companies());
 }
Exemple #2
0
 /**
  * Initializer.
  *
  * @access   public
  * @return BaseController
  */
 public function __construct()
 {
     list($this->link_type, $this->link, $this->layout, $this->current_theme) = current_section();
     View::share('link_type', $this->link_type);
     View::share('current_theme', $this->current_theme);
     $website_settings = Setting::lists('value', 'name');
     View::share('website_settings', $website_settings);
     $this->user = current_user();
     View::share('current_user', $this->user);
     View::share('current_user_companies', current_user_companies());
 }
 /**
  * Show the form for creating a new resource.
  *
  * @param $form_id
  */
 public function create()
 {
     $country_model = $this->module_namespace . 'Models\\Country';
     $company_model = $this->module_namespace . 'Models\\Company';
     $countries = $country_model::names();
     $current_user_companies = current_user_companies();
     if ($current_user_companies) {
         $companies = $company_model::where('id', $current_user_companies)->lists('name', 'id');
     } else {
         $companies = $company_model::names();
     }
     $this->layout->title = "Add New Entry in {$this->module_name}";
     $this->layout->content = View::make("{$this->module_alias}::branches.{$this->type}.create_edit")->with('title', "Add New Entry in {$this->module_name}")->with('companies', $companies)->with('countries', $countries)->with('incharge_count', 1);
 }
 /**
  * Display a listing of the resource.
  *
  */
 public function index()
 {
     $router = app()->make('router');
     $route = $router->currentRouteName() ?: $router->current()->getPath();
     // Enable tabbed view for company_info only
     $tabbed_view = ends_with($route, 'company_info');
     $vendor = Str::lower($this->module_vendor);
     $company_model = $this->module_namespace . 'Models\\Company';
     $company_branch_model = $this->module_namespace . 'Models\\CompanyBranch';
     $companies = $company_model::with('country')->get();
     $company_branches = $company_branch_model::with('country');
     if (current_user_companies()) {
         $company_branches = $company_branches->where('company_id', current_user_companies());
     }
     $company_branches = $company_branches->get();
     $title = 'All Companies and Company Branches';
     $this->layout->title = $title;
     $this->layout->content = View::make("{$this->module_alias}::companies.{$this->type}.index")->with('title', $title)->with('companies', $companies)->with('company_branches', $company_branches)->with('tabbed_view', $tabbed_view);
 }
Exemple #5
0
/**
 * Check whether or not user can access the company
 * @param   $company_id
 * @return  boolean
 */
function can_user_access_company($company_id)
{
    $current_user_companies = current_user_companies();
    return !$current_user_companies || in_array($company_id, $current_user_companies);
}