Changeset 3c89e27 for app/Http/Controllers/CrimeCaseController.php
- Timestamp:
- 08/26/24 16:17:04 (4 months ago)
- Branches:
- main
- Parents:
- 5372778
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/CrimeCaseController.php
r5372778 r3c89e27 9 9 class CrimeCaseController extends Controller 10 10 { 11 private function policeStationIsPoliceman() 12 { 13 return DB::table('police_station') 14 ->where('p_id', Session::get('p_id')) 15 ->get(); 16 } 17 private function policeStationIsOfficer() 18 { 19 return DB::table('police_station') 20 ->where('pe_id', Session::get('pe_id')) 21 ->get(); 22 } 11 23 function cases(){ 12 24 if(Session::get('pe_id') == null) { … … 14 26 } 15 27 16 17 28 if(Session::get('is_policeman')){ 18 $police_station = DB::select('select * from police_station where p_id=:p_id;',['p_id'=> Session::get('p_id')]);29 $police_station = $this->policeStationIsPoliceman(); 19 30 } else { 20 $police_station = DB::select('select * from police_station where pe_id=:pe_id;',['pe_id'=> Session::get('pe_id')]);31 $police_station = $this->policeStationIsOfficer(); 21 32 } 22 33 23 $cases = DB::select('select * from crime_case where p_id=:p_id;',['p_id'=> $police_station[0]->p_id]); 24 34 $cases = DB::table('crime_case') 35 ->where('p_id', $police_station[0]->p_id) 36 ->get(); 25 37 26 38 return view('cases', [ … … 44 56 'incident_place'=>'required' 45 57 ]); 46 $statement["statement_date"] = Carbon::now()->format('Y-m-d');47 $covek = DB::select('select pe_id from people where embg=:embg;',['embg'=> $statement["embg"]]);58 $statement["statement_date"] = Carbon::now()->format('Y-m-d'); 59 $covek = DB::select('select pe_id from people where embg=:embg;',['embg'=> $statement["embg"]]); 48 60 $s_id_b = DB::select('select MAX(s_id) from statements'); 49 61 $s_id = $s_id_b[0]->max; 50 $s_id = $s_id +1 ;51 $policaec = DB::select('select pe_id from policeman where badge_no=:badge_no;',['badge_no'=> Session::get("badge_no")]);62 $s_id = $s_id +1 ; 63 $policaec = DB::select('select pe_id from policeman where badge_no=:badge_no;',['badge_no'=> Session::get("badge_no")]); 52 64 53 65 if ($role === 'witness') { … … 84 96 } 85 97 function finished_cases(){ 86 87 98 if(Session::get('is_policeman')){ 88 $police_station = DB::select('select * from police_station where p_id=:p_id;',['p_id'=> Session::get('p_id')]);99 $police_station = $this->policeStationIsPoliceman(); 89 100 } else { 90 $police_station = DB::select('select * from police_station where pe_id=:pe_id;',['pe_id'=> Session::get('pe_id')]);101 $police_station = $this->policeStationIsOfficer(); 91 102 } 92 103 93 $cases = DB::select('select * from crime_case where p_id=:p_id and c_status=\'Z\';', ['p_id' => $police_station[0]->p_id]); 94 104 $cases = DB::table('crime_case') 105 ->where('p_id', $police_station[0]->p_id) 106 ->where('c_status', 'Z') 107 ->get(); 95 108 return view('archive', [ 96 109 'cases' => $cases, … … 100 113 function case($wildcard){ 101 114 Session::put('c_id', $wildcard); 102 $case = DB::select('select * from crime_case where c_id=:c_id;',['c_id'=> $wildcard]); 103 $p_address = DB::select('select p_address from police_station where p_id=:p_id;',['p_id'=> $case[0]->p_id]); 104 $statements = DB::select('select * from statements where c_id=:c_id;',['c_id'=> $wildcard]); 105 115 $case = DB::table('crime_case') 116 ->where('c_id', $wildcard) 117 ->get(); 118 $p_address = DB::table('police_station') 119 ->where('p_id', $case[0]->p_id) 120 ->value('p_address'); 121 $statements = DB::table('statements') 122 ->where('c_id', $wildcard) 123 ->get(); 106 124 107 125 $victims=[]; … … 110 128 $evidence = []; 111 129 foreach ($statements as $statement) { 112 $evidence_id = DB::select('select * from mentions_evidence where s_id=:s_id;',['s_id'=> $statement->s_id]); 113 if (!empty($evidence_id)) { // Check if $evidence_id is not empty 114 $evidence_id[] = $evidence_id[0]; 115 } 130 $evidence_id = DB::table('mentions_evidence') 131 ->where('s_id', $statement->s_id) 132 ->get(); 133 // if (!empty($evidence_id)) { // Check if $evidence_id is not empty 134 // $evidence_id[] = $evidence_id[0]; 135 // } 116 136 } 117 137 $evidence_id=collect($evidence_id)->unique(); 118 138 foreach ($evidence_id as $e) { 119 $evidence = DB::select('select * from evidence where e_id=:e_id;',['e_id'=> $e->e_id]); 120 $evidence[] = $evidence[0]; 139 $evidence = DB::table('evidence') 140 ->where('e_id', $e->e_id)->get(); 141 121 142 } 122 143 foreach ($statements as $st){ 123 144 if (!($st->victim_pe_id)==NULL){ 124 $victim=DB::select('select * from people where pe_id=:pe_id;',['pe_id'=> $st->victim_pe_id]); 145 $victim = DB::table('people') 146 ->where('pe_id', $st->victim_pe_id)->get(); 125 147 $victims[] = $victim[0]; 126 148 } … … 128 150 foreach ($statements as $st){ 129 151 if (!($st->witness_pe_id)==NULL) { 130 $witnes = DB::select('select * from people where pe_id=:pe_id;', ['pe_id' => $st->witness_pe_id]); 152 $witnes = DB::table('people') 153 ->where('pe_id', $st->witness_pe_id)->get(); 131 154 $witness[] = $witnes[0]; 132 155 } 133 156 } 134 157 135 136 158 return view('case', [ 137 159 'case' => $case[0], 138 'p_address'=>$p_address [0]->p_address,160 'p_address'=>$p_address, 139 161 'statements'=>$statements, 140 162 'evidence'=>$evidence,
Note:
See TracChangeset
for help on using the changeset viewer.