Blame view

api/app/Http/Controllers/V1/Partners/VdmController.php 1.51 KB
b28322f5b   Chris Bellas   Added VDM endpoint
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  <?php
  
  namespace App\Http\Controllers\V1\Partners;
  
  
  use App\Http\Controllers\Controller;
  use App\Http\Requests\VdmRequest;
  use Carbon\Carbon;
  use Illuminate\Support\Facades\DB;
  use Illuminate\Support\Facades\Log;
  use Salman\Mqtt\Facades\Mqtt;
  
  class VdmController extends Controller
  {
      public function store(VdmRequest $request)
      {
  //        $dbEvents = [];
  //        $mqttEvents = [];
  //        foreach ($request->get('event_alarm') as $ev) {
  //            $dbEvents[] = [
  //                'asset_id' => $request->get('asset_id'),
  //                'event_alarm_id' => $ev['event_alarm_id'],
  //                'event_alarm_char' => $ev['event_alarm_char'],
  //                'name' => isset($ev['name']) ? $ev['name'] : null,
  //                'time' => Carbon::createFromTimestamp($request->get('timestamp')),
  //            ];
  //            $mqttEvents[] = [
  //                'asset_id' => $request->get('asset_id'),
  //                'event_alarm_id' => $ev['event_alarm_id'],
  //                'event_alarm_char' => $ev['event_alarm_char'],
  //                'name' => isset($ev['name']) ? $ev['name'] : null,
  //                'time' => $request->get('timestamp'),
  //            ];
  //        }
  //
  //        // publish to MQTT Broker
  //        // Mqtt::ConnectAndPublish('adt/event', json_encode($mqttEvents), $request->user()->id);
  //        //Mqtt::ConnectAndPublish('adt/event', json_encode($mqttEvents), 1);
  //        //DB::table('vdm')->insert($dbEvents);
  
          return response()->json(['success' => 'success'], 200);
      }
  }