Index: app/Http/Controllers/OfficerController.php
===================================================================
--- app/Http/Controllers/OfficerController.php	(revision 249bf91ed01b2668de0b85629744c0ae1c0ba930)
+++ 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',"Додадено");
     }
 
 
+
+
 }
