From 9de5f8bef34c3e143632fea457b5de4386b9df40 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 5 Jun 2019 22:31:25 -0600 Subject: [PATCH] Add Contact model/view/controller --- app/Contact.php | 13 +++++ app/Http/Controllers/ContactController.php | 29 +++++++++++ ...019_06_06_032316_create_contacts_table.php | 37 ++++++++++++++ resources/views/site/contact.blade.php | 49 +++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 app/Contact.php create mode 100644 app/Http/Controllers/ContactController.php create mode 100644 database/migrations/2019_06_06_032316_create_contacts_table.php create mode 100644 resources/views/site/contact.blade.php diff --git a/app/Contact.php b/app/Contact.php new file mode 100644 index 000000000..bd4133367 --- /dev/null +++ b/app/Contact.php @@ -0,0 +1,13 @@ +belongsTo(User::class); + } +} diff --git a/app/Http/Controllers/ContactController.php b/app/Http/Controllers/ContactController.php new file mode 100644 index 000000000..ead90b458 --- /dev/null +++ b/app/Http/Controllers/ContactController.php @@ -0,0 +1,29 @@ +validate($request, [ + 'message' => 'required|string|min:5|max:500', + 'request_response' => 'string|max:3' + ]); + + $message = $request->input('message'); + $request_response = $request->input('request_response') == 'on' ? true : false; + $user = Auth::user(); + return $request->all(); + } +} diff --git a/database/migrations/2019_06_06_032316_create_contacts_table.php b/database/migrations/2019_06_06_032316_create_contacts_table.php new file mode 100644 index 000000000..2dabd047f --- /dev/null +++ b/database/migrations/2019_06_06_032316_create_contacts_table.php @@ -0,0 +1,37 @@ +bigIncrements('id'); + $table->bigInteger('user_id')->unsigned()->index(); + $table->boolean('response_requested')->default(false); + $table->text('message'); + $table->text('response'); + $table->timestamp('read_at')->nullable(); + $table->timestamp('responded_at')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('contacts'); + } +} diff --git a/resources/views/site/contact.blade.php b/resources/views/site/contact.blade.php new file mode 100644 index 000000000..3b45cc25a --- /dev/null +++ b/resources/views/site/contact.blade.php @@ -0,0 +1,49 @@ +@extends('site.partial.template') + +@section('section') + +
+

Contact

+
+
+
+ @auth +
+ @csrf +
+ + + 0/500 +
+
+ + +
+ +
+ @else +

+ @if(filter_var(config('instance.email'), FILTER_VALIDATE_EMAIL) == true) + You can contact the admins by sending an email to {{config('instance.email')}}. + @else + The admins have not listed any public email. Please log in to send a message. + @endif +

+ @endauth +
+@endsection + +@auth +@push('styles') + +@endpush + +@push('scripts') + +@endpush +@endauth \ No newline at end of file