Blame view

api/app/Http/Controllers/V1/Partners/VdmController.php 1.21 KB
b28322f5b   Chris Bellas   Added VDM endpoint
1
2
3
4
5
6
  <?php
  
  namespace App\Http\Controllers\V1\Partners;
  
  
  use App\Http\Controllers\Controller;
67201a804   Chris Bellas   Updated VdmContro...
7
  //use App\Http\Requests\VdmRequest;
b28322f5b   Chris Bellas   Added VDM endpoint
8
9
  use Carbon\Carbon;
  use Illuminate\Support\Facades\DB;
39c2e3bd6   George Vlahavas   Log IP for VDM re...
10
11
  use Illuminate\Http\Request;
  use Illuminate\Support\Facades\Log;
b28322f5b   Chris Bellas   Added VDM endpoint
12
13
14
  
  class VdmController extends Controller
  {
67201a804   Chris Bellas   Updated VdmContro...
15
16
      //public function store(VdmRequest $request)
      public function store()
b28322f5b   Chris Bellas   Added VDM endpoint
17
      {
67201a804   Chris Bellas   Updated VdmContro...
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
         // $records = [];
  
         // // merge two input arrays
         // $cve = $request->get('cve');
         // $cwe = $request->get('cwe');
  
         // $merged = array_merge($cve, $cwe);
  
         // foreach ($merged as $item) {
         //     $records[] = [
         //         'asset_id' => $request->get('asset_id'),
         //         'time' => Carbon::createFromTimestamp($request->get('timestamp')),
         //         'value' => $item
         //     ];
         // }
         // DB::table('vdm')->insert($records);
39c2e3bd6   George Vlahavas   Log IP for VDM re...
34
          Log::info('Received VDM report from IP '.\Request::ip().'. Storing into database');
b28322f5b   Chris Bellas   Added VDM endpoint
35
36
          return response()->json(['success' => 'success'], 200);
      }
2f4aeec4c   Chris Bellas   Added GET endpoin...
37
38
39
40
41
42
43
44
45
46
  
      public function get()
      {
          return DB::table('vdm')->select([
              'uuid',
              'time',
              'asset_id',
              'value',
          ])->paginate(20);
      }
b28322f5b   Chris Bellas   Added VDM endpoint
47
  }