<?php /** * Add a ScopeActive to an Eloquent Model */ namespace App\Traits; trait ScopeActive { /** * Only query active records */ public function scopeActive($query) { return $query->where($this->getTable().'.active',TRUE); } }