Skip to content
This repository was archived by the owner on Apr 7, 2020. It is now read-only.

Commit aeaa686

Browse files
author
Alex Urucu
committed
Change scoptWithQuestionUnresponded and update client->questionAnswered when sending email
1 parent 513a3ff commit aeaa686

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

app/Client.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function scopeConfirmed($query) {
108108
}
109109

110110
public function scopeWithQuestionUnresponded($query) {
111-
return $query->doesntHave('emails');
111+
return $query->where('questionAnswered', 0);
112112
}
113113

114114
public function scopeForSite($query, $siteId) {
@@ -119,6 +119,15 @@ public function scopeIsActive($query) {
119119
return $query->where('confirmed', 1)->where('ignore', 0)->where('unsubscribed', 0);
120120
}
121121

122+
public function setQuestionAnswered() {
123+
if (! $this->questionAnswered) {
124+
$this->questionAnswered = 1;
125+
$this->save();
126+
}
127+
128+
return true;
129+
}
130+
122131
public function setDefaultAttributes() {
123132
$this->domainname = getDomainFromEmailAddress($this->emailaddress);
124133
if (!$this->format) {

app/Http/Controllers/EmailsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ public function sendMail($site, EmailRequest $request) {
152152
$client = $site->clients()->emailAddress($input['email'])->first();
153153

154154
if ($client) {
155+
$client->setQuestionAnswered();
155156
$input['name'] = $client->fullName;
156157
}
157158

158-
159159
$emailData = [
160160
'sent' => 1,
161161
'from_email' => $site->email,

0 commit comments

Comments
 (0)