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'); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $ubicacio = UserProfile::poblacio($id); $dades = ['ubicacio' => $ubicacio, 'id' => $id]; //dd($poblacio->toArray()[0]['poblacio']); return view('privat.usuari', ['dades' => $dades]); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(CrearCampRequest $request) { $camp = new Camp($request->all()); if (!($request->punts == "")) { //dd($request->poligon); $centre = GoogleMapsController::calcularCentrePoligon($request->punts); $arraycoords = GoogleMapsController::stringToArray($request->punts); //es forma el string per a insertar en mysql el linestring. Entre punt i //punt s'inserta una ',' excepte l'ultim punt (no es guarda si acaba en ',') $string = 'GeomFromText(\'LINESTRING('; for ($i = 0; $i < count($arraycoords); $i++) { $string = $string . $arraycoords[$i] . ' '; $i++; if (!($i < count($arraycoords) - 1)) { $string = $string . $arraycoords[$i]; } else { $string = $string . $arraycoords[$i] . ','; } } $string = $string . ')\')'; $camp->poligon = DB::raw($string); $camp->centre = DB::raw('PointFromText(\'POINT(' . $centre[0] . ' ' . $centre[1] . ')\')'); } $camp->user_profile_id = UserProfile::perfilId(Auth::user()->id); $camp->save(); return redirect('home/camp/' . $camp->id); }
/** * @param RegisterRequest $request * @return \Illuminate\Http\RedirectResponse */ public function postRegister(RegisterRequest $request) { $regData = ['name' => $request->name, 'email' => $request->email, 'password' => $request->password]; //Use native auth login because do not need to check status when registering // auth()->login($user = $this->auth->create($regData)); // if (config('access.users.confirm_email')) { if ($user = $this->auth->create($regData)) { auth()->login($user); $userData = ['address' => $request->address, 'date_of_birth' => $request->dob, 'phone' => $request->phone, 'gender' => $request->gender, 'next_of_kin_relationship' => $request->kin_rel, 'next_of_kin_address' => $request->kin_address, 'next_of_kin_gender' => $request->kin_gender, 'next_of_kin_phone' => $request->kin_number, 'next_of_kin_name' => $request->kin_name, 'user_id' => auth()->user()->id]; $userProfile = new UserProfile(); if ($userProfile->create($userData)) { return redirect('dashboard'); } else { return redirect()->back()->withErrors('An Error Occurred'); } } }
public static function informacioPersonal($id) { $result = UserProfile::select('nom', 'cognoms', 'naiximent', 'poblacio')->where('user_id', '=', $id)->first(); $nick = User::nickUser($id); if (!is_null($result)) { $info = ['nom' => $result->nom, 'cognoms' => $result->cognoms, 'naiximent' => $result->naiximent, 'poblacio' => $result->poblacio, 'nick' => $nick]; return $info; } }
/** * Run the users seeds. * * @return void */ public function run() { DB::table('users_profiles')->delete(); $statement = "ALTER TABLE users_profiles AUTO_INCREMENT = 1;"; DB::unprepared($statement); UserProfile::create(['firstname' => 'Alexandre', 'lastname' => 'Mangin', 'phone' => '0616391876', 'user_id' => 1]); UserProfile::create(['firstname' => 'Alan', 'lastname' => 'Corbel', 'phone' => '0626381876', 'user_id' => 2]); UserProfile::create(['firstname' => 'Christophe', 'lastname' => 'Larquey', 'phone' => '0605040302', 'user_id' => 3]); }
public function loadImage() { $userID = Auth::user()['id']; $path = UserProfile::find($userID)->profile_picture; $testpath = basename($path); if (Storage::exists("images/" . $userID . "/" . $testpath)) { return response()->download($path); } return response()->download(storage_path() . "/app/images/default/icon.png"); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (UserProfile::perfilId($this->auth->user()->id) === Cultiu::perfilId(app()->router->getCurrentRoute()->getParameter('cultiu'))) { return $next($request); } else { if ($request->ajax()) { return response('Unauthorized.', 401); } else { return new RedirectResponse(url('/home')); } } }
public function __construct() { $this->middleware('auth'); $this->sidebarTags = Tag::with(['user' => function ($query) { $query->where('id', Auth::id()); }])->where('count', '>=', '0')->orderBy('count', 'desc')->orderBy('updated_at', 'desc')->take(8)->get(); $this->recentPosts = Article::where('article_uid', Auth::id())->orderBy('created_at', 'desc')->take(3)->get(); $this->userProfile = UserProfile::where('user_id', Auth::id())->get()->first(); View::share('sidebarTags', $this->sidebarTags); View::share('recentPosts', $this->recentPosts); View::share('userProfile', $this->userProfile); }
public function actualitzarEvents() { $camps = Camp::idCampsUsuari(UserProfile::perfilId(Auth::user()->id)); if (!is_null($camps)) { foreach ($camps as $item) { $resultatcultius[] = Cultiu::idCultiusCamp($item['id']); } foreach ($resultatcultius as $cultiuscamp) { if (isset($cultiuscamp)) { if (!is_null($cultiuscamp)) { foreach ($cultiuscamp as $item) { if (isset($item)) { if (!is_null($item)) { $cultius[] = $item; } } } } } } } //dd($cultius); if (!is_null($cultius)) { $events = Event::eventsUsuari($cultius); } //dd($events); foreach ($events as $event) { //dd($event['cultiu_id']); //$event->cultiu_id = //obtindre el registre del cultiu_id actual $key1 = array_search($event['id'], array_column($events, 'id')); //array multidimensional //obtindre el registre dins de $cultius on està el cultiu_id actual $key2 = array_search($event['cultiu_id'], array_column($cultius, 'id')); //array multidimensional //obtindre el registre dins de "camps del camp_id actual //$key3 = $cultius[$key2]['camp_id']; //dd($cultius[$key2]['camp_id']); $key3 = array_search($cultius[$key2]['camp_id'], array_column($camps, 'id')); //array multidimensional //dd($key3); //modificar a $events el id del cultiu pel nom del cultiu $events[$key1]['cultiu_nom'] = $cultius[$key2]['nom']; $events[$key1]['bancal_nom'] = $camps[$key3]['nom']; $events[$key1]['bancal_id'] = $camps[$key3]['id']; //$key = array_search($event['cultiu_id'], $cultius); //array unidimensional //dd($events[$key1]); } //dd($events); return view('homeevents')->with('dades', $events); }
public function create(Request $request) { // プロフィール登録 $inputs = $request->all(); if (Auth::user()->is_student) { $tech_items = ['Java' => $inputs['Java'], 'C' => $inputs['C'], 'C++' => $inputs['C++'], 'Python' => $inputs['Python'], 'C#' => $inputs['C#'], 'Objective-C' => $inputs['Objective-C'], 'Perl' => $inputs['Perl'], 'HTML' => $inputs['HTML'], 'CSS' => $inputs['CSS'], 'JavaScript' => $inputs['JavaScript'], 'PHP' => $inputs['PHP'], 'Ruby' => $inputs['Ruby'], 'Scala' => $inputs['Scala']]; $tech = json_encode($tech_items); $inputs += ['tech' => $tech]; UserProfile::where('student_id', '=', Auth::user()->id)->first()->update($inputs); } else { logger($inputs); CompanyProfile::where('company_id', '=', Auth::user()->id)->first()->update($inputs); } return redirect('mypage'); }
/** * 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); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { // dd("hola"); // dd(app()->router->getCurrentRoute()->getParameter('perfil')); //dd($this->auth->user()->id); //dd(UserProfile::perfilId($this->auth->user()->id)); if (UserProfile::perfilId($this->auth->user()->id) === app()->router->getCurrentRoute()->getParameter('id')) { return $next($request); } else { if ($request->ajax()) { return response('Unauthorized.', 401); } else { dd("NO"); //return redirect()->guest('/'); return new RedirectResponse(url('/home')); } } }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { return UserProfile::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]); }
/** * Show the form for creating a new resource. * * @return Response */ public function create() { $cultiu = new Cultiu(); $array = ['user' => UserProfile::perfilId(\Auth::user()->id), 'camp' => \Input::get('id')]; return view('crear.cultiu', ['user' => UserProfile::perfilId(\Auth::user()->id), 'camp' => \Input::get('id'), 'cultiu' => $cultiu]); }
/** * @param $input * @return mixed * @throws GeneralException */ public function updateProfile($input) { $user = access()->user(); $user->name = $input['name']; if ($user->canChangeEmail()) { //Address is not current address if ($user->email != $input['email']) { //Emails have to be unique if (User::where('email', $input['email'])->first()) { throw new GeneralException("That e-mail address is already taken."); } $user->email = $input['email']; } } $profile = UserProfile::where('user_id', $user->id)->first(); $profile->address = $input['address']; $profile->phone = $input['phone']; $profile->date_of_birth = $input['date_of_birth']; $profile->gender = $input['gender']; $profile->next_of_kin_name = $input['next_of_kin_name']; $profile->next_of_kin_phone = $input['next_of_kin_phone']; $profile->next_of_kin_address = $input['next_of_kin_address']; $profile->next_of_kin_gender = $input['next_of_kin_gender']; $profile->next_of_kin_relationship = $input['next_of_kin_relationship']; $profile->save(); return $user->save(); }
public function index() { $ProfileUser = UserProfile::findOrFail(1); return view('pages.home_page', ['user_info' => $ProfileUser]); }
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 userProfile() { return UserProfile::find($this->getAttribute('profileid')); }
public function saveProfile(Request $request) { if (Auth::check()) { $rules1 = ['name' => 'required|max:100', 'country' => 'required|max:20', 'city' => 'required|max:20 ', 'phone' => 'required|regex:/^(\\+\\d{1,2}\\s)?\\(?\\d{3}\\)?[\\s.-]?\\d{3}[\\s.-]?\\d{4}$/', 'description' => 'required|max:200']; $rules2 = ['name' => 'max:100', 'country' => 'max:20|min:2', 'city' => 'max:20 |min:2', 'phone' => 'regex:/^(\\+\\d{1,2}\\s)?\\(?\\d{3}\\)?[\\s.-]?\\d{3}[\\s.-]?\\d{4}$/', 'description' => 'max:200']; $validator1 = Validator::make($request->input(), $rules1); $validator2 = Validator::make($request->input(), $rules2); if ($this->userProfile != null) { if ($validator2->passes()) { if ($request->hasFile('image')) { if ($request->file('image')->isValid()) { $destPath = '/home/vagrant/Code/Project/LaravelProject/public/storage/uploads/' . Auth::id(); // upload path $extension = $request->file('image')->getClientOriginalExtension(); $fileName = date('Y_m_d_H_i_s') . '_' . rand(1, 9999) . '.' . $extension; // renameing image $request->file('image')->move($destPath, $fileName); $this->userProfile->portrait = 'storage/uploads/' . Auth::id() . '/' . $fileName; } } if ($request->input('name') != "") { $this->userProfile->user->name = $request->input('name'); $this->userProfile->user->save(); } if ($request->input('gender') != "") { $this->userProfile->gender = $request->input('gender'); } if ($request->input('country') != "") { $this->userProfile->country = $request->input('country'); } if ($request->input('city') != "") { $this->userProfile->city = $request->input('city'); } if ($request->input('phone') != "") { $this->userProfile->phone = $request->input('phone'); } if ($request->input('description') != "") { $this->userProfile->description = $request->input('description'); } $this->userProfile->save(); } else { return "Hello!!1"; return redirect('/profile')->withInput()->withErrors($validator2); } } else { if ($validator1->passes()) { $destPath = ""; $fileName = ""; if ($request->hasFile('image')) { if ($request->file('image')->isValid()) { $destPath = '/home/vagrant/Code/Project/LaravelProject/public/storage/uploads/' . Auth::id(); // upload path $extension = $request->file('image')->getClientOriginalExtension(); $fileName = date('Y_m_d_H_i_s') . '_' . rand(1, 9999) . '.' . $extension; // renameing image $request->file('image')->move($destPath, $fileName); } } UserProfile::create(['user_id' => Auth::id(), 'phone' => $request->input('phone'), 'gender' => $request->input('gender'), 'city' => $request->input('city'), 'country' => $request->input('country'), 'description' => $request->input('description'), 'portrait' => 'storage/uploads/' . Auth::id() . '/' . $fileName]); $this->userProfile = UserProfile::where('user_id', Auth::id())->get()->first(); $this->userProfile->description = $request->input('description'); $this->userProfile->portrait = 'storage/uploads/' . Auth::id() . '/' . $fileName; $this->userProfile->save(); $user = User::where('id', Auth::id())->get()->first(); $user->name = $request->input('name') == "" ? $user->name : $request->input('name'); } else { return redirect('/profile')->withInput()->withErrors($validator1); } } return redirect()->action('SelfMainpageController@showProfile'); } }
static function dibuixarMapa($id, $tipus) { $llistat = ""; $centre = ""; $coordenades = null; $items = null; switch ($tipus) { case 0: //usuari $info['poble'] = UserProfile::poblacio($id); $llistat = HomeController::llistarCamps($id); $items = Camp::campsUsuari($id); $ubicacio_centre = 'no_valor'; break; case 1: //camp $info = Camp::infoCamp($id); $ubicacio = Camp::coordenades($id); $llistat = CampController::llistarCultius($id); if (!is_null($ubicacio['ubicacio'])) { $coordenades[] = ['punts' => GoogleMapsController::formarPoligon($ubicacio['ubicacio']), 'color' => '#FF0000', 'info' => GoogleMapsController::crearInfowindow($id, UserProfile::perfilId(Auth::user()->id))]; $ubicacio_centre['y'] = $ubicacio['centrey']; $ubicacio_centre['x'] = $ubicacio['centrex']; $items = Camp::campsVeins($id); } else { $ubicacio_centre = 'no_valor'; } break; default: return false; break; } foreach ($items as $item) { if (!is_null($temp = Camp::coordenades($item->id))) { $coordenades[] = ['punts' => GoogleMapsController::formarPoligon($temp['ubicacio']), 'color' => GoogleMapsController::getColor($item->id, UserProfile::perfilId(Auth::user()->id)), 'info' => GoogleMapsController::crearInfowindow($item->id, UserProfile::perfilId(Auth::user()->id))]; } } $dades = ['ubicacio' => $info['poble'], 'ubicacio_centre' => $ubicacio_centre, 'info' => $info, 'id' => $id, 'cultius' => $llistat, 'coordenades' => $coordenades]; return $dades; }
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')); }