protected static function boot()
 {
     parent::boot();
     self::creating(function ($model) {
         $model->backend_users_id = \BackendAuth::getUser()->id;
     });
 }
 /**
  * {@inheritDoc}
  */
 public function render()
 {
     $dataProvider = new DataProvider();
     $budgetControlService = new BudgetControlService(new PurchaseService($dataProvider), new Goalr());
     $monthlyGoal = MonthlyGoal::query()->mine()->currentMonth()->first();
     if ($monthlyGoal) {
         $todayBudget = new Currency($budgetControlService->getDailyMonthlyBudget($monthlyGoal, \BackendAuth::getUser()));
         $todayBudget->setFormat('{number}');
         $todaySpent = new Currency(Purchase::calcAmountByPeriod(new \DateTime(), new \DateTime(), \BackendAuth::getUser()->id));
         $todaySpent->setFormat('{number}');
         $this->vars['todaySpent'] = $todaySpent;
         $this->vars['todayBudget'] = $todayBudget;
         return $this->makePartial('dailybudget');
     } else {
         return $this->makePartial('no_monthly_goal');
     }
 }
Beispiel #3
0
 public function beforeSave()
 {
     $original = $this->getOriginals();
     if (empty($original) === false) {
         // wydobywanie i zapisywanie dodatkowych parametrów
         $dynamicAttributes = array_except($this->getAttributes(), array_keys($original));
         foreach ($dynamicAttributes as $key => $attribute) {
             if (strpos($key, 'additional->>') !== false) {
                 // wywalenie z klucza 'additional->>' tworzonego przez relację
                 // @todo obczaić co tu się dzieje:)
                 $newkey = preg_replace('/additional->>\'?([a-z0-9\\-\\_]+)\'?/', '$1', $key);
                 $dynamicAttributes[$newkey] = $dynamicAttributes[$key];
                 unset($dynamicAttributes[$key]);
                 unset($this->{$newkey});
             }
             unset($this->{$key});
         }
         $this->additional = $dynamicAttributes;
     }
     // generwanie atrybutu url
     $this->getUrl();
     $this->user_id = \BackendAuth::getUser() ? \BackendAuth::getUser()->id : null;
 }
 public function scopeMine($query)
 {
     $query->where('user_id', \BackendAuth::getUser()->id);
 }
<?php

App::before(function ($request) {
    // route for beta
    if (Config::get('app.beta') && !Session::get('genius.beta.unlocked') && !BackendAuth::getUser()) {
        $allowed = ['beta', trim(Config::get('app.beta'), ' /'), trim(Config::get('cms.backendUri'), ' /')];
        Route::any('{any}', function ($any) {
            return Redirect::to(Config::get('app.beta'));
        })->where('any', '^(?!(' . implode('|', $allowed) . ')).*');
    }
    Route::any('beta', function () {
        Session::put('genius.beta.unlocked', true);
        return Redirect::to('');
    });
});
 public function listExtendQuery($query)
 {
     $query->where('backend_users_id', \BackendAuth::getUser()->id);
 }
 public function debug()
 {
     return \BackendAuth::getUser();
 }