/** * Display a administrator dashboard. * * @return \Illuminate\Http\Response */ public function index() { $activities = Activity::with('contributor')->paginate(8); $statistics = ['ARTICLES' => Article::count(), 'MEMBERS' => Contributor::count(), 'CATEGORIES' => Subcategory::count(), 'MESSAGES' => Message::count(), 'FEEDBACK' => Feedback::count(), 'VISITORS' => (int) Visitor::sum('unique')]; $visitors = Visitor::take(10)->get(); return view('admin.dashboard.index', compact('activities', 'statistics', 'visitors')); }
/** * Perform revisit or unique visitor. */ public function revisit() { $cookie_visitor = "infogue-visitor"; $cookie_ip = Request::ip(); setcookie($cookie_visitor, $cookie_ip, time() + 86400, "/"); $current_date = date("Y-m-d"); $result = $this->where('date', $current_date)->first(); if (count($result) > 0) { $result->unique = $result->unique + 1; $result->save(); } else { $visitor = new Visitor(); $visitor->date = $current_date; $visitor->unique = 1; $visitor->hit = 0; $visitor->save(); } }
/** * Bootstrap any application services. * * @return void */ public function boot() { $visitor = new Visitor(); $visitor->checkVisitor(); $this->app->singleton('site_settings', function () { $settings = Setting::all(); $keys = array(); foreach ($settings as $setting) { $keys[$setting->key] = $setting->value; } return $keys; }); View::share('site_settings', app('site_settings')); $this->app->singleton('site_menus', function () { $categories = Category::all(); return $categories; }); View::share('site_menus', app('site_menus')); $this->app->singleton('site_statistic', function () { $article = Article::whereStatus('published')->count(); $member = Contributor::whereStatus('activated')->count(); return ['article' => $article, 'member' => $member]; }); View::share('site_statistic', app('site_statistic')); Validator::extend('check_password', function ($attribute, $value, $parameter) { if (count($parameter) > 0 && $parameter[0] == 'admin') { return Hash::check($value, Auth::guard('admin')->user()->getAuthPassword()); } return Hash::check($value, Auth::user()->getAuthPassword()); }); Blade::directive('datetime', function ($expression) { return "<?php echo with{$expression}->format('d/m/Y H:i'); ?>"; }); Blade::directive('simpledate', function ($expression) { return "<?php echo with{$expression}->format('d M Y'); ?>"; }); Blade::directive('fulldate', function ($expression) { return "<?php echo with{$expression}->format('d F Y'); ?>"; }); Blade::directive('datetime', function ($expression) { return "<?php echo with{$expression}->format('d F Y h:m A'); ?>"; }); }