main
Last change
on this file since 92df8cd was 92df8cd, checked in by bube-ristovska <ristovska725@…>, 9 months ago |
Add policeman
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
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 |
|
---|
9 | class PeopleController extends Controller
|
---|
10 | {
|
---|
11 | function filter(){
|
---|
12 | if(Session::get('pe_id') == null) {
|
---|
13 | return view('login');
|
---|
14 | }
|
---|
15 | $peoples = DB::select('select * from people;');
|
---|
16 |
|
---|
17 | return view('filter', [
|
---|
18 | 'peoples' => $peoples
|
---|
19 | ]);
|
---|
20 | }
|
---|
21 | function filter_post(){
|
---|
22 | if(Session::get('pe_id') == null) {
|
---|
23 | return view('login');
|
---|
24 | }
|
---|
25 | $credentials = request()->validate([
|
---|
26 | 'embg' => 'required'
|
---|
27 | ]);
|
---|
28 | $embg = $credentials['embg'];
|
---|
29 |
|
---|
30 | $peoples = DB::select('SELECT * FROM people WHERE embg ~ :embg', ['embg' => '^' . $embg]);
|
---|
31 |
|
---|
32 | return view('filter', [
|
---|
33 | 'peoples' => $peoples
|
---|
34 | ]);
|
---|
35 | }
|
---|
36 | public function getPerson(Request $request)
|
---|
37 | {
|
---|
38 | $embg = $request->input('embg');
|
---|
39 | $person = DB::select('SELECT * FROM people WHERE embg = :embg', ['embg' => $embg]);
|
---|
40 |
|
---|
41 | return response()->json($person[0] ?? null);
|
---|
42 | }
|
---|
43 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.