added missed condition in marketing

This commit is contained in:
rahul shukla 2021-01-18 20:13:46 +05:30
parent e61d89a3d0
commit 9f67e46ef8
3 changed files with 17 additions and 1 deletions

View File

@ -70,6 +70,12 @@ class SubscriptionController extends Controller
$subscriber = $this->subscribersListRepository->findOrFail($id);
$customer = $subscriber->customer;
$customer->subscribed_to_news_letter = $data['is_subscribed'];
$customer->save();
$result = $subscriber->update($data);
if ($result) {
@ -99,7 +105,7 @@ class SubscriptionController extends Controller
return response()->json(['message' => true], 200);
} catch (\Exception $e) {
report($e);
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Subscriber']));
}

View File

@ -3,6 +3,7 @@
namespace Webkul\Core\Models;
use Illuminate\Database\Eloquent\Model;
use Webkul\Customer\Models\CustomerProxy;
use Webkul\Core\Contracts\SubscribersList as SubscribersListContract;
class SubscribersList extends Model implements SubscribersListContract
@ -24,4 +25,12 @@ class SubscribersList extends Model implements SubscribersListContract
];
protected $hidden = ['token'];
/**
* Get the customer associated with the subscription.
*/
public function customer()
{
return $this->belongsTo(CustomerProxy::modelClass());
}
}

View File

@ -97,6 +97,7 @@ class RegistrationController extends Controller
'is_verified' => core()->getConfigData('customer.settings.email.verification') ? 0 : 1,
'customer_group_id' => $this->customerGroupRepository->findOneWhere(['code' => 'general'])->id,
'token' => md5(uniqid(rand(), true)),
'subscribed_to_news_letter' => isset(request()->input()['is_subscribed']) ? 1 : 0,
]);
Event::dispatch('customer.registration.before');