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 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 | $evidence = DB::select('select * from evidence_of_case where c_id=:c_id;',['c_id'=> $wildcard]);
|
---|
36 | $victims=[];
|
---|
37 | $witness=[];
|
---|
38 | foreach ($statements as $st){
|
---|
39 | $victim=DB::select('select * from people where pe_id=:pe_id;',['pe_id'=> $st->victim_pe_id]);
|
---|
40 | $victims[] = $victim[0];
|
---|
41 | }
|
---|
42 | foreach ($statements as $st){
|
---|
43 | $witnes=DB::select('select * from people where pe_id=:pe_id;',['pe_id'=> $st->witness_pe_id]);
|
---|
44 | $witness[] = $witnes[0];
|
---|
45 | }
|
---|
46 |
|
---|
47 | return view('case', [
|
---|
48 | 'case' => $case[0],
|
---|
49 | 'p_address'=>$p_address[0]->p_address,
|
---|
50 | 'statements'=>$statements,
|
---|
51 | 'evidence'=>$evidence,
|
---|
52 | 'victims'=> $victims,
|
---|
53 | 'witness'=> $witness
|
---|
54 | ]);
|
---|
55 |
|
---|
56 | }
|
---|
57 | }
|
---|