|
@@ -22,38 +22,38 @@ class ProfileController extends Controller
|
|
|
public function anyBase(Request $request)
|
|
|
{
|
|
|
$user = $request->user();
|
|
|
- if($request->isMethod('POST')){
|
|
|
+ if ($request->isMethod('POST')) {
|
|
|
$request->flash();
|
|
|
$validateRules = [
|
|
|
'name' => 'required|max:128',
|
|
|
'title' => 'sometimes|max:128',
|
|
|
'description' => 'sometimes|max:9999',
|
|
|
];
|
|
|
- $this->validate($request,$validateRules);
|
|
|
+ $this->validate($request, $validateRules);
|
|
|
$user->name = $request->input('name');
|
|
|
$user->gender = $request->input('gender');
|
|
|
- if($request->input('birthday')){
|
|
|
+ if ($request->input('birthday')) {
|
|
|
$user->birthday = $request->input('birthday');
|
|
|
}
|
|
|
$user->title = $request->input('title');
|
|
|
$user->description = $request->input('description');
|
|
|
$user->province = $request->input('province');
|
|
|
$user->city = $request->input('city');
|
|
|
- if($request->hasFile('qrcode')){
|
|
|
+ if ($request->hasFile('qrcode')) {
|
|
|
$validateRules = [
|
|
|
- 'qrcode' => 'required|image|max:'.config('tipask.upload.image_size'),
|
|
|
+ 'qrcode' => 'required|image|max:' . config('tipask.upload.image_size'),
|
|
|
];
|
|
|
- $this->validate($request,$validateRules);
|
|
|
+ $this->validate($request, $validateRules);
|
|
|
$file = $request->file('qrcode');
|
|
|
$extension = $file->getClientOriginalExtension();
|
|
|
- $filePath = 'qrcodes/'.gmdate("Y")."/".gmdate("m")."/".uniqid(str_random(8)).'.'.$extension;
|
|
|
- Storage::disk('local')->put($filePath,File::get($file));
|
|
|
- Image::make(storage_path('app/'.$filePath))->resize(320,435)->save();
|
|
|
- $user->qrcode = str_replace("/","-",$filePath);
|
|
|
+ $filePath = 'qrcodes/' . gmdate("Y") . "/" . gmdate("m") . "/" . uniqid(str_random(8)) . '.' . $extension;
|
|
|
+ Storage::disk('local')->put($filePath, File::get($file));
|
|
|
+ Image::make(storage_path('app/' . $filePath))->resize(320, 435)->save();
|
|
|
+ $user->qrcode = str_replace("/", "-", $filePath);
|
|
|
}
|
|
|
|
|
|
$user->save();
|
|
|
- return $this->success(route('auth.profile.base'),'个人资料修改成功');
|
|
|
+ return $this->success(route('auth.profile.base'), '个人资料修改成功');
|
|
|
|
|
|
}
|
|
|
$provinces = Area::provinces();
|
|
@@ -63,7 +63,7 @@ class ProfileController extends Controller
|
|
|
'cities' => $cities,
|
|
|
];
|
|
|
|
|
|
- return view('theme::profile.base')->with('data',$data);
|
|
|
+ return view('theme::profile.base')->with('data', $data);
|
|
|
}
|
|
|
|
|
|
function upload_image($path, $file, $drive = 'oss')
|
|
@@ -84,30 +84,29 @@ class ProfileController extends Controller
|
|
|
{
|
|
|
|
|
|
|
|
|
-
|
|
|
$validateRules = [
|
|
|
'user_avatar' => 'required|image',
|
|
|
];
|
|
|
|
|
|
- if($request->hasFile('user_avatar')){
|
|
|
- $this->validate($request,$validateRules);
|
|
|
+ if ($request->hasFile('user_avatar')) {
|
|
|
+ $this->validate($request, $validateRules);
|
|
|
$user_id = $request->user()->id;
|
|
|
$file = $request->file('user_avatar');
|
|
|
$avatarDir = User::getAvatarDir($user_id);
|
|
|
$extension = strtolower($file->getClientOriginalExtension());
|
|
|
$extArray = array('png', 'gif', 'jpeg', 'jpg');
|
|
|
|
|
|
- if(in_array($extension, $extArray)){
|
|
|
+ if (in_array($extension, $extArray)) {
|
|
|
// if($extension != 'jpg'){
|
|
|
// Image::make(File::get($file))->save(storage_path('app/'.User::getAvatarPath($user_id,'origin')));
|
|
|
// Image::make(File::get($file))->save(app('path.public').'/static/uploads/user_origin_'.$user_id.'.jpg');
|
|
|
- $path = 'avatar/' . date("Ym/d", time());
|
|
|
- $data['qrcode'] = $this->upload_image($path, $request->user_avatar);
|
|
|
- DB::table('users')->where('id','=',$user_id)->update($data);
|
|
|
+ $path = 'avatar/' . date("Ym/d", time());
|
|
|
+ $data['qrcode'] = $this->upload_image($path, $request->user_avatar);
|
|
|
+ DB::table('users')->where('id', '=', $user_id)->update($data);
|
|
|
// }else{
|
|
|
// Storage::disk('local')->put($avatarDir.'/'.User::getAvatarFileName($user_id,'origin').'.'.$extension,File::get($file));
|
|
|
// }
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return response('error');
|
|
|
}
|
|
|
|
|
@@ -117,7 +116,7 @@ class ProfileController extends Controller
|
|
|
));
|
|
|
}
|
|
|
|
|
|
- if($request->isMethod('POST')){
|
|
|
+ if ($request->isMethod('POST')) {
|
|
|
$x = intval($request->input('x'));
|
|
|
$y = intval($request->input('y'));
|
|
|
$width = intval($request->input('width'));
|
|
@@ -133,14 +132,14 @@ class ProfileController extends Controller
|
|
|
// Image::make(storage_path('app/'.User::getAvatarPath($user_id,'origin')))->crop($width,$height,$x,$y)->resize(24,24)->save(storage_path('app/'.User::getAvatarPath($user_id,'small')));
|
|
|
// $path = 'avatar/' . date("Ym/d", time());
|
|
|
// $data['qrcode'] = $this->upload_image($path, $request->user_avatar);
|
|
|
- File::delete(app('path.public').'/static/uploads/user_big_'.$user_id.'.jpg');
|
|
|
- File::delete(app('path.public').'/static/uploads/user_middle_'.$user_id.'.jpg');
|
|
|
- File::delete(app('path.public').'/static/uploads/user_small_'.$user_id.'.jpg');
|
|
|
- Image::make(storage_path('app/'.User::getAvatarPath($user_id,'origin')))->crop($width,$height,$x,$y)->resize(128,128)->save(app('path.public').'/static/uploads/user_big_'.$user_id.'.jpg');
|
|
|
- Image::make(storage_path('app/'.User::getAvatarPath($user_id,'origin')))->crop($width,$height,$x,$y)->resize(64,64)->save(app('path.public').'/static/uploads/user_middle_'.$user_id.'.jpg');
|
|
|
- Image::make(storage_path('app/'.User::getAvatarPath($user_id,'origin')))->crop($width,$height,$x,$y)->resize(24,24)->save(app('path.public').'/static/uploads/user_small_'.$user_id.'.jpg');
|
|
|
- $data['qrcode'] = '/static/uploads/user_big_'.$user_id.'.jpg';
|
|
|
- DB::table('users')->where('id','=',$user_id)->update($data);
|
|
|
+ File::delete(app('path.public') . '/static/uploads/user_big_' . $user_id . '.jpg');
|
|
|
+ File::delete(app('path.public') . '/static/uploads/user_middle_' . $user_id . '.jpg');
|
|
|
+ File::delete(app('path.public') . '/static/uploads/user_small_' . $user_id . '.jpg');
|
|
|
+ Image::make(storage_path('app/' . User::getAvatarPath($user_id, 'origin')))->crop($width, $height, $x, $y)->resize(128, 128)->save(app('path.public') . '/static/uploads/user_big_' . $user_id . '.jpg');
|
|
|
+ Image::make(storage_path('app/' . User::getAvatarPath($user_id, 'origin')))->crop($width, $height, $x, $y)->resize(64, 64)->save(app('path.public') . '/static/uploads/user_middle_' . $user_id . '.jpg');
|
|
|
+ Image::make(storage_path('app/' . User::getAvatarPath($user_id, 'origin')))->crop($width, $height, $x, $y)->resize(24, 24)->save(app('path.public') . '/static/uploads/user_small_' . $user_id . '.jpg');
|
|
|
+ $data['qrcode'] = '/static/uploads/user_big_' . $user_id . '.jpg';
|
|
|
+ DB::table('users')->where('id', '=', $user_id)->update($data);
|
|
|
return response()->json(array(
|
|
|
'status' => 1,
|
|
|
'msg' => '头像截剪成功'
|
|
@@ -155,23 +154,23 @@ class ProfileController extends Controller
|
|
|
*/
|
|
|
public function anyPassword(Request $request)
|
|
|
{
|
|
|
- if($request->isMethod('POST')){
|
|
|
+ if ($request->isMethod('POST')) {
|
|
|
$validateRules = [
|
|
|
'old_password' => 'required|min:6|max:16',
|
|
|
'password' => 'required|min:6|max:16',
|
|
|
- 'password_confirmation'=>'same:password',
|
|
|
+ 'password_confirmation' => 'same:password',
|
|
|
'captcha' => 'required|captcha',
|
|
|
|
|
|
];
|
|
|
- $this->validate($request,$validateRules);
|
|
|
+ $this->validate($request, $validateRules);
|
|
|
|
|
|
$user = $request->user();
|
|
|
|
|
|
- if(Hash::check($request->input('old_password'),$user->password)){
|
|
|
+ if (Hash::check($request->input('old_password'), $user->password)) {
|
|
|
$user->password = Hash::make($request->input('password'));
|
|
|
$user->save();
|
|
|
Auth()->logout();
|
|
|
- return $this->success(route('auth.user.login'),'密码修改成功,请重新登录');
|
|
|
+ return $this->success(route('auth.user.login'), '密码修改成功,请重新登录');
|
|
|
}
|
|
|
|
|
|
return redirect(route('auth.profile.password'))
|
|
@@ -185,31 +184,30 @@ class ProfileController extends Controller
|
|
|
/*修改邮箱*/
|
|
|
public function anyEmail(Request $request)
|
|
|
{
|
|
|
- if($request->isMethod('POST'))
|
|
|
- {
|
|
|
+ if ($request->isMethod('POST')) {
|
|
|
$validateRules = [
|
|
|
- 'email' => 'required|email|unique:users,email,'.$request->user()->id,
|
|
|
+ 'email' => 'required|email|unique:users,email,' . $request->user()->id,
|
|
|
'captcha' => 'required|captcha',
|
|
|
];
|
|
|
- $this->validate($request,$validateRules);
|
|
|
+ $this->validate($request, $validateRules);
|
|
|
|
|
|
- if($request->input('email') !== $request->user()->email){
|
|
|
+ if ($request->input('email') !== $request->user()->email) {
|
|
|
$request->user()->email = $request->input('email');
|
|
|
$request->user()->status = 0;
|
|
|
$request->user()->save();
|
|
|
$emailToken = EmailToken::create([
|
|
|
- 'email' =>$request->input('email'),
|
|
|
+ 'email' => $request->input('email'),
|
|
|
'action' => 'verify',
|
|
|
'token' => EmailToken::createToken(),
|
|
|
]);
|
|
|
|
|
|
- if($emailToken){
|
|
|
- $subject = '欢迎注册'.Setting()->get('website_name').',请激活您注册的邮箱!';
|
|
|
- $content = "「".$request->user()->name."」您好,请激活您在 ".Setting()->get('website_name')." 的注册邮箱!<br /> 请在1小时内点击该链接激活注册账号 → ".route('auth.email.verifyToken',['action'=>$emailToken->action,'token'=>$emailToken->token])."<br />如非本人操作,请忽略此邮件!";
|
|
|
- $this->sendEmail($emailToken->email,$subject,$content);
|
|
|
+ if ($emailToken) {
|
|
|
+ $subject = '欢迎注册' . Setting()->get('website_name') . ',请激活您注册的邮箱!';
|
|
|
+ $content = "「" . $request->user()->name . "」您好,请激活您在 " . Setting()->get('website_name') . " 的注册邮箱!<br /> 请在1小时内点击该链接激活注册账号 → " . route('auth.email.verifyToken', ['action' => $emailToken->action, 'token' => $emailToken->token]) . "<br />如非本人操作,请忽略此邮件!";
|
|
|
+ $this->sendEmail($emailToken->email, $subject, $content);
|
|
|
}
|
|
|
|
|
|
- return $this->success(route('auth.profile.email'),'邮箱修改成功!一封验证邮件已经发到您的邮箱'.$request->user()->email.',请登陆邮箱进行验证!');
|
|
|
+ return $this->success(route('auth.profile.email'), '邮箱修改成功!一封验证邮件已经发到您的邮箱' . $request->user()->email . ',请登陆邮箱进行验证!');
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -219,19 +217,19 @@ class ProfileController extends Controller
|
|
|
|
|
|
public function anyMobile(Request $request)
|
|
|
{
|
|
|
- if($request->isMethod('post')){
|
|
|
+ if ($request->isMethod('post')) {
|
|
|
$validateRules = [
|
|
|
- 'mobile' => 'required|max:11,'.$request->user()->id,
|
|
|
+ 'mobile' => 'required|max:11,' . $request->user()->id,
|
|
|
'code' => 'required|min:4|max:10',
|
|
|
];
|
|
|
|
|
|
- $this->validate($request,$validateRules);
|
|
|
+ $this->validate($request, $validateRules);
|
|
|
|
|
|
$mobile = $request->input('mobile');
|
|
|
$code = $request->input('code');
|
|
|
|
|
|
- if(!SmsService::verifySmsCode($mobile,$code)){
|
|
|
- return $this->error(route('auth.profile.mobile'),"短信验证码错误,请重新验证");
|
|
|
+ if (!SmsService::verifySmsCode($mobile, $code)) {
|
|
|
+ return $this->error(route('auth.profile.mobile'), "短信验证码错误,请重新验证");
|
|
|
}
|
|
|
|
|
|
$request->user()->mobile = $mobile;
|
|
@@ -239,14 +237,12 @@ class ProfileController extends Controller
|
|
|
$request->user()->save();
|
|
|
$request->user()->userData->mobile_status = 1;
|
|
|
$request->user()->userData->save();
|
|
|
- return $this->success(route('auth.profile.mobile'),'手机号码绑定成功!');
|
|
|
+ return $this->success(route('auth.profile.mobile'), '手机号码绑定成功!');
|
|
|
}
|
|
|
return view('theme::profile.mobile');
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/*第三方系统账号绑定*/
|
|
|
public function anyOauth()
|
|
|
{
|
|
@@ -257,25 +253,25 @@ class ProfileController extends Controller
|
|
|
/*消息通知设置*/
|
|
|
public function anyNotification(Request $request)
|
|
|
{
|
|
|
- if($request->isMethod('post')){
|
|
|
- $siteNotifications = $request->input('site_notifications','');
|
|
|
- $emailNotifications = $request->input('email_notifications','');
|
|
|
+ if ($request->isMethod('post')) {
|
|
|
+ $siteNotifications = $request->input('site_notifications', '');
|
|
|
+ $emailNotifications = $request->input('email_notifications', '');
|
|
|
$request->user()->site_notifications = '';
|
|
|
- if($siteNotifications){
|
|
|
- $request->user()->site_notifications = implode(",",$siteNotifications);
|
|
|
+ if ($siteNotifications) {
|
|
|
+ $request->user()->site_notifications = implode(",", $siteNotifications);
|
|
|
}
|
|
|
$request->user()->email_notifications = '';
|
|
|
- if($emailNotifications){
|
|
|
- $request->user()->email_notifications = implode(",",$emailNotifications);
|
|
|
+ if ($emailNotifications) {
|
|
|
+ $request->user()->email_notifications = implode(",", $emailNotifications);
|
|
|
}
|
|
|
|
|
|
$request->user()->save();
|
|
|
- return $this->success(route('auth.profile.notification'),'通知提醒策略设置成功');
|
|
|
+ return $this->success(route('auth.profile.notification'), '通知提醒策略设置成功');
|
|
|
|
|
|
}
|
|
|
- $siteNotifications = explode(",",$request->user()->site_notifications);
|
|
|
- $emailNotifications = explode(",",$request->user()->email_notifications);
|
|
|
- return view('theme::profile.notification')->with(compact('siteNotifications','emailNotifications'));
|
|
|
+ $siteNotifications = explode(",", $request->user()->site_notifications);
|
|
|
+ $emailNotifications = explode(",", $request->user()->email_notifications);
|
|
|
+ return view('theme::profile.notification')->with(compact('siteNotifications', 'emailNotifications'));
|
|
|
|
|
|
}
|
|
|
|