Create ImportCreated and ImportDeleted events
ADD
app/Events/ImportCreated.php
+<?php
+
+namespace App\Events;
+
+use App\Import;
+use App\Notification;
+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 ImportCreated {
+ use Dispatchable, InteractsWithSockets, SerializesModels;
+
+ public function __construct(Import $import) {
+ Notification::create([
+ 'space_id' => $import->space_id,
+ 'user_id' => Auth::user()->id,
+ 'entity_id' => $import->id,
+ 'entity_type' => 'import',
+ 'action' => 'import.created'
+ ]);
+ }
+}

ADD
app/Events/ImportDeleted.php
+<?php
+
+namespace App\Events;
+
+use App\Import;
+use App\Notification;
+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 ImportDeleted {
+ use Dispatchable, InteractsWithSockets, SerializesModels;
+
+ public function __construct(Import $import) {
+ Notification::create([
+ 'space_id' => $import->space_id,
+ 'user_id' => Auth::user()->id,
+ 'entity_id' => $import->id,
+ 'entity_type' => 'import',
+ 'action' => 'import.deleted'
+ ]);
+ }
+}

MODIFY
app/Import.php
app/Import.php
namespace App;
+use App\Events\ImportCreated;
+use App\Events\ImportDeleted;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -18,6 +20,11 @@ class Import extends Model {
'column_amount'
];
+ protected $dispatchesEvents = [
+ 'created' => ImportCreated::class,
+ 'deleted' => ImportDeleted::class
+ ];
+
// Relations
public function spendings() {
return $this->hasMany(Spending::class);

MODIFY
resources/lang/en/notifications.php
resources/lang/en/notifications.php
@@ -11,5 +11,10 @@ return [
'created' => 'Created Tag',
'modified' => 'Modified Tag',
'deleted' => 'Deleted Tag'
+ ],
+
+ 'import' => [
+ 'created' => 'Created Import',
+ 'deleted' => 'Deleted Import'
]
];

Create ImportCreated and ImportDeleted events