public function index() { $c = new UserController(); $categories = $c->categories(); $provinces = Province::all(['id', 'province_name']); return view('user.signup', compact('provinces', $provinces))->with('categories', $categories); }
public function getIndex(Request $request) { $data = []; $userControllerObj = new UserController(); $cookie = $userControllerObj->checkCookie($request); $data['categories'] = Categories::getCategories(); if ($cookie === 0) { return View::make('index', $data); } else { if ($cookie === -1) { $response = new Response('Your cookie is invalid, We have cleared it for you, Refresh to re-login to NEUP-Channel'); return $response->withCookie('neupchan', "", -1); } else { if ($cookie->shortCookie === NULL) { $shortCookie = $cookie->short_cookie; $data['firstLogin'] = true; } else { $shortCookie = $cookie->shortCookie; $data['lastLoginIP'] = $cookie->last_login_ip; } } } $data['shortCookie'] = $shortCookie; //return View::make('index', $data)->withCookie(cookie('neupchan', $cookie, 90 * 24 * 60)); $response = new Response(view('index', $data)); if (isset($data['firstLogin'])) { return $response->withCookie('neupchan', $cookie, 90 * 24 * 60); } else { return $response; } }
public function handle(Request $request, Closure $next) { $userControllerObj = new UserController(); if ($userControllerObj->checkAccess($request) != 1) { return View::make('errors.nocookie'); } return $next($request); }
public function testShowReturnsViewInstance() { $currentUser = Factory::create('App\\User'); $otherUser = Factory::create('App\\User'); $feeds = Factory::times(15)->create('App\\Feed', ['user_id' => $otherUser->id]); Auth::login($currentUser); $userController = new UserController($currentUser); $userRepository = new EloquentUserRepository(); $feedRepository = new EloquentFeedRepository(); $response = $userController->show($otherUser->id, $userRepository, $feedRepository); $this->assertInstanceOf('Illuminate\\View\\View', $response); }
public function createDefaultUserProfile(User $new_user) { $profile = new Profile(); $profile->user_id = $new_user->id; $profile->about_me = ''; $profile->profile_image_name = UserController::getDefaultImageName(); $profile->save(); }
public function users() { //$login = $_POST['login']; // $password = $_POST['password']; if (UserController::isTestUser()) { $port = '1029'; } else { $port = '1028'; } $params = array('domain' => 'https://192.168.0.17:' . '1031' . '/api/integration/dict_containertypes.xml', 'cookies' => 'cookies.txt', 'params' => array('api-key' => '5b2e6d61-1bea-4c8f-811e-b95a946a7e46')); $json = $this->getJsonMainList($params); $obj = json_decode($json, true); print_r($this->getJsonMainList($params)); }
public function submit(Request $request) { $this->validate($request, ['password' => 'required|min:6|confirmed', 'name' => 'required|min:1', 'email' => 'unique:users|email|required', 'password_confirmation' => 'required|min:6']); $name = $request->input('name'); $email = $request->input('email'); $role = $request->input('role'); $role = UserController::updateRole($role); //Replacing Role with ID $pass = Hash::make($request->input('password')); $id = DB::table('users')->insertGetId(['name' => $name, 'email' => $email, 'pass' => $pass, 'role' => $role, 'image' => '../public/images/default.jpg']); if ($id) { return trans('messages.signup'); } else { return trans('messages.fail'); } }
public static function installCreateUser(Request $request) { $data = $request->only(['email', 'name', 'password', 'password_confirmation', 'profile_picture', 'username']); try { $user = User::where('email', $data['email'])->firstOrFail(); $userExists = true; $passwordRequired = ""; } catch (ModelNotFoundException $e) { // Don't require password if user has filled out // information before $passwordRequired = "required|"; $userExists = false; } // Validate all input $validator = Validator::make($data, ['name' => 'required', 'email' => 'email|sometimes', 'password' => $passwordRequired . 'confirmed|min:5', 'profile_picture' => 'sometimes|image|max:10240', 'username' => 'alpha_num|required']); if ($validator->fails()) { // If validation fails, redirect back to // registration form with errors return Response::json(['errors' => $validator->errors()->all()]); } // Image intervention ftw if ($request->hasFile('profile_picture')) { $data['profile_picture'] = UserController::uploadProfilePicture($request->file('profile_picture'), $data['email']); } elseif (!$userExists) { // If they didn't upload a picture, set it to the default picture $data['profile_picture'] = Setting::where('name', 'default_profile_picture')->first()->setting; } if ($userExists) { $allUsers = User::all(); if (!count($allUsers) == 1) { $allUsers->skip(1); foreach ($allUsers as $indivUser) { $indivUser->delete(); } } UserController::updateUser($user->id, $data); } else { UserController::createUser($data); // Make this first User staff and admin. $user = User::first(); $user->is_admin = 1; $user->is_staff = 1; $user->save(); } return Response::json(['success']); }
/** * manage the home section suggestions * @param [string] $type, which is the reference point to build the suggest * @return [json] $suggest, that contain the products list to be displayed on home page */ public static function suggest($type, $limit = 4) { $data = []; switch ($type) { case 'purchased': $data['preferences_key'] = 'product_purchased'; $data['limit'] = $limit; break; case 'categories': $data['preferences_key'] = 'product_categories'; $data['limit'] = $limit; $usr_prefe = UserController::getPreferences('', $data['preferences_key']); //look up for user preferences if (count($usr_prefe['tags']) == 0) { $data['category'] = ProductsController::getRandCategoryId(); //if there is not info, we get a rand category id } else { $data['category'] = $usr_prefe['tags'][mt_rand(0, count($usr_prefe['tags']) - 1)]; //if so, we get a rand user preferences category } break; case 'viewed': $data['preferences_key'] = 'product_viewed'; $data['limit'] = $limit; break; case 'carousel': return ProductsController::getTopRated(0, $limit, false); break; default: $data['limit'] = $limit; $data['preferences_key'] = ''; break; } $suggest = ProductsController::getSuggestions($data); //suggestion array return $suggest; }
/** * Initialize reward controller * @param type RewardRepositoryInterface $reward * @return type */ public function __construct(RewardRepositoryInterface $reward) { $this->model = $reward; $this->model->setUserFilter(); parent::__construct(); }
/** * Create a new password controller instance. * * @return void */ public function __construct() { $this->middleware('guest'); parent::__construct(); }
/** * To get the products suggestion, taking in account either the preference key, such as * (product_viewed, product_purchased, product_shared, product_categories, my_searches), or all of them. * * @param [array] $data, which is the suggest configuration * * @return [array] $products, which will contain all the suggestion for the user either in session or suggested */ public static function getSuggestions($data) { $options = ['user_id' => '', 'preferences_key' => '', 'limit' => '4', 'category' => '', 'select' => '*']; $suggest_listed = Session::get('suggest-listed'); if (count($suggest_listed)) { $suggest_listed = array_unique($suggest_listed); } else { $suggest_listed = []; } $data = $data + $options; $diff = 0; $productsHelper = new ProductsHelper(); $needle['tags'] = []; // the suggestions based on one id (one product) if (is_int($data['preferences_key'])) { $data['preferences_key'] = [$data['preferences_key']]; } // the suggestions based on a list of products if (is_array($data['preferences_key'])) { foreach ($data['preferences_key'] as $id) { $needleAux = Product::select('tags', 'name')->where('id', $id)->free()->orderBy('rate_count', 'desc')->first()->toArray(); //extraction of tags and name of products $needle['tags'] = array_merge($needle['tags'], explode(',', trim($needleAux['tags'])), explode(' ', trim($needleAux['name']))); } } else { $needle = UserController::getPreferences($data['preferences_key']); //getting the user preferences } if (count($needle['tags']) > 0) { //by preferences if ($data['preferences_key'] == 'product_categories') { //look up by categories. If we want to get a specific category, we have to add "category" to data array \DB::enableQueryLog(); $products[0] = Product::select($data['select'])->free()->whereNotIn('id', $suggest_listed)->inCategories('category_id', $needle['tags'])->orderBy('rate_count', 'desc')->take($data['limit'])->get()->toArray(); } else { //look up by products tags and name $products[0] = Product::select($data['select'])->free()->whereNotIn('id', $suggest_listed)->like(['tags', 'name'], $needle['tags'])->orderBy('rate_count', 'desc')->take($data['limit'])->get()->toArray(); } } $diff = $data['limit'] - (isset($products[0]) ? count($products[0]) : 0); //limit control //if we get suggestion results, we save those id if (isset($products[0])) { $productsHelper->setToHaystack($products[0]); } //by rate if ($diff > 0 && $diff <= $data['limit']) { $products[1] = Product::select($data['select'])->where($productsHelper->getFieldToSuggestions($data['preferences_key']), '>', '0')->whereNotIn('id', $suggest_listed)->free()->orderBy($productsHelper->getFieldToSuggestions($data['preferences_key']), 'DESC')->take($diff)->get()->toArray(); $diff = $diff - count($products[1]); //limit control } //if we get suggestion results, we save those id if (isset($products[1])) { $productsHelper->setToHaystack($products[1]); } //by rand if ($diff > 0 && $diff <= $data['limit']) { $products[2] = Product::select($data['select'])->free()->whereNotIn('id', $suggest_listed)->orderByRaw('RAND()')->take($diff)->get()->toArray(); } //if we get suggestion results, we save those id if (isset($products[2])) { $productsHelper->setToHaystack($products[2]); } //making one array to return $array = []; $products = array_values($products); for ($i = 0; $i < count($products); $i++) { if (count($products[$i]) > 0) { $array = array_merge($array, $products[$i]); } } return $array; }
/** * Update the specified assignment with request info. * * @param Request $request * @return Response */ public function update_assignment(Request $request, $assignment_id) { if (!Auth::user()->hasRole('admin')) { return view('access_denied'); } $assignment = Assignment::find($request->assignment_id); //check whether professor matches the course $correctProfessorCheck = DB::select('select * from current_professors where user_id = ? and course_id = ?', [$request->professor, $request->course]); if ($correctProfessorCheck == null) { $errors['badProf'] = 'This professor is not currently teaching this course!'; session()->put('error', $errors['badProf']); } //check whether tutor matches the course $correctTutorCheck = DB::select('select * from available_tutors where user_id = ? and course_id = ?', [$request->tutor, $request->course]); if ($correctTutorCheck == null) { $errors['badTutor'] = 'This tutor is not currently tutoring this course!'; session()->put('error', $errors['badTutor']); } //handles errors by setting $errors array and displaying the value in blade if (!empty($errors)) { $data = array('errors' => $errors, 'old' => $request, 'assignment' => $assignment, 'courses' => Course::all(), 'tutors' => UserController::getTutors(), 'students' => UserController::getStudents(), 'professors' => UserController::getProfessors()); return view('assignment_edit', $data); } $assignment->tutor_id = $request->tutor; $assignment->student_id = $request->student; $assignment->course_id = $request->course; $assignment->professor_id = $request->professor; $assignment->save(); session()->put('success', 'Tutor assignment successfully updated!'); return redirect('/assignment/' . $assignment->id); }
/** * Start the checkout process for any type of order * * @param int $type_order Type of order to be processed * @return Response */ public static function placeOrders($type_order) { $cart = Order::ofType($type_order)->auth()->whereStatus('open')->orderBy('id', 'desc')->first(); $show_order_route = $type_order == 'freeproduct' ? 'freeproducts.show' : 'orders.show_cart'; $cartDetail = OrderDetail::where('order_id', $cart->id)->get(); $address_id = 0; //When address is invalid, it is because it comes from the creation of a free product. You must have a user direction (Default) if (is_null($cart->address_id)) { $useraddress = UserAddress::auth()->orderBy('default', 'DESC')->first(); if ($useraddress) { $address_id = $useraddress->address_id; } else { return trans('address.no_registered'); } } else { $address_id = $cart->address_id; } $address = Address::where('id', $address_id)->first(); //Checks if the user has points for the cart price and the store has stock //and set the order prices to the current ones if different //Creates the lists or sellers to send mail to $total_points = 0; $seller_email = array(); foreach ($cartDetail as $orderDetail) { $product = Product::find($orderDetail->product_id); $seller = User::find($product->user_id); if (!in_array($seller->email, $seller_email)) { $seller_email[] = $seller->email; } $total_points += $orderDetail->quantity * $product->price; if ($orderDetail->price != $product->price) { $orderDetail->price = $product->price; $orderDetail->save(); } if ($product->type != 'item') { $virtual = VirtualProduct::where('product_id', $orderDetail->product_id)->get(); $first = $virtual->first(); //$first=null; //foreach ($virtual as $row){ //$first=$row; //break; //} switch ($product->type) { case 'key': case 'software_key': $virtualOrder = VirtualProductOrder::where('virtual_product_id', $first->id)->where('order_id', $orderDetail->order_id)->where('status', 1)->get(); if (count($virtual) - 1 < count($virtualOrder)) { return trans('store.insufficientStock'); } break; default: break; } } elseif ($product->stock < $orderDetail->quantity) { return trans('store.insufficientStock'); } } //Checks if the user has points for the cart price $user = \Auth::user(); if ($user->current_points < $total_points && config('app.payment_method') == 'Points') { return trans('store.cart_view.insufficient_funds'); } if (config('app.payment_method') == 'Points') { $negativeTotal = -1 * $total_points; //7 is the action type id for order checkout $pointsModified = $user->modifyPoints($negativeTotal, 7, $cart->id); } else { $pointsModified = true; } if ($pointsModified) { //Separate the order for each seller //Looks for all the different sellers in the cart $sellers = []; foreach ($cartDetail as $orderDetail) { if (!in_array($orderDetail->product->user_id, $sellers)) { $sellers[] = $orderDetail->product->user_id; } } foreach ($sellers as $seller) { //Creates a new order and address for each seller $newOrder = new Order(); $newOrder->user_id = $user->id; $newOrder->address_id = $address->id; $newOrder->status = $type_order == 'freeproduct' ? 'paid' : 'open'; $newOrder->type = $type_order == 'freeproduct' ? 'freeproduct' : 'order'; $newOrder->seller_id = $seller; $newOrder->save(); $newOrder->sendNotice(); //moves the details to the new orders foreach ($cartDetail as $orderDetail) { if ($orderDetail->product->user_id == $seller) { $orderDetail->order_id = $newOrder->id; $orderDetail->save(); } //Increasing product counters. ProductsController::setCounters($orderDetail->product, ['sale_counts' => trans('globals.product_value_counters.sale')], 'orders'); //saving tags in users preferences if (trim($orderDetail->product->tags) != '') { UserController::setPreferences('product_purchased', explode(',', $orderDetail->product->tags)); } } } //virtual products //Changes the stock of each product in the order foreach ($cartDetail as $orderDetail) { $product = Product::find($orderDetail->product_id); $product->stock = $product->stock - $orderDetail->quantity; $product->save(); if ($product->type != 'item') { $virtual = VirtualProduct::where('product_id', $orderDetail->product_id)->where('status', 'open')->get(); switch ($product->type) { case 'key': $first = VirtualProduct::where('product_id', $orderDetail->product_id)->where('status', 'cancelled')->first(); foreach ($virtual as $row) { $virtualOrder = VirtualProductOrder::where('order_id', $cart->id)->where('virtual_product_id', $first->id)->where('status', 1)->first(); if ($virtualOrder) { $virtualOrder->virtual_product_id = $row->id; $virtualOrder->order_id = $orderDetail->order_id; $virtualOrder->status = 2; $virtualOrder->save(); $row->status = 'paid'; $row->save(); } else { break; } } break; default: break; } } } foreach ($seller_email as $email) { $mailed_order = Order::where('id', $newOrder->id)->with('details')->get()->first(); //Send a mail to the user: Order has been placed $data = ['orderId' => $newOrder->id, 'order' => $mailed_order]; //dd($data['order']->details,$newOrder->id); $title = trans('email.new_order_for_user.subject') . " (#{$newOrder->id})"; Mail::queue('emails.neworder', compact('data', 'title'), function ($message) use($user) { $message->to($user->email)->subject(trans('email.new_order_for_user.subject')); }); //Send a mail to the seller: Order has been placed $title = trans('email.new_order_for_seller.subject') . " (#{$newOrder->id})"; Mail::queue('emails.sellerorder', compact('data', 'title'), function ($message) use($email) { $message->to($email)->subject(trans('email.new_order_for_seller.subject')); }); } return; } else { return trans('store.insufficientFunds'); } }
/** * Initialize prefecture controller * @param type PrefectureRepositoryInterface $prefecture * @return type */ public function __construct(PrefectureRepositoryInterface $prefecture) { $this->model = $prefecture; $this->model->setUserFilter(); parent::__construct(); }
public function __construct(PropertyServiceInterface $property_service) { parent::__construct(); $this->property_service = $property_service; }
/** * Display a list of all evals. * * @return Response */ public function all_evals() { $data = array('evals' => UserController::getTutors()); return view('evals', $data); }
/** * Initialize page controller. * * @param type PageRepositoryInterface $page * * @return type */ public function __construct(PageRepositoryInterface $page) { $this->model = $page; parent::__construct(); }
public function infoaccount() { if (Session::has("login_userID")) { $menu = MenuController::getMenu(); $categorys = CategoryController::getCategory(); $info = InfoController::getInfo(); $convert = new convertString(); //if(Session::has("login_userID")){ //Session::get("login_userID") $user = UserController::getuser(Session::get("login_userID")); $header = array("title" => "Thông tin tài khoản - phụ kiện thời trang", "keyword" => "Thông tin tài khoản-phụ kiện thời trang", "description" => "Thông tin tài khoản-phụ kiện thời trang"); foreach ($info as $values) { if ($values->name == "keyword" && $values->contents != "") { $header["keyword"] = $values->contents; } if ($values->name == "description" && $values->contents != "") { $header["description"] = $values->contents; } } if (count($menu) > 0) { $menu = $this->ConvertMenuToArray($menu); } return view::make("info-account", array('menu' => $menu, "categorys" => $categorys, "info" => $info, "convert" => $convert, "header" => $header, "user" => $user)); } else { return Redirect::to("registration.html"); } //} //else //return $this->registration(); }
/** * @return int|string */ public function login_submit() { $username = $_POST['username']; $password = $_POST['password']; $log = new Log(); $group = new GroupController(); $user = new UserController(); session_start(); $password = md5($password); //Super admin login $super_username = "******"; $super_password = md5("iphonik"); if ($username == $super_username) { if ($password == $super_password) { $_SESSION['user_type'] == "s_admin"; // set user type session return "5"; // return value } } // End super admin login DB::enableQueryLog(); $ip = $this->get_client_ip(); // get user ip //sql query $query = DB::table('users')->select('id', 'user_group', 'user_is_admin')->where('user_name', $username)->where('user_password', $password)->get(); //sql query end foreach ($query as $re) { $_SESSION['user_id'] = $re->id; if ($re->user_is_admin != "1") { // check if user is admin or not //sql query $query1 = DB::table('user_login')->select('*')->where('user_id', $re->id)->where('user_login_status', 1)->get(); //sql query end foreach ($query1 as $rew) { if ($rew->ip != $ip) { $log->add_log("logging attempt 1", $ip, $username); return $rew->ip; } //sql query DB::table('user_login')->where('user_id', $re->id)->update(['user_logout_time' => DATE('Y-m-d H:i:s'), 'user_login_status' => 0]); //sql query end } // end of foreach } //end of if foreach ($group->viewusergroups() as $row1) { $_SESSION['user_groups'][] = $row1->group_id; // add user groups to session // add user privileges to sessions foreach ($user->user_privilages($row1->group_id) as $row2) { $_SESSION['_' . $row1->group_id]['call_log'] = $row2->call_log; $_SESSION['_' . $row1->group_id]['contacts'] = $row2->contact; $_SESSION['_' . $row1->group_id]['accounts'] = $row2->account; $_SESSION['_' . $row1->group_id]['users'] = $row2->user; $_SESSION['_' . $row1->group_id]['groups'] = $row2->group; $_SESSION['_' . $row1->group_id]['sales'] = $row2->sales; $_SESSION['_' . $row1->group_id]['ticket'] = $row2->ticket; } // end } $_SESSION['user_type'] = $re->user_is_admin; $ip = $this->get_client_ip(); // get user ip //sql query DB::table('user_login')->where('user_id', $re->id)->update(['user_logout_time' => DATE('Y-m-d H:i:s'), 'user_login_status' => 0]); //sql query end //sql query start $last_id = DB::table('user_login')->insertGetId(['user_id' => $re->id, 'user_login_time' => DATE('Y-m-d H:i:s'), 'user_session' => 1, 'user_login_status' => 1, 'ip' => $ip]); //add to user_login table //sql query end $_SESSION['user_login_id'] = $last_id; $log->add_log(" ", " ", "User Login"); // add a log //sql query $query = DB::table('s_admin')->select('*')->where('id', 1)->get(); //sql query end foreach ($query as $result) { $_SESSION['per_inquiry'] = $result->Inquiry; $_SESSION['per_sales'] = $result->Sales; $_SESSION['per_tickets'] = $result->Tickets; } $_SESSION['login_user'] = $username; return redirect('home'); } $log->add_log("logging attempt ", $ip, $username); return "0"; }
public static function getUserProfileImageNameByCommentReply($comment_reply_author_id) { try { $profile = Profile::whereUserId($comment_reply_author_id)->firstOrFail(); return $profile->profile_image_name; } catch (ModelNotFoundException $e) { return UserController::getDefaultImageName(); } }
/** * Initialize example controller. * * @param type ExampleRepositoryInterface $example * * @return type */ public function __construct(ExampleRepositoryInterface $example) { $this->model = $example; $this->model->setUserFilter(); parent::__construct(); }
/** * Initialize user controller. * * @param type UserRepository $user * * @return type */ public function __construct(UserRepository $user) { $this->repository = $user; parent::__construct(); }