Esempio n. 1
1
 public function findByUserNameOrCreate($userData)
 {
     $user = User::where('social_id', '=', $userData->id)->first();
     if (!$user) {
         $user = new User();
         $user->social_id = $userData->id;
         $user->email = $userData->email;
         $user->first_name = $userData->user['first_name'];
         $user->last_name = $userData->user['last_name'];
         $name = str_random(32);
         while (!User::where('avatar', '=', $name . '.jpg')->get()->isEmpty()) {
             $name = str_random(32);
         }
         $filename = $name . '.' . 'jpg';
         Image::make($userData->avatar_original)->fit(1024, 1024)->save(public_path() . '/avatars_large/' . $filename);
         Image::make(public_path() . '/avatars_large/' . $filename)->resize(200, 200)->save(public_path() . '/avatars/' . $filename);
         $user->avatar = $filename;
         $user->gender = $userData->user['gender'];
         $user->verified = $userData->user['verified'];
         $user->save();
         \Session::put('auth_photo', $filename);
     } else {
         $this->checkIfUserNeedsUpdating($userData, $user);
         \Session::put('auth_photo', $user->avatar);
     }
     return $user;
 }
Esempio n. 2
1
 public function slots()
 {
     $user = Auth::user();
     $location = $user->location;
     $slot = Slot::where('location', '=', $location)->first();
     $input = Input::get('wager');
     $owner = User::where('name', '=', $slot->owner)->first();
     $num1 = rand(1, 10);
     $num2 = rand(5, 7);
     $num3 = rand(5, 7);
     if ($user->name != $owner->name) {
         if ($num1 & $num2 & $num3 == 6) {
             $money = rand(250, 300);
             $payment = $money += $input * 1.75;
             $user->money += $payment;
             $user->save();
             session()->flash('flash_message', 'You rolled three sixes!!');
             return redirect('/home');
         } else {
             $user->money -= $input;
             $user->save();
             $owner->money += $input;
             $owner->save();
             session()->flash('flash_message_important', 'You failed to roll three sixes!!');
             return redirect(action('SlotsController@show', [$slot->location]));
         }
     } else {
         session()->flash('flash_message_important', 'You own this slot!!');
         return redirect(action('SlotsController@show', [$slot->location]));
     }
 }
 /**
  * View a user.
  *
  * @param $username
  * @return mixed
  */
 public function viewUser($username)
 {
     $user = $this->user->where('username', $username);
     if ($user->count() > 0) {
         return view('Admin.Users.View')->withUser($user->first());
     }
     abort(404);
 }
 public function index()
 {
     $usersData = [];
     $usersData['count'] = User::all()->count();
     $usersData['incompleteCount'] = User::where('status', 0)->count();
     $picsData = [];
     $picsData['count'] = Pic::all()->count();
     $clubsData = [];
     $clubsData['count'] = Club::all()->count();
     $badgesData = [];
     $badgesData['count'] = Badge::all()->count();
     $fixtures = Fixture::all();
     $fixturesData = [];
     $fixturesData['count'] = $fixtures->count();
     $fixturesData['overCount'] = $fixtures->filter(function ($fxt) {
         return $fxt->isOver();
     })->count();
     $fixturesData['closedNotOverCount'] = $fixtures->filter(function ($fxt) {
         return $fxt->isClosed() and !$fxt->isOver();
     })->count();
     $gameweeks = Gameweek::all();
     $gameweeksData = [];
     $gameweeksData['count'] = $gameweeks->count();
     $gameweeksData['completeCount'] = Gameweek::complete()->get()->count();
     $gameweeksData['pendingCount'] = Gameweek::incomplete()->get()->filter(function ($gw) {
         return $gw->hasCompletedFixture();
     })->count();
     $adminsData = [];
     $adminsData['count'] = Admin::all()->count();
     return view('admin.dashboard.index', compact('usersData', 'picsData', 'clubsData', 'badgesData', 'fixturesData', 'gameweeksData', 'adminsData'));
 }
 public function send(ResponseSchedule $schedule)
 {
     //Check for any new email/phone/in-person type types for this contact and reschedule responses based on the Note
     // return $schedule->most_recent_note_id;
     $note = $schedule->contact->notes()->where(function ($q) {
         $q->where('note_type', 'Email');
         $q->orWhere('note_type', 'Phone');
         $q->orWhere('note_type', 'In-Person');
     })->whereRaw('note_date > IFNULL((SELECT note_date FROM notes WHERE id = ' . $schedule->most_recent_note_id . " ),'" . $schedule->created_at . "')")->orderBy('note_date', 'desc')->first();
     //If a notes exists, call a reschedule of all items in this Response Template using the Note Date and log Note ID to the scheduled response.
     // return $note;
     if ($note) {
         //If a New Note exists, Reschedule Responses and Exit
         $schedules = $this->reschedule($schedule, $note);
         return $schedules;
     }
     // Else Send the scheduled response using the response detail template
     // Log a Note to Contact containing copy of the message
     // return $schedule->load('detail');
     $note = view('emails.templates.' . $schedule->detail->template_file_name, ['contact' => $schedule->contact]);
     $note_entry = $schedule->contact->notes()->create(['note_date' => Carbon::now(), 'title' => 'Sent: ' . $schedule->detail->template . ": " . $schedule->detail->subject, 'note_type' => 'Scheduled Response', 'create_user_id' => \App\User::where('email', '*****@*****.**')->first()->id, 'note' => \Purifier::clean($note)]);
     // Send the email
     \Mail::send('emails.templates.' . $schedule->detail->template_file_name, ['contact' => $schedule->contact], function ($m) use($schedule) {
         $m->to('*****@*****.**', 'Chris Rundlett')->cc('*****@*****.**', 'Tim Bradshaw')->from('*****@*****.**', 'LTD Sailing')->subject($schedule->detail->subject);
     });
     //Mark the Scheduled Response as SENT
     $schedule->sent_date = Carbon::now();
     $schedule->save();
     return $schedule;
     // return $note_entry->note;
 }
 public function facebooklogin(Request $request)
 {
     $user = User::where('email', '=', $request->input('email'))->first();
     var_dump($user);
     if ($user) {
         echo 'exists';
     } else {
         echo '!!!!exists';
     }
     if (!$user) {
         // return 'no user';
         $newUser = new User();
         $newUser->name = $request->input('name');
         $newUser->surname = $request->input('surname');
         $newUser->email = $request->input('email');
         $newUser->ip = $request->getClientIp();
         $newUser->is_facebook = true;
         $newUser->isAdmin = 0;
         $newUser->residcence = "";
         $newUser->address = "";
         $newUser->save();
         Auth::login($newUser);
     } else {
         Auth::login($user);
     }
     return $user;
 }
 public function run()
 {
     // create roles
     $admin = Role::create(['name' => 'admin', 'display_name' => 'Admin', 'description' => 'performs administrative tasks', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     $cashier = Role::create(['name' => 'cashier', 'display_name' => 'Cashier', 'description' => 'performs cashier tasks', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     $user = Role::create(['name' => 'user', 'display_name' => 'Portal User', 'description' => 'performs all basic tasks like print receipt, etc...', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     // create permissions
     $editUser = Permission::create(['name' => 'edit-user', 'display_name' => 'Edit Users', 'description' => 'manage users', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     $reporting = Permission::create(['name' => 'reporting', 'display_name' => 'Print Report, Print receipt', 'description' => 'manage reports', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     $editReporting = Permission::create(['name' => 'edit-reporting', 'display_name' => 'Edit Report, Edit receipt', 'description' => 'manage reports', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     $receipt = Permission::create(['name' => 'view-receipt', 'display_name' => 'View receipt, View Billings', 'description' => 'View recipent and view billings', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     // assign permissions to roles
     $admin->attachPermissions(array($editUser, $reporting, $receipt, $editReporting));
     $cashier->attachPermissions(array($reporting, $receipt, $editReporting));
     $user->attachPermissions(array($reporting, $receipt));
     // attach admin user to admin role
     $userAdmin = User::where('email', env('ADMIN_EMAIL'))->firstOrFail();
     $userAdmin->attachRole($admin);
     // assign default role to users
     $users = User::all();
     foreach ($users as $normalUser) {
         if ($normalUser->hasRole('user')) {
             continue;
         }
         $normalUser->attachRole($user);
     }
 }
 private function newBatch($dbId, $userId)
 {
     $expiresAt = Carbon::now()->subDay(2);
     \DebugBar::warning('New Batch');
     $ownBatch = \App\Batch::where('user_id', $userId)->where('remain_count', '>', 0)->first();
     if ($ownBatch != null) {
         \DebugBar::warning('You own a batch');
         return $ownBatch;
         // if a batch is still owns by a user, give it to our user.
     }
     $expireBatch = \App\Batch::where('updated_at', '<=', $expiresAt)->first();
     $db = \App\Dataset::find($dbId);
     if ($expireBatch == null) {
         \DebugBar::warning('if($expireBatch == null)');
         $current_standard_id = $db->current_standard_id;
         if ($current_standard_id == 0) {
             // no standard id
             \DebugBar::warning('if($current_standard_id == 0)');
             return null;
         }
         $current_standard = \App\StandardItem::find($current_standard_id);
         $batches = \App\Batch::where('user_id', $userId)->orderBy('standard_item_id', 'desc')->first();
         if ($current_standard->batch_count == 3) {
             // all dispatched
             \DebugBar::warning('if( $current_standard->batch_count == 3 )');
             $current_standard = \App\StandardItem::where('id', '>', $current_standard_id)->first();
             if ($current_standard == null) {
                 return null;
             }
             $current_standard_id = $current_standard->id;
             $db->current_standard_id = $current_standard_id;
             $db->save();
         }
         if ($batches) {
             $max_standard_id = max($batches->standard_item_id + 1, $current_standard_id);
         } else {
             $max_standard_id = $current_standard_id;
         }
         $current_standard = \App\StandardItem::where("id", ">=", $max_standard_id)->first();
         \DebugBar::warning('$current_standard:' . $current_standard);
         if ($current_standard == null) {
             return null;
         }
         $newBatch = new \App\Batch();
         $newBatch->fill(['standard_item_id' => $current_standard->id, 'user_id' => $userId, 'remain_count' => count($current_standard->Items)]);
         $newBatch->save();
         $current_standard->batch_count++;
         $current_standard->save();
         \DebugBar::warning('$newBatch:' . $newBatch);
         return $newBatch;
     } else {
         $expiredUserId = $expireBatch->user_id;
         $expiredUser = \App\User::where("user_id", $expiredUserId);
         $expiredUser->batch_id = -1;
         $expiredUser->save();
         $expireBatch->user_id = $userId;
         $expireBatch->save();
         return $expireBatch;
     }
 }
Esempio n. 9
0
 public function users()
 {
     $ppk = Auth::user()->ppk->id;
     $level = Auth::user()->level->id;
     $users = User::where('ppk_id', $ppk)->where('level_id', '>', $level)->get();
     return View('ppk.rekod.users', compact('users'));
 }
Esempio n. 10
0
 public function addCashInvoice(Request $request)
 {
     $ci_data = $request->only('invoice_number', 'customer', 'order_date', 'vat_sales', 'vat', 'total', 'prepared_by', 'received_by');
     $product = $request->input('product');
     $quantity = $request->input('quantity');
     $uprice = $request->input('unit_price');
     $amount = $request->input('amount');
     // Cash Invoice Header Entries
     $employee = User::where('name', $ci_data['prepared_by'])->first();
     $ci = new CashInvoice();
     $ci->ci_date = date('Y-m-d', strtotime($ci_data['order_date']));
     $ci->customer_id = $ci_data['customer'];
     $ci->total = $ci_data['total'];
     $ci->vat = $ci_data['vat'];
     $ci->vat_sales = $ci_data['vat_sales'];
     $ci->prepared_by = $employee->id;
     $ci->received_by = $ci_data['received_by'];
     $ci->record_status = CashInvoice::STATUS_ACTIVE;
     $ci->save();
     //Cash Invoice Detail Entries
     for ($i = 0; $i < count($product); $i++) {
         $cid = new CashInvoiceDetail();
         $cid->ci_no = $ci_data['invoice_number'];
         $cid->product_id = $product[$i];
         $cid->quantity = $quantity[$i];
         $cid->unit_price = $uprice[$i];
         $cid->amount = $amount[$i];
         $cid->record_status = CashInvoiceDetail::STATUS_ACTIVE;
         $cid->save();
     }
     return redirect()->route('home')->with('msg', 'Order Saved');
 }
Esempio n. 11
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $user = Auth::user();
     $topic_exist = topic::where('question_topic', $request['question_topic'])->count();
     if ($topic_exist !== 1) {
         $profile = User::where('id', $user['id'])->first();
         $profile->user_topic()->create($request->all());
         //$topic=topic::where('profile_id',$user['id'])->count();
     }
     $topic = topic::where('question_topic', $request['question_topic'])->get()->first();
     $count = $topic->count + 1;
     $affected = DB::update('update topics set count = :vote where id = :id', ['vote' => $count, 'id' => $topic->id]);
     //return $topic->id;
     $question = new question();
     $question->user_id = $user['id'];
     $question->topic_id = $topic->id;
     if ($request->anonymously === 'Yes') {
         $question->anonymously = 1;
     } else {
         $question->anonymously = 0;
     }
     $question->question = $request->question;
     $question->details = $request->details;
     $question->save();
     //$topic->question_topic()->create($request->all());
     return redirect()->action('questionController@show');
 }
Esempio n. 12
0
 public function follow($name)
 {
     if (\Auth::guest()) {
         return redirect('/');
     }
     $follower = \Auth::user()->name;
     $followee = $name;
     if ($followee == $follower) {
         return Redirect::back();
     } else {
         $count = User::where('name', '=', $name)->count();
         if ($count == 0) {
             \Flash::warning('ユーザー名:' . $name . 'は存在しません。');
         } else {
             if ($count == 1) {
                 if (FollowController::isFollow($name) == 0) {
                     DB::table('followings')->insert(array('follower' => $follower, 'followee' => $followee));
                     \Flash::success($name . 'をフォローしました。');
                 } else {
                     \Flash::warning($name . 'はすでにフォローしています。');
                 }
             }
         }
     }
     return Redirect::back();
 }
Esempio n. 13
0
 /**
  * Returns HTML markup for search results in users search form.
  *
  * @return \Illuminate\View\View
  */
 public function search()
 {
     $input = Input::get('input');
     // Populates search results of users with first and last names similar to user input.
     $user_results = User::where('first_name', 'LIKE', '%' . $input . '%')->orWhere('last_name', 'LIKE', '%' . $input . '%')->get();
     return view('search.users', compact('user_results'));
 }
 /**
  * Get a validator for an incoming registration request.
  *
  * @param  array  $data
  * @return \Illuminate\Contracts\Validation\Validator
  */
 protected function validator(array $data)
 {
     $validator = Validator::make($data, ['email' => 'required|email|max:255|unique:users', 'password' => 'required|min:6|max:60', 'zip' => 'required|integer|max:99999']);
     //
     // After Validation hooks
     // https://laravel.com/docs/5.2/validation#manually-creating-validators
     //
     // Check to see if the email address has already registered.
     //
     $validator->after(function ($validator) use($data) {
         $res = User::where('email', $data['email'])->first();
         if ($res) {
             $validator->errors()->add('email', 'This email address has already registered');
         }
     });
     //
     // Check to see if the zipcode is used in the US.
     //
     $validator->after(function ($validator) use($data) {
         $res = DB::table('Zipcodes')->where('zipcode', $data['zip'])->first();
         if (!$res) {
             $validator->errors()->add('zip', 'Please enter a valid US zipcode.');
         }
     });
     return $validator;
 }
Esempio n. 15
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(MecanexUserRequest $request)
 {
     //		$thematic_area=$request->interest;
     //		dd($thematic_area);
     $mecanexuser = MecanexUser::create($request->all());
     $username = $request->username;
     $user = User::where('username', $username)->get()->first();
     // create records in table users_terms-scores once a mecanex user has been created
     $terms = Term::all();
     $total_terms = $terms->count();
     foreach ($terms as $term) {
         $mecanexuser->term()->sync([$term->id => ['user_score' => 0]], false);
         $mecanexuser->profilescore()->sync([$term->id => ['profile_score' => 0]], false);
     }
     //create record in table mecanex_user_term_home_term_neighbor once a mecanex user has been created
     for ($i = 1; $i <= $total_terms; $i++) {
         for ($j = $i + 1; $j <= $total_terms; $j++) {
             $mec_matrix = new MecanexUserTermHomeTermNeighbour();
             $mec_matrix->mecanex_user_id = $mecanexuser->id;
             $mec_matrix->term_home_id = $i;
             $mec_matrix->term_neighbor_id = $j;
             $mec_matrix->link_score = 0.1;
             $mec_matrix->save();
         }
     }
     //the following is only needed for linking an existing authorized user (users_table) with a new mecanex user provided they have the same username
     if (empty($user)) {
         $response = array('message' => 'Store successful');
     } else {
         $mecanexuser->user_id = $user->id;
         $mecanexuser->save();
         $response = array('message' => 'Store successful');
     }
     return response($response, 201)->header('Content-Type', 'application/json');
 }
Esempio n. 16
0
 public function borrow2()
 {
     //$user = user::where('email', '=', Input::get('bemail'))->firstOrFail();
     $returnData = "";
     $name = Input::get("name");
     $email = Input::get("email");
     if (Request::ajax()) {
         $userCount = User::where('email', '=', Input::get('email'))->count();
         $bookCount = Book::where('barcode', '=', Input::get('barcode'))->count();
         if ($userCount == 1) {
             $returnData = $returnData . " user existed ";
             $user = User::where('email', '=', Input::get('email'))->find(1);
         }
         if ($userCount == 0) {
             $name = Input::get("name");
             $email = Input::get("email");
             $user = user::create(array('email' => $email, 'name' => $name));
             $returnData = $returnData . " user is created ";
         }
         if ($bookCount == 1) {
             $returnData = $returnData . " book existed ";
             $book = Book::where('barcode', '=', Input::get('barcode'))->find(1);
         }
         if ($bookCount == 0) {
             $title = Input::get('title');
             $author = Input::get('author');
             $barcode = Input::get('barcode');
             $book = book::create(array('title' => $title, 'author' => $author, 'barcode' => $barcode));
             $returnData = $returnData . " book is created ";
         }
         $borrow = Borrow::create(array('user_id' => $user->id, 'book_id' => $book->id));
         $returnData = $returnData . " borrowing is successful user id =" . $user->id . " book id =" . $book->id;
     }
     return $returnData;
 }
Esempio n. 17
0
 public function checkCookie(Request $request)
 {
     $userCookie = $request->cookie('neupchan');
     if ($userCookie == NULL) {
         $channelCookies = ChCookie::where('state', 0)->first();
         //var_dump($channelCookies);
         if ($channelCookies == NULL) {
             //No cookie return 0
             return 0;
         } else {
             $this->giveCookie($request, $channelCookies->id);
             return $channelCookies;
         }
     } else {
         //Check OK
         $cookieStr = $userCookie['cookie'];
         $cookieObj = ChCookie::where('cookie', $cookieStr)->first();
         if ($cookieObj === NULL) {
             return -1;
         }
         $userObj = User::where('cookie_id', $cookieObj->id)->first();
         $userObj->shortCookie = $cookieObj->short_cookie;
         User::find($userObj->id)->update(['last_login_ip' => $request->ip()]);
         return $userObj;
     }
 }
 public function postRegister()
 {
     $rules = ['email' => 'required|email', 'ngo-name' => 'required|min:5', 'ngo-desc' => 'string|min:20', 'ngo-email' => 'required|email', 'ngo-phone' => 'required|min:7'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return redirect('/envy/auth/register')->withErrors($validator)->withInput();
     } else {
         $user = User::where('user_email', Input::get('email'))->first();
         if ($user && !$user->is_user_ngo) {
             $user->is_user_ngo = true;
             $user->save();
             $ngo = new Ngo();
             $ngo->user_id = $user->user_id;
             $ngo->ngo_name = Input::get('ngo-name');
             $ngo->ngo_email = Input::get('ngo-email');
             $ngo->ngo_phone = Input::get('ngo-phone');
             $ngo->ngo_description = Input::get('ngo-desc');
             $ngo->save();
         }
         // $user = new User;
         // $user->user_name = Input::get('name');
         // $user->user_email = Input::get('email');
         // $user->password = Hash::make(Input::get('password'));
         // $user->is_user_ngo = true;
         // $user->save();
         return redirect('/envy/auth/login');
     }
 }
Esempio n. 19
0
 public function saveuserfacebook(Request $request)
 {
     $all = $request->all();
     if (!empty($all['id']) && !empty($all['email']) && !empty($all['name'])) {
         $check_user = User::where("facebook_id", "=", $all['id'])->first();
         if (empty($check_user)) {
             $news = new User();
             $news->username = $all['email'];
             $news->sex = "name";
             $news->password = md5($all['id']);
             $news->fullname = $all['name'];
             $news->email = $all['email'];
             $news->date_cre = date("d-m-y");
             $news->lastlogin = date("d-m-y");
             $news->country = "VN";
             $news->distict = 784;
             $news->city = 30;
             $news->facebook_id = $all['id'];
             $news->is_facebook = '1';
             $news->date_login = date("Y-m-d");
             $news->is_send_mail = '0';
             $news->save();
             Auth::login($news);
             return Response::json($news);
         } else {
             $check_user->date_login = date("Y-m-d");
             $check_user->is_send_mail = '0';
             $check_user->save();
             Auth::login($check_user);
             return Response::json($check_user);
         }
         return Response::json(array("error" => 1));
     }
 }
Esempio n. 20
0
 public function submit(Request $request)
 {
     //dd(bcrypt('123456'));
     //dd($request->all());
     $user = $this->user;
     $this->validate($request, ['email' => 'required|email', 'password' => 'required|confirmed|min:6']);
     $input = $request->all();
     $findUser = User::where('email', $input['email'])->first();
     //dd($findUser);
     if ($findUser) {
         if ($findUser->id === $user->id) {
             //dd('ok');
             $user->update(['password' => bcrypt($input['password'])]);
             Flash::success('گذرواژه با موفقیت تغییر کرد');
             Auth::logout();
             return redirect(route('xadmin.index'));
         } else {
             Flash::error('اطلاعات وارد شده صحیح نمی باشد');
             return redirect(route('xadmin.index'));
         }
     } else {
         Flash::error('اطلاعات وارد شده صحیح نمی باشد');
         return redirect()->back();
     }
 }
 public function getSocialHandle($provider)
 {
     $user = Socialite::driver($provider)->user();
     $socialUser = null;
     $userCheck = User::where('email', '=', $user->email)->first();
     // Create new user id doesn't exists
     if (!empty($userCheck)) {
         $socialUser = $userCheck;
     } else {
         $socialUser = User::create(['name' => $user->name, 'email' => $user->email, 'avatar' => $user->avatar]);
     }
     // End
     // Update social information
     if ($socialUser->google() and $provider == 'google') {
         $socialUser->google()->save($this->fillSocialData($user));
     }
     if ($socialUser->facebook() and $provider == 'facebook') {
         $socialUser->facebook()->save($this->fillSocialData($user));
     }
     if ($socialUser->twitter() and $provider == 'twitter') {
         $socialUser->twitter()->save($this->fillSocialData($user));
     }
     // End
     // Authenticate user
     Auth::login($socialUser);
     // End
     return redirect()->route('home');
 }
 public function show($username)
 {
     // Find the user
     $user = User::where('username', '=', $username)->firstOrFail();
     $userPosts = $user->tweets()->get();
     return view('profile.show', compact('user', 'userPosts'));
 }
Esempio n. 23
0
 public function index()
 {
     $data = $this->load_common_data();
     $users = User::where('status', 'ENABLED')->get();
     $data['users'] = $users;
     return $this->back_view('users.list', $data);
 }
Esempio n. 24
0
 public function postEmail(PasswdResetRequest $request)
 {
     $u = User::where('username', $request['username'])->first();
     if ($u == null) {
         $uu = User::where('email', $request['email']);
         if ($u->count() > 1) {
             flash()->overlay("Your email does not match a single result. You will need to contact support.");
             return redirect('/auth/login');
         }
         $u = $uu->first();
     }
     if ($u != null) {
         $token = $this->createNewToken();
         PasswordResets::create(['user_id' => $u->id, 'token' => $token]);
         $data = ['name' => $u->name, 'url' => url('/password/change-password', ["token" => $token]), "to" => $u->email, "ton" => $u->name, 'from' => env('MAIL_DEFAULT_FROM'), 'fromn' => env('MAIL_DEFAULT_FROMN')];
         Mail::send('emailtemps.resetpassword', $data, function ($message) use($data) {
             $message->to($data['to'], $data['ton']);
             $message->from($data['from'], $data['fromn']);
             $message->subject('Password Reset Request ');
         });
         flash()->overlay("Your password reset request was successful, check the email address associated to your user profile.");
     } else {
         flash()->overlay("Your Username and Email entries do not match our records.");
     }
     return redirect('/auth/login');
 }
Esempio n. 25
0
 public function restore($id)
 {
     $specificUser = User::withTrashed()->find($id);
     $specificUser->restore();
     $users = User::where('admin1_user0', '=', 0)->withTrashed()->get();
     return Redirect::to('dashboard')->with('users', $users);
 }
Esempio n. 26
0
 public function refresh()
 {
     if (!\Session::get('user')->is_admin()) {
         abort(401);
     }
     $group_id = config('gapper.group_id');
     $members = Client::getMembers($group_id);
     if (count($members)) {
         $deleted_users = User::all()->lists('gapper_id', 'id')->toArray();
         foreach ($members as $member) {
             $id = $member['id'];
             $user = User::where('gapper_id', $id)->first();
             if (!$user) {
                 $user = new \App\User();
                 $user->gapper_id = $member['id'];
                 $user->name = $member['name'];
                 $user->icon = $member['icon'];
             } else {
                 $user->name = $member['name'];
                 $user->icon = $member['icon'];
                 //从 deleted_users 中删除当前 gapper_id 对应的用户
                 //最后剩下的, 就是 User 中不包含 gapper_id 的用户
                 if (array_key_exists($member['id'], $deleted_users)) {
                     unset($deleted_users[$id]);
                 }
             }
             $user->save();
         }
         //发现有需要删除的 User
         if (count($deleted_users)) {
             $to_deleted_users = User::whereIn('id', array_values($deleted_users))->delete();
         }
     }
     return redirect()->to('users')->with('message_content', '同步成功!')->with('message_type', 'info');
 }
Esempio n. 27
0
 public function active($email)
 {
     $affectedRows = User::where('email', $email)->update(['active' => 'A']);
     if ($affectedRows) {
         return view('auth.activada');
     }
 }
Esempio n. 28
0
 public function update(Request $request)
 {
     $data = $request->all();
     $user = User::whereId(Auth::user()->id)->first();
     if ($user->email != $data['email']) {
         $checkemail = User::where('email', '=', $data['email'])->first();
         if (!$checkemail) {
             $user->email = $data['email'];
         } else {
             alert()->warning(' ', 'Cet adresse email est déjà utilisée !')->autoclose(3500);
             return back()->withInput();
         }
     }
     $user->firstname = $data['firstname'];
     $user->lastname = $data['lastname'];
     if ($data['password']) {
         if ($data['password'] == $data['password_confirmation']) {
             $user->password = bcrypt($data['password']);
         } else {
             alert()->warning(' ', 'Les mots de passe ne correspondent pas !')->autoclose(3500);
             return back()->withInput();
         }
     }
     $user->save();
     alert()->success(' ', 'Profil modifié !')->autoclose(3500);
     return redirect('/membres/profil/');
 }
Esempio n. 29
0
 /**
  * Send a reset link to the given user.
  *
  * @param  Request  $request
  * @return Response
  */
 public function postEmail(Request $request)
 {
     $validator = \Validator::make(['email' => $request->get('email')], ['email' => 'required|email|min:6|max:255']);
     if ($validator->passes()) {
         $user = User::where('email', '=', $request->onLy('email'))->first();
         if (!$user) {
             return \Response::json(['success' => 'false', 'status' => trans(\PasswordBroker::INVALID_USER)]);
         } else {
             if (!$user->check_activate_email()) {
                 return \Response::json(['success' => 'false', 'status' => trans('error.auth.user_not_actived')]);
             }
         }
         $response = $this->passwords->sendResetLink($request->only('email'), function ($m) {
             $m->subject($this->getEmailSubject());
         });
         switch ($response) {
             case PasswordBroker::RESET_LINK_SENT:
                 return \Response::json(['success' => 'true']);
                 //return redirect()->back()->with('status', trans($response));
             //return redirect()->back()->with('status', trans($response));
             case PasswordBroker::INVALID_USER:
                 return \Response::json(['success' => 'false', 'status' => trans(\PasswordBroker::INVALID_USER)]);
                 //return redirect()->back()->withErrors(['username' => trans($response)]);
         }
     } else {
         return \Response::json(['error' => ['messages' => $validator->getMessageBag(), 'rules' => $validator->getRules()]]);
     }
 }
Esempio n. 30
0
 public function create(Request $request)
 {
     if ($request->isMethod('get')) {
         $this->data['items'] = Event::orderBy('created_at', 'desc')->get();
         $this->data['questions'] = Question::get();
         // return var_dump($this->data['questions']);
         return view('pages.event.create', $this->data);
     } elseif ($request->isMethod('post')) {
         $data = $request->all();
         $event = Event::create($request->all());
         $user = User::where('positionid', 1)->get();
         foreach ($user as $lala) {
             $item = new Score();
             $item->eventid = $event->id;
             $item->score = 0;
             $item->userid = $lala->id;
             $item->save();
         }
         if ($event) {
             if (array_key_exists('questions', $data)) {
                 $event->question()->sync($data['questions']);
                 $event->update(['enabled' => 1]);
             }
             return redirect('event');
         } else {
             return redirect('event');
         }
     }
 }