Create RecurringCreated and RecurringDeleted events
ADD
app/Events/RecurringCreated.php
+<?php
+
+namespace App\Events;
+
+use App\Notification;
+use App\Recurring;
+use Illuminate\Broadcasting\Channel;
+use Illuminate\Queue\SerializesModels;
+use Illuminate\Broadcasting\PrivateChannel;
+use Illuminate\Broadcasting\PresenceChannel;
+use Illuminate\Foundation\Events\Dispatchable;
+use Illuminate\Broadcasting\InteractsWithSockets;
+use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
+use Illuminate\Support\Facades\Auth;
+
+class RecurringCreated {
+ use Dispatchable, InteractsWithSockets, SerializesModels;
+
+ public function __construct(Recurring $recurring) {
+ Notification::create([
+ 'space_id' => $recurring->space_id,
+ 'user_id' => Auth::user()->id,
+ 'entity_id' => $recurring->id,
+ 'entity_type' => 'recurring',
+ 'action' => 'recurring.created'
+ ]);
+ }
+}

ADD
app/Events/RecurringDeleted.php
+<?php
+
+namespace App\Events;
+
+use App\Notification;
+use App\Recurring;
+use Illuminate\Broadcasting\Channel;
+use Illuminate\Queue\SerializesModels;
+use Illuminate\Broadcasting\PrivateChannel;
+use Illuminate\Broadcasting\PresenceChannel;
+use Illuminate\Foundation\Events\Dispatchable;
+use Illuminate\Broadcasting\InteractsWithSockets;
+use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
+use Illuminate\Support\Facades\Auth;
+
+class RecurringDeleted {
+ use Dispatchable, InteractsWithSockets, SerializesModels;
+
+ public function __construct(Recurring $recurring) {
+ Notification::create([
+ 'space_id' => $recurring->space_id,
+ 'user_id' => Auth::user()->id,
+ 'entity_id' => $recurring->id,
+ 'entity_type' => 'recurring',
+ 'action' => 'recurring.deleted'
+ ]);
+ }
+}

MODIFY
app/Recurring.php
app/Recurring.php
namespace App;
+use App\Events\RecurringCreated;
+use App\Events\RecurringDeleted;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -10,6 +12,11 @@ class Recurring extends Model {
protected $dates = ['deleted_at'];
+ protected $dispatchesEvents = [
+ 'created' => RecurringCreated::class,
+ 'deleted' => RecurringDeleted::class
+ ];
+
// Accessors
public function getDueDaysAttribute() {
if ($this->starts_on <= date('Y-m-d') && ($this->ends_on >= date('Y-m-d') || !$this->ends_on)) {

MODIFY
resources/lang/en/notifications.php
resources/lang/en/notifications.php
@@ -7,6 +7,11 @@ return [
'deleted' => 'Deleted Transaction'
],
+ 'recurring' => [
+ 'created' => 'Created Recurring',
+ 'deleted' => 'Deleted Recurring'
+ ],
+
'tag' => [
'created' => 'Created Tag',
'modified' => 'Modified Tag',

Create RecurringCreated and RecurringDeleted events