Prechádzať zdrojové kódy

changed web.php and UserController.php

Maksimus111 5 rokov pred
rodič
commit
60fb3b74d4
2 zmenil súbory, kde vykonal 8 pridanie a 54 odobranie
  1. 6 40
      app/Http/Controllers/UserController.php
  2. 2 14
      routes/web.php

+ 6 - 40
app/Http/Controllers/UserController.php

@@ -23,54 +23,20 @@ class UserController extends Controller
         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);
-
-}
+    public function userdata(User $id, $date) {
+      
 
-return view('userdate',compact('dates'));
+    return $id->locations()->whereDate('created_at', $date)->get();
+  
+   
     }
 }

+ 2 - 14
routes/web.php

@@ -19,23 +19,11 @@ Auth::routes();
 
 Route::get('/home', 'HomeController@index')->name('home');
 
-//Route::get('/user', 'UserController@index')->name('all.positions');
+Route::get('/user','UserController@action');
 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');
+