Ejemplo n.º 1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $type = Input::get('type');
     $inputs = Input::all();
     $inputs['slug'] = FoxHelper::createSlug($inputs['title']);
     $inputs['type'] = $type != '' ? $type : 'published';
     $obj = Project::find($id);
     if ($obj->user_id != Auth::user()->id) {
         return array('status' => '403', 'messaeg' => 'Permission denied');
     }
     $obj->update($inputs);
     $photosId = Session::has('pIds') ? Session::get('pIds') : array();
     foreach ($photosId as $i => $d) {
         $photo = ProjectPhoto::update(array('id' => $d, 'project_id' => $obj->id));
     }
     Session::forget('pIds');
     return $obj;
 }
Ejemplo n.º 2
0
 public static function socialMediaLogin($email, $first_name, $last_name, $id, $site, $data)
 {
     $newUser = false;
     if ($site == 'fb') {
         $user = User::where('fb_id', $id)->first();
     } else {
         if ($site == 'google') {
             $user = User::where('google_id', $id)->first();
         }
     }
     if (!$user) {
         $user = User::where('email', $email)->first();
         if (!$user) {
             $user = new User();
             $newUser = true;
         }
     }
     if ($site == 'fb') {
         $user->fb_id = $id;
     } else {
         if ($site == 'google') {
             $user->google_id = $id;
             $user->avatar = $data['picture'];
         }
     }
     $user->firstname = $first_name;
     $user->lastname = $last_name;
     $user->email = $email;
     $user->is_buyer = true;
     $matches = explode("@", $user->email);
     $user->username = isset($matches[0]) && $matches[0] != '' ? $matches[0] : (isset($data['username']) ? $data['username'] : strtolower(str_replace(' ', '_', $first_name)));
     $random = '';
     if ($newUser) {
         $random = FoxHelper::genRandomPassword();
         $user->password = $random;
         $user->password_confirmation = $random;
         $user->confirmed = true;
     }
     if ($user->email == '') {
         $user->email = '*****@*****.**';
     }
     if ($newUser && $user->save()) {
         Auth::login($user);
         return Redirect::to('member')->with('alert', array('type' => 'alert', 'message' => "You're account has been successfully created<br/>This is your generated password: <b>" . $random . "</b><br/>Please go change it now <a href='" . URL::to('member/buyer/profile') . "'>Profile Settings</a>"));
     } else {
         // return $user->validationErrors;
         $user->updateUniques();
         Auth::login($user);
         return Redirect::to('member');
     }
 }