File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 6
6
use Eugenefvdm \NotificationSubscriptions \Models \NotificationTemplate ;
7
7
use App \Models \User ;
8
8
use Eugenefvdm \NotificationSubscriptions \Enums \RepeatFrequency ;
9
+ use Exception ;
9
10
use Illuminate \Database \Eloquent \Model ;
10
11
use Illuminate \Notifications \Notification ;
11
12
use Illuminate \Support \Carbon ;
@@ -123,7 +124,13 @@ public function getSubscriptionFromNotifiable(object $notifiable): ?Notification
123
124
*/
124
125
public static function getTemplate (): ?NotificationTemplate
125
126
{
126
- return NotificationTemplate::where ('notification_class ' , basename (static ::class))->firstOrFail ();
127
+ $ template = NotificationTemplate::where ('notification_class ' , basename (static ::class))->first ();
128
+
129
+ if (!$ template ) {
130
+ throw new Exception ("Notification template not found for class: " . basename (static ::class). ". Please ensure a notification has already been sent. " );
131
+ }
132
+
133
+ return $ template ;
127
134
}
128
135
129
136
/**
Original file line number Diff line number Diff line change 6
6
use Illuminate \Database \Eloquent \Casts \Attribute ;
7
7
use Illuminate \Database \Eloquent \Factories \HasFactory ;
8
8
use Illuminate \Database \Eloquent \Model ;
9
- use Illuminate \Database \Eloquent \Relations \BelongsTo ;
10
9
use Illuminate \Database \Eloquent \Relations \HasMany ;
11
10
12
11
class NotificationTemplate extends Model
You can’t perform that action at this time.
0 commit comments