1 | <?php
|
---|
2 |
|
---|
3 | namespace App\Http\Controllers;
|
---|
4 |
|
---|
5 | use Illuminate\Http\Request;
|
---|
6 | use Illuminate\Support\Facades\DB;
|
---|
7 | use Illuminate\Support\Facades\Session;
|
---|
8 | class 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 register_statement(){
|
---|
32 | return view('register-statement');
|
---|
33 | }
|
---|
34 | function register_statement_post()
|
---|
35 | {
|
---|
36 | //TODO: so kiki i bojan vodete se po logikata na add policeman
|
---|
37 | }
|
---|
38 | function finished_cases(){
|
---|
39 |
|
---|
40 | if(Session::get('is_policeman')){
|
---|
41 | $police_station = DB::select('select * from police_station where p_id=:p_id;',['p_id'=> Session::get('p_id')]);
|
---|
42 | } else {
|
---|
43 | $police_station = DB::select('select * from police_station where pe_id=:pe_id;',['pe_id'=> Session::get('pe_id')]);
|
---|
44 | }
|
---|
45 |
|
---|
46 | $cases = DB::select('select * from crime_case where p_id=:p_id and c_status=\'Z\';', ['p_id' => $police_station[0]->p_id]);
|
---|
47 |
|
---|
48 | return view('archive', [
|
---|
49 | 'cases' => $cases,
|
---|
50 | 'p_address'=>$police_station[0]->p_address
|
---|
51 | ]);
|
---|
52 | }
|
---|
53 | function case($wildcard){
|
---|
54 | $case = DB::select('select * from crime_case where c_id=:c_id;',['c_id'=> $wildcard]);
|
---|
55 | $p_address = DB::select('select p_address from police_station where p_id=:p_id;',['p_id'=> $case[0]->p_id]);
|
---|
56 | $statements = DB::select('select * from statements where c_id=:c_id;',['c_id'=> $wildcard]);
|
---|
57 |
|
---|
58 |
|
---|
59 | $victims=[];
|
---|
60 | $witness=[];
|
---|
61 | $evidence_id = [];
|
---|
62 | $evidence = [];
|
---|
63 | foreach ($statements as $statement) {
|
---|
64 | $evidence_id = DB::select('select * from mentions_evidence where s_id=:s_id;',['s_id'=> $statement->s_id]);
|
---|
65 | if (!empty($evidence_id)) { // Check if $evidence_id is not empty
|
---|
66 | $evidence_id[] = $evidence_id[0];
|
---|
67 | }
|
---|
68 | }
|
---|
69 | $evidence_id=collect($evidence_id)->unique();
|
---|
70 | foreach ($evidence_id as $e) {
|
---|
71 | $evidence = DB::select('select * from evidence where e_id=:e_id;',['e_id'=> $e->e_id]);
|
---|
72 | $evidence[] = $evidence[0];
|
---|
73 | }
|
---|
74 | 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];
|
---|
77 | }
|
---|
78 | 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];
|
---|
81 | }
|
---|
82 |
|
---|
83 | return view('case', [
|
---|
84 | 'case' => $case[0],
|
---|
85 | 'p_address'=>$p_address[0]->p_address,
|
---|
86 | 'statements'=>$statements,
|
---|
87 | 'evidence'=>$evidence,
|
---|
88 | 'victims'=> $victims,
|
---|
89 | 'witness'=> $witness
|
---|
90 | ]);
|
---|
91 |
|
---|
92 | }
|
---|
93 | }
|
---|