- Timestamp:
- 06/12/24 20:14:25 (5 months ago)
- Branches:
- main
- Children:
- 69e9f5d
- Parents:
- 249bf91
- Location:
- app/Http/Controllers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/CrimeCaseController.php
r249bf91 r768f473 3 3 namespace App\Http\Controllers; 4 4 5 use Carbon\Carbon; 5 6 use Illuminate\Http\Request; 6 7 use Illuminate\Support\Facades\DB; … … 34 35 function register_statement_post() 35 36 { 36 //TODO: so kiki i bojan vodete se po logikata na add policeman 37 $role = request()->input('role'); 38 39 40 $statement = request()->validate([ 41 'embg' => 'required', 42 'description' => 'required', 43 'incident_timestamp' => 'required', 44 'incident_place'=>'required' 45 ]); 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"]]); 48 $s_id_b = DB::select('select MAX(s_id) from statements'); 49 $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")]); 52 53 if ($role === 'witness') { 54 DB::insert('INSERT INTO statements (s_id, statement_date, description, incident_timestamp, incident_place, c_id, pe_id, victim_pe_id, witness_pe_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)', 55 [ 56 $s_id, 57 $statement["statement_date"], 58 $statement["description"], 59 $statement["incident_timestamp"], 60 $statement["incident_place"], 61 Session::get("c_id"), 62 $policaec[0]->pe_id, 63 NULL, 64 $covek[0]->pe_id 65 66 ]); 67 } elseif ($role === 'victim') { 68 DB::insert('INSERT INTO statements (s_id, statement_date, description, incident_timestamp, incident_place, c_id, pe_id, victim_pe_id, witness_pe_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)', 69 [ 70 $s_id, 71 $statement["statement_date"], 72 $statement["description"], 73 $statement["incident_timestamp"], 74 $statement["incident_place"], 75 Session::get("c_id"), 76 $policaec[0]->pe_id, 77 $covek[0]->pe_id, 78 NULL 79 ]); 80 } 81 return redirect()->route('case', ['wildcard' => Session::get("c_id"),]); 82 83 37 84 } 38 85 function finished_cases(){ … … 52 99 } 53 100 function case($wildcard){ 101 Session::put('c_id', $wildcard); 54 102 $case = DB::select('select * from crime_case where c_id=:c_id;',['c_id'=> $wildcard]); 55 103 $p_address = DB::select('select p_address from police_station where p_id=:p_id;',['p_id'=> $case[0]->p_id]); … … 73 121 } 74 122 foreach ($statements as $st){ 75 $victim=DB::select('select * from people where pe_id=:pe_id;',['pe_id'=> $st->victim_pe_id]); 76 $victims[] = $victim[0]; 123 if (!($st->victim_pe_id)==NULL){ 124 $victim=DB::select('select * from people where pe_id=:pe_id;',['pe_id'=> $st->victim_pe_id]); 125 $victims[] = $victim[0]; 126 } 77 127 } 78 128 foreach ($statements as $st){ 79 $witnes=DB::select('select * from people where pe_id=:pe_id;',['pe_id'=> $st->witness_pe_id]); 80 $witness[] = $witnes[0]; 129 if (!($st->witness_pe_id)==NULL) { 130 $witnes = DB::select('select * from people where pe_id=:pe_id;', ['pe_id' => $st->witness_pe_id]); 131 $witness[] = $witnes[0]; 132 } 81 133 } 134 82 135 83 136 return view('case', [ … … 86 139 'statements'=>$statements, 87 140 'evidence'=>$evidence, 88 'victims' => $victims,89 'witness' =>$witness141 'victims' => $victims, 142 'witness' =>$witness 90 143 ]); 91 144 -
app/Http/Controllers/SessionsController.php
r249bf91 r768f473 42 42 Session::put('is_policeman', $policeman); 43 43 if($policeman){ 44 Session::put('p e_id', $exists[0]->p_id);44 Session::put('p_id', $exists[0]->p_id); 45 45 } else { 46 46 Session::put('pe_id', $exists[0]->pe_id);
Note:
See TracChangeset
for help on using the changeset viewer.