Make subscribers is verified a attribute getter

This commit is contained in:
Joseph Cohen 2015-12-09 17:32:18 -06:00
parent 412c119131
commit e5c90b25b2
2 changed files with 7 additions and 4 deletions

View File

@ -81,7 +81,7 @@ class SubscribeController extends Controller
$subscriber = Subscriber::where('verify_code', '=', $code)->first();
if (!$subscriber || $subscriber->verified()) {
if (!$subscriber || $subscriber->is_verified) {
throw new BadRequestHttpException();
}
@ -106,7 +106,7 @@ class SubscribeController extends Controller
$subscriber = Subscriber::where('verify_code', '=', $code)->first();
if (!$subscriber || !$subscriber->verified()) {
if (!$subscriber || !$subscriber->is_verified) {
throw new BadRequestHttpException();
}

View File

@ -14,6 +14,7 @@ namespace CachetHQ\Cachet\Models;
use AltThree\Validator\ValidatingTrait;
use CachetHQ\Cachet\Presenters\SubscriberPresenter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use McCool\LaravelAutoPresenter\HasPresenter;
class Subscriber extends Model implements HasPresenter
@ -65,9 +66,11 @@ class Subscriber extends Model implements HasPresenter
/**
* Scope a query to only include verified subscribers.
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeVerified($query)
public function scopeVerified(Builder $query)
{
return $query->whereNotNull('verified_at');
}
@ -77,7 +80,7 @@ class Subscriber extends Model implements HasPresenter
*
* @return bool
*/
public function verified()
public function getIsVerifiedAttribute()
{
return $this->verified_at !== null;
}