Prechádzať zdrojové kódy

Sets up api routes to load initial data into work order page.

Christopher Leggett 5 rokov pred
rodič
commit
59deee4939

+ 86 - 0
app/Http/Controllers/Api/WorkOrdersController.php

@@ -0,0 +1,86 @@
+<?php
+
+namespace App\Http\Controllers\Api;
+
+use App\Http\Controllers\Controller;
+use App\WorkOrder;
+use Illuminate\Http\Request;
+
+class WorkOrdersController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\WorkOrder  $workOrder
+     * @return \Illuminate\Http\Response
+     */
+    public function show(WorkOrder $workOrder)
+    {
+        return $workOrder;
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\WorkOrder  $workOrder
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(WorkOrder $workOrder)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\WorkOrder  $workOrder
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, WorkOrder $workOrder)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\WorkOrder  $workOrder
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(WorkOrder $workOrder)
+    {
+        //
+    }
+}

+ 6 - 0
public/js/app.js

@@ -1957,6 +1957,12 @@ __webpack_require__.r(__webpack_exports__);
   mounted: function mounted() {
     var _this = this;
 
+    var url = window.location.href;
+    var id = url.substring(url.lastIndexOf('/') + 1);
+    axios.get('/api/workorder/' + id).then(function (response) {
+      _this.probdesc = response.data.probdesc;
+      _this.suggested = response.data.suggested;
+    });
     Echo.channel('work-orders').listen('WorkOrderUpdated', function (e) {
       _this.probdesc = e.probdesc;
       _this.suggested = e.suggested;

+ 6 - 0
resources/js/components/probdesc.vue

@@ -13,6 +13,12 @@
             }
         },
         mounted() {
+            let url = window.location.href;
+            let id = url.substring(url.lastIndexOf('/') + 1);
+            axios.get('/api/workorder/' + id).then((response) => {
+                this.probdesc = response.data.probdesc;
+                this.suggested = response.data.suggested;
+            });
             Echo.channel('work-orders')
                 .listen('WorkOrderUpdated', (e) => {
                     this.probdesc = e.probdesc;

+ 2 - 0
routes/api.php

@@ -16,3 +16,5 @@ use Illuminate\Http\Request;
 Route::middleware('auth:api')->get('/user', function (Request $request) {
     return $request->user();
 });
+
+Route::get('/workorder/{workOrder}', 'Api\WorkOrdersController@show');