UserController.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\User;
  4. use Illuminate\Http\Request;
  5. class UserController extends Controller
  6. {
  7. public function index(){
  8. $locations = [];
  9. foreach (User::all() as $user){
  10. $locations[] = $user->locations;
  11. }
  12. return $locations;
  13. }
  14. public function show(User $id){
  15. return $id->locations;
  16. }
  17. public function showLast(User $id){
  18. $koordinata = $id->lastCoordinates;
  19. //return $id->lastCoordinates;
  20. return view('lastposition',compact('koordinata'));
  21. }
  22. public function action() {
  23. $users=User::all();
  24. return view('allpositions',compact('users'));
  25. }
  26. public function userdata(User $id, $date) {
  27. //$dates = [];
  28. if($id){
  29. $dates = $id->locations()->whereDate('created_at', $date)->get();
  30. //return $id->locations()->whereDate('created_at', $date)->get();
  31. return view('userdate',['user' => $id, 'dates' => $dates]);
  32. //return $dates[0]["lat"]." ".$dates[0]["lng"];
  33. }
  34. return abort(404);
  35. }
  36. }