UserController.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. $userse = $id->locations;
  16. //return view('user',compact('userse'));
  17. return view('user',['uss' => $id, 'userse' =>$userse]);
  18. //return $id->locations;
  19. }
  20. public function showLast(User $id){
  21. $koordinata = $id->lastCoordinates;
  22. //return $id->lastCoordinates;
  23. return view('lastposition',compact('koordinata'));
  24. }
  25. public function action() {
  26. $users=User::all();
  27. return view('allpositions',compact('users'));
  28. }
  29. public function userdata(User $id, $date) {
  30. //$dates = [];
  31. if($id){
  32. $dates = $id->locations()->whereDate('created_at', $date)->get();
  33. //return $id->locations()->whereDate('created_at', $date)->get();
  34. return view('userdate',['user' => $id, 'dates' => $dates]);
  35. //return $dates[0]["lat"]." ".$dates[0]["lng"];
  36. }
  37. return abort(404);
  38. }
  39. }