PHP 5.5.9 adds the new static `class` property which provides the fully qualified class name. This is preferred over using strings for class names since the `class` property references are checked by PHP.
31 lines
685 B
PHP
31 lines
685 B
PHP
<?php
|
|
|
|
namespace App\Filters;
|
|
|
|
use App\Models\Subscriber;
|
|
|
|
class SubscriptionFilter extends FilterAbstract
|
|
{
|
|
/**
|
|
* The model class to filter
|
|
*
|
|
* @var mixed
|
|
*/
|
|
protected $class = \App\Models\Subscription::class;
|
|
|
|
|
|
/**
|
|
* Return an array of attributes visible in the results
|
|
*
|
|
* @param array $attributes Attributes currently visible.
|
|
* @param User|null $user Current logged in user or null.
|
|
* @return mixed
|
|
*/
|
|
protected function seeAttributes(array $attributes, mixed $user)
|
|
{
|
|
if ($user?->hasPermission('admin/users') !== true) {
|
|
return ['id', 'email', 'confirmed_at'];
|
|
}
|
|
}
|
|
}
|