MailBlocker::setPreferences($user, [acme.blog::post.new_reply => 0])
MailBlocker::setPreferences($user, [acme.blog::post.new_reply => 0], [fillable => [acme.blog::post.new_reply]])
MailBlocker::setPreferences($user, [template_alias => 0], [aliases => [template_alias => acme.blog::post.new_reply]])
Supported options:
- aliases: Alias definitions, with alias as key and template as value.
- fillable: An array of expected templates, undefined templates are ignored.
- verify: Only allow mail templates that are registered in the system.
public function onUpdate() { try { if (!$this->canEdit()) { throw new ApplicationException('Permission denied.'); } $member = $this->getMember(); if (!$member) { return; } /* * Process mail preferences */ if ($member->user) { MailBlocker::setPreferences($member->user, post('MailPreferences'), ['aliases' => $this->getMailTemplates()]); } /* * Save member */ $data = array_except(post(), 'MailPreferences'); $member->fill($data); $member->save(); Flash::success(post('flash', 'Settings successfully saved!')); return $this->redirectToSelf(); } catch (Exception $ex) { Flash::error($ex->getMessage()); } }