1 | <?php
|
---|
2 |
|
---|
3 | namespace App\Http\Controllers;
|
---|
4 |
|
---|
5 | use App\Models\Policeman;
|
---|
6 | use Illuminate\Contracts\Auth\Authenticatable;
|
---|
7 | use Illuminate\Http\Request;
|
---|
8 | use Illuminate\Support\Carbon;
|
---|
9 | use Illuminate\Support\Facades\DB;
|
---|
10 | use Illuminate\Support\Facades\Session;
|
---|
11 |
|
---|
12 | class OfficerController extends Controller
|
---|
13 | {
|
---|
14 | function employees()
|
---|
15 | {
|
---|
16 | if(Session::get('pe_id') == null) {
|
---|
17 | return view('login');
|
---|
18 | }
|
---|
19 | $results = DB::select('select * from policeman join people on policeman.pe_id = people.pe_id;');
|
---|
20 | return view('employees', [
|
---|
21 | 'employees' => $results
|
---|
22 | ]);
|
---|
23 | }
|
---|
24 |
|
---|
25 | function register()
|
---|
26 | {
|
---|
27 | return view('register-policeman');
|
---|
28 | }
|
---|
29 | function register_post()
|
---|
30 | {
|
---|
31 | $policeman = request()->validate([
|
---|
32 | 'badge_no' => 'required',
|
---|
33 | 'embg' => 'required',
|
---|
34 | 'password' => 'required',
|
---|
35 | 'rank'=>'required'
|
---|
36 | ]);
|
---|
37 |
|
---|
38 | $pe_id = DB::select('select pe_id from people where embg = :embg;', ['embg' => $policeman["embg"]]);
|
---|
39 | 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"], $policeSTATION,$policeman["password"]]);
|
---|
40 | return view('register-policeman');
|
---|
41 | }
|
---|
42 |
|
---|
43 |
|
---|
44 | }
|
---|