From 20943b784d9acb78af09cd91b60a97a823b59301 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Thu, 5 Apr 2018 14:43:29 +0200 Subject: [PATCH] Revert previous patch --- app/Http/Controllers/ContactUsController.php | 48 +++------------ app/Http/Requests/ContactFormRequest.php | 32 ---------- app/Models/Admin.php | 25 -------- app/Notifications/InboxMessage.php | 65 -------------------- resources/views/themes/Gentele/contact.tpl | 21 ++++--- routes/web.php | 4 +- 6 files changed, 22 insertions(+), 173 deletions(-) delete mode 100644 app/Http/Requests/ContactFormRequest.php delete mode 100644 app/Models/Admin.php delete mode 100644 app/Notifications/InboxMessage.php diff --git a/app/Http/Controllers/ContactUsController.php b/app/Http/Controllers/ContactUsController.php index 2c0acfac9..f0a8a8158 100644 --- a/app/Http/Controllers/ContactUsController.php +++ b/app/Http/Controllers/ContactUsController.php @@ -2,25 +2,17 @@ namespace App\Http\Controllers; -use App\Models\Admin; use App\Mail\ContactUs; use App\Models\Settings; use Illuminate\Http\Request; -use App\Notifications\InboxMessage; use Illuminate\Support\Facades\Mail; -use App\Http\Requests\ContactFormRequest; -class ContactUsController extends Controller +class ContactUsController extends BasePageController { - /** - * @param mixed $ability - * @param array $arguments - * - * @return bool|\Illuminate\Auth\Access\Response - */ - public function authorize($ability, $arguments = []) + public function __construct(Request $request) { - return true; + parent::__construct($request); + $this->middleware('guest'); } /** @@ -28,7 +20,7 @@ class ContactUsController extends Controller * * @throws \Exception */ - public function contact(Request $request) + public function showContactForm(Request $request) { $this->validate($request, [ 'useremail' => 'required', @@ -58,46 +50,24 @@ class ContactUsController extends Controller } $msg = "

Thank you for getting in touch with ".Settings::settingValue('site.main.title').'.

'; } - app('smarty.view')->assign('message', $msg); - } - - /** - * @throws \Exception - */ - public function show() - { - $theme = Settings::settingValue('site.main.style'); + $this->smarty->assign('msg', $msg); $title = 'Contact '.Settings::settingValue('site.main.title'); $meta_title = 'Contact '.Settings::settingValue('site.main.title'); $meta_keywords = 'contact us,contact,get in touch,email'; $meta_description = 'Contact us at '.Settings::settingValue('site.main.title').' and submit your feedback'; - $content = app('smarty.view')->fetch($theme.'/contact.tpl'); + $content = $this->smarty->fetch('contact.tpl'); - app('smarty.view')->assign( + $this->smarty->assign( [ 'title' => $title, 'content' => $content, - 'nocaptcha' => env('NOCAPTCHA_ENABLED'), 'meta_title' => $meta_title, 'meta_keywords' => $meta_keywords, 'meta_description' => $meta_description, ] ); - app('smarty.view')->display($theme.'/basepage.tpl'); - } - - /** - * @param \App\Http\Requests\ContactFormRequest $message - * @param \App\Models\Admin $admin - * - * @return \Illuminate\Http\RedirectResponse - */ - public function mailToAdmin(ContactFormRequest $message, Admin $admin) - { //send the admin an notification - $admin->notify(new InboxMessage($message)); - // redirect the user back - return redirect()->back()->with('message', 'Thanks for the message! We will get back to you soon!'); + $this->pagerender(); } } diff --git a/app/Http/Requests/ContactFormRequest.php b/app/Http/Requests/ContactFormRequest.php deleted file mode 100644 index 6f5a57080..000000000 --- a/app/Http/Requests/ContactFormRequest.php +++ /dev/null @@ -1,32 +0,0 @@ - 'required|max: 255', - 'useremail' => 'required|email|max: 255', - 'message' => 'required', - ]; - } -} diff --git a/app/Models/Admin.php b/app/Models/Admin.php deleted file mode 100644 index 6ebc51c4b..000000000 --- a/app/Models/Admin.php +++ /dev/null @@ -1,25 +0,0 @@ -admin = env('ADMIN_USER'); - $this->email = Settings::settingValue('site.main.email'); - } -} diff --git a/app/Notifications/InboxMessage.php b/app/Notifications/InboxMessage.php deleted file mode 100644 index 893fe18b9..000000000 --- a/app/Notifications/InboxMessage.php +++ /dev/null @@ -1,65 +0,0 @@ -message = $message; - } - - /** - * Get the notification's delivery channels. - * - * @param mixed $notifiable - * @return array - */ - public function via($notifiable) - { - return ['mail']; - } - - /** - * Get the mail representation of the notification. - * - * @param mixed $notifiable - * @return \Illuminate\Notifications\Messages\MailMessage - */ - public function toMail($notifiable) - { - return (new MailMessage) - ->subject(env('ADMIN_USER').', you got a new message!') - ->greeting(' ') - ->salutation(' ') - ->from($this->message->email, $this->message->name) - ->line($this->message->message); - } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } -} diff --git a/resources/views/themes/Gentele/contact.tpl b/resources/views/themes/Gentele/contact.tpl index 4be1cfb39..525517713 100755 --- a/resources/views/themes/Gentele/contact.tpl +++ b/resources/views/themes/Gentele/contact.tpl @@ -1,3 +1,10 @@ + + + + + {$meta_title}{if $meta_title != "" && $site->metatitle != ""} - {/if}{$site->metatitle} + +
@@ -28,14 +35,9 @@ happy to help you.
- {if {(session('message'))}} -
- {{session('message')}} -
- {/if}
-
+ {{csrf_field()}}
@@ -49,12 +51,10 @@ class="form-control form-white">
- - - {if $nocaptcha != false} {NoCaptcha::display()}{NoCaptcha::renderJs()} - {/if} @@ -73,3 +73,4 @@
+ diff --git a/routes/web.php b/routes/web.php index 21d17277e..8b1231fa4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -90,8 +90,8 @@ Route::get('/xxx', function () { redirect('/xxx'); })->middleware('auth'); -Route::get('/contact-us', 'ContactUsController@show'); -Route::post('/contact-us', 'ContactUsController@mailToAdmin'); +Route::get('contact-us', 'ContactUsController@showContactForm'); +Route::post('contact-us', 'ContactUsController@showContactForm'); Route::post('/contact-us', function () { redirect('/contact-us');