diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 4f153f78ef..30f28726f1 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -1,10 +1,12 @@ message, function ($message) { + $subject = 'Customer Message'; + if ( ! Utils::isNinja()) { + $subject .= ': v' . NINJA_VERSION; + } + $message->to(CONTACT_EMAIL) + ->from(CONTACT_EMAIL, Auth::user()->present()->fullName) + ->replyTo(Auth::user()->email, Auth::user()->present()->fullName) + ->subject($subject); + }); + + return redirect(Request::server('HTTP_REFERER')) + ->with('message', trans('texts.contact_us_response')); + } } diff --git a/app/Http/routes.php b/app/Http/routes.php index d76119e431..a8031c2768 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -131,6 +131,7 @@ Route::group(['middleware' => 'auth:user'], function() { Route::get('account/get_search_data', ['as' => 'get_search_data', 'uses' => 'AccountController@getSearchData']); Route::get('check_invoice_number/{invoice_id?}', 'InvoiceController@checkInvoiceNumber'); Route::post('save_sidebar_state', 'UserController@saveSidebarState'); + Route::post('contact_us', 'HomeController@contactUs'); Route::get('settings/user_details', 'AccountController@showUserDetails'); Route::post('settings/user_details', 'AccountController@saveUserDetails'); diff --git a/app/Models/User.php b/app/Models/User.php index f4e49a259a..72fe6e8d78 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -7,12 +7,20 @@ use App\Events\UserSettingsChanged; use App\Events\UserSignedUp; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Database\Eloquent\SoftDeletes; +use Laracasts\Presenter\PresentableTrait; /** * Class User */ class User extends Authenticatable { + use PresentableTrait; + + /** + * @var string + */ + protected $presenter = 'App\Ninja\Presenters\UserPresenter'; + /** * @var array */ diff --git a/app/Ninja/Presenters/UserPresenter.php b/app/Ninja/Presenters/UserPresenter.php new file mode 100644 index 0000000000..ce1098d41f --- /dev/null +++ b/app/Ninja/Presenters/UserPresenter.php @@ -0,0 +1,14 @@ +', $this->fullName(), $this->entity->email)); + } + + public function fullName() + { + return $this->entity->first_name . ' ' . $this->entity->last_name; + } +} diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 8724859439..1d3e666633 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2274,6 +2274,7 @@ $LANG = array( 'marked_sent_invoices' => 'Successfully marked invoices sent', 'invoice_name' => 'Invoice', 'product_will_create' => 'product will be created', + 'contact_us_response' => 'Your message has been sent', ); diff --git a/resources/views/header.blade.php b/resources/views/header.blade.php index bff66040e6..2b2dd5fac3 100644 --- a/resources/views/header.blade.php +++ b/resources/views/header.blade.php @@ -517,7 +517,7 @@ @include('partials.navigation_option', ['option' => 'settings'])
  • +@include('partials.contact_us') @if (!Auth::check() || !Auth::user()->registered)