Changeset 92df8cd
- Timestamp:
- 02/11/24 18:29:24 (11 months ago)
- Branches:
- main
- Children:
- 7e9dadd
- Parents:
- d9c4096
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/OfficerController.php
rd9c4096 r92df8cd 6 6 use Illuminate\Contracts\Auth\Authenticatable; 7 7 use Illuminate\Http\Request; 8 use Illuminate\Support\Carbon; 8 9 use Illuminate\Support\Facades\DB; 9 10 use Illuminate\Support\Facades\Session; … … 26 27 return view('register-policeman'); 27 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 } 28 42 29 43 -
app/Http/Controllers/PeopleController.php
rd9c4096 r92df8cd 34 34 ]); 35 35 } 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 ]);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 42 } 43 43 } -
resources/views/filter.blade.php
rd9c4096 r92df8cd 280 280 <tr> 281 281 <th class="text-left py-3 px-4 uppercase font-semibold text-sm">ЕМБГ</th> 282 <th class=" w-1/3text-left py-3 px-4 uppercase font-semibold text-sm">Име</th>283 <th class=" w-1/3text-left py-3 px-4 uppercase font-semibold text-sm">Презиме</th>284 <th class=" w-1/3text-left py-3 px-4 uppercase font-semibold text-sm">Пол</th>285 <th class=" w-1/3text-left py-3 px-4 uppercase font-semibold text-sm">Адреса</th>286 <th class=" w-1/3text-left py-3 px-4 uppercase font-semibold text-sm">Држава</th>287 <th class=" w-1/3text-left py-3 px-4 uppercase font-semibold text-sm">Националност</th>282 <th class=" text-left py-3 px-4 uppercase font-semibold text-sm">Име</th> 283 <th class="text-left py-3 px-4 uppercase font-semibold text-sm">Презиме</th> 284 <th class=" text-left py-3 px-4 uppercase font-semibold text-sm">Пол</th> 285 <th class=" text-left py-3 px-4 uppercase font-semibold text-sm">Адреса</th> 286 <th class=" text-left py-3 px-4 uppercase font-semibold text-sm">Држава</th> 287 <th class=" text-left py-3 px-4 uppercase font-semibold text-sm">Националност</th> 288 288 <th class="text-left py-3 px-4 uppercase font-semibold text-sm">Телефон</th> 289 289 </tr> … … 293 293 @foreach($peoples as $people) 294 294 <tr> 295 <td class=" w-1/3 text-left py-3 px-4">{{$people->embg}}</td>296 <td class=" w-1/3 text-left py-3 px-4">{{$people->first_name}}</td>297 <td class=" w-1/3 text-left py-3 px-4">{{$people->last_name}}</td>298 <td class=" w-1/3 text-left py-3 px-4">{{$people->gender}}</td>299 <td class=" w-1/3 text-left py-3 px-4">{{$people->address}}</td>300 <td class=" w-1/3 text-left py-3 px-4">{{$people->country}}</td>301 <td class=" w-1/3 text-left py-3 px-4">{{$people->nationality}}</td>302 <td class="text-left py-3 px- 4"><a class="hover:text-blue-500" href="tel:622322662">{{$people->contact}}</a></td>295 <td class=" text-left py-3 px-3">{{$people->embg}}</td> 296 <td class=" text-left py-3 px-3">{{$people->first_name}}</td> 297 <td class=" text-left py-3 px-3">{{$people->last_name}}</td> 298 <td class=" text-left py-3 px-3"> {{ $people->gender === 'F' ? 'Ж' : 'М' }}</td> 299 <td class=" text-left py-3 px-3">{{$people->address}}</td> 300 <td class=" text-left py-3 px-3">{{$people->country}}</td> 301 <td class=" text-left py-3 px-3">{{$people->nationality}}</td> 302 <td class="text-left py-3 px-3"><a class="hover:text-blue-500" href="tel:622322662">{{$people->contact}}</a></td> 303 303 </tr> 304 304 @endforeach -
resources/views/register-policeman.blade.php
rd9c4096 r92df8cd 266 266 type="text" 267 267 name="first_name" 268 value=" {{(Input::has('embg'))?? 'embg'}}"268 value="" 269 269 id="first_name" 270 270 required … … 297 297 <div class="mb-6"> 298 298 <label class="block mb-2 uppercase font-bold text-xs text-gray-700" 299 for=" email"300 > 301 Email299 for="badge_no" 300 > 301 Број на значка 302 302 </label> 303 303 304 304 <input class="border border-gray-400 p-2 w-full" 305 type=" email"306 name=" email"307 value="{{old(' email')}}"308 id=" email"309 required 310 > 311 </div> 312 @error(' email')305 type="text" 306 name="badge_no" 307 value="{{old('badge_no')}}" 308 id="badge_no" 309 required 310 > 311 </div> 312 @error('badge_no') 313 313 <p class="text-red-500 text-xs mt-1">{{$message}}</p> 314 314 @enderror … … 363 363 <!-- ChartJS --> 364 364 <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js" integrity="sha256-R4pqcOYV8lt7snxMQO/HSbVCFRPMdrhAFMH+vr9giYI=" crossorigin="anonymous"></script> 365 <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script> 366 367 <script> 368 $(document).ready(function () { 369 $('#embg').on('input', function () { 370 var embg = $(this).val(); 371 372 $.ajax({ 373 url: '/get-person', // Replace with your actual route 374 type: 'POST', 375 data: { embg: embg, _token: '{{ csrf_token() }}' }, 376 success: function (data) { 377 $('#first_name').val(data.first_name); 378 $('#last_name').val(data.last_name); 379 } 380 }); 381 }); 382 }); 383 </script> 365 384 366 385 -
routes/web.php
rd9c4096 r92df8cd 48 48 49 49 Route::get('register-policeman', [OfficerController::class, 'register'])->middleware('guest'); 50 Route::post('register-policeman', [OfficerController::class, 'register '])->middleware('guest');50 Route::post('register-policeman', [OfficerController::class, 'register_post'])->middleware('guest'); 51 51 52 Route:: get('/get_person/{{embg}}', [PeopleController::class, 'get_person'])->middleware('guest');52 Route::post('/get-person', [PeopleController::class, 'getPerson']);
Note:
See TracChangeset
for help on using the changeset viewer.