Index: app/Http/Controllers/CrimeCaseController.php
===================================================================
--- app/Http/Controllers/CrimeCaseController.php	(revision 5372778f696f189be18e765182cf61d30ea9728a)
+++ app/Http/Controllers/CrimeCaseController.php	(revision 3c89e273abd0f2c9572a3c99106ff267777fa3a2)
@@ -9,4 +9,16 @@
 class CrimeCaseController extends Controller
 {
+    private function policeStationIsPoliceman()
+    {
+        return DB::table('police_station')
+            ->where('p_id', Session::get('p_id'))
+            ->get();
+    }
+    private function policeStationIsOfficer()
+    {
+        return DB::table('police_station')
+            ->where('pe_id', Session::get('pe_id'))
+            ->get();
+    }
     function cases(){
         if(Session::get('pe_id') == null) {
@@ -14,13 +26,13 @@
         }
 
-
         if(Session::get('is_policeman')){
-            $police_station = DB::select('select * from police_station where p_id=:p_id;',['p_id'=>  Session::get('p_id')]);
+            $police_station = $this->policeStationIsPoliceman();
         } else {
-            $police_station = DB::select('select * from police_station where pe_id=:pe_id;',['pe_id'=>  Session::get('pe_id')]);
+            $police_station = $this->policeStationIsOfficer();
         }
 
-        $cases = DB::select('select * from crime_case where p_id=:p_id;',['p_id'=> $police_station[0]->p_id]);
-
+        $cases = DB::table('crime_case')
+            ->where('p_id', $police_station[0]->p_id)
+            ->get();
 
         return view('cases', [
@@ -44,10 +56,10 @@
             'incident_place'=>'required'
         ]);
-        $statement["statement_date"] = Carbon::now()->format('Y-m-d');
-        $covek = DB::select('select pe_id from people where embg=:embg;',['embg'=> $statement["embg"]]);
+         $statement["statement_date"] = Carbon::now()->format('Y-m-d');
+         $covek = DB::select('select pe_id from people where embg=:embg;',['embg'=> $statement["embg"]]);
          $s_id_b = DB::select('select MAX(s_id) from statements');
          $s_id = $s_id_b[0]->max;
-        $s_id = $s_id +1 ;
-        $policaec =  DB::select('select pe_id from policeman where badge_no=:badge_no;',['badge_no'=> Session::get("badge_no")]);
+         $s_id = $s_id +1 ;
+         $policaec =  DB::select('select pe_id from policeman where badge_no=:badge_no;',['badge_no'=> Session::get("badge_no")]);
 
         if ($role === 'witness') {
@@ -84,13 +96,14 @@
     }
     function finished_cases(){
-
         if(Session::get('is_policeman')){
-            $police_station = DB::select('select * from police_station where p_id=:p_id;',['p_id'=>  Session::get('p_id')]);
+            $police_station = $this->policeStationIsPoliceman();
         } else {
-            $police_station = DB::select('select * from police_station where pe_id=:pe_id;',['pe_id'=>  Session::get('pe_id')]);
+            $police_station = $this->policeStationIsOfficer();
         }
 
-        $cases = DB::select('select * from crime_case where p_id=:p_id and c_status=\'Z\';', ['p_id' => $police_station[0]->p_id]);
-
+        $cases = DB::table('crime_case')
+            ->where('p_id', $police_station[0]->p_id)
+            ->where('c_status', 'Z')
+            ->get();
         return view('archive', [
             'cases' => $cases,
@@ -100,8 +113,13 @@
     function case($wildcard){
         Session::put('c_id', $wildcard);
-        $case = DB::select('select * from crime_case where c_id=:c_id;',['c_id'=> $wildcard]);
-        $p_address = DB::select('select p_address from police_station where p_id=:p_id;',['p_id'=> $case[0]->p_id]);
-        $statements = DB::select('select * from statements where c_id=:c_id;',['c_id'=> $wildcard]);
-
+        $case = DB::table('crime_case')
+            ->where('c_id', $wildcard)
+            ->get();
+        $p_address = DB::table('police_station')
+            ->where('p_id', $case[0]->p_id)
+            ->value('p_address');
+        $statements = DB::table('statements')
+            ->where('c_id', $wildcard)
+            ->get();
 
         $victims=[];
@@ -110,17 +128,21 @@
         $evidence = [];
         foreach ($statements as $statement) {
-            $evidence_id = DB::select('select * from mentions_evidence where s_id=:s_id;',['s_id'=> $statement->s_id]);
-            if (!empty($evidence_id)) { // Check if $evidence_id is not empty
-                $evidence_id[] = $evidence_id[0];
-            }
+            $evidence_id = DB::table('mentions_evidence')
+                ->where('s_id', $statement->s_id)
+                ->get();
+//            if (!empty($evidence_id)) { // Check if $evidence_id is not empty
+//                $evidence_id[] = $evidence_id[0];
+//            }
         }
          $evidence_id=collect($evidence_id)->unique();
         foreach ($evidence_id as $e) {
-            $evidence = DB::select('select * from evidence where e_id=:e_id;',['e_id'=> $e->e_id]);
-            $evidence[] = $evidence[0];
+            $evidence = DB::table('evidence')
+                ->where('e_id', $e->e_id)->get();
+
         }
         foreach ($statements as $st){
             if (!($st->victim_pe_id)==NULL){
-                $victim=DB::select('select * from people where pe_id=:pe_id;',['pe_id'=> $st->victim_pe_id]);
+                $victim = DB::table('people')
+                    ->where('pe_id', $st->victim_pe_id)->get();
                 $victims[] = $victim[0];
             }
@@ -128,13 +150,13 @@
         foreach ($statements as $st){
             if (!($st->witness_pe_id)==NULL) {
-                $witnes = DB::select('select * from people where pe_id=:pe_id;', ['pe_id' => $st->witness_pe_id]);
+                $witnes = DB::table('people')
+                    ->where('pe_id', $st->witness_pe_id)->get();
                 $witness[] = $witnes[0];
             }
         }
 
-
         return view('case', [
             'case' => $case[0],
-            'p_address'=>$p_address[0]->p_address,
+            'p_address'=>$p_address,
             'statements'=>$statements,
             'evidence'=>$evidence,
Index: app/Http/Controllers/OfficerController.php
===================================================================
--- app/Http/Controllers/OfficerController.php	(revision 5372778f696f189be18e765182cf61d30ea9728a)
+++ app/Http/Controllers/OfficerController.php	(revision 3c89e273abd0f2c9572a3c99106ff267777fa3a2)
@@ -12,4 +12,16 @@
 class OfficerController extends Controller
 {
+    private function policeStationIsPoliceman()
+    {
+        return DB::table('police_station')
+            ->where('p_id', Session::get('p_id'))
+            ->get();
+    }
+    private function policeStationIsOfficer()
+    {
+       return DB::table('police_station')
+           ->where('pe_id', Session::get('pe_id'))
+           ->get();
+    }
     function employees()
     {
@@ -18,10 +30,13 @@
         }
         if(Session::get('is_policeman')){
-            $police_station = DB::select('select * from police_station where p_id=:p_id;',['p_id'=>  Session::get('p_id')]);
+            $police_station = $this->policeStationIsPoliceman();
         } else {
-            $police_station = DB::select('select * from police_station where pe_id=:pe_id;',['pe_id'=>  Session::get('pe_id')]);
+            $police_station = $this->policeStationIsOfficer();
         }
-        $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;');
+        $results = DB::table('policeman')
+            ->join('people', 'policeman.pe_id', '=', 'people.pe_id')
+            ->where('policeman.p_id', $police_station[0]->p_id)
+            ->get();
+
 
         return view('employees', [
@@ -33,11 +48,16 @@
     function show($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')]);
+            $police_station = $this->policeStationIsPoliceman();
         } else {
-            $police_station = DB::select('select * from police_station where pe_id=:pe_id;',['pe_id'=>  Session::get('pe_id')]);
+            $police_station = $this->policeStationIsOfficer();
         }
-        $result = DB::select('select * from policeman join people on policeman.pe_id = people.pe_id where p_id=:p_id and people.pe_id=:pe_id;',['p_id'=>  $police_station[0]->p_id, 'pe_id' => $id]);
-        $cases = DB::select('select * from statements where pe_id=:pe_id;',['pe_id' => $id]);
-
+        $result = DB::table('policeman')
+            ->join('people', 'policeman.pe_id', '=', 'people.pe_id')
+            ->where('p_id', $police_station[0]->p_id)
+            ->where('people.pe_id', $id)
+            ->get();
+        $cases = DB::table('statements')
+            ->where('pe_id', $id)
+            ->get();
         return view('employee', [
             'employee' => $result[0],
@@ -61,11 +81,22 @@
 
 
-        $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"], $police_station[0]->p_id,$policeman["password"]]);
+        $police_station = $this->policeStationIsOfficer();
+        $pe_id = DB::table('people')
+            ->where('embg', $policeman['embg'])->get();
+        $data = [
+            'pe_id' => $pe_id[0]->pe_id,
+            'badge_no' => $policeman["badge_no"],
+            'p_date_of_employment' => Carbon::now()->format('Y-m-d'),
+            'rank' => $policeman["rank"],
+            'p_id' => $police_station[0]->p_id,
+            'p_password' => $policeman["password"]
+        ];
+        DB::table('policeman')->insert($data);
+//        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 5372778f696f189be18e765182cf61d30ea9728a)
+++ app/Http/Controllers/PeopleController.php	(revision 3c89e273abd0f2c9572a3c99106ff267777fa3a2)
@@ -13,6 +13,5 @@
             return view('login');
         }
-        $peoples = DB::select('select * from people;');
-
+        $peoples = DB::table('people')->get();
         return view('filter', [
             'peoples' => $peoples
@@ -75,6 +74,6 @@
     {
         $embg = $request->input('embg');
-        $person = DB::select('SELECT * FROM people WHERE embg = :embg', ['embg' => $embg]);
-
+        $person = DB::table('people')
+            ->where('embg', $embg)->get();
         return response()->json($person[0] ?? null);
     }
Index: app/Http/Controllers/SessionsController.php
===================================================================
--- app/Http/Controllers/SessionsController.php	(revision 5372778f696f189be18e765182cf61d30ea9728a)
+++ app/Http/Controllers/SessionsController.php	(revision 3c89e273abd0f2c9572a3c99106ff267777fa3a2)
@@ -24,6 +24,11 @@
             'password' => 'required'
         ]);
+
         $password = $credentials['password'];
         $badge_no = $credentials['badge_no'];
+        if (!is_numeric($badge_no)) {
+            // Redirect back with an error message
+            return back()->withErrors(['password' => 'Invalid credentials']);
+        }
         // mozhe da se najavi kako policaec i kako officer, znaeme koj e koj po znachkata
 
@@ -69,5 +74,4 @@
         return back()->withErrors(['password' => 'Invalid credentials']);
     }
-
     public function logout()
     {
