Index: app/Http/Controllers/OfficerController.php
===================================================================
--- app/Http/Controllers/OfficerController.php	(revision 92df8cd98026d57c406e8df5eb637e826a769230)
+++ app/Http/Controllers/OfficerController.php	(revision 7e9daddcf9c070e939faa93d57c7c504bfd38947)
@@ -17,7 +17,15 @@
             return view('login');
         }
-        $results = DB::select('select * from policeman join people on policeman.pe_id = people.pe_id;');
+        if(Session::get('is_policeman')){
+            $police_station = DB::select('select * from police_station where p_id=:p_id;',['p_id'=>  Session::get('p_id')]);
+        } else {
+            $police_station = DB::select('select * from police_station where pe_id=:pe_id;',['pe_id'=>  Session::get('pe_id')]);
+        }
+        $results = DB::select('select * from policeman join people on policeman.pe_id = people.pe_id where p_id=:p_id;',['p_id'=>  $police_station[0]->p_id]);
+//        $results = DB::select('select * from policeman join people on policeman.pe_id = people.pe_id;');
+
         return view('employees', [
-            'employees' => $results
+            'employees' => $results,
+            'p_address'=>$police_station[0]->p_address
         ]);
     }
@@ -36,7 +44,10 @@
         ]);
 
+
+        $police_station = DB::select('select * from police_station where pe_id=:pe_id;',['pe_id'=>  Session::get('pe_id')]);
+
         $pe_id = DB::select('select pe_id from people where embg = :embg;', ['embg' => $policeman["embg"]]);
-        DB::insert('INSERT INTO policeman (pe_id, badge_no, p_date_of_employment, rank, p_id, p_password) VALUES (?, ?, ?, ?, ?, ?)', [$pe_id[0]->pe_id, $policeman["badge_no"], Carbon::now()->format('Y-m-d'), $policeman["rank"], $policeSTATION,$policeman["password"]]);
-        return view('register-policeman');
+        DB::insert('INSERT INTO policeman (pe_id, badge_no, p_date_of_employment, rank, p_id, p_password) VALUES (?, ?, ?, ?, ?, ?)', [$pe_id[0]->pe_id, $policeman["badge_no"], Carbon::now()->format('Y-m-d'), $policeman["rank"], $police_station[0]->p_id,$policeman["password"]]);
+        return redirect()->back()->with('message',"Додадено");
     }
 
Index: app/Http/Controllers/PeopleController.php
===================================================================
--- app/Http/Controllers/PeopleController.php	(revision 92df8cd98026d57c406e8df5eb637e826a769230)
+++ app/Http/Controllers/PeopleController.php	(revision 7e9daddcf9c070e939faa93d57c7c504bfd38947)
@@ -23,14 +23,52 @@
             return view('login');
         }
+//        $credentials = request()->validate([
+//            'embg' => 'required'
+//        ]);
+//        $embg = $credentials['embg'];
+//
+//        $peoples = DB::select('SELECT * FROM people WHERE embg ~ :embg', ['embg' =>  '^' . $embg]);
+
         $credentials = request()->validate([
-            'embg' => 'required'
+            'embg' => 'nullable', // Assuming embg is not always required
+            'gender' => 'nullable',
+            'age' => 'nullable',
         ]);
-        $embg = $credentials['embg'];
+        $query = 'SELECT * FROM people WHERE true';
 
-        $peoples = DB::select('SELECT * FROM people WHERE embg ~ :embg', ['embg' =>  '^' . $embg]);
+        $embg = '^' . $credentials['embg'];
+        if ($credentials['embg']) {
+            $query .= " AND embg LIKE '{$credentials['embg']}%'";
+        }
 
-        return view('filter', [
-            'peoples' => $peoples
-        ]);
+        // Check if $credentials['gender'] is an array and handle accordingly
+        if (isset($credentials['gender']) && (is_array($credentials['gender']) && count($credentials['gender']) > 0)) {
+            $genderConditions = implode(" OR ", array_map(function ($gender) {
+                return "gender = '{$gender}'";
+            }, $credentials['gender']));
+
+            $query .= " AND ({$genderConditions})";
+        } elseif (isset($credentials['gender']) && !is_array($credentials['gender'])) {
+            $query .= " AND gender = '{$credentials['gender']}'";
+        }
+
+        // Check if $credentials['age'] is an array and handle accordingly
+        if (isset($credentials['age']) && is_array($credentials['age']) && count($credentials['age']) > 0) {
+            $ageConditions = [];
+
+            foreach ($credentials['age'] as $ageRange) {
+                // Extract minimum and maximum ages from the range
+                list($minAge, $maxAge) = explode('-', $ageRange);
+
+                // Add condition for the age range
+                $ageConditions[] = "EXTRACT(YEAR FROM AGE(current_date, date_of_birth)) BETWEEN {$minAge} AND {$maxAge}";
+            }
+
+            $query .= " AND (" . implode(" OR ", $ageConditions) . ")";
+        }
+        // Use a raw SQL query with the built conditions
+
+        $peoples = DB::select($query);
+        return view('filter', ['peoples' => $peoples]);
     }
     public function getPerson(Request $request)
Index: app/Http/Controllers/SessionsController.php
===================================================================
--- app/Http/Controllers/SessionsController.php	(revision 92df8cd98026d57c406e8df5eb637e826a769230)
+++ app/Http/Controllers/SessionsController.php	(revision 7e9daddcf9c070e939faa93d57c7c504bfd38947)
@@ -46,5 +46,5 @@
                 Session::put('pe_id', $exists[0]->pe_id);
             }
-            return redirect()->intended('/');
+            return view('welcome');
         }
 
