### Install dependencies with composer install Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/AGENTS.md Run this command to install the project dependencies after cloning the repository. ```bash composer install ``` -------------------------------- ### Install package with Composer Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/README.md Installs the package via Composer. Requires PHP 8.2+ and Laravel 12 or 13. The service provider and facade are auto-discovered. ```bash composer require jeffersongoncalves/laravel-newsletter ``` -------------------------------- ### Run database migrations Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/README.md Runs the database migrations. ```bash php artisan migrate ``` -------------------------------- ### Run test, analyse, and format commands Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/AGENTS.md These commands run the Pest test suite, PHPStan (Larastan) level 5 analysis, and Pint formatting. CI enforces all three on every push, so run them before considering a change done. ```bash composer test # Pest test suite ``` ```bash composer analyse # PHPStan (Larastan) level 5 ``` ```bash composer format # Pint (Laravel preset) ``` -------------------------------- ### Run tests with composer test Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/README.md Runs the test suite for the package. Use this command to execute all tests defined in the project. ```bash composer test ``` -------------------------------- ### Publish newsletter configuration Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/README.md Publishes the configuration file to config/newsletter.php. ```bash php artisan vendor:publish --tag=newsletter-config ``` -------------------------------- ### Publish newsletter migrations Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/README.md Publishes the package migrations. ```bash php artisan vendor:publish --tag=newsletter-migrations ``` -------------------------------- ### Send a test newsletter to a preview address Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/resources/boost/skills/newsletter-development/SKILL.md Sends a test newsletter synchronously to a single address, bypassing status transitions and recipient tracking. Useful for previewing before a real send. ```php Newsletter::sendTest($newsletter, 'preview@example.com'); ``` -------------------------------- ### Newsletter configuration file Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/README.md Configuration file for the package. Adjust route prefix, default email group, scheduling, tracking, and subscribe form settings. ```php return [ // URI prefix for subscribe/confirm/unsubscribe/tracking/webview routes 'route_prefix' => 'newsletter', // Email group used when a subscription request does not specify one 'default_email_group' => 'Website', // Registers `newsletter:send-scheduled` on the schedule (hourly) 'schedule_enabled' => true, // Tag outgoing links with UTM parameters and inject the open-tracking pixel 'tracking_enabled' => true, // Registers a simple Tailwind-styled subscribe page at {route_prefix}/subscribe (GET) 'subscribe_form_enabled' => true, ]; ``` -------------------------------- ### Subscribe a member to an EmailGroup with double opt-in Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/resources/boost/skills/newsletter-development/SKILL.md Subscribes an email address to a named email group. The returned member's confirmed_at remains null until the double opt-in link is clicked, as noted in the comment. ```php use JeffersonGoncalves\Newsletter\Facades\Newsletter; $member = Newsletter::subscribe('subscriber@example.com', 'Website'); // $member->confirmed_at is null until the subscriber clicks the confirmation link ``` -------------------------------- ### Create and attach a Newsletter to an EmailGroup Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/resources/boost/skills/newsletter-development/SKILL.md Creates a newsletter with subject, sender, content, and UTM campaign, then attaches it to an email group. The content_type uses the NewsletterContentType enum, and the pivot table newsletter_email_group links the newsletter to EmailGroup models. ```php use JeffersonGoncalves\Newsletter\Models\Newsletter; use JeffersonGoncalves\Newsletter\Enums\NewsletterContentType; $newsletter = Newsletter::create([ 'subject' => 'Monthly Update', 'sender_email' => 'news@example.com', 'sender_name' => 'Example Co', 'content' => '
Hello!
', 'content_type' => NewsletterContentType::Html, 'utm_campaign' => 'monthly-update', ]); $newsletter->emailGroups()->attach($group); ``` -------------------------------- ### Compose a newsletter Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/README.md Creates a newsletter and attaches it to an email group. The email group is created if it doesn't exist. ```php use JeffersonGoncalves\Newsletter\Models\Newsletter; use JeffersonGoncalves\Newsletter\Enums\NewsletterContentType; $newsletter = Newsletter::create([ 'subject' => 'Monthly Update', 'sender_name' => 'Example Co', 'sender_email' => 'news@example.com', 'content' => 'Hello there!
', 'content_type' => NewsletterContentType::Html, 'send_unsubscribe_link' => true, 'send_webview_link' => true, 'route' => 'monthly-update', 'published' => true, 'utm_campaign' => 'monthly-update', ]); $emailGroup = \JeffersonGoncalves\Newsletter\Models\EmailGroup::firstOrCreate(['title' => 'Website']); $newsletter->emailGroups()->attach($emailGroup); ``` -------------------------------- ### Publish newsletter translations Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/README.md Publishes translation files (optional). ```bash php artisan vendor:publish --tag=newsletter-translations ``` -------------------------------- ### Publish newsletter views Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/README.md Publishes the Blade views for the subscribe page: subscribe.blade.php, confirmed.blade.php, unsubscribed.blade.php, and layout.blade.php. ```bash php artisan vendor:publish --tag=newsletter-views ``` -------------------------------- ### Send a newsletter via Newsletter facade Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/resources/boost/skills/newsletter-development/SKILL.md Sends a newsletter to all confirmed, non-unsubscribed recipients who have not already received it. The action dispatches a SendNewsletterEmailJob per recipient inside a Bus::batch, and marks the newsletter as sent when the batch completes. ```php use JeffersonGoncalves\Newsletter\Facades\Newsletter; Newsletter::send($newsletter); ``` -------------------------------- ### Schedule a newsletter send with ScheduleNewsletterAction Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/resources/boost/skills/newsletter-development/SKILL.md Use ScheduleNewsletterAction to schedule a newsletter for a future date. The command 'newsletter:send-scheduled' runs hourly and dispatches SendScheduledNewslettersJob, which sends due newsletters via SendNewsletterAction. ```php use JeffersonGoncalves\Newsletter\Actions\ScheduleNewsletterAction; app(ScheduleNewsletterAction::class)->handle($newsletter, now()->addDay()); ``` -------------------------------- ### Schedule newsletter Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/README.md Schedules a newsletter for sending. The newsletter:send-scheduled command runs hourly by default and sends due newsletters. ```php use JeffersonGoncalves\Newsletter\Enums\NewsletterStatus; $newsletter->update([ 'status' => NewsletterStatus::Scheduled, 'scheduled_at' => now()->addDay(), ]); ``` -------------------------------- ### Find broken newsletter links Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/README.md Detects broken links in the newsletter. Returns a collection of ['url' => ..., 'status' => int|null, 'error' => string|null] for each link/image that returned an error or could not be reached. ```php use JeffersonGoncalves\Newsletter\Actions\FindBrokenNewsletterLinksAction; $broken = app(FindBrokenNewsletterLinksAction::class)->handle($newsletter); ``` -------------------------------- ### Find broken links with FindBrokenNewsletterLinksAction Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/resources/boost/skills/newsletter-development/SKILL.md Use FindBrokenNewsletterLinksAction to detect broken links in a newsletter. Returns a collection of arrays with 'url', 'status' (int|null), and 'error' (string|null). ```php use JeffersonGoncalves\Newsletter\Actions\FindBrokenNewsletterLinksAction; $broken = app(FindBrokenNewsletterLinksAction::class)->handle($newsletter); // Collection of ['url' => ..., 'status' => int|null, 'error' => string|null] ``` -------------------------------- ### Add attachment to newsletter Source: https://github.com/jeffersongoncalves/laravel-newsletter/blob/master/README.md Adds an attachment to the newsletter's 'attachments' media collection, powered by spatie/laravel-medialibrary. ```php $newsletter->addMedia($uploadedFile)->toMediaCollection('attachments'); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.