function index() { // $custom = User::leftJoin('articles' , 'users.id' ,'=','articles.user_id')->get(); // print_r($custom); //var_dump(User::custom()); $data['title'] = "Articles"; $data['module'] = "articles"; $data['view_file'] = "articles"; /* |Find all articles with specific user |Model User |Model Article */ $user = User::with("articles")->find(1); /* |Find all articles with specific coloumns |Model Article */ $data['articles'] = Article::all(); /* |Find article by id & relation to user |Model Article |Model User */ /* BOTH ARE SIMILAR */ // $user = Article::with("users")->find(3); // $user = Article::find(3); /* BOTH ARE SIMILAR */ $users = Article::all(); foreach ($users as $user) { // var_dump($user->users->name); } $this->tamplate->front($data); // $this->tamplate->admin($data); }
public function getProfile() { if (!Auth::check()) { return Redirect::to(""); } return View::make("user.profile", array("user" => User::with('contact')->with('bodyInformation')->find(Auth::user()->id))); }
/** * get my posts * @author Kydz 2015-07-04 * @return array posts info */ public function myPosts() { $token = Input::get('token', ''); $u_id = Input::get('u_id', 0); $keyWord = Input::get('key'); try { $user = User::chkUserByToken($token, $u_id); $user = User::with(['posts' => function ($q) use($keyWord) { $q->where('p_status', '=', 1); if (!empty($keyWord)) { $q->where('p_title', 'LIKE', '%' . $keyWord . '%'); } }, 'posts.replys' => function ($q) { $q->where('r_status', '=', 1); }, 'posts.replys.user', 'posts.replys.toUser', 'posts.praises'])->find($user->u_id); $posts = $user->getPosts(); $re = ['result' => 2000, 'data' => $posts, 'info' => '获取用户帖子成功']; } catch (Exception $e) { $code = 2001; if ($e->getCode() > 2000) { $code = $e->getCode(); } $re = ['result' => $code, 'data' => [], 'info' => $e->getMessage()]; } return Response::json($re); }
public function profile($id) { $user = User::with('gender', 'course', 'userType')->where('StudentID', $id)->first(); $courses = Course::all()->lists('CourseAbbr', 'CourseID'); $genders = Gender::all()->lists('Gender', 'GenderID'); return View::make('validated.profile.edit', compact('user', 'courses', 'genders')); }
public function edit($id) { $user = User::with('AssigmentRole')->with('Neighbors')->findOrFail($id); $status = Status::all(); $roles = Role::all(); return View::make('dashboard.users.edit', ['row' => $user, 'status' => $status, 'roles' => $roles]); }
public static function findUserByToken($access_token) { $row = DB::table('oauth_sessions')->join('oauth_access_tokens', 'oauth_sessions.id', '=', 'oauth_access_tokens.session_id')->join('users', 'users.id', '=', 'oauth_sessions.owner_id')->select('oauth_sessions.owner_id')->where('oauth_access_tokens.id', $access_token)->where('oauth_access_tokens.expire_time', '>', time())->where('users.activated', true)->first(); if (isset($row)) { return User::with('bookmarks')->find($row->owner_id); } }
public function login() { $response = array("status" => "ERROR", "messages" => array("id" => 1, "message" => "Incorrect user data...")); if (Input::has('facebookID')) { $facebookID = Input::get('facebookID'); $user = User::with('ciudad')->where('facebookID', $facebookID)->take(1)->first(); } else { if (Input::has('email') && Input::has('password')) { $email = Input::get('email'); $password = Input::get('password'); $user = User::with('ciudad')->where('email', $email)->where('password', $password)->take(1)->first(); } } if ($user) { $user->ciudad->pais; $response = array(); if ($user) { //Generar token $token = md5($user->id . $user->name . time()); $session = new MobileSession(); $session->user()->associate($user); $session->token = $token; $session->validFrom = Carbon::now(); if (Config::get('qpon.MOBILE_SESSION_TIMEOUT')) { $session->validTo = Carbon::now()->addMinutes(Config::get('qpon.MOBILE_SESSION_TIMEOUT')); } $session->save(); $response = array("status" => "OK", "messages" => array("id" => 1, "message" => "User logged in succesfully..."), "profile" => $user->toArray(), "session" => $session->toArray()); } else { $response = array("status" => "ERROR", "messages" => array("id" => 1, "message" => "User does not exist or login data is incorrect...")); } } return Response::json($response); }
function listMessagesForUser($id, $password = null) { // get messages $user = User::with('messages.sender', 'groups.messages.sender')->findOrFail($id); $userMessages = $user->unreadMessages()->with('sender', 'urgency')->get(); $arr = $userMessages->toArray(); // remove message content if not authed if ($user->password !== $password) { foreach ($arr as &$message) { unset($message['message']); } } echo json_encode($arr); /*foreach($userMessages as $message) { $message->is_sent = true; $message->save(); } $groups = $user->groups; $groupMessages = array(); foreach($groups as $group) { $messages = $group->unreadMessages()->with('sender', 'group', 'urgency')->get(); foreach($messages as $message) { $message->is_sent = true; $message->save(); } $groupMessages = array_merge($groupMessages, $messages->toArray()); } echo json_encode(array_merge($userMessages->toArray(), $groupMessages));*/ }
public function index() { $filters = Input::get('filters', null); //dd($filters); $search = !empty($filters['query']) ? $filters['query'] : ''; $autoApproveOnly = !empty($filters['autoApproveOnly']) ? $filters['autoApproveOnly'] : null; $sortOptions = self::processSort(); $usersQuery = User::with('profiles')->with('autoApproveEnabled')->orderBy($sortOptions['sort'], $sortOptions['sortType']); if (Input::get('download')) { return self::downloadEmails($usersQuery); } if ($search) { $usersQuery->where('name', 'like', '%' . $search . '%'); } if ($autoApproveOnly) { $usersQuery->has('autoApproveEnabled'); } $users = $usersQuery->paginate(self::$perPage); if ($search) { $users->appends(['search' => $search]); } //dd(DB::getQueryLog()); self::addSerialNumbers($users); //dd($users->toArray()); View::share(array('users' => $users, 'filters' => $filters)); return View::make('admin/users/index')->with(array('currentPage' => 'usersIndex')); }
/** * Display a listing of users * * @return Response */ public function index() { if (!User::canList()) { return $this->_access_denied(); } if (Request::ajax()) { $users_under_me = Auth::user()->getAuthorizedUserids(User::$show_authorize_flag); if (empty($users_under_me)) { $users = User::with('roles')->whereNotNull('users.created_at'); } else { $users = User::with('roles')->whereIn('users.user_id', $users_under_me); } $users = $users->select(['users.id', 'users.last_name', 'users.id as roles_column', 'users.confirmed', 'users.id as actions', 'users.first_name']); return Datatables::of($users)->edit_column('last_name', function ($user) { return $user->first_name . ' ' . $user->last_name; })->edit_column('roles_column', function ($user) { return '<ul>' . implode('', array_map(function ($name) { return '<li>' . $name . '</li>'; }, $user->roles->lists('name'))) . '</ul>'; })->edit_column('confirmed', function ($user) { return $user->status(); })->edit_column('actions', function ($data) { $actions = []; $actions[] = $data->canShow() ? link_to_action('users.show', 'Show', $data->id, ['class' => 'btn btn-xs btn-primary']) : ''; $actions[] = $data->canUpdate() ? link_to_action('users.edit', 'Update', $data->id, ['class' => 'btn btn-xs btn-default']) : ''; $actions[] = $data->canDelete() ? Former::open(action('users.destroy', $data->id))->class('form-inline') . Former::hidden('_method', 'DELETE') . '<button type="button" class="btn btn-danger btn-xs confirm-delete">Delete</button>' . Former::close() : ''; return implode(' ', $actions); })->remove_column('id')->make(); } Asset::push('js', 'datatables'); return View::make('users.index'); }
public function index() { $with = array('followers' => function ($query) { $query->where('user_id', '=', Auth::id()); }); $people = User::with($with)->get()->take(25); return View::make('people', array('people' => $people)); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $groups = Sentry::getGroups(); $outlets = SalesOutlets::dropdownList(); $roles = ['' => 'Select Role'] + User::$roles; $user = User::with('groups')->find($id); return View::make('users.edit', compact('groups', 'outlets', 'roles', 'user')); }
/** * Display the specified resource. * GET /profiles/{id} * * @param $username * @return Response */ public function show($username) { try { $user = User::with('profile')->whereUsername($username)->firstOrFail(); } catch (ModelNotFoundException $e) { return Redirect::home(); } return View::make('profiles.show')->withUser($user); }
public static function user() { if (self::check()) { $user = User::with('role')->findOrFail(Session::get('user_id')); return $user; } else { return false; } }
public function testMethod() { $users = User::with(array('departments' => function ($query) { $query->where('id', '=', 2); }))->get(); foreach ($users as $user) { echo $user->first_name; } }
/** * Display a listing of the resource. * * @return Response */ public function indexUsuarios($id = null) { if ($id == null) { $data['usuarios'] = User::with('Perfil')->orderBy('id', 'asc')->get(); $data['perfiles'] = Perfil::orderBy('id', 'asc')->get(); return $data; } else { return $this->show($id); } }
public function home() { $active = 'home'; if (Auth::user()) { $user = User::with('role')->where('user_id', Auth::user()->user_id)->first(); return View::make('home', compact('user', 'active')); } else { return View::make('login'); } }
/** * Display a listing of the resource. * * @return Response */ public function index() { //We have to change the All() method! All is not good! $users = User::with('company', 'provider')->get(); if (!check_admin_auth()) { return Redirect::action('SessionsController@create'); } $role = check_admin_auth(); return View::make('users.index', compact('role', 'users')); }
/** * Save a user * * @return string */ public function save() { // Find record if we have an ID, otherwise create a new record $user = Input::get('id') ? User::with('addresses')->find(Input::get('id')) : new User(); $result = $user->saveRecursive(); // Capture errors to return via JSON model if we have some if (!$result) { $user->errors = $user->getErrors(); } return $user; }
public function index() { $active = 'user'; if (Auth::user()) { $user = User::with('role')->where('user_id', Auth::user()->user_id)->first(); $users = User::nonAdministrator()->get(); $roles = Role::all(); return View::make('user', compact('user', 'active', 'users', 'roles')); } else { return View::make('login'); } }
public function myGroupSearchPeople($id) { $in = Input::all(); $name = $in['name']; if (strlen($name) < 1) { return ''; } $users = User::with('course', 'groupChatMember')->where('StudentID', '!=', Auth::user()->StudentID)->where(function ($q) use($name) { $q->where('StudentID', 'LIKE', '%' . $name . '%')->orWhere('Lastname', 'LIKE', '%' . $name . '%')->orWhere('Firstname', 'LIKE', '%' . $name . '%')->get(); })->paginate(10); return View::make('validated.message.mygroup.search', compact('users', 'id')); }
public function permission_index() { $president_id = Auth::user()->id; $users = User::with('AssigmentRole')->with('Neighbors')->paginate(10); $president_urbanism = Neighbors::with('NeighborProperty')->findOrFail($president_id); foreach ($president_urbanism->NeighborProperty as $row) { $urbanism_id = $row->urbanism_id; $neighbors = NeighborProperty::where('urbanism_id', '=', $urbanism_id)->get(); } $roles = Role::orderBy('id', 'ASC')->lists('name', 'id'); return View::make('dashboard.admin.permission.index', ['select' => ['' => 'Seleccione'], 'neighbors' => $neighbors, 'roles' => $roles, 'users' => $users]); }
public function update($request, $response) { if (Auth::check()) { $user = User::with('role')->find($request->id); $user->name = $request->name; $user->email = $request->email; $user->password = ncrypt($request->password); $user->role->permission = $request->permission; $user->push(); return $this->view('dashboard/edit', ['user' => $user]); } else { return $response->redirect('/login', $code = 302); } }
public function search() { $search = Input::get('search'); $searchTerms = explode(' ', $search); $queryPost = Post::with('user'); $queryUser = User::with('post'); foreach ($searchTerms as $term) { $queryPost->where('title', 'LIKE', '%' . $term . '%')->orWhere('body', 'LIKE', '%' . $term . '%')->orWhere('location', 'LIKE', '%' . $term . '%'); $queryUser->where('username', 'LIKE', '%' . $term . '%')->orWhere('email', 'LIKE', '%' . $term . '%')->orWhere('location', 'LIKE', '%' . $term . '%'); } $resultsPost = $queryPost->orderBy('created_at', 'desc')->get(); $resultsUser = $queryUser->orderBy('created_at', 'desc')->get(); return View::make('search')->with(['resultsPost' => $resultsPost, 'resultsUser' => $resultsUser]); }
public function get_index($json = false) { if ($json) { $users = User::users_from_group($json); $array = array_map(function ($object) { return $object->to_array(); }, $users); $data = array('aaData' => $array); return Response::json($data); } else { $users = User::with('group')->order_by('username', 'asc')->get(); $data = array('users' => $users); return View::make('user.index', $data); } }
public function show($id) { // init $data = array(); // get user data - with slug $user = User::with('city')->where('slug', '=', $id)->where('status', '=', 1)->first(); if ($user == null) { return App::abort('404'); } // get user's activities $activities = User::getSocialActivity($user->id); // set data $data = array('user' => $user, 'activities' => $activities); return View::make('bagikasih.user.detail', $data); }
public function get_show($id) { $data['object'] = User::with('palettes')->find($id); if (!$data['object']) { return Redirect::error(404); } $data['title'] = "User '" . $data['object']->firstname . " " . $data['object']->lastname . "'"; $data['lead'] = "View user details"; $data['tabs'][] = array('All', URL::to('litmus/users')); $data['tabs'][] = array('View', URL::to('litmus/users/' . $id), 'active'); $data['tabs'][] = array('Edit', URL::to('litmus/users/' . $id . '/edit')); $data['show']['object'] = $data['object']; $data['content'] = View::make('litmus::partials.show', $data['show'])->render(); return $this->layout($data); }
public function index() { $size = Input::has('size') && Input::get('size') < 50 ? Input::get('size') : 25; if (Input::has('last')) { $emergencies = $this->user->emergencies()->where('id', '<', Input::get('last'))->orWhere('receiver', $this->user->id)->where('id', '<', Input::get('last')); } else { $emergencies = $this->user->emergencies()->orWhere('receiver', $this->user->id); } $emergencies = $emergencies->take($size)->orderBy('id', 'desc')->get(); $response['emergencies'] = $emergencies->transform(function ($emergency) { $sender = User::with('phone')->find($emergency->sender); return ['id' => $emergency->id, 'sender' => $emergency->sender, 'created_at' => $emergency->created_at, 'number' => $emergency->number, 'phone_number' => $emergency->sender_phone, 'delivered_at' => $emergency->delivered_at, 'status' => $emergency->status, 'via_sms' => $emergency->via_sms, 'complained_at' => $emergency->complained_at, 'failed' => $emergency->failed]; }); $response['tries'] = $this->user->urgent_calls; return $this->respond($response); }
public function updateUserProfile() { $user = User::with('ciudad')->find(Input::get('id')); if ($user) { $user->update(Input::all()); } if (Input::hasFile('image')) { $imageName = $user->id . '.' . Input::file('image')->getClientOriginalExtension(); Input::file('image')->move(public_path() . '/storage/profiles/', $imageName); $user->image = $imageName; $user->save(); } $user = User::with('ciudad')->find(Input::get('id')); $user->ciudad->pais; $response = array("status" => "OK", "messages" => array("id" => 1, "message" => "User profile was successfully updated..."), "profile" => $user->toArray()); return Response::json($response); }
public function usersList($username) { $session = Utilities::getSession(); $username = strip_tags(htmlspecialchars($username)); $username = filter_var($username, FILTER_SANITIZE_STRING); if ($session['username'] == $username) { $users = User::with('perfil', 'level')->where('level_id', '=', 4)->get(); $links = Utilities::getMenu($session); foreach ($users as $key => $value) { $action = '/' . $value->perfil->username; $value->perfil->action = $action; } $this->view = new UsersListView($users, $links); $this->view->display(); } else { $this->app->redirect($app->urlFor('admin-login')); } }