/** * Store a newly created resource in storage. * * @return Response */ public function store(CrearUsuariRequest $request) { $password = \Hash::make($request->password); $user = new User($request->all()); $user->password = $password; $user->acces = 1; $userprofile = new UserProfile(); $userprofile->nom = "Inici"; $userprofile->cognoms = "Benvingut"; $userprofile->naiximent = '2011/02/02'; $userprofile->genere = 1; $userprofile->cp = "Inici"; $userprofile->poblacio = "Benvingut"; $userprofile->provincia = "Inici"; $userprofile->pais = "Benvingut"; $userprofile->acces = 1; $userprofile->visibilitat_id = 1; $user->save(); $userprofile->user_id = $user->id; $userprofile->save(); return redirect('perfil/' . $userprofile->id); //usuari normal //dd($password); }
public function saveAboutMe(Request $request) { $userID = Auth::user()['id']; $userProfile = UserProfile::find($userID); if ($userProfile == null) { //create new row $userProfile = new UserProfile(); $userProfile->id = $userID; } //fill in fields $userProfile->about_me = Request::input('aboutme'); $userProfile->save(); return new RedirectResponse(url('/editprofile')); }
public function saveAboutMe(Request $request) { $this->validate($request, ['aboutme' => 'string|max:500']); $userID = Auth::user()['id']; $userProfile = UserProfile::find($userID); if ($userProfile == null) { //create new row $userProfile = new UserProfile(); $userProfile->id = $userID; } //fill in fields $userProfile->about_me = RequestF::input('aboutme'); $userProfile->save(); return new RedirectResponse(url('/profile')); }
public function postIndex(Request $request) { $user = $request->user(); if (UserProfile::where('user_id', $user->id)->count()) { $profile = UserProfile::where('user_id', $user->id)->first(); $profile_picture = $profile->profile_pic; $proof = $profile->photo_id_proof; } else { $profile = new UserProfile(); $profile_picture = NULL; $proof = NULL; } if ($request->hasFile('profile_picture')) { $profile_picture = $user->id . '_' . $request->file('profile_picture')->getClientOriginalName(); $request->file('profile_picture')->move('uploads/profile_pics/', $profile_picture); } if ($request->hasFile('proof')) { $proof = $user->id . '_' . $request->file('proof')->getClientOriginalName(); $request->file('proof')->move('uploads/proof/', $proof); } $profile->user_id = $user->id; $profile->profile_pic = $profile_picture; $profile->designation = $request->designation; $profile->address = $request->address; $profile->city = $request->city; $profile->state = $request->state; $profile->country = $request->country; $profile->photo_id_proof = $proof; $profile->save(); return redirect('profile'); }