*/ namespace MillionsMissingFrance\FreescoutRestrictedCustomers; use Illuminate\Database\Eloquent\Model; use Watson\Rememberable\Rememberable; use App\Email as BaseEmail; class Email extends BaseEmail { /** * Check if an Email already exists for a given Mailbox. * * @param Mailbox $mailbox * @param string $email * * @return bool */ public static function alreadyExistsInMailbox($mailbox, $email) { $emails_count = self ::whereHas('customer', function($query) use($mailbox) { $query->where('mailbox_id', '=', $mailbox->id); }) ->where('email', $email) ->count(); return ( $emails_count != 0 ); } }