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
|
Rev | Line | |
---|
[75151c6] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | namespace App\Http\Controllers;
|
---|
| 4 |
|
---|
| 5 | use Illuminate\Http\Request;
|
---|
[cf84baa] | 6 | use Illuminate\Support\Facades\DB;
|
---|
[d9c4096] | 7 | use Illuminate\Support\Facades\Session;
|
---|
[75151c6] | 8 |
|
---|
| 9 | class PeopleController extends Controller
|
---|
| 10 | {
|
---|
| 11 | function filter(){
|
---|
[d9c4096] | 12 | if(Session::get('pe_id') == null) {
|
---|
| 13 | return view('login');
|
---|
| 14 | }
|
---|
[cf84baa] | 15 | $peoples = DB::select('select * from people;');
|
---|
| 16 |
|
---|
| 17 | return view('filter', [
|
---|
| 18 | 'peoples' => $peoples
|
---|
| 19 | ]);
|
---|
| 20 | }
|
---|
| 21 | function filter_post(){
|
---|
[d9c4096] | 22 | if(Session::get('pe_id') == null) {
|
---|
| 23 | return view('login');
|
---|
| 24 | }
|
---|
[cf84baa] | 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 | ]);
|
---|
[75151c6] | 35 | }
|
---|
[92df8cd] | 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);
|
---|
[d9c4096] | 42 | }
|
---|
[75151c6] | 43 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.