#11 add support for selectable attributes
This minor version adds a function in the trait that allows the developer to determine what attributes their clients can obtain from their models.
<?php
namespace App;
// ...
use Restql\Traits\RestqlAttributes;
class Book extends Model
{
use RestqlAttributes;
/**
* Get the fillable attributes for selects.
*
* @return array
*/
public function onSelectFillables(): array
{
if ($this->isPrivate) {
return ['title', 'created_at'];
}
return $this->getFillable();
}
}