Changeset d9c4096 for app


Ignore:
Timestamp:
02/10/24 17:58:54 (9 months ago)
Author:
bube-ristovska <ristovska725@…>
Branches:
main
Children:
92df8cd
Parents:
6dec591
Message:

Bug with embg

Location:
app/Http/Controllers
Files:
4 edited

Legend:

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

    r6dec591 rd9c4096  
    99{
    1010    function cases(){
     11        if(Session::get('pe_id') == null) {
     12            return view('login');
     13        }
    1114
    12         $police_station= DB::select('select * from police_station where pe_id=:pe_id;',['pe_id'=> Session::get('pe_id')]);
     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
    1322        $cases = DB::select('select * from crime_case where p_id=:p_id;',['p_id'=> $police_station[0]->p_id]);
    1423
     24
    1525        return view('cases', [
    16             'cases' => $cases
     26            'cases' => $cases,
     27            'p_address'=>$police_station[0]->p_address
    1728        ]);
    1829
    1930    }
    20     function case(){
    21         return view('case');
     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        return view('case', [
     37            'case' => $case[0],
     38            'p_address'=>$p_address[0]->p_address,
     39            'statements'=>$statements,
     40            'evidence'=>$evidence,
     41        ]);
    2242    }
    2343}
  • app/Http/Controllers/OfficerController.php

    r6dec591 rd9c4096  
    77use Illuminate\Http\Request;
    88use Illuminate\Support\Facades\DB;
     9use Illuminate\Support\Facades\Session;
    910
    1011class OfficerController extends Controller
     
    1213    function employees()
    1314    {
     15        if(Session::get('pe_id') == null) {
     16            return view('login');
     17        }
    1418        $results = DB::select('select * from policeman join people on policeman.pe_id = people.pe_id;');
    1519        return view('employees', [
  • app/Http/Controllers/PeopleController.php

    r6dec591 rd9c4096  
    55use Illuminate\Http\Request;
    66use Illuminate\Support\Facades\DB;
     7use Illuminate\Support\Facades\Session;
    78
    89class PeopleController extends Controller
    910{
    1011    function filter(){
     12        if(Session::get('pe_id') == null) {
     13            return view('login');
     14        }
    1115        $peoples = DB::select('select * from people;');
    1216
     
    1620    }
    1721    function filter_post(){
     22        if(Session::get('pe_id') == null) {
     23            return view('login');
     24        }
    1825        $credentials = request()->validate([
    1926            'embg' => 'required'
     
    2734        ]);
    2835    }
     36    function get_person($embg){
     37        $person = DB::select('SELECT * FROM people WHERE embg=:embg', ['embg' => $embg]);
     38        dd($person);
     39        return view('register-policeman', [
     40            'person' => $person[0]
     41        ]);
     42    }
    2943}
  • app/Http/Controllers/SessionsController.php

    r6dec591 rd9c4096  
    2828        }
    2929        if($exists == null) {
    30             return back()->withErrors(['badge_no' => 'Invalid credentials']);
     30            return back()->withErrors(['badge_no' => 'Invalid badge_no']);
    3131        }
    3232
     
    4141            Session::put('badge_no', $badge_no);
    4242            Session::put('is_policeman', $policeman);
    43             Session::put('pe_id', $exists[0]->pe_id);
     43            if($policeman){
     44                Session::put('p_id', $exists[0]->p_id);
     45            } else {
     46                Session::put('pe_id', $exists[0]->pe_id);
     47            }
    4448            return redirect()->intended('/');
    4549        }
Note: See TracChangeset for help on using the changeset viewer.