-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
accommodation rating system #165
base: main
Are you sure you want to change the base?
Conversation
- added newer version & css of jquery plugin - added am accommodation calculated rating property - displayed rating on the accommodation & for reviews
should be ok for review |
Din ce inteleg, intr-un loc de cazare pot sta mai multi refugiati. Asta inseamna ca in pagina spatiului de cazare, un host ar trebui sa poata alege carui refugiat sa ii lase review-ul. |
sistemul de rating ar trebui sa fie in ambele directii: atat refugiatul sa poata da review unei cazari cat si gazda sa poata da review unui refugiat. Propun ca in acest PR sa rezolvam doar parte de review de la un refugiat pentru o cazare, iar review-ul in cealalta directie sa il facem intr-un PR separat. |
Box-ul de review pentru o cazare apare atat pentru refugiat cat si pentru gazda, dar bat ambele in acelasi endpoint de review al refugiatului pentru cazare. Ar trebui ca box-ul sa nu apara host-ului. |
uu nice catch, fixez acum |
Pare ca rating-ul nu se seteaza corect. Oricat stelute as selecta, valoarea trimisa in backend este tot 0. Poti adauga ceva erori mai user friendly pentru validarile de pe campuriel de review? ai aici cateva detalii: https://laravel.com/docs/7.x/validation#customizing-the-error-messages |
Done 👍 Despre validari, picau ca nu se updata hidden input dupa upgrade-ul de jquery lib, mesajele de eroare erau cele default. Am avut intentia sa le modific dar am vazut ca existau deja traduceri pentru ele asa ca le-am lasat asa. |
…view listing a little bit more condensed
am deschis un PR in branch-ul tau cu niste modificari. |
every allocated refugee may write a review for same location; make re…
L-am acceptat, ti-am dat access pe fork-ul meu |
@@ -74,4 +77,15 @@ public function viewAccommodation(Accommodation $accommodation) | |||
->with('otherFacilities', $otherFacilities) | |||
->with('availabilityIntervals', $availabilityIntervals); | |||
} | |||
|
|||
public function reviewAccommodation(AccommodationReviewRequest $request, Accommodation $accommodation): View |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aici ar fi bine sa faci un double check ca userul curent chiar a fost alocat (probabil si ca a fost cazat la locatia) unde lasa review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds like a good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're mostly there. Mai rămân de rezolvat înainte să facem merge:
- câteva todo comments prin cod;
- o sugestie de extra checks de la @beniamin;
- the merge conflict
public function reviewedByUser(User $user): bool | ||
{ | ||
return (bool)$this->reviews()->where(['user_id' => $user->id])->count(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function reviewedByUser(User $user): bool | |
{ | |
return (bool)$this->reviews()->where(['user_id' => $user->id])->count(); | |
} | |
public function isReviewedBy(User $user): bool | |
{ | |
return $this->reviews()->where('user_id', $user->id)->exists(); | |
} |
</h6> | ||
</div> | ||
|
||
@if ($accommodation->reviewedByUser(auth()->user())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@if ($accommodation->reviewedByUser(auth()->user())) | |
@if ($accommodation->isReviewedBy(auth()->user())) |
@@ -74,4 +77,15 @@ public function viewAccommodation(Accommodation $accommodation) | |||
->with('otherFacilities', $otherFacilities) | |||
->with('availabilityIntervals', $availabilityIntervals); | |||
} | |||
|
|||
public function reviewAccommodation(AccommodationReviewRequest $request, Accommodation $accommodation): View |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds like a good idea
if ($count = $this->reviews()->count()) { | ||
return $this->reviews()->sum('rating') / $count; | ||
} | ||
|
||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aici putem avea un query în loc de două
if ($count = $this->reviews()->count()) { | |
return $this->reviews()->sum('rating') / $count; | |
} | |
return 0; | |
return $this->reviews()->avg('rating') ?? 0; |
*/ | ||
public function authorize(): bool | ||
{ | ||
return Auth::user()->isRefugee(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return Auth::user()->isRefugee(); | |
return $this->user()->isRefugee(); |
Requirements for making a pull request
Thank you for contributing to our project!
Please fill out the template below to help the project maintainers review it as fast as possible and include your contribution to the project.
What does it fix?
Closes #151
Please mention the main changes this PR brings.
How has it been tested?
Please describe the tests that you ran to verify your changes.