Example #1
0
 /**
  * Displays the specified user.
  *
  * @param int|string $id
  *
  * @return \Illuminate\View\View
  */
 public function show($id)
 {
     $this->authorize('admin.users.show');
     $user = $this->user->with(['roles'])->findOrFail($id);
     $permissions = $this->presenter->tablePermissions($user);
     $formPermissions = $this->presenter->formPermissions($user);
     return view('admin.users.show', compact('user', 'permissions', 'formPermissions'));
 }
Example #2
0
 protected function profile(int $type, string $id_slug)
 {
     $id = unslug($id_slug)[0];
     $user = User::with('location', 'links.network', 'links')->findOrFail($id);
     $myself = \Auth::user() && \Auth::user()->id == $user->id;
     return view('user.profile', compact('id', 'type', 'user', 'myself'));
 }
Example #3
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $roles = Role::all();
     $permissions = Permission::all();
     $usersWithRoles = User::with('roles')->orderBy('last_name')->get();
     return view('admin.roles.index', ['roles' => $roles, 'permissions' => $permissions, 'users' => $usersWithRoles]);
 }
 public function history($match_id)
 {
     $since = Request::input('since', 0);
     $full = Request::input('full', false) === 'true';
     $match = Match::findOrFail($match_id);
     $events = $match->events()->with(['game.beatmap.beatmapset', 'game.scores' => function ($query) {
         $query->with('game')->default();
     }])->where('event_id', '>', $since);
     if ($full) {
         $events->default();
     } else {
         $events->orderBy('event_id', 'desc')->take(config('osu.mp-history.event-count'));
     }
     $events = $events->get();
     if (!$full) {
         $events = $events->reverse();
     }
     $userIds = [];
     foreach ($events as $event) {
         if ($event->user_id) {
             $userIds[] = $event->user_id;
         }
         if ($event->game) {
             foreach ($event->game->scores as $score) {
                 $userIds[] = $score->user_id;
             }
         }
     }
     $users = User::with('country')->whereIn('user_id', array_unique($userIds))->get();
     $users = json_collection($users, new UserCompactTransformer(), 'country');
     $events = json_collection($events, new EventTransformer(), ['game.beatmap.beatmapset', 'game.scores']);
     return ['events' => $events, 'users' => $users, 'all_events_count' => $match->events()->count()];
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $data['users'] = User::with('group')->get();
     $data['createbtn'] = Permission::hasPermission('users.create');
     $data['editbtn'] = Permission::hasPermission('users.edit');
     $data['deletebtn'] = Permission::hasPermission('users.delete');
     return view('users.index', $data);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $site = Config::get('site');
     if ($result = check_auth_to('YHLB_INDEX')) {
         return $result;
     }
     $data['userList'] = User::with('userRole')->paginate($site['page_size']);
     return view('admin.user.index', $data);
 }
 public function index()
 {
     $users = User::with(['userEvents' => function ($query) {
         $query->where('event_id', 1);
     }])->with(['userTransactions' => function ($query) {
         $query->where('event_id', 1);
     }])->has('userEvents')->has('userTransactions')->get();
     return view('admin.users')->with('users', $users);
 }
Example #8
0
 public function getHackersWithRating()
 {
     $hackers = [];
     foreach (Application::where("team_id", $this->id)->get() as $app) {
         $hacker = User::with('application', 'application.ratings', 'application.school')->find($app->user_id);
         $hacker['application']['ratinginfo'] = $hacker->application->ratingInfo();
         $hackers[] = $hacker;
     }
     return $hackers;
 }
 public function getUsers($limit, $skip)
 {
     //Pega todos os usuários do banco, transforma a Collection em Array para
     //ser armazenada em cache
     $users = User::with('company')->take($limit)->skip($skip)->get()->toArray();
     //Gera o slug do nome para cada usuário
     foreach ($users as $key => $user) {
         $users[$key]['name'] = explode('-', Slug::generate(strtolower($user['name'])));
     }
     return $users;
 }
 /**
  * get user by id
  * @param            $id
  * @param bool|false $withRoles
  * @return array|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model|null
  */
 public function find($id, $withRoles = false)
 {
     if ($withRoles) {
         $user = User::with('roles')->withTrashed()->find($id);
     } else {
         $user = User::withTrashed()->find($id);
     }
     if (!is_null($user)) {
         return $user;
     }
     return array();
 }
Example #11
0
 public function index()
 {
     $name = Input::get('name', '');
     $onlyActive = Input::get('only_active', '');
     $perPage = Input::get('per_page', 50);
     if ($name || $onlyActive) {
         $users = User::simpleSearch($name, $onlyActive)->with('profile')->paginate($perPage);
     } else {
         $users = User::with('profile')->paginate($perPage);
     }
     return view('admin.pages.user.list', compact('users', 'onlyActive', 'name'));
 }
Example #12
0
 function index()
 {
     $user_shokushus = User::with('user_shokushus.shokushu')->find($this->user['id']);
     $shokushus = $user_shokushus['user_shokushus'];
     $user_kinmuchi = User::with('user_kinmuchis.kinmuchi')->find($this->user['id']);
     //                return($user_kinmuchi);
     $kinmuchis = $user_kinmuchi['user_kinmuchis'];
     $user_keitais = User::with('user_keitais.keitai')->find($this->user['id']);
     $keitais = $user_keitais['user_keitais'];
     //        return ($keitais);
     return view('my.edit.edit', ['shokushus' => $shokushus, 'kinmuchis' => $kinmuchis, 'keitais' => $keitais]);
 }
 public function __construct()
 {
     $this->middleware('auth');
     $user_types = UserType::lists("name", "id");
     $states = State::lists("name", "id");
     $users_count = User::with("state")->latest()->get()->count();
     $universities_count = University::latest()->get()->count();
     $sos_count = SosModel::latest()->get()->count();
     $students_count = Student::latest()->get()->count();
     $companies_count = Company::latest()->get()->count();
     \View::share(compact("users_count", "universities_count", "sos_count", "states", "user_types", "students_count", "companies_count"));
 }
Example #14
0
 /**
  * @param $id
  * @param bool $withRoles
  * @return mixed
  * @throws GeneralException
  */
 public function findOrThrowException($id, $withRoles = false)
 {
     if ($withRoles) {
         $user = User::with('roles')->withTrashed()->find($id);
     } else {
         $user = User::withTrashed()->find($id);
     }
     if (!is_null($user)) {
         return $user;
     }
     throw new GeneralException('That user does not exist.');
 }
 /**
  * Redirect to the profile page.
  *
  * @return Redirect
  */
 public function getIndex()
 {
     $user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed()->find(Auth::user()->id);
     $userlog = $user->userlog->load('assetlog', 'consumablelog', 'assetlog.model', 'licenselog', 'accessorylog', 'userlog', 'adminlog');
     if (isset($user->id)) {
         return View::make('account/view-assets', compact('user', 'userlog'));
     } else {
         // Prepare the error message
         $error = trans('admin/users/message.user_not_found', compact('id'));
         // Redirect to the user management page
         return redirect()->route('users')->with('error', $error);
     }
 }
Example #16
0
 public static function chkPerm($route)
 {
     $user = \App\Models\User::with('roles')->find(Session::get('loggedinUserId'));
     $roles = $user->roles;
     $roles_data = $roles->toArray();
     $r = \App\Models\Role::find($roles_data[0]['id']);
     $per = $r->perms()->get(['name'])->toArray();
     if (in_array($route, array_flatten($per))) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     $selfFirmUser = User::with('firm')->where('role_id', User::ADMIN)->first();
     $clientCompany = User::with('firm')->where('id', $this->order->user_id)->first();
     $products = $this->order->products_in_order;
     $firm = $clientCompany->firm;
     $productsArr = [];
     foreach ($products as $product) {
         $productsArr[] = ['product_name' => $product->product_name, 'product_amount' => $product->product_amount, 'product_price' => $product->product_price];
     }
     $date = DateTime::createFromFormat('Y-m-d H:i:s', $this->order->created_at);
     $date = strtotime($date->format('d F Y'));
     $pdf = App::make('dompdf.wrapper');
     $viewType = null;
     if ($this->isTorg) {
         $viewType = 'documents.torg_12';
     } else {
         $viewType = 'documents.schet_factura';
     }
     $pdf->loadView($viewType, ['orderNumber' => $this->order->id, 'orderDate' => date('d.m.Y', $date), 'firm' => $firm, 'selfFirm' => $selfFirmUser->firm, 'products' => $productsArr]);
     //$pdf->setOrientation('landscape');
     $pdf->setPaper('A4', 'landscape');
     $documents = Config::get('documents');
     $whereAreClientDocuments = $documents['documents_folder'];
     //client_{id}
     if (!Storage::disk('local')->exists($whereAreClientDocuments . DIRECTORY_SEPARATOR . 'client_' . $this->order->user_id)) {
         Storage::makeDirectory($whereAreClientDocuments . DIRECTORY_SEPARATOR . 'client_' . $this->order->user_id);
     }
     //paymentDocs
     if (!Storage::disk('local')->exists($whereAreClientDocuments . DIRECTORY_SEPARATOR . 'client_' . $this->order->user_id . DIRECTORY_SEPARATOR . 'paymentDocs')) {
         Storage::makeDirectory($whereAreClientDocuments . DIRECTORY_SEPARATOR . 'client_' . $this->order->user_id . DIRECTORY_SEPARATOR . 'paymentDocs');
     }
     $clientFolder = storage_path() . DIRECTORY_SEPARATOR . 'app' . $whereAreClientDocuments . DIRECTORY_SEPARATOR . 'client_' . $this->order->user_id . DIRECTORY_SEPARATOR . 'paymentDocs';
     //(torg12/schetfactura)_{orderID}_{depoName}_date_{currentDate}
     $fileNameTemplate = $documents['client_invoice_template'];
     $fileNameTemplate = Utils::mb_str_replace('{docType}', Order::getDocTypeName($this->isTorg ? Order::AUCTION_12_TYPE : Order::INVOICE_ACCT_TYPE), $fileNameTemplate);
     $fileNameTemplate = Utils::mb_str_replace('{orderID}', $this->order->id, $fileNameTemplate);
     $depo = Stantion::find($this->order->products_in_order[0]->stantion_id);
     $depoName = Utils::mb_str_replace(' ', '', $depo->stantion_name);
     $depoName = Utils::translit($depoName);
     $fileNameTemplate = Utils::mb_str_replace('{depoName}', $depoName, $fileNameTemplate);
     $fileNameTemplate = Utils::mb_str_replace('{currentDate}', time(), $fileNameTemplate);
     $pdf->save($clientFolder . DIRECTORY_SEPARATOR . $fileNameTemplate);
     $docs = new Document();
     $docs->type = $this->isTorg ? Order::AUCTION_12_TYPE : Order::INVOICE_ACCT_TYPE;
     $docs->user_id = $this->order->user_id;
     $docs->order_id = $this->order->id;
     $docs->file_name = $clientFolder . DIRECTORY_SEPARATOR . $fileNameTemplate;
     $docs->save();
     Bus::dispatch(new SendEmailWithPaymentDocs($docs->file_name, $this->isTorg, $this->order));
 }
Example #18
0
 public function chk_admin_user()
 {
     $userDetails = User::where("email", "=", Input::get("email"))->first();
     $userData = ['email' => Input::get('email'), 'password' => Input::get('password')];
     if (Auth::attempt($userData, true)) {
         $user = User::with('roles')->find($userDetails->id);
         Session::put('loggedinUserId', $userDetails->id);
         $roles = $user->roles()->first();
         $r = Role::find($roles->id);
         $per = $r->perms()->get()->toArray();
         return redirect()->route('admin.dashboard');
     } else {
         Session::flash('invalidUser', 'Invalid Username or Password');
         return redirect()->route('adminLogin');
     }
 }
Example #19
0
 public function checkLogin()
 {
     $email = Input::get('email');
     $userDetails = User::where('email', "=", $email)->get()->first();
     //  dd($user_type);
     $userData = ['email' => Input::get('email'), 'password' => Input::get('password')];
     if (Auth::attempt($userData, true)) {
         $user = User::with('roles')->find($userDetails->id);
         Session::put('loggedinUserId', $userDetails->id);
         Session::put('userName', $userDetails->first_name . " " . $userDetails->last_name);
         return redirect()->route('home');
     } else {
         //echo "false";
         Session::flash('invalidUser', 'Invalid username or Password');
         return redirect()->route('login');
     }
 }
Example #20
0
 public static function bind($openid, $provider)
 {
     $user = User::with('openids')->where('email', '=', $openid->getEmail())->first();
     $user_open_id = new UserOpenid(['provider' => $provider, 'provider_user_id' => $openid->getId(), 'access_token' => $openid->token, 'expires_at' => Carbon::now()->addMinutes(5)]);
     if (!$user) {
         $user = new User(['email' => $openid->getEmail(), 'name' => $openid->getName(), 'nickname' => $openid->getNickname(), 'avatar' => $openid->getAvatar()]);
         $user->save();
         $user->openids()->save($user_open_id);
     } else {
         $exists = $user->openids->where('provider', $provider)->where('provider_user_id', (string) $openid->getId());
         if ($exists->isEmpty()) {
             $user->openids()->save($user_open_id);
         } else {
             $exists->first()->fill($user_open_id->getAttributes())->save();
         }
     }
     return $user;
 }
 public function authenticate(LoginRequest $loginRequest)
 {
     Auth::logout();
     $email = Input::get('email');
     $password = Input::get('password');
     if (Str::contains($email, '@')) {
         if (Auth::attempt(['email' => $email, 'password' => $password])) {
             $user = Auth::user();
             $user->roles;
             return $user;
         } else {
             return \Response::json(["error" => "E-mail or Password is invalid"], 500);
         }
     } else {
         $username = $email;
         $password = $password;
         $server = "dcup-01.up.local";
         //dc1-nu
         $userlocal = $username . "@up.local";
         // connect to active directory
         $ad = ldap_connect($server);
         if (!$ad) {
             return \Response::json(["error" => "ไม่สามารถติดต่อ server มหาลัยเพื่อตรวจสอบรหัสผ่านได้"], 500);
         } else {
             $b = @ldap_bind($ad, $userlocal, $password);
             if (!$b) {
                 return \Response::json(["error" => "ไม่สามารถเข้าสู่ระบบได้ กรุณาตรวจสอบอีกครั้ง"], 500);
             } else {
                 //ldap ok
                 $useremail = $username . "@up.ac.th";
                 $user = User::with('roles')->where('email', '=', $useremail)->first();
                 if ($user) {
                     Auth::login($user);
                 } else {
                     $user = $this->userService->createUserFromSoap($username, $password);
                     Auth::login($user);
                 }
                 return $user;
             }
         }
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     return view('user.show')->with('user', User::with('score')->find($id)->toJson());
 }
Example #23
0
 /**
  * 	Post route for creating / updating documents.
  */
 public function postDocs()
 {
     $user = Auth::user();
     if (!$user->can('admin_manage_documents')) {
         // If there's a group
         if (Input::get('group_id')) {
             $groupUser = User::with('groups')->whereHas('groups', function ($query) {
                 $query->where('status', 'active');
                 $query->where('group_id', Input::get('group_id'));
             })->find($user->id);
             if (!isset($groupUser->id)) {
                 return Response::json($this->growlMessage("You do not have permission", 'error'));
             }
         } elseif (!$user->getSponsorStatus()) {
             return Response::json($this->growlMessage("You do not have permission", 'error'));
         }
     }
     //Creating new document
     $title = Input::get('title');
     $slug = Input::get('slug', str_replace(array(' ', '.'), array('-', ''), strtolower($title)));
     // If the slug is taken
     if (Doc::where('slug', $slug)->count()) {
         $counter = 0;
         $tooMany = 10;
         do {
             if ($counter > $tooMany) {
                 return Response::json($this->growlMessage('Can\'t create document with that name, please try another.', 'error'));
             }
             $counter++;
             $new_slug = $slug . '-' . str_random(8);
         } while (Doc::where('slug', $new_slug)->count());
         $slug = $new_slug;
     }
     $doc_details = Input::all();
     $rules = array('title' => 'required');
     $validation = Validator::make($doc_details, $rules);
     if ($validation->fails()) {
         return Response::json($this->growlMessage('A valid title is required.', 'error'));
     }
     try {
         $doc = new Doc();
         $doc->title = $title;
         $doc->slug = $slug;
         $doc->save();
         if (Input::get('group_id')) {
             $doc->groupSponsors()->sync(array(Input::get('group_id')));
         } else {
             $doc->userSponsors()->sync(array($user->id));
         }
         $starter = new DocContent();
         $starter->doc_id = $doc->id;
         $starter->content = "New Doc Content";
         $starter->save();
         $doc->init_section = $starter->id;
         $doc->save();
         $response = $this->growlMessage('Document created successfully', 'success');
         $response['doc'] = $doc->toArray();
         return Response::json($response, 200);
     } catch (Exception $e) {
         return Response::json($this->growlMessage($e->getMessage(), 'error'));
     }
 }
 public function prepareUsersData($record)
 {
     if (!$record) {
         return false;
     }
     $userIds = [];
     for ($i = 1; $i <= 5; $i++) {
         $field = "user_id{$i}";
         if ($record->{$field}) {
             $userIds[] = $record->{$field};
         }
     }
     $users = User::with('account')->whereIn('id', $userIds)->get();
     $data = [];
     foreach ($users as $user) {
         $item = new stdClass();
         $item->id = $record->id;
         $item->user_id = $user->id;
         $item->user_name = $user->getDisplayName();
         $item->account_id = $user->account->id;
         $item->account_name = $user->account->getDisplayName();
         $item->pro_plan_paid = $user->account->pro_plan_paid;
         $item->logo_path = file_exists($user->account->getLogoPath()) ? $user->account->getLogoPath() : null;
         $data[] = $item;
     }
     return $data;
 }
Example #25
0
 public function index()
 {
     $users = User::with('userGroup')->where('user_group_id', '!=', 1)->paginate(5);
     return view('users.index', compact('users'));
 }
 /**
  * Fetch user
  * (You can extract this to repository method)
  *
  * @param $username
  * @return mixed
  */
 public function getUserByUsername($username)
 {
     return User::with('profile')->wherename($username)->firstOrFail();
 }
 public function getDatatable()
 {
     // $users = User::select(['id', 'first_name', 'email', 'created_at', 'updated_at']);
     $users = User::with('roles')->select('*');
     return Datatables::of($users)->editColumn('first_name', '{{ $first_name }}')->addColumn('action', function ($user) {
         return '<a href="/users/user/edit/' . $user->id . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>
                     <a href="/users/user/delete/' . $user->id . '" onclick="return confirm(\'Hapus Data? \')" class="btn btn-xs btn-danger"><i class="glyphicon glyphicon-trash"></i> Delete</a>';
     })->make(true);
 }
 public function getAllOrderedBy($column = 'id', $order = 'asc')
 {
     $users = User::with('roles')->orderBy($column, $order)->get();
     return $users;
 }
Example #29
0
 public function getUserWithRoles($user_id)
 {
     return User::with('roles')->where('id', $user_id)->first();
 }
Example #30
0
 public function GetDashboardView()
 {
     if (Auth::check()) {
         $user_obj = User::with('getRole')->find(Auth::user()->id);
         //            return dd($audit_obj);
         return view('dashboard')->with('user_obj', $user_obj);
     }
     return Redirect::to(url('user/login'));
 }