/** * Create a new profile from Github data. * * @param \League\OAuth2\Client\Provider\User $userDetails * @param \Tricks\User $user * @param string $token * @return \Tricks\Profile */ public function createFromGithubData(OAuthUser $details, User $user, $token) { $profile = $this->getNew(); $profile->uid = $details->uid; $profile->username = $details->nickname; $profile->name = $details->name; $profile->email = $details->email; $profile->first_name = $details->first_name; $profile->last_name = $details->last_name; $profile->location = $details->location; $profile->description = $details->description; $profile->image_url = $details->imageUrl; //$profile->urls = serialize($details->urls); $profile->access_token = $token; $profile = $user->profile()->save($profile); return $profile; }
/** * Update the user's settings. * * @param \Tricks\User $user * @param array $data * * @return \Tricks\User */ public function updateSettings(User $user, array $data) { $user->username = $data['username']; if ($data['password'] != '') { $user->password = Hash::make($data['password']); } if ($data['avatar'] != '') { File::move(public_path() . '/img/avatar/temp/' . $data['avatar'], 'img/avatar/' . $data['avatar']); if ($user->photo) { File::delete(public_path() . '/img/avatar/' . $user->photo); } $user->photo = $data['avatar']; } return $user->save(); }
/** * Find all tricks that are favorited by the given user paginated. * * @param \Tricks\User $user * @param integer $perPage * @return \Illuminate\Pagination\Paginator|\Tricks\Trick[] */ public function findAllFavorites(User $user, $perPage = 9) { $tricks = $user->votes()->orderBy('created_at', 'DESC')->paginate($perPage); return $tricks; }
/** * @group tricks */ public function testIsAdmin() { $user = new User(); $this->assertFalse($user->isAdmin()); $user->is_admin = false; $this->assertFalse($user->isAdmin()); $user->is_admin = true; $this->assertTrue($user->isAdmin()); }
public function postcvNew() { $flag_save = \Input::get('flag_save'); $exp_type = \Input::get('exp_type'); //return \Input::get('rel'); //return \Input::get('title'); if ($flag_save == "cv_exp_delete") { $ser = \Input::get('ser2'); //$cv_exp->delete($ser); $affectedRows = CvExp::where('ser', '=', $ser)->delete(); } if ($flag_save == "cv_exp") { if ($exp_type != -1) { $user2 = \Auth::user()->id; $cv_exp = new CvExp(); $fdate = new \Carbon\Carbon(\Input::get('from_date')); $todate = new \Carbon\Carbon(\Input::get('to_date')); if ($fdate < $todate) { $cv_exp = CvExp::create(array('id' => $user2, 'title' => \Input::get('title'), 'desc' => \Input::get('desc'), 'tag_id' => \Input::get('tags'), 'exp_type' => \Input::get('exp_type'), 'from_date' => $fdate, 'to_date' => $todate)); $cv_exp->save(); } } } if ($flag_save == "user") { //// Eng info $user_id = \Auth::user()->id; $user = User::find($user_id); $avatar = \Input::get('avatar'); $user->phonenumber = \Input::get('cv_eng_phone'); $user->email = \Input::get('cv_email'); //$user->photo = \Input::get('avatar'); if ($avatar != '') { \File::move(public_path() . '/img/avatar/temp/' . $avatar, 'img/avatar/' . $avatar); /* if ($user->photo) { \File::delete(public_path().'/img/avatar/'.$user->photo); }*/ $user->photo = $avatar; } $user->save(); /// end Eng ifno } ///////////////////////////////////////////////////// if ($flag_save == "cv") { $user = \Auth::user()->id; $fuser = Cv::find($user); if (!empty($fuser)) { $z = \Input::file('cv_attachment'); $z = "CV_" . $user; $user = \Auth::user()->id; $cv = Cv::find($user); $cv->cv_title = \Input::get('cv_title'); $cv->cv_summary = \Input::get('cv_summary'); if (\Input::hasFile('cv_attachment')) { $size = \Input::file('cv_attachment')->getSize(); $mime = \Input::file('cv_attachment')->getMimeType(); if ($size < 500000) { if ($mime == "application/msword") { \Input::file('cv_attachment')->move("img/CV/", $z); $cv->cv_attachment = $z; } elseif ($mime == "application/pdf") { \Input::file('cv_attachment')->move("img/CV/", $z); $cv->cv_attachment = $z; } } } $cv->save(); } else { $cv = Cv::create(array('id' => $user, 'cv_title' => \Input::get('cv_title'), 'cv_summary' => \Input::get('cv_summary'), 'cv_attachment' => \Input::file('cv_attachment'))); $cv->save(); } } return \Redirect::to('user/cv/new'); }
/** * Update the user's settings. * * @param \Tricks\User $user * @param array $data * @return \Tricks\User */ public function updateSettings(User $user, array $data) { $user->username = $data['username']; $user->companyname = $data['companyname']; $user->phonenumber = $data['phonenumber']; $user->Address = $data['Address']; $user->flag_name = $data['flag_name']; /*if ($data['flag_name'] = ''){ $user->flag_name = 0;#$data['flag_name']; } else { $user->flag_name = 1; } */ $user->password = $data['password'] != '' ? $data['password'] : $user->password; //Hash::make($data['password']) : $user->password; if ($data['avatar'] != '') { File::move(public_path() . '/img/avatar/temp/' . $data['avatar'], 'img/avatar/' . $data['avatar']); if ($user->photo) { File::delete(public_path() . '/img/avatar/' . $user->photo); } $user->photo = $data['avatar']; } return $user->save(); }