/**
  * Setup the layout used by the controller.
  *
  * @return void
  */
 public function index()
 {
     $search_value = Input::get('s');
     if (!empty($search_value)) {
         $users = User::where('username', 'LIKE', '%' . $search_value . '%')->orWhere('email', 'LIKE', '%' . $search_value . '%')->orderBy('created_at', 'desc')->get();
     } else {
         $users = User::all();
     }
     $data = array('users' => $users, 'admin_user' => Auth::user());
     return View::make('admin.users.index', $data);
 }
 /**
  * Setup the layout used by the controller.
  *
  * @return void
  */
 public function index()
 {
     $start = (new Carbon('now'))->hour(0)->minute(0)->second(0);
     $end = (new Carbon('now'))->hour(23)->minute(59)->second(59);
     $total_subscribers = count(User::where('active', '=', 1)->where('role', '=', 'subscriber')->where('stripe_active', '=', 1)->get());
     $new_subscribers = count(User::where('active', '=', 1)->where('role', '=', 'subscriber')->where('stripe_active', '=', 1)->whereBetween('created_at', [$start, $end])->get());
     $total_videos = count(Video::where('active', '=', 1)->get());
     $total_posts = count(Post::where('active', '=', 1)->get());
     $settings = Setting::first();
     $data = array('admin_user' => Auth::user(), 'total_subscribers' => $total_subscribers, 'new_subscribers' => $new_subscribers, 'total_videos' => $total_videos, 'total_posts' => $total_posts, 'settings' => $settings);
     return View::make('admin.index', $data);
 }
 public function renew($username)
 {
     $user = User::where('username', '=', $username)->first();
     $payment_settings = PaymentSetting::first();
     if ($payment_settings->live_mode) {
         User::setStripeKey($payment_settings->live_secret_key);
     } else {
         User::setStripeKey($payment_settings->test_secret_key);
     }
     if (Auth::user()->username == $username) {
         $data = array('user' => $user, 'post_route' => URL::to('user') . '/' . $user->username . '/update', 'type' => 'renew_subscription', 'menu' => Menu::orderBy('order', 'ASC')->get(), 'payment_settings' => $payment_settings, 'video_categories' => VideoCategory::all(), 'post_categories' => PostCategory::all(), 'theme_settings' => ThemeHelper::getThemeSettings(), 'pages' => Page::all());
         return View::make('Theme::user', $data);
     } else {
         return Redirect::to('/');
     }
 }