[75151c6] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | namespace App\Http\Controllers;
|
---|
| 4 |
|
---|
[6b10b67] | 5 | use App\Models\Policeman;
|
---|
[cf84baa] | 6 | use Illuminate\Contracts\Auth\Authenticatable;
|
---|
[75151c6] | 7 | use Illuminate\Http\Request;
|
---|
[92df8cd] | 8 | use Illuminate\Support\Carbon;
|
---|
[6b10b67] | 9 | use Illuminate\Support\Facades\DB;
|
---|
[d9c4096] | 10 | use Illuminate\Support\Facades\Session;
|
---|
[75151c6] | 11 |
|
---|
| 12 | class OfficerController extends Controller
|
---|
| 13 | {
|
---|
| 14 | function employees()
|
---|
| 15 | {
|
---|
[d9c4096] | 16 | if(Session::get('pe_id') == null) {
|
---|
| 17 | return view('login');
|
---|
| 18 | }
|
---|
[7e9dadd] | 19 | if(Session::get('is_policeman')){
|
---|
| 20 | $police_station = DB::select('select * from police_station where p_id=:p_id;',['p_id'=> Session::get('p_id')]);
|
---|
| 21 | } else {
|
---|
| 22 | $police_station = DB::select('select * from police_station where pe_id=:pe_id;',['pe_id'=> Session::get('pe_id')]);
|
---|
| 23 | }
|
---|
| 24 | $results = DB::select('select * from policeman join people on policeman.pe_id = people.pe_id where p_id=:p_id;',['p_id'=> $police_station[0]->p_id]);
|
---|
| 25 | // $results = DB::select('select * from policeman join people on policeman.pe_id = people.pe_id;');
|
---|
| 26 |
|
---|
[6b10b67] | 27 | return view('employees', [
|
---|
[7e9dadd] | 28 | 'employees' => $results,
|
---|
| 29 | 'p_address'=>$police_station[0]->p_address
|
---|
[6b10b67] | 30 | ]);
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | function register()
|
---|
| 34 | {
|
---|
| 35 | return view('register-policeman');
|
---|
[75151c6] | 36 | }
|
---|
[92df8cd] | 37 | function register_post()
|
---|
| 38 | {
|
---|
| 39 | $policeman = request()->validate([
|
---|
| 40 | 'badge_no' => 'required',
|
---|
| 41 | 'embg' => 'required',
|
---|
| 42 | 'password' => 'required',
|
---|
| 43 | 'rank'=>'required'
|
---|
| 44 | ]);
|
---|
| 45 |
|
---|
[7e9dadd] | 46 |
|
---|
| 47 | $police_station = DB::select('select * from police_station where pe_id=:pe_id;',['pe_id'=> Session::get('pe_id')]);
|
---|
| 48 |
|
---|
[92df8cd] | 49 | $pe_id = DB::select('select pe_id from people where embg = :embg;', ['embg' => $policeman["embg"]]);
|
---|
[7e9dadd] | 50 | DB::insert('INSERT INTO policeman (pe_id, badge_no, p_date_of_employment, rank, p_id, p_password) VALUES (?, ?, ?, ?, ?, ?)', [$pe_id[0]->pe_id, $policeman["badge_no"], Carbon::now()->format('Y-m-d'), $policeman["rank"], $police_station[0]->p_id,$policeman["password"]]);
|
---|
| 51 | return redirect()->back()->with('message',"Додадено");
|
---|
[92df8cd] | 52 | }
|
---|
[cf84baa] | 53 |
|
---|
| 54 |
|
---|
[75151c6] | 55 | }
|
---|