Пример #1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     $this->findDateSpecificDistance = Spot::whereImei($_GET['item_id'])->where('created_at', ">=", $_GET['date'])->get();
     $this->lngArray = array();
     $this->latArray = array();
     $this->carInfo = null;
     if (is_object($this->findDateSpecificDistance)) {
         foreach ($this->findDateSpecificDistance as $key => $dist) {
             if ($dist->lng) {
                 $this->lngArray[] = $dist->lng;
             } else {
                 $this->lngArray[] = 0;
             }
             if ($dist->lat) {
                 $this->latArray[] = $dist->lat;
             } else {
                 $this->latArray[] = 0;
             }
         }
         for ($i = 1; $i < sizeof($this->latArray); $i++) {
             $this->totalDistance += $this->distance($this->latArray[$i - 1], $this->lngArray[$i - 1], $this->latArray[$i], $this->lngArray[$i], "K");
         }
     }
     $cars = Cars::whereImei($_GET['item_id'])->get();
     foreach ($cars as $key => $car) {
         $this->carInfo = $car->manufacturer . ' ' . $car->num_plate;
     }
     return view('Spot/Create')->with('distance', $this->totalDistance)->with('carInfo', $this->carInfo)->with('date', $_GET['date']);
 }
Пример #2
0
 public function all()
 {
     return Cars::all();
 }
Пример #3
0
<?php

use App\Cars;
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::resource('/', "CarsController");
Route::get('distance', function () {
    return Cars::all();
});
Route::get("all-cars", "CarsController@all");
Route::resource('cars', 'CarsController');
Route::resource('spot', 'SpotController');