/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { $appointmentId = $this->get('appointment'); $businessId = $this->get('business'); $issuer = auth()->user(); $business = Business::find($businessId); $appointment = Appointment::find($appointmentId); $authorize = $appointment->issuer->id == $issuer->id || $issuer->isOwner($business); # \Log::info("Authorize AlterAppointmentRequest for issuer:{$issuer->id} appointment:$appointmentId business:$businessId authorize:$authorize"); return $authorize; }
/** * To handle all the mesaging functionality * * @param int $id * @return Response */ public function index(Request $request) { $user = User::find(Auth::user()->id); $userDetail = UserDetail::where('userId', $user->id)->first(); $business = Business::find($userDetail->businessId); if (empty($business)) { $business = (object) array_merge($user->toArray(), $userDetail->toArray()); } else { $business = (object) array_merge($user->toArray(), $userDetail->toArray(), $business->toArray()); } return view('message.index')->withBusiness($business); }
/** * Display a loggedin user's business ourFeeds. * * @return Response */ public function ourFeed($id) { //all users $user = User::where('userName', $id)->first(); if (empty($user)) { return redirect()->back(); } $userDetail = UserDetail::where('userId', $user->id)->first(); $business = Business::find($userDetail->businessId); if (empty($business)) { return redirect('/user/' . $user->userName . '/profile'); } $business = (object) array_merge($user->toArray(), $userDetail->toArray(), $business->toArray()); return view('business.our-feed')->withBusiness($business); }
/** * Guarda los cambio del usuario. * * @param Request $request peticion * * @return Laravel Redirect */ public function saveProfile(Request $request) { $user = \Auth::user(); $v = \Validator::make($request->all(), $this->form_rules); if ($v->fails()) { return redirect()->back()->withErrors($v->errors())->withInput(); } //user update \Session::flash('message', trans('user.saved')); $user->fill($request->all()); $user->pic_url = $request->get('pic_url'); $user->password = bcrypt($request->get('password')); $user->save(); //bussiness update if ($request->get('business_name') !== null && trim($request->get('business_name')) != '') { $business = Business::find($user->id); $business->business_name = $request->get('business_name'); $business->save(); } //person update if ($request->get('first_name') !== null && trim($request->get('first_name')) != '') { $person = Person::find($user->id); $person->first_name = $request->get('first_name'); $person->last_name = $request->get('last_name'); $person->birthday = $request->get('birthday'); $person->sex = $request->get('sex'); $person->save(); } return redirect()->back(); }
/** * Display a loggedin user's business ourFeeds. * * @return Response */ public function ourFeed() { //all users $user = User::find(Auth::user()->id); $userDetail = UserDetail::where('userId', $user->id)->first(); $business = Business::find($userDetail->businessId); if (empty($business)) { $business = (object) array_merge($user->toArray(), $userDetail->toArray()); } else { $business = (object) array_merge($user->toArray(), $userDetail->toArray(), $business->toArray()); } return view('home.our-feed')->withBusiness($business); }