-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to hide relation attributes? #26
Comments
Hi there, Number one will not work. Number two does work, but you forgot to implement the |
Thank you for your reply. However I still have some problems. I tried also what you told, but I thought it was uncorrect, since I got an exception. I have the following (simplifying): class User extends Authenticable implements PortableContract
{
use Portable;
protected $gdprWith = ['relation'];
protected $gdprHidden = ['password', 'remember_token', 'created_at', 'updated_at'];
public function relation()
{
return $this->hasOne(Relation::class);
}
public function getNameAttribute()
{
return ucfirst(strtolower($this->person->name)); // <-- HERE LIES THE PROBLEM
}
...
} and class Relation extends Model implements PortableContract
{
use Portable;
protected $gdprHidden = ['id'];
...
} with this setup I get the following exception:
where It seems that, notwithstanding it is a If a remove |
It seems like the Feel free to use the following workaround for the time being. I'll get back to you with a new release. /**
* Load and transform a portable relation.
*
* @param string $relation
* @return void
*/
private function loadPortableRelation(string $relation)
{
$items = $this
->$relation()
->get()
->transform(function ($item) {
return $item->portable();
});
if ($items->count() === 1) {
$items = $items->first();
}
$this->attributes[$relation] = $items;
} |
Ok, thank you for your time |
Thanks! |
Hi, I am not able to hide specific attributes from relations. I have tried the following:
in
User
set$gdprHidden = ['relation.attribute']
Add
Portable
trait toRelation
and inside it set$gdprHidden = ['attribute']
What am I missing? Thank you.
The text was updated successfully, but these errors were encountered: