source: app/Http/Controllers/CrimeCaseController.php@ f7acd52

main
Last change on this file since f7acd52 was f7acd52, checked in by bube-ristovska <ristovska725@…>, 7 months ago

Initial changes in database

  • Property mode set to 100644
File size: 2.5 KB
Line 
1<?php
2
3namespace App\Http\Controllers;
4
5use Illuminate\Http\Request;
6use Illuminate\Support\Facades\DB;
7use Illuminate\Support\Facades\Session;
8class CrimeCaseController extends Controller
9{
10 function cases(){
11 if(Session::get('pe_id') == null) {
12 return view('login');
13 }
14
15
16 if(Session::get('is_policeman')){
17 $police_station = DB::select('select * from police_station where p_id=:p_id;',['p_id'=> Session::get('p_id')]);
18 } else {
19 $police_station = DB::select('select * from police_station where pe_id=:pe_id;',['pe_id'=> Session::get('pe_id')]);
20 }
21
22 $cases = DB::select('select * from crime_case where p_id=:p_id;',['p_id'=> $police_station[0]->p_id]);
23
24
25 return view('cases', [
26 'cases' => $cases,
27 'p_address'=>$police_station[0]->p_address
28 ]);
29
30 }
31 function case($wildcard){
32 $case = DB::select('select * from crime_case where c_id=:c_id;',['c_id'=> $wildcard]);
33 $p_address = DB::select('select p_address from police_station where p_id=:p_id;',['p_id'=> $case[0]->p_id]);
34 $statements = DB::select('select * from statements where c_id=:c_id;',['c_id'=> $wildcard]);
35
36
37 $victims=[];
38 $witness=[];
39 $evidence_id = [];
40 $evidence = [];
41 foreach ($statements as $statement) {
42 $evidence_id = DB::select('select * from mentions_evidence where s_id=:s_id;',['s_id'=> $statement->s_id]);
43 if (!empty($evidence_id)) { // Check if $evidence_id is not empty
44 $evidence_id[] = $evidence_id[0];
45 }
46 }
47 $evidence_id=collect($evidence_id)->unique();
48 foreach ($evidence_id as $e) {
49 $evidence = DB::select('select * from evidence where e_id=:e_id;',['e_id'=> $e->e_id]);
50 $evidence[] = $evidence[0];
51 }
52 foreach ($statements as $st){
53 $victim=DB::select('select * from people where pe_id=:pe_id;',['pe_id'=> $st->victim_pe_id]);
54 $victims[] = $victim[0];
55 }
56 foreach ($statements as $st){
57 $witnes=DB::select('select * from people where pe_id=:pe_id;',['pe_id'=> $st->witness_pe_id]);
58 $witness[] = $witnes[0];
59 }
60
61 return view('case', [
62 'case' => $case[0],
63 'p_address'=>$p_address[0]->p_address,
64 'statements'=>$statements,
65 'evidence'=>$evidence,
66 'victims'=> $victims,
67 'witness'=> $witness
68 ]);
69
70 }
71}
Note: See TracBrowser for help on using the repository browser.