Super Simple User Based Feature Flags
Through a simple addition to the user model we can enable application features for specific users only
Last updated
public function hasFeature($code)
{
// ignores user setting if the feature code is globally enabled.
if(collect(config('app.features' ?? [] ))->contains($code)){
return true;
}
return !! collect(explode(',',$this->features))->contains($code);
}@if(Auth::user()->hasFeature('SE'))
<a href="{{ route('search') }}" class="px-2 py-2 text-sm font-bold text-center">SEARCH</a>
@endifif($user->hasFeature('NU')){
// something to do with feature
}