{"id":18973755,"url":"https://github.com/64robots/batch-notifications","last_synced_at":"2025-10-08T23:58:04.677Z","repository":{"id":32950102,"uuid":"147431124","full_name":"64robots/batch-notifications","owner":"64robots","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-10T00:42:29.000Z","size":101,"stargazers_count":14,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-08T23:58:03.141Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/64robots.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-09-04T23:13:30.000Z","updated_at":"2025-08-17T04:44:00.000Z","dependencies_parsed_at":"2024-11-08T15:13:02.179Z","dependency_job_id":"2ae0e604-0736-4f01-a21c-bf72959e041b","html_url":"https://github.com/64robots/batch-notifications","commit_stats":{"total_commits":16,"total_committers":5,"mean_commits":3.2,"dds":0.5,"last_synced_commit":"55c5cd9f6410f94d988cab1b413c023ae0f16a52"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/64robots/batch-notifications","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/64robots%2Fbatch-notifications","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/64robots%2Fbatch-notifications/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/64robots%2Fbatch-notifications/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/64robots%2Fbatch-notifications/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/64robots","download_url":"https://codeload.github.com/64robots/batch-notifications/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/64robots%2Fbatch-notifications/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000707,"owners_count":26082862,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T15:13:00.096Z","updated_at":"2025-10-08T23:58:04.662Z","avatar_url":"https://github.com/64robots.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Batch Notifications\n\n## Description\n\nBatch Notifications is a Laravel package that groups repetitive notifications in batches.\nThis package is intended for cases where notifications are dispatched repeatedly for a same Notifiable model.\nSo, instead of sending lots of notifications (ex.: email messages) repeatedly to the Notifiable model, the\nnotifications are grouped in batches that will be sent in periods of time.\n\n## Installation\n\n#### 1 - Require the package\n\n``\ncomposer require 64robots/batch-notifications\n``\n\n#### 2 - Publish\n\n``\nphp artisan vendor:publish --provider=\"R64\\BatchNotifications\\BatchNotificationsServiceProvider\"\n``\n\n#### 3 - Run the migration that was just published\n\n``\nphp artisan migrate\n``\n\n## Usage\n\n#### 1 - Create you notification as you normally do, but add the \"$eventables\" parameter to the constructor:\n\n```\nclass DocumentAssignedEmail extends Notification implements ShouldQueue\n{\n    use Queueable;\n\n    /** @var Collection $eventables */\n    private $eventables;\n\n    /**\n     * Create a new notification instance.\n     *\n     * @return void\n     */\n    public function __construct(Collection $eventables)\n    {\n        $this-\u003eeventables = $eventables;\n    }\n\n    /**\n     * Get the notification's delivery channels.\n     *\n     * @param  mixed  $notifiable\n     * @return array\n     */\n    public function via($notifiable)\n    {\n        return ['mail'];\n    }\n\n    /**\n     * Get the mail representation of the notification.\n     *\n     * @param  mixed  $notifiable\n     * @return \\Illuminate\\Notifications\\Messages\\MailMessage\n     */\n    public function toMail($notifiable)\n    {\n        if ($this-\u003eeventables-\u003ecount() == 1) {\n            return (new MailMessage)-\u003eview('mail.documents-assigned', [\n                'user' =\u003e $notifiable,\n                'document' =\u003e $this-\u003eeventables-\u003efirst(),\n            ])-\u003esubject(\"New Document Assigned\");\n        }\n\n        return (new MailMessage)-\u003eview('mail.documents-assigned', [\n            'user' =\u003e $notifiable,\n            'documents' =\u003e $this-\u003eeventables,\n        ])-\u003esubject(\"New Documents Assigned\");\n    }\n\n    /**\n     * Get the array representation of the notification.\n     *\n     * @param  mixed  $notifiable\n     * @return array\n     */\n    public function toArray($notifiable)\n    {\n        return [\n            //\n        ];\n    }\n}\n```\n\n#### 2 - Create the notification event for the intended notification:\n\n```\nBatchNotificationEvent::queue(\n    Auth::user(), /* The notifiable model instance. This can be any Notifiable Eloquent model */\n    $document, /* The eventable instance you want to attach to the notification. All batch's eventables will be present on your notification constructor. This can be any Eloquent model. */\n    DocumentAssignedEmail::class, /* The fully qualified name of your notification class */\n    now()-\u003eaddMinutes(2) /* The minimum interval that the notifiable model will be notified. In this example, the notifications will be sent every two minutes */\n);\n```\n\n#### 3 - Add the command to your Console/Kernel.php file:\n\n\n```\nclass Kernel extends ConsoleKernel\n{\n    /**\n     * The Artisan commands provided by your application.\n     *\n     * @var array\n     */\n    protected $commands = [\n        //\n    ];\n\n    /**\n     * Define the application's command schedule.\n     *\n     * @param  \\Illuminate\\Console\\Scheduling\\Schedule  $schedule\n     * @return void\n     */\n    protected function schedule(Schedule $schedule)\n    {\n        $schedule-\u003ecommand('batch-notifications:dispatch')-\u003eeveryMinute();\n    }\n\n    //...\n}\n```\n\n#### 4 - \"mail.documents-assigned\" view example:\n\n```\n@extends('layouts.email')\n\n@section('content')\n    \u003cp style=\"color: #444444\"\u003e\n        Hello {{ $user-\u003efirst_name }},\n    \u003c/p\u003e\n\n    @if (isset($document))\n        \u003cp style=\"color: #444444\"\u003e\n            A new document has been assigned to you: \u003ca href=\"{{ url('/documents/' . $document-\u003eid) }}\"\u003eDocument #{{ $document-\u003eid }}\u003c/a\u003e.\n        \u003c/p\u003e\n    @else\n        \u003cp style=\"color: #444444\"\u003e\n            New documents have been assigned to you:\u003cbr/\u003e\u003cbr/\u003e\n\n            @foreach ($documents as $document)\n                \u003ca href=\"{{ url('/documents/' . $document-\u003eid) }}\"\u003eDocument #{{ $document-\u003eid }}\u003c/a\u003e\u003cbr/\u003e\n            @endforeach\n        \u003c/p\u003e\n    @endif\n@endsection\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F64robots%2Fbatch-notifications","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F64robots%2Fbatch-notifications","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F64robots%2Fbatch-notifications/lists"}