This repository was archived by the owner on Dec 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
#41 - report system #57
Open
AKasprzy
wants to merge
152
commits into
main
Choose a base branch
from
41-report-system
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 145 commits
Commits
Show all changes
152 commits
Select commit
Hold shift + click to select a range
68e8220
Implement login and register, localization feature
PrabuckiDominik cb3a938
Remove suffix
PrabuckiDominik 478614b
Fix workflow test
PrabuckiDominik c4cc684
Add .env.ci
PrabuckiDominik 476f850
Try to fix workflow
PrabuckiDominik 75ed108
Try to fix workflow
PrabuckiDominik b187077
Try to fix workflow
PrabuckiDominik 627985f
Implement reset password, add Spatie's activity log
PrabuckiDominik e9075b5
Fix TestCase
PrabuckiDominik 6c06208
Fix workflow test's warnings
PrabuckiDominik 0b8d97b
Fix workflow test's warnings
PrabuckiDominik 4080f09
Add organization
PrabuckiDominik cd29821
Implement facebook login with tests
33fea8f
Unification of declaring Response as Status
PrabuckiDominik ebc9be1
Unification of declaring Response as Status
PrabuckiDominik 0c0da65
Implement facebook login with tests
7ce97e7
Change property type for user id
PrabuckiDominik f407303
Fix
099b6e7
Factory update
56509a3
Fix fail a login message
PrabuckiDominik c272a66
Fix fail a login message
PrabuckiDominik c22bfde
Merge branch '8-add-authentication' of https://github.com/blumilksoft…
PrabuckiDominik ccc30af
Fix rules, change name for first name and last name in a user model
PrabuckiDominik 6c0931e
Fix response for existing or non-existing mail while sending reset pa…
PrabuckiDominik 2e98425
Merge branch '8-add-authentication' of https://github.com/blumilksoft…
PrabuckiDominik b08535e
Add event model
PrabuckiDominik e8a9a44
Add seeder
PrabuckiDominik 034dcb9
fix and remove avatar
2a7fbd3
Add Email Verification Controller
PrabuckiDominik 709835f
Fix adaptation to Code Review
PrabuckiDominik 5171231
Fix typo
PrabuckiDominik a5c5c96
Fix typo
PrabuckiDominik c2251ba
Fix adjusted to code review
PrabuckiDominik 9c3f7e2
Remove useless permission function
PrabuckiDominik dd81354
merge with 08
5f0ca90
Move Notification::fake to setUp() in TestCase
PrabuckiDominik a764c1f
Merge branch '8-add-authentication' of https://github.com/blumilksoft…
5e87c1a
merge fixes
debf707
verify email fix
1cb1344
add profile and password management with tests
6fbac51
Merge branch '12-user-profile---backend' into 16-crud-for-users---bac…
db99f04
Fix adaptation to Code Review
PrabuckiDominik 41bfdfb
Fix permission import
PrabuckiDominik b89bebd
Fix permission import
PrabuckiDominik f52f1bd
Merge branch 'main' of https://github.com/blumilksoftware/interns2025…
PrabuckiDominik 9cd1a98
Merge branch '8-add-authentication' of https://github.com/blumilksoft…
PrabuckiDominik 7368847
Merge branch '15-organization-model' of https://github.com/blumilksof…
PrabuckiDominik 6f05d10
Remove .cache and fix code style
PrabuckiDominik a14de99
Merge 3 migrations into 1, fix tests
PrabuckiDominik 96c6a4f
Fix role seeder
PrabuckiDominik 7979a6a
Update database/migrations/2025_06_16_070140_create_activity_log_tabl…
PrabuckiDominik a666a63
Implement User Management CRUD, refine validation, and update depende…
6f7ea17
Add Admin Management CRUD with validation and resources
c419df0
Add return type, unification style in request
PrabuckiDominik 4b1255c
Merge branch '8-add-authentication' of https://github.com/blumilksoft…
PrabuckiDominik 077e28c
Merge branch '8-add-authentication' of https://github.com/blumilksoft…
PrabuckiDominik 7f1241e
Remove unnecessary authorize function
PrabuckiDominik c79ec87
Merge branch '8-add-authentication' of https://github.com/blumilksoft…
PrabuckiDominik 1b87b4b
Remove unnecessary variable, fix function in factory
PrabuckiDominik afc8b39
Fix function name in user factory
PrabuckiDominik 3348dab
Add details for certain event
PrabuckiDominik 17e17a4
Refactor Admin and User Management for streamlined role handling, upd…
0bae801
Merge branch 'main' of https://github.com/blumilksoftware/interns2025…
PrabuckiDominik f14c69f
Fix field in OrganizationFactory
PrabuckiDominik 51c0243
Merge branch 'main' of https://github.com/blumilksoftware/interns2025…
eec729d
Apply suggestions from code review
PrabuckiDominik c7edb1c
Apply suggestions from code review
PrabuckiDominik 6f40241
Merge branch 'main' of https://github.com/blumilksoftware/interns2025…
PrabuckiDominik e0d6a0b
Merge branch '15-organization-model' of https://github.com/blumilksof…
PrabuckiDominik b8446ba
Refactor Event model queries in EventController.
PrabuckiDominik 78c0553
Refactor migrations to use `foreignIdFor` syntax replacing `foreignId`
PrabuckiDominik 0e98908
Refactor `OrganizationController` to use `OrganizationResource` and s…
PrabuckiDominik 79ebabf
Merge branch '15-organization-model' of https://github.com/blumilksof…
PrabuckiDominik 956a82b
Refactor `EventController` to use `EventResource` for consistent and …
PrabuckiDominik d8a2f85
Refactor `EventFactory` to ensure proper method usage for faker attri…
PrabuckiDominik 70ed748
Merge branch 'main' of https://github.com/blumilksoftware/interns2025…
PrabuckiDominik 201f60a
Specify return type for user mapping in `OrganizationResource`.
PrabuckiDominik 0f816ac
Merge branch '15-organization-model' of https://github.com/blumilksof…
PrabuckiDominik d2175b8
Merge branch '16-crud-for-users---backend' into 29-crud-for-events---…
a33603c
Merge branch 'main' of https://github.com/blumilksoftware/interns2025…
PrabuckiDominik 035fc7d
Add Event Management with CRUD operations, validation, policies, and …
a8676fc
Refactor `Event` model, migrations, and related resources to utilize …
PrabuckiDominik 5b1724f
Apply suggestions from code review
PrabuckiDominik c09ff5d
Add `laravel/socialite` dependency to composer.json
PrabuckiDominik 2421d22
Update composer.lock with dependency
PrabuckiDominik 37998b8
Merge branch 'main' of https://github.com/blumilksoftware/interns2025…
6e4118b
Merge branch '22-event-model' of https://github.com/blumilksoftware/i…
ff56387
Merge branch 'main' of https://github.com/blumilksoftware/interns2025…
cf3a732
Enhance UserManagementControllerTest with stricter JSON assertions fo…
103c798
merge fixes
65db078
Add Organization-specific Event Management with CRUD operations, role…
8913631
Merge remote-tracking branch 'origin/29-crud-for-events---backend' in…
f0b0b5f
Remove AdminEventController, update EventPolicy with admin role check…
22bd981
Update EventRequest validation, add `authorize` method, and enhance E…
049116f
Replace hardcoded messages with translatable strings for UserManageme…
3ef0756
Merge branch 'main' of https://github.com/blumilksoftware/interns2025…
e1376b0
Refactor Admin and User management tests for consistency by reusing s…
d65c578
Refactor User query in UserManagementController for consistency and r…
ec39b1d
Enhance User and Admin tests with additional edge case validations an…
d87c7ac
Merge branch 'main' of https://github.com/blumilksoftware/interns2025…
ba6cf67
Add tests for multi-organization user creation and not found response…
4059b46
Update profile validation rules, adjust admin routes, and remove unus…
d10a8f4
Update profile validation rules, adjust admin routes, and remove unus…
0eb0c54
Refactor Admin and UserManagementController to utilize RegisterUserAc…
c67ad34
Fix adjusted to code review
611abdf
Resource fix
5e6664f
Merge branch 'main' of https://github.com/blumilksoftware/interns2025…
4ffbcb1
Merge branch '16-crud-for-users---backend' of https://github.com/blum…
3e9022d
Add OrganizationEventController tests and implement comprehensive CRU…
85e36a0
Merge branch 'main' of https://github.com/blumilksoftware/interns2025…
e364580
Add and schedule UpdateEventStatuses command with tests and EventReso…
598acb4
Add pagination to EventController index endpoint and update related t…
937eb51
Merge
5d2c362
Localize event-related responses and enhance OrganizationEventControl…
97ba1b2
Refactor OrganizationEventController to use authorization policies; u…
bb82d7f
Remove unused AuthServiceProvider and related policy registration.
030a3e9
Refactor OrganizationEventControllerTest to streamline setup and reus…
bb9404b
Update routes/api.php
AKasprzy 4597d19
Merge branch 'main' of https://github.com/blumilksoftware/interns2025…
0267a7c
Merge remote-tracking branch 'origin/29-crud-for-events---backend' in…
ce2a94c
Merge remote-tracking branch 'origin/29-crud-for-events---backend' in…
931b097
Merge remote-tracking branch 'origin/29-crud-for-events---backend' in…
7b470a3
Refactor `OrganizationEventController` to streamline request handling…
c7f27c5
Refactor routes and tests: remove duplicate user route, update test p…
974fdd5
Add latitude and longitude generation to EventSeeder for randomly ass…
5b8576d
Add return types to latitude and longitude closures in EventSeeder fo…
975a2fb
Apply suggestions from code review
AKasprzy 14aa9f6
Refactor event request validation and route definitions; improve type…
385b926
Refactor event-organization relationship: add pivot table and streaml…
e1b727a
Merge branch 'main' of https://github.com/blumilksoftware/interns2025…
bf1dfd0
Introduce request throttling for account deletion, password updates, …
f19cfd0
Add validation restricting users to one active event; update tests an…
10b24b3
Update deletion confirmation route to GET; adjust test and translatio…
4489c45
Refactor event test setup to reuse a shared `$event` instance. Optimi…
5aa8863
Update tests/Feature/OrganizationInvitationTest.php
AKasprzy ab4223e
Refactor tests to use `createPublishedEventForUser` helper; introduce…
c15e4dd
Merge remote-tracking branch 'origin/40-permissions' into 40-permissions
389eaa7
Refactor tests to use `createPublishedEventForUser` helper; introduce…
3397181
Refactor throttling logic into `ThrottleAction`; simplify controllers…
AKasprzy 4f871eb
Refactor throttling logic into `ThrottleAction`; simplify controllers…
c777627
Refactor throttling logic into `ThrottleAction`; simplify controllers…
AKasprzy 36e9923
Add reporting feature with daily throttling and polymorphic relations…
AKasprzy 1c8936c
Merge branch 'main' of https://github.com/blumilksoftware/interns2025…
AKasprzy 435533e
Merge branch 'main' of https://github.com/blumilksoftware/interns2025…
AKasprzy b77a1de
Add reporting system with polymorphic support, APIs, and admin report…
AKasprzy a9239d1
Apply suggestions from code review
AKasprzy 7238778
Apply suggestions from code review
AKasprzy 9620294
Refactor routes and remove unnecessary whitespace in `StoreReportRequ…
AKasprzy 85909b5
Extract report messages to language files and update `ReportControlle…
AKasprzy 7b23849
Refactor `ReportController`, simplify `Report` model logic, and updat…
AKasprzy 2ab970f
Remove unused `Carbon` import and adjust whitespace formatting in `Re…
AKasprzy c349a59
Merge branch 'main' of https://github.com/blumilksoftware/interns2025…
AKasprzy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Interns2025b\Http\Controllers; | ||
|
|
||
| use Carbon\Carbon; | ||
| use Illuminate\Http\JsonResponse; | ||
| use Illuminate\Http\Resources\Json\AnonymousResourceCollection; | ||
| use Interns2025b\Http\Requests\StoreReportRequest; | ||
| use Interns2025b\Http\Resources\ReportResource; | ||
| use Interns2025b\Models\Event; | ||
| use Interns2025b\Models\Organization; | ||
| use Interns2025b\Models\Report; | ||
| use Interns2025b\Models\User; | ||
| use Symfony\Component\HttpFoundation\Response as Status; | ||
|
|
||
| class ReportController | ||
| { | ||
| public function store(StoreReportRequest $request): JsonResponse | ||
| { | ||
| $user = $request->user(); | ||
|
|
||
| $type = match ($request->input("type")) { | ||
| "user" => User::class, | ||
| "organization" => Organization::class, | ||
| "event" => Event::class, | ||
| }; | ||
|
|
||
| $alreadyReported = Report::where("reporter_id", $user->id) | ||
AKasprzy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ->where("reportable_type", $type) | ||
| ->where("reportable_id", $request->input("id")) | ||
| ->whereDate("created_at", Carbon::today()) | ||
PrabuckiDominik marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ->exists(); | ||
|
|
||
| if ($alreadyReported) { | ||
| return response()->json([ | ||
| "message" => __("You have already reported this today."), | ||
PrabuckiDominik marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ], Status::HTTP_TOO_MANY_REQUESTS); | ||
| } | ||
|
|
||
| Report::create([ | ||
| "reporter_id" => $user->id, | ||
| "reportable_type" => $type, | ||
| "reportable_id" => $request->input("id"), | ||
| "reason" => $request->input("reason"), | ||
| ]); | ||
|
|
||
| return response()->json([ | ||
| "message" => __("Reported successfully."), | ||
| ], Status::HTTP_OK); | ||
| } | ||
|
|
||
| public function userReports(): AnonymousResourceCollection | ||
| { | ||
| return ReportResource::collection( | ||
| Report::where("reportable_type", User::class)->latest()->get(), | ||
AKasprzy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ); | ||
| } | ||
|
|
||
| public function organizationReports(): AnonymousResourceCollection | ||
| { | ||
| return ReportResource::collection( | ||
| Report::where("reportable_type", Organization::class)->latest()->get(), | ||
AKasprzy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ); | ||
| } | ||
|
|
||
| public function eventReports(): AnonymousResourceCollection | ||
PrabuckiDominik marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| return ReportResource::collection( | ||
| Report::where("reportable_type", Event::class)->latest()->get(), | ||
AKasprzy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Interns2025b\Http\Requests; | ||
|
|
||
| use Illuminate\Foundation\Http\FormRequest; | ||
|
|
||
| class StoreReportRequest extends FormRequest | ||
| { | ||
| public function authorize(): bool | ||
| { | ||
| return true; | ||
| } | ||
AKasprzy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| public function rules(): array | ||
| { | ||
| return [ | ||
| "type" => "required|in:user,organization,event", | ||
| "id" => "required|integer", | ||
| "reason" => "nullable|string|max:1000", | ||
| ]; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Interns2025b\Http\Resources; | ||
|
|
||
| use Illuminate\Http\Request; | ||
| use Illuminate\Http\Resources\Json\JsonResource; | ||
|
|
||
| class ReportResource extends JsonResource | ||
| { | ||
| public function toArray(Request $request): array | ||
| { | ||
| return [ | ||
| "id" => $this->id, | ||
| "reporter_id" => $this->reporter_id, | ||
| "reportable_type" => class_basename($this->reportable_type), | ||
| "reportable_id" => $this->reportable_id, | ||
| "reason" => $this->reason, | ||
| "created_at" => $this->created_at->toISOString(), | ||
PrabuckiDominik marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ]; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Interns2025b\Models; | ||
|
|
||
| use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
| use Illuminate\Database\Eloquent\Model; | ||
| use Illuminate\Database\Eloquent\Relations\MorphTo; | ||
|
|
||
| class Report extends Model | ||
| { | ||
PrabuckiDominik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| use HasFactory; | ||
|
|
||
| protected $fillable = [ | ||
| "reporter_id", | ||
| "reportable_type", | ||
| "reportable_id", | ||
| "reason", | ||
| ]; | ||
|
|
||
| public function reportable(): MorphTo | ||
| { | ||
| return $this->morphTo(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Database\Factories; | ||
|
|
||
| use Illuminate\Database\Eloquent\Factories\Factory; | ||
| use Interns2025b\Models\Event; | ||
| use Interns2025b\Models\Organization; | ||
| use Interns2025b\Models\Report; | ||
| use Interns2025b\Models\User; | ||
|
|
||
| class ReportFactory extends Factory | ||
| { | ||
| protected $model = Report::class; | ||
|
|
||
| public function definition(): array | ||
| { | ||
| $reportables = [ | ||
| User::class, | ||
| Organization::class, | ||
| Event::class, | ||
| ]; | ||
|
|
||
| $reportableType = $this->faker->randomElement($reportables); | ||
| $reportableId = $reportableType::factory()->create()->id; | ||
|
|
||
| return [ | ||
| "reporter_id" => User::factory()->create()->id, | ||
| "reportable_type" => $reportableType, | ||
| "reportable_id" => $reportableId, | ||
| "reason" => $this->faker->sentence(), | ||
| "created_at" => now(), | ||
| "updated_at" => now(), | ||
| ]; | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
database/migrations/2025_07_25_082312_create_reports_table.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,32 @@ | ||||||||||||||||||||||||||||
| <?php | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| declare(strict_types=1); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| use Illuminate\Database\Migrations\Migration; | ||||||||||||||||||||||||||||
| use Illuminate\Database\Schema\Blueprint; | ||||||||||||||||||||||||||||
| use Illuminate\Support\Facades\Schema; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| return new class() extends Migration { | ||||||||||||||||||||||||||||
| public function up(): void | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| Schema::create("reports", function (Blueprint $table): void { | ||||||||||||||||||||||||||||
| $table->id(); | ||||||||||||||||||||||||||||
| $table->foreignId("reporter_id")->constrained("users")->cascadeOnDelete(); | ||||||||||||||||||||||||||||
| $table->morphs("reportable"); | ||||||||||||||||||||||||||||
| $table->text("reason")->nullable(); | ||||||||||||||||||||||||||||
| $table->timestamps(); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| $table->unique([ | ||||||||||||||||||||||||||||
| "reporter_id", | ||||||||||||||||||||||||||||
| "reportable_type", | ||||||||||||||||||||||||||||
| "reportable_id", | ||||||||||||||||||||||||||||
| "created_at", | ||||||||||||||||||||||||||||
|
Comment on lines
+18
to
+23
|
||||||||||||||||||||||||||||
| $table->unique([ | |
| "reporter_id", | |
| "reportable_type", | |
| "reportable_id", | |
| "created_at", | |
| $table->date("created_date")->virtualAs("DATE(created_at)"); | |
| $table->unique([ | |
| "reporter_id", | |
| "reportable_type", | |
| "reportable_id", | |
| "created_date", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The type mapping logic is duplicated in three methods (store, userReports, organizationReports, eventReports). Consider extracting this into a private method or constant to reduce duplication.