Преглед на файлове

Request marketing materials

Samson Mutunga преди 2 години
родител
ревизия
bc0d6e168d

+ 29 - 0
app/Http/Controllers/PhysiciansController.php

@@ -10,6 +10,7 @@ use Illuminate\Http\Request;
 use App\Models\PhysicianTrainingRequest;
 use App\Models\PhysicianContactMessage;
 use App\Models\PhysicianDirectoryListingRequest;
+use App\Models\PhysicianMarketingMaterialsRequest;
 
 class PhysiciansController extends Controller
 {
@@ -145,5 +146,33 @@ class PhysiciansController extends Controller
       $record->save();
       return redirect()->back()->with('success', 'Your request has been submitted!');
     }
+    public function submitOrderProductsMarketing(Request $request) {
+      $request->validate([
+        'name_first' => 'required|string',
+        'name_last' => 'required|string',
+        'title' => 'required|string',
+        'practice_name' => 'required|string',
+        'practice_address' => 'required|string',
+        'email' => 'required|email',
+        'phone' => 'required|string',
+        'zip' => 'required|string',
+        'comment' => 'required|string',
+      ]);
+
+      $record = new PhysicianMarketingMaterialsRequest;
+      $record->iid = $this->makeIID();
+      $record->uid = Uuid::uuid6();
+      $record->name_first = $request->get('name_first');
+      $record->name_last = $request->get('name_last');
+      $record->title = $request->get('title');
+      $record->practice_name = $request->get('practice_name');
+      $record->practice_address = $request->get('practice_address');
+      $record->email = $request->get('email');
+      $record->phone = $request->get('phone');
+      $record->zip = $request->get('zip');
+      $record->comment = $request->get('comment');
 
+      $record->save();
+      return redirect()->back()->with('success', 'Your request has been submitted!');
+    }
 }

+ 11 - 0
app/Models/PhysicianMarketingMaterialsRequest.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace App\Models;
+
+use App\Models\Base\BaseModel;
+use Illuminate\Database\Eloquent\Model;
+
+class PhysicianMarketingMaterialsRequest extends BaseModel
+{
+    protected $table = 'physician_marketing_materials_request';
+}

+ 42 - 0
database/migrations/2022_11_16_095025_create_physician_marketing_materials_request_table.php

@@ -0,0 +1,42 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreatePhysicianMarketingMaterialsRequestTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('physician_marketing_materials_request', function (Blueprint $table) {
+            $table->id();
+            $table->string('uid')->unique();
+            $table->string('iid')->unique();
+            $table->string('name_first');
+            $table->string('name_last');
+            $table->string('title')->nullable();
+            $table->string('practice_name')->nullable();
+            $table->string('practice_address')->nullable();
+            $table->string('email')->nullable();
+            $table->string('phone')->nullable();
+            $table->string('zip')->nullable();
+            $table->text('comment')->nullable();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('physician_marketing_materials_request');
+    }
+}

+ 43 - 4
resources/views/app/physicians/order-products/marketing.blade.php

@@ -34,49 +34,88 @@
       <p class="mt-4">We know that marketing materials are a huge asset in helping patients and staff understand the Snyder HemBand procedure. Because of this, we’re happy to provide a variety of marketing materials at no cost to you or your practice.</p>
       <p>To place an order, please fill out the form below or submit an order form via fax or email <a href="mailto:info@snyderhemband.org">info@snyderhemband.org</a>.</p>
       <div class="bg-light p-4">
-        <form class="" action="" method="post">
+        <form class="" action="{{ route('physicians.submit-order-products-marketing') }}" method="post">
           @csrf
           <div class="row">
+            <div class="col-12">
+              @if($errors->any())
+                <div class="alert alert-danger fade show" role="alert">
+                  There were errors found!
+                </div>
+              @endif
+              @if(session('success'))
+                <div class="alert alert-success fade show" role="alert">
+                  {{session('success')}}
+                </div>
+              @endif
+            </div>
             <div class="col-lg-6 form-group mb-4">
               <label>First Name <span class="text-danger">*</span> </label>
               <input type="text" class="form-control rounded-0 py-3" required name="name_first" value="{{ old('name_first') }}">
+              @error('name_first')
+                <small class="text-warning">{{$message}}</small>
+              @enderror
             </div>
             <div class="col-lg-6 form-group mb-4">
               <label>Last Name <span class="text-danger">*</span> </label>
               <input type="text" class="form-control rounded-0 py-3" required name="name_last" value="{{ old('name_last') }}">
+              @error('name_last')
+                <small class="text-warning">{{$message}}</small>
+              @enderror
             </div>
           </div>
           <div class="form-group mb-4">
             <label>Title <span class="text-danger">*</span> </label>
             <input type="text" class="form-control rounded-0 py-3" required name="title" value="{{ old('title') }}">
+            @error('title')
+                <small class="text-warning">{{$message}}</small>
+              @enderror
           </div>
           <div class="row">
             <div class="col-lg-4 form-group mb-4">
               <label>Practice Name <span class="text-danger">*</span> </label>
               <input type="text" class="form-control rounded-0 py-3" required name="practice_name" value="{{ old('practice_name') }}">
+              @error('practice_name')
+                <small class="text-warning">{{$message}}</small>
+              @enderror
             </div>
             <div class="col-lg-5 form-group mb-4">
               <label>Practice Address <span class="text-danger">*</span> </label>
               <input type="text" class="form-control rounded-0 py-3" required name="practice_address" value="{{ old('practice_address') }}">
+              @error('practice_address')
+                <small class="text-warning">{{$message}}</small>
+              @enderror
             </div>
             <div class="col-lg-3 form-group mb-4">
               <label>Practice Zip Code <span class="text-danger">*</span> </label>
-              <input type="text" class="form-control rounded-0 py-3" required name="practice_zip" value="{{ old('practice_zip') }}">
+              <input type="text" class="form-control rounded-0 py-3" required name="zip" value="{{ old('zip') }}">
+              @error('zip')
+                <small class="text-warning">{{$message}}</small>
+              @enderror
             </div>
           </div>
           <div class="row">
             <div class="col-lg-6 form-group mb-4">
               <label>Contact Phone Number <span class="text-danger">*</span> </label>
-              <input type="tel" class="form-control rounded-0 py-3 phone" required placeholder="(xxx) xxx-xxxx" name="contact_phone" value="{{ old('contact_phone') }}">
+              <input type="tel" class="form-control rounded-0 py-3 phone" required placeholder="(xxx) xxx-xxxx" name="phone" value="{{ old('phone') }}">
+              @error('phone')
+                <small class="text-warning">{{$message}}</small>
+              @enderror
             </div>
             <div class="col-lg-6 form-group mb-4">
               <label>Contact Email <span class="text-danger">*</span> </label>
               <input type="email" class="form-control rounded-0 py-3" required name="email" value="{{ old('email') }}">
+              @error('email')
+                <small class="text-warning">{{$message}}</small>
+              @enderror
             </div>
           </div>
           <div class="form-group mb-4">
             <label>Order request</label>
-            <textarea name="request" class="form-control rounded-0" rows="6">{{ old('request') }}</textarea>
+            <textarea name="comment" class="form-control rounded-0" rows="6">{{ old('comment') }}</textarea>
+              @error('comment')
+                <small class="text-warning">{{$message}}</small>
+              @enderror
           </div>
           <button type="submit" class="btn btn-pry w-100 py-3">SUBMIT</button>
         </form>

+ 1 - 0
routes/web.php

@@ -37,6 +37,7 @@ Route::prefix('/physicians/')->name('physicians.')->group(function () {
     Route::get('/order-products', [PhysiciansController::class, 'orderProducts'])->name('order-products');
     Route::get('/order-products/ligators', [PhysiciansController::class, 'orderProductsLigators'])->name('order-products-ligators');
     Route::get('/order-products/marketing-materials', [PhysiciansController::class, 'orderProductsMarketing'])->name('order-products-marketing');
+    Route::post('/order-products/submit-marketing-materials-request', [PhysiciansController::class, 'submitOrderProductsMarketing'])->name('submit-order-products-marketing');
     Route::get('/order-products/obp', [PhysiciansController::class, 'orderProductsObp'])->name('order-products-obp');
     Route::get('/fda-registration', [PhysiciansController::class, 'fdaRegistration'])->name('fda-registration');
     Route::get('/contact-us', [PhysiciansController::class, 'contactUs'])->name('contact-us');