Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Larareact Laravel Package

theizerdev/larareact

Larareact is a Laravel package that streamlines adding React to Laravel applications, offering scaffolding, helpers, and sensible conventions so you can build modern single-page or hybrid frontends with less configuration and boilerplate.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Pull v1.0.5 and re-run the permission seeder. The release adds whatsapp.view, whatsapp.manage, whatsapp.send, plus proveedores.send-carnet-whatsapp and productores.send-carnet-whatsapp. Without seeding, every integration route will 403 because the can() middleware will not resolve.
    php artisan migrate
    php artisan db:seed --class=PermissionSeeder
    php artisan permission:cache-reset
    
  2. Verify the permissions landed in the right UI sector (they should be grouped under Integraciones):
    Spatie\Permission\Models\Permission::findByName('whatsapp.send');
    
    If the permission exists but is missing from the admin UI, the sector-mapping branch in PermissionSeeder.php is the first place to look.
  3. First use case: connect and send. Log in as a user holding whatsapp.manage, open Integraciones → WhatsApp (/integrations/whatsapp), fill credentials, then hit /integrations/whatsapp/connect and poll /integrations/whatsapp/status. Once connected, send a PDF via /api/whatsapp/send-document with whatsapp.send.
  4. Where to look first in the codebase: WhatsAppService.php (transport, MIME/size validation, error logging, JSON fallback), routes/modules/integration.php (route group + middleware), and README.md (now the source of truth for valid endpoints — note /api/whatsapp/send-image no longer exists).

Implementation Patterns

Always inject WhatsAppService, never call the HTTP client directly. The service encapsulates the multipart document field, MIME/size validation, structured error logging (HTTP status + response body), and the JSON fallback. If you bypass it you lose all of that.

Sending a carnet from a controller – permission-check the caller, then delegate:

Route::post('/proveedores/{proveedor}/carnet', [CarnetController::class, 'send'])
    ->middleware(['auth', 'verified', 'can:proveedores.send-carnet-whatsapp']);

Follow the naming convention for integration routes. The release standardises on name('integrations.whatsapp.*'), so route('integrations.whatsapp.status') etc. resolves. When adding a new endpoint, keep it inside the same Route::prefix('integrations/whatsapp')->name('integrations.whatsapp.') group so middleware and names stay consistent.

Two API endpoints, two intents:

  • /api/whatsapp/send – plain JSON text payload.
  • /api/whatsapp/send-document – multipart with document; use this for PDFs/images.

Do not attempt to reuse /send with a file payload; the multipart path is a separate code path with its own fallback.

Credential lifecycle as a workflow. Treat connect/disconnect/reconnect/generate-token as an admin flow driven by the /status endpoint: generate token → update credentials → connect → poll status → disconnect/reconnect on failure. Wrap this in a UI component rather than scattering calls across views.

Leverage the permission granularity in views. Gate UI with @can('whatsapp.view') / @can('whatsapp.manage') and hide the send button behind @can('whatsapp.send'). This matches the route-level can() checks and keeps users from hitting dead-ending 403s.

Gotchas and Tips

  • document is the only accepted multipart field. The whole point of this release is that using anything else (e.g. file, image) fails. If you have legacy callers, patch them before deploying.
  • /api/whatsapp/send-image returns 404 by design. It was removed from the README as a non-existent endpoint. Search your front-end for any send-image references during the upgrade.
  • MIME and size are validated before the request goes out. When debugging a rejected file, check the service's validation branch first, not the WhatsApp side — the logged error will tell you which constraint tripped.
  • JSON fallback hides the original failure. If document sends silently succeed via fallback, the multipart path is broken. Read the logs: the service now records HTTP code and response body, which is where the fallback trigger reason lives.
  • Permission caching is the #1 false alarm. After seeding new permissions, php artisan permission:cache-reset (or clear the app cache) before deciding the middleware is misconfigured.
  • Sector mapping is a seeder-side concern. Adding a whatsapp.* permission without extending the integraciones sector mapping means it will appear in a different admin group. Re-run the seeder after editing, and keep the mapping table in sync with new permission names.
  • All integration routes now require auth + verified. API consumers using tokens still need an email-verified user; test with a verified fixture or your smoke tests will 302/403 unexpectedly.
  • Route refactors break hard-coded URLs. The rename pass means any Blade/JS that hard-codes /integrations/whatsapp/... paths should be moved to route('integrations.whatsapp.*') — otherwise future renames will silently break the page.
  • Extension point: the service is the right seam for adding retries, queueing, or a provider adapter. Subclass/wrap WhatsAppService rather than editing it in place, since the multipart/fallback logic is delicate and the release explicitly documents it for future maintainers.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console