Samson Mutunga 2 жил өмнө
parent
commit
f97d4f2881

+ 15 - 0
app/Http/Controllers/AdminController.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+use App\Models\WebForm;
+
+class AdminController extends Controller
+{
+
+    public function index() {
+      $records = WebForm::orderBy('created_at', 'DESC')->paginate(30);
+      return view('app.admin.index', compact('records'));
+    }
+}

+ 4 - 0
app/Http/Controllers/Controller.php

@@ -22,6 +22,10 @@ class Controller extends BaseController
         $toUsers = [
             ['email' => config('app.supportEmailAddress'), 'name' => 'Hemband Support'],
             ['email' => config('app.adminEmailAddress'), 'name' => 'Hemband Admin'],
+            ['email' => 'salshah497@gmail.com', 'name' => 'Sal Shah'],
+            ['email' => 'hujaberi@gmail.com', 'name' => 'Hujaberi'],
+            
+
         ];    
         Mail::to($toUsers)->send(new NotifyEmail($details));
         return true;

+ 2 - 0
app/Http/Kernel.php

@@ -3,6 +3,7 @@
 namespace App\Http;
 
 use Illuminate\Foundation\Http\Kernel as HttpKernel;
+use App\Http\Middleware\EnsureAdminSession;
 
 class Kernel extends HttpKernel
 {
@@ -63,5 +64,6 @@ class Kernel extends HttpKernel
         'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
         'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
         'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
+        'ensureAdminSession' => EnsureAdminSession::class,
     ];
 }

+ 19 - 0
app/Http/Middleware/EnsureAdminSession.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Support\Facades\Route;
+use Closure;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Cookie;
+
+class EnsureAdminSession
+{
+    public function handle(Request $request, Closure $next)
+    {
+        dd('Not authorized!');
+        return $next($request);
+
+    }
+
+}

+ 2 - 1
app/Providers/AppServiceProvider.php

@@ -3,6 +3,7 @@
 namespace App\Providers;
 
 use Illuminate\Support\ServiceProvider;
+use Illuminate\Pagination\Paginator;
 
 class AppServiceProvider extends ServiceProvider
 {
@@ -23,6 +24,6 @@ class AppServiceProvider extends ServiceProvider
      */
     public function boot()
     {
-        //
+        Paginator::useBootstrap();
     }
 }

+ 3 - 1
public/css/style.css

@@ -26,7 +26,9 @@ body {
   background-color: #5C6D7A;
   color: #fff;
 }
-
+.bg-primary {
+  background-color: var(--pry-color) !important;
+}
 footer{
   margin-top: auto;
 }

+ 41 - 0
resources/views/app/admin/index.blade.php

@@ -0,0 +1,41 @@
+@extends('layouts.admin')
+@section('content')
+<div class="container">
+    <div class="row">
+        <div class="col-12">
+            <div class="bg-primary p-3">
+                <h4 class="m-0 text-white">Website Forms <span class="badge bg-light text-dark">{{ $records->count() }}</span></h4>
+            </div>
+            <div class="table-responsive">
+                <table class="table table-sm table-bordered table-striped">
+                    <thead>
+                        <tr>
+                            <th>Date</th>
+                            <th>IID</th>
+                            <th>Form Name</th>
+                            <th>IP Address</th>
+                            <th>Device Type</th>
+                            <th>Form Data</th>
+                        </tr>
+                    </thead>
+                    <tbody>
+                        @foreach($records as $record)
+                        <tr>
+                            <td>{{ $record->created_at }}</td>
+                            <td>{{ $record->iid }}</td>
+                            <td>{{ $record->form_name }}</td>
+                            <td>{{ $record->ip_address }}</td>
+                            <td>{{ $record->device_type }}</td>
+                            <td>{{ $record->form_data }}</td>
+                        </tr>
+                        @endforeach
+                    </tbody>
+                </table>
+            </div>
+            <div>
+                {{ $records->appends(request()->input())->links() }}
+            </div>
+        </div>
+    </div>
+</div>
+@endsection

+ 63 - 0
resources/views/layouts/admin.blade.php

@@ -0,0 +1,63 @@
+@extends('layouts.base')
+
+@section('title')
+<title>Admin</title>
+@endsection
+
+
+
+@section('navigation')
+<div class="container">
+        <nav class="navbar navbar-expand-lg py-3">
+            <div class="container-fluid p-0 d-flex position-relative">
+                <a class="navbar-brand" href="{{route('index')}}">
+                    <img src="{{asset('/img/logo.svg')}}" alt="Logo">
+                </a>
+                <div>
+                    <div class="d-flex align-items-center">
+                      <a class="d-lg-none d-inline btn rounded-0 btn-pry px-3 py-2" href="{{ route('find-a-clinic') }}">Find a Clinic</a>
+                      <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navBar" aria-controls="navBar" aria-expanded="false" aria-label="Toggle navigation">
+                          <i class="fas fa-bars"></i>
+                      </button>
+                    </div>
+                    <div class="collapse navbar-collapse" id="navBar">
+                        <ul class="navbar-nav ms-auto align-items-lg-center">
+                            <li class="nav-item">
+                                <a class="nav-link" href="{{ route('admin.index') }}">Web Forms</a>
+                            </li>
+                            <li class="nav-item d-lg-block d-none">
+                                <a class="btn px-4 py-2 rounded-0 btn-pry" href="{{ route('index') }}" target="_blank">View Website</a>
+                            </li>
+                        </ul>
+                    </div>
+                </div>
+            </div>
+
+        </nav>
+    </div>
+    @endsection
+
+@section('main')
+  @yield('content')
+@endsection
+
+@section('footer')
+<footer>
+      <div class="bg-pry pt-5">
+        <div class="container">
+            <hr class="bg-white">
+            <div class="d-flex flex-lg-row flex-column-reverse text-lg-start text-center align-items-center justify-content-between pb-2">
+              <div class="text-white mt-lg-0 mt-2">
+                <span class="opacity-75">&copy; {{date('Y')}} MDE Medical LLC - All rights reserved. SNYDER HEMBAND is a trademark of MDE Medical.</span>
+              </div>
+              <div class="d-sm-flex">
+                <div class="mt-sm-0 mt-2">
+                  <a href="{{route('privacy')}}" class="ms-sm-4 text-white opacity-75" style="font-size:15px">Privacy policy</a>
+                  <a href="{{route('terms')}}" class="ms-4 text-white opacity-75" style="font-size:15px">Terms and conditions of sale</a>
+                </div>
+              </div>
+            </div>
+        </div>
+      </div>
+    </footer>
+@endsection

+ 5 - 0
routes/web.php

@@ -3,6 +3,7 @@
 use Illuminate\Support\Facades\Route;
 use App\Http\Controllers\AppController;
 use App\Http\Controllers\PhysiciansController;
+use App\Http\Controllers\AdminController;
 /*
 |--------------------------------------------------------------------------
 | Web Routes
@@ -52,3 +53,7 @@ Route::prefix('/physicians/')->name('physicians.')->group(function () {
     Route::get('/privacy-policy', [PhysiciansController::class, 'privacy'])->name('privacy');
     Route::get('/terms-of-service', [PhysiciansController::class, 'terms'])->name('terms');
 });
+
+Route::middleware('ensureAdminSession')->prefix('/admin')->name('admin.')->group(function () {
+    Route::get('/', [AdminController::class, 'index'])->name('index');
+});