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

Simple Support Laravel Package

nikservik/simple-support

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps to First Use

  1. Installation

    composer require nikservik/simple-support
    php artisan vendor:publish --tag="simple-support-migrations"
    php artisan vendor:publish --tag="simple-support-config"
    php artisan migrate
    
  2. Publish Config Edit config/simple-support.php to enable features (e.g., 'user-can-send-message').

  3. First Use Case: Sending a System-Wide Notification

    use Nikservik\SimpleSupport\Facades\Support;
    
    // Send a broadcast message to all users
    Support::notifyAll('System Maintenance', 'The site will be down for 1 hour.');
    
  4. First Use Case: User Support Dialog

    // Start a conversation with a user (assuming User model has `supportConversations()`)
    $conversation = auth()->user()->supportConversations()->create([
        'subject' => 'Technical Issue',
        'message' => 'My app is crashing.'
    ]);
    

Implementation Patterns

Core Workflows

  1. User-Initiated Support Requests

    • Extend the Supportable trait to users/models needing support access.
    • Use the hasSupportConversations() relationship in your User model:
      public function supportConversations()
      {
          return $this->hasMany(\Nikservik\SimpleSupport\Models\Conversation::class);
      }
      
  2. Admin Dashboard Integration

    • Publish the admin views (if available) via:
      php artisan vendor:publish --tag="simple-support-views"
      
    • Integrate routes (check routes/simple-support.php after publishing).
  3. Broadcast Notifications

    • Use Support::notifyAll() for system-wide alerts:
      Support::notifyAll('News', 'Check out our new feature!', ['url' => '/new-feature']);
      
    • Customize notification templates in resources/views/vendor/simple-support/.
  4. API Endpoints

    • Leverage the built-in API routes for:
      • Fetching user conversations: GET /api/support/conversations.
      • Sending replies: POST /api/support/conversations/{id}/replies.

Integration Tips

  • Middleware: Protect support routes with auth or custom middleware:
    Route::middleware(['auth', 'can:access-support'])->group(function () {
        // Support routes
    });
    
  • Events: Listen for SupportConversationCreated or SupportMessageSent events:
    event(new SupportConversationCreated($conversation));
    
  • Notifications: Extend the SupportNotification class to customize email/SMS templates.

Gotchas and Tips

Pitfalls

  1. Migration Conflicts

    • If autoload-migrations is enabled in config, ensure no duplicate tables exist (e.g., conversations, messages).
    • Fix: Manually check database/migrations/ for conflicts before running migrate.
  2. Feature Flags

    • Disabling features (e.g., 'user-can-send-message') requires commenting out the line in config/simple-support.php. Uncommenting re-enables it.
    • Tip: Use environment variables for dynamic toggling:
      'features' => [
          env('SUPPORT_USER_MESSAGES', 'user-can-send-message'),
      ],
      
  3. GitHub OAuth Misconfiguration

    • The github-oauth config in composer.json is unused in the package (likely a leftover). Ignore it unless the package evolves to use GitHub auth.
  4. Translation Strings

    • Default translations may be missing. Publish them first:
      php artisan vendor:publish --tag="simple-support-translations"
      
    • Tip: Override translations in resources/lang/en/simple-support.php.

Debugging

  • Logs: Enable debug mode in config/simple-support.php:

    'debug' => env('APP_DEBUG', false),
    

    Logs appear in storage/logs/laravel.log.

  • Database Issues:

    • Run php artisan db:seed --class=SupportTableSeeder if test data is missing.
    • Tip: Use Tinker to inspect conversations:
      php artisan tinker
      >>> \Nikservik\SimpleSupport\Models\Conversation::all();
      

Extension Points

  1. Custom Models

    • Override default models by binding them in AppServiceProvider:
      $this->app->bind(
          \Nikservik\SimpleSupport\Models\Conversation::class,
          \App\Models\CustomConversation::class
      );
      
  2. API Responses

    • Extend the SupportController to modify responses:
      use Nikservik\SimpleSupport\Http\Controllers\SupportController as BaseController;
      
      class CustomSupportController extends BaseController {
          public function showConversation($id) {
              $data = parent::showConversation($id);
              $data['custom_field'] = 'value';
              return response()->json($data);
          }
      }
      
  3. Webhooks

    • Listen for SupportMessageSent events to trigger external actions (e.g., Slack):
      SupportMessageSent::subscribe(function ($event) {
          // Send to Slack/other service
      });
      
  4. Rate Limiting

    • Add rate limiting to API routes in app/Http/Kernel.php:
      'api' => [
          \Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
          \Nikservik\SimpleSupport\Http\Middleware\LimitSupportRequests::class,
      ],
      
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.
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle