/** * Display a listing of the resource. * * @return Response */ public function index() { $counts = array(); $counts['article_total'] = \Article::count(); $counts['category_total'] = \Category::count(); $counts['user_total'] = \User::count(); $counts['page_total'] = \Page::count(); return View::make('admin.index.index')->with('counts', $counts); }
/** * User create form processing. * * @return Redirect */ public function postCreate() { // Create a new validator instance from our validation rules $validator = Validator::make(Input::all(), $this->validationRules); // If validation fails, we'll exit the operation now. if ($validator->fails()) { // Ooops.. something went wrong return Redirect::back()->withInput()->withErrors($validator); } try { // We need to reverse the UI specific logic for our // permissions here before we create the user. $permissions = Input::get('permissions', array()); $this->decodePermissions($permissions); app('request')->request->set('permissions', $permissions); // Get the inputs, with some exceptions $inputs = Input::except('csrf_token', 'password_confirm', 'groups'); // Was the user created? if ($user = Sentry::getUserProvider()->create($inputs)) { // Assign the selected groups to this user foreach (Input::get('groups', array()) as $groupId) { $group = Sentry::getGroupProvider()->findById($groupId); $user->addGroup($group); $mail = Input::get('email'); $getu_id = \User::where('email', $mail)->first(); $user_id = $getu_id->id; $agent_id = Sentry::getUser()->id; $getu_id->created_by = $agent_id; $getu_id->update(); $passwordlogin = Input::get('password'); $maillogin = Input::get('email'); $fname = Input::get('first_name'); $to = Input::get('phone'); $message = ' Hi ' . $fname . ' Your Web ' . $group->name . ' username is ' . $maillogin . ' and the password: '******'.To logon Visit mteja.co.ke '; \LaravelAtApi::sendMessage($to, $message); if ($groupId == 3) { $user->addGroup($group); $tenant = new \Tenant(); $tenant->tenant_id = $user_id; $tenant->agent_id = $agent_id; $tenant->name = Input::get('first_name'); $tenant->lname = Input::get('last_name'); $tenant->phone = Input::get('phone'); $tenant->email = $mail; $tenant->save(); } else { if ($groupId == 1) { $user->addGroup($group); $owner = new \Owner(); $owner->owner_id = $user_id; $owner->agent_id = $agent_id; $owner->name = Input::get('first_name'); $owner->lname = Input::get('last_name'); $owner->phone = Input::get('phone'); $owner->email = $mail; $owner->save(); } } } // Prepare the success message $success = Lang::get('admin/users/message.success.create'); // Redirect to the new user page return Redirect::route('admin.invoice.index', $user->id)->withFlashMessage($group->name . ' Created successfully'); } // Prepare the error message $error = Lang::get('admin/users/message.error.create'); // Redirect to the user creation page return Redirect::route('create/user')->with('error', $error); } catch (LoginRequiredException $e) { $error = Lang::get('admin/users/message.user_login_required'); } catch (PasswordRequiredException $e) { $error = Lang::get('admin/users/message.user_password_required'); } catch (UserExistsException $e) { $error = Lang::get('admin/users/message.user_exists'); } // Redirect to the user creation page return Redirect::route('create/user')->withInput()->with('error', $error); }