Changeset View
Changeset View
Standalone View
Standalone View
src/app/User.php
Show First 20 Lines • Show All 568 Lines • ▼ Show 20 Lines | public function removeSku(Sku $sku, int $count = 1): User | ||||
$entitlements_count--; | $entitlements_count--; | ||||
$count--; | $count--; | ||||
} | } | ||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
public function senderPolicyFrameworkWhitelist($clientName) | |||||
machniak: I'm not sure I like this functionality in the User model class. | |||||
{ | |||||
$setting = $this->getSetting('spf_whitelist'); | |||||
if (!$setting) { | |||||
return false; | |||||
} | |||||
$whitelist = json_decode($setting); | |||||
$matchFound = false; | |||||
foreach ($whitelist as $entry) { | |||||
if (substr($entry, 0, 1) == '/') { | |||||
$match = preg_match($entry, $clientName); | |||||
if ($match) { | |||||
$matchFound = true; | |||||
} | |||||
continue; | |||||
} | |||||
if (substr($entry, 0, 1) == '.') { | |||||
if (substr($clientName, (-1 * strlen($entry))) == $entry) { | |||||
$matchFound = true; | |||||
} | |||||
continue; | |||||
} | |||||
if ($entry == $clientName) { | |||||
$matchFound = true; | |||||
continue; | |||||
} | |||||
} | |||||
return $matchFound; | |||||
} | |||||
/** | /** | ||||
* Any (additional) properties of this user. | * Any (additional) properties of this user. | ||||
* | * | ||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | * @return \Illuminate\Database\Eloquent\Relations\HasMany | ||||
*/ | */ | ||||
public function settings() | public function settings() | ||||
{ | { | ||||
return $this->hasMany('App\UserSetting', 'user_id'); | return $this->hasMany('App\UserSetting', 'user_id'); | ||||
▲ Show 20 Lines • Show All 150 Lines • Show Last 20 Lines |
I'm not sure I like this functionality in the User model class.