theHocineSaad / linatabara3

Linatabara3 is an open source Laravel 9 blood donation platform that connects blood seekers with blood donors in their region.
https://linatabara3.com
MIT License
78 stars 12 forks source link

DonorsController refactoring #8

Closed IsmailBourbie closed 1 year ago

IsmailBourbie commented 1 year ago

Removing duplication in Search action. improving request time by reducing SQL queries.

before:

image

after:

image

theHocineSaad commented 1 year ago

looks like the code you contributed in 42fe979 in not working properly, please have a second look at it and retest it.

IsmailBourbie commented 1 year ago

looks like the code you contributed in 42fe979 in not working properly, please have a second look at it and retest it.

Can you please give me more details, and tell what's wrong exactly?

theHocineSaad commented 1 year ago

tell w

Your code in fine, It's just me getting wrong results because of the Test that was running in the main database, my bad. Just one more thing, you can ignore checking if $filters['blood_group'] (in app\Models\User.php - line 51) exists, it will always exist, because of the validation in DonorRequest (in app\Http\Controllers\DonorController.php - line 22).

IsmailBourbie commented 1 year ago

Just one more thing, you can ignore checking if $filters['blood_group'] (in app\Models\User.php - line 51) exists, it will always exist, because of the validation in DonorRequest (in app\Http\Controllers\DonorController.php - line 22).

Yes you can ignore checking for now, but am planning to delete Search feature and replace it with Filters in DonorsController::index, for exmaple:


// using DonorsController::index
linatabra3.com/donors // get all donors 
linatabra3.com/donors?blood_group=1 // get all donors with donors_group = 1
linatabra3.com/donors?blood_group=1&wilaya=1 // get all donors with donors_group = 1 and wilaya = 1

instead of:


// using DonorsController::index and DonorsController::search
linatabra3.com/donors // get all donors
linatabra3.com/donors/search?blood_group=1 // get all donors with donors_group = 1
linatabra3.com/donors/search?blood_group=1&wilaya=1 // get all donors with donors_group = 1 and wilaya = 1
theHocineSaad commented 1 year ago
h?bloo

Okay, good idea. Thanks for your contributions