Browse Source

добавлено две вьюхи allpositions and userdate,поменял в роутах код и добавил несколько методов в UserController

Maksimus111 5 years ago
parent
commit
bb9805c36a

+ 52 - 1
app/Http/Controllers/UserController.php

@@ -16,10 +16,61 @@ class UserController extends Controller
     }
 
     public function show(User $id){
-        return $id->locations;
+       return $id->locations;
     }
 
     public function showLast(User $id){
         return $id->lastCoordinates;
     }
+
+ /*public function vse(){
+        $userse = [];
+        foreach (User::all() as $user){
+            $userse[] = $user;
+        }
+        return $userse; 
+    }
+*/
+ public function action() {
+            $users=User::all();
+                 
+        return view('allpositions',compact('users'));
+    }
+    
+    public function date() {
+        //[$id, date];
+        
+        
+        
+    }
+
+    public function userdata(Request $request) {
+
+    //$dates = DB::table('locations')->find($id);
+     //return view('userdate',compact('dates'));
+        $mysqli = mysqli_connect("geolook", "root", "2701198927", "geolook"); //Здесь свои данные пишем
+        $dates = [];
+        $id= "$request->id";
+        $data= "$request->date%";
+        $zapros = "SELECT * from locations where user_id = '$id' and created_at like '$data'";
+$res = mysqli_query($mysqli, $zapros);
+while($row = mysqli_fetch_object($res)) {
+
+  //  $dates[]= $request->date;
+    $dates[] = $row->created_at;
+    $dates[] = $row->lat;
+    $dates[] = $row->lng;
+    $dates[] = $row->id;
+    
+    //$dates[] = $request->id;
+  //  $dates[] = $_POST["{date}"];
+    //$url='http://geolook/public/user/';
+
+//$dates[] = 'select * from locations where user_id='.$id.' and created_at like '.$date.'%';
+//$dates[] = mysqli_free_result($row);
+
+}
+
+return view('userdate',compact('dates'));
+    }
 }

+ 24 - 0
resources/views/allpositions.blade.php

@@ -0,0 +1,24 @@
+
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+    <title>Document</title>
+</head>
+<body>
+
+    <ul>
+      @foreach ($users as $user)
+
+
+        <li>
+        	<a href="{{route('user.position', $user->id)}}">{{ $user->name }}</a>
+        </li>
+
+
+    @endforeach
+    </ul>
+</body>
+
+   
+</html>

+ 25 - 0
resources/views/userdate.blade.php

@@ -0,0 +1,25 @@
+
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+    <title>Document</title>
+</head>
+<body>
+
+    <ul>
+      @foreach ($dates as $data)
+
+
+        <li>
+		
+        	{{ $data }}
+        </li>
+
+
+    @endforeach
+    </ul>
+</body>
+
+   
+</html>

+ 14 - 1
routes/web.php

@@ -19,10 +19,23 @@ Auth::routes();
 
 Route::get('/home', 'HomeController@index')->name('home');
 
-Route::get('/user', 'UserController@index')->name('all.positions');
+//Route::get('/user', 'UserController@index')->name('all.positions');
 Route::get('/user/{id}', 'UserController@show')->where('id', '[0-9]+')->name('user.position');
+//Route::get('/user/{id}', 'UserController@date')->where('id', '[0-9]+')->name('user.position');
+Route::get('/user/{id}/{date}', 'UserController@userdata')->where(['id'=>'[0-9]+','date'=>'[0-9]{4}-[0-9]{2}-[0-9]{2}'])->name('user.date');
 Route::get('/user/{id}/last', 'UserController@showLast')->where('id', '[0-9]+')->name('last.position');
+//Route::get('/user/{id}','UserController@userdata');
+//Route::get('/user/{id}', function($user_id) {
+
+	//$dati = DB::table('locations')::user_id->find($user_id);    //DB::table('locations')->find($user_id);
+          
+    //   return view('userdate',compact('dati'));
+//})->where('id', '[0-9]+')->name('user.position');
 
 Route::post('/tbot/'.Telegram::getAccessToken(), function(){
     Telegram::commandsHandler(true);
 });
+//Route::get('/user', function () {
+//	return view ('allpositions');
+//});
+Route::get('/user','UserController@action');