Changeset 768f473 for app/Http


Ignore:
Timestamp:
06/12/24 20:14:25 (7 months ago)
Author:
bube-ristovska <ristovska725@…>
Branches:
main
Children:
69e9f5d
Parents:
249bf91
Message:

Final features

Location:
app/Http/Controllers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • app/Http/Controllers/CrimeCaseController.php

    r249bf91 r768f473  
    33namespace App\Http\Controllers;
    44
     5use Carbon\Carbon;
    56use Illuminate\Http\Request;
    67use Illuminate\Support\Facades\DB;
     
    3435    function register_statement_post()
    3536    {
    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
    3784    }
    3885    function finished_cases(){
     
    5299    }
    53100    function case($wildcard){
     101        Session::put('c_id', $wildcard);
    54102        $case = DB::select('select * from crime_case where c_id=:c_id;',['c_id'=> $wildcard]);
    55103        $p_address = DB::select('select p_address from police_station where p_id=:p_id;',['p_id'=> $case[0]->p_id]);
     
    73121        }
    74122        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            }
    77127        }
    78128        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            }
    81133        }
     134
    82135
    83136        return view('case', [
     
    86139            'statements'=>$statements,
    87140            'evidence'=>$evidence,
    88             'victims'=> $victims,
    89             'witness'=> $witness
     141            'victims' => $victims,
     142            'witness' =>$witness
    90143        ]);
    91144
  • app/Http/Controllers/SessionsController.php

    r249bf91 r768f473  
    4242            Session::put('is_policeman', $policeman);
    4343            if($policeman){
    44                 Session::put('pe_id', $exists[0]->p_id);
     44                Session::put('p_id', $exists[0]->p_id);
    4545            } else {
    4646                Session::put('pe_id', $exists[0]->pe_id);
Note: See TracChangeset for help on using the changeset viewer.