Edit File: ContactReplay.php
<?php namespace App\Models; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\MorphTo; class ContactReplay extends BaseModel { protected $fillable = ['replay', 'replayer_id', 'replayer_type', 'contact_id']; /** * Get the replayer of the replay. */ public function replayer(): MorphTo { return $this->morphTo(); } /** * Get the contact that owns the replay. */ public function contact(): BelongsTo { return $this->belongsTo(Contact::class); } // booted method protected static function booted(): void { static::creating(function ($replay) { // send email to the contact $replay->contact->sendReplayEmail($replay->replay); }); } }
Back to File Manager