UserController.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. $dates = $id->locations()->whereDate('created_at', $date)->get();
  29. //return $id->locations()->whereDate('created_at', $date)->get();
  30. return view('userdate',compact('dates'));
  31. //return $dates[0]["lat"]." ".$dates[0]["lng"];
  32. }
  33. }