Prevent create a record if error in observer Laravel

Posted 2 months ago by Dronax

How I can block create a record on model if function give me error?

I have Observer:

public function created(Post $post)
    Auth::guest() ? $post->sendEmailNotification($post->guest_token) : '';

I need: if sendEmailNotification get a exception, then not create record. Now, if I get exception, post whatever creating..

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.