feat: add earnings endpoint #1

Open
Rodrigo wants to merge 1 commit from feat/earnings into main
Owner

Walkthrough — Shop Earnings Endpoint

Changes Made

New File

  • ShopEarningsController.php — Controller with show() method computing total earnings, per-product and per-payment-method breakdowns, and recent transactions

Modified Files

  • Shop.php — Added payments() hasManyThrough relationship (Shop → Product → Payment)

  • ShopPolicy.php — Added viewEarnings() method (shop owner + admins)

  • web.php — Added GET /estabelecimentos/{shop}/financeiro inside auth:sanctum group

Endpoint Reference

Detail Value
Method GET
URL /estabelecimentos/{shop}/financeiro
Auth auth:sanctum (shop owner or admin)
Filters ?start_date=YYYY-MM-DD&end_date=YYYY-MM-DD (optional)

Verification

  • All 4 files pass php -l syntax checks
  • Route confirmed registered at line 118 of web.php
  • php artisan route:list could not run (vendor/ not installed in this workspace)
# Walkthrough — Shop Earnings Endpoint ## Changes Made ### New File - [ShopEarningsController.php](file:///home/rodrigo/Documentos/ecomm/app/Http/Controllers/ShopEarningsController.php) — Controller with `show()` method computing total earnings, per-product and per-payment-method breakdowns, and recent transactions ### Modified Files - [Shop.php](file:///home/rodrigo/Documentos/ecomm/app/Models/Shop.php) — Added `payments()` `hasManyThrough` relationship (`Shop → Product → Payment`) - [ShopPolicy.php](file:///home/rodrigo/Documentos/ecomm/app/Policies/ShopPolicy.php) — Added `viewEarnings()` method (shop owner + admins) - [web.php](file:///home/rodrigo/Documentos/ecomm/routes/web.php) — Added `GET /estabelecimentos/{shop}/financeiro` inside `auth:sanctum` group ## Endpoint Reference | Detail | Value | |---|---| | Method | `GET` | | URL | `/estabelecimentos/{shop}/financeiro` | | Auth | `auth:sanctum` (shop owner or admin) | | Filters | `?start_date=YYYY-MM-DD&end_date=YYYY-MM-DD` (optional) | ## Verification - ✅ All 4 files pass `php -l` syntax checks - ✅ Route confirmed registered at line 118 of `web.php` - ⚠ `php artisan route:list` could not run (vendor/ not installed in this workspace)
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/earnings:feat/earnings
git switch feat/earnings

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff feat/earnings
git switch feat/earnings
git rebase main
git switch main
git merge --ff-only feat/earnings
git switch feat/earnings
git rebase main
git switch main
git merge --no-ff feat/earnings
git switch main
git merge --squash feat/earnings
git switch main
git merge --ff-only feat/earnings
git switch main
git merge feat/earnings
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Rodrigo/PvAuto!1
No description provided.