From ec61ab6c7aa79a4b63c720a68c6c1549e2b76d35 Mon Sep 17 00:00:00 2001 From: Manish Verma Date: Mon, 17 Oct 2016 17:47:10 +0530 Subject: [PATCH] bug-fix-patch Soleved user profile pic issue and application URL in outgoing mail. --- .../Controllers/Common/PhpMailController.php | 2 +- app/User.php | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Common/PhpMailController.php b/app/Http/Controllers/Common/PhpMailController.php index a1c3e2a8e..614fc6b58 100644 --- a/app/Http/Controllers/Common/PhpMailController.php +++ b/app/Http/Controllers/Common/PhpMailController.php @@ -108,7 +108,7 @@ class PhpMailController extends Controller } $system_link = $this->checkElement('system_link', $template_variables); if ($system_link === '') { - $system_link = url('/'); + $system_link = \Config::get('app.url'); } $system_error = $this->checkElement('system_error', $template_variables); $agent_sign = $this->checkElement('agent_sign', $template_variables); diff --git a/app/User.php b/app/User.php index 31a1a11d7..aaf946661 100644 --- a/app/User.php +++ b/app/User.php @@ -47,7 +47,8 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon if (!$pic) { $pic = asset('uploads/profilepic/'.$value); } - if (!$pic) { + + if ($this->endsWith($pic, 'profilepic')) { $pic = \Gravatar::src($this->attributes['email']); } @@ -155,4 +156,18 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon return $this->user_name; } + /** + * @category function to check profile pic source srting ends with profilepic or not + * @param string $haystack, $needle + * @return boolean true/false + */ + function endsWith($haystack, $needle) + { + $length = strlen($needle); + if ($length == 0) { + return true; + } + + return (substr($haystack, -$length) === $needle); + } }