protected static function boot() { parent::boot(); self::creating(function ($model) { $model->backend_users_id = \BackendAuth::getUser()->id; }); }
function auth_user($col = null) { $user = json_decode(BackendAuth::user(), true); if (key_exists($col, $user)) { return $user[$col]; } return null; }
public function getPermissionOptions($keyValue = null) { $all = \BackendAuth::listPermissions(); $ret = []; foreach ($all as $permission) { $ret[$permission->code] = $permission->code; } return $ret; }
/** * {@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'); } }
protected function loadPosts() { //\Log::info($this->parentPage); if ($this->parentPage != '') { $parent = $this->parentPage; $BlogPosts = BlogPost::where('parent', $parent); } else { $BlogPosts = new BlogPost(); } $BlogPosts = $BlogPosts->isPublished(); /* * Preset Fitlers * First we cycle through all possible preset filtering * @type - category,tag,author,date-time */ if ($this->property('filter_type') == 'category') { $category_name = $this->property('filter_value'); $category = CategoryModel::whereRaw("LOWER(name) = '{$category_name}'")->first(); if ($category) { $catID = $category->id; } else { $catID = '#'; } $BlogPosts->filterByCategory($catID); } if ($this->property('filter_type') == 'tag') { $tag = TagModel::where('name', '=', $this->property('filter_value'))->first(); return $tag->posts()->paginate($this->property('postsPerPage')); } if ($this->property('filter_type') == 'author') { $author = BackendUserModel::findUserByLogin($this->property('filter_value')); if ($author) { $author_id = $author->id; } else { $author_id = '#'; } $BlogPosts->filterByAuthor($author_id); } /* * Filter Request * Next we cycle through all possible request filters * @type - category,tag,author,canonical * (canonical requires additional different page vars /:year?/:month?/) */ if ($this->param('filter')) { if ($this->param('filter') !== 'category' && !$this->param('slug')) { $slug = $this->param('filter'); $type = 'category'; } else { $type = $this->param('filter'); $slug = $this->param('slug'); } $slug = $slug; $slug = strtolower($slug); $slug = str_replace('-', ' ', $slug); $slug = str_replace('%20', ' ', $slug); if ($type == 'category') { $this->page['blogCurrentCategorySlug'] = $slug; $category = CategoryModel::whereRaw("LOWER(name) = '{$slug}'")->first(); if ($category) { $catID = $category->id; } else { $catID = '#'; } $BlogPosts->filterByCategory($catID); } elseif ($type == 'tag') { $this->page['blogCurrentTagSlug'] = $slug; $tag = TagModel::where('name', '=', $slug)->first(); if ($tag) { return $tag->posts()->paginate($this->property('postsPerPage')); } return false; } elseif ($type == 'author') { $author = BackendUserModel::findUserByLogin($slug); if ($author) { $author_id = $author->id; } else { $author_id = '#'; } $BlogPosts->filterByAuthor($author_id); } elseif ($type == 'search') { $this->page['search_slug'] = $slug; $BlogPosts->filterBySearch($slug); } elseif ($type == 'cannonical') { $y = $this->param('year'); $m = $this->param('month'); $BlogPosts->filterByDate($y, $m); } else { $component = $this->addComponent('Radiantweb\\Problog\\Components\\Post', 'proBlogPost', array('slug' => $slug)); $component->onRun(); $this->render_post = $this->page['render_post'] = $slug; return $this->render_post; } } /* * no filters, we go get all */ $posts = $BlogPosts->orderBy('published_at', 'desc')->paginate($this->property('postsPerPage'), $this->currentPage); //$queries = DB::getQueryLog(); //$last_query = end($queries); //\Log::info($last_query); return $posts; }
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(''); }); });
/** * Админка */ Route::group(['prefix' => \Backend::getPathPrefix(), 'namespace' => 'Doberbeatz\\Laraback', 'before' => array('backend.auth')], function () { Route::get('/', ['as' => \Backend::getPathPrefix() . '.main', 'uses' => 'BackendController@index']); /** Администраторы **/ Route::get('backend_users/ajaxUpdate', array('as' => \Backend::getPathPrefix() . '.backend_users.ajaxUpdate', 'uses' => 'BackendUsersController@ajaxUpdate')); Route::resource('backend_users', "BackendUsersController"); }); /** * Авторизация */ Route::group(['prefix' => \Backend::getPathPrefix(), 'namespace' => 'Doberbeatz\\Laraback\\Controllers'], function () { /** Форма логина **/ Route::get('login', "AuthController@index"); /** Авторизация **/ Route::post('login', array('before' => 'backend.auth.config', "as" => \Backend::getPathPrefix() . "/login", function () { $userdata = array('login' => Input::get('login'), 'password' => Input::get('password'), 'is_active' => 1); if (BackendAuth::attempt($userdata)) { return Redirect::to(\Backend::getPathPrefix()); } else { return Redirect::to(\Backend::getPathPrefix() . '/login')->with('login_errors', true); } })); /** Выход **/ Route::get('logout', array("as" => \Backend::getPathPrefix() . "/logout", function () { BackendAuth::logout(); return Redirect::to(\Backend::getPathPrefix() . '/login'); })); });
public function getAuthor($id) { $author = BackendUserModel::findUserById($id); if ($author->avatar) { $author->image = $author->avatar->getThumb(100, 100, ['mode' => 'crop']); } return $author; }
public function listExtendQuery($query) { $query->where('backend_users_id', \BackendAuth::getUser()->id); }
public function debug() { return \BackendAuth::getUser(); }