This PR proposes to change the syntax of the user share to avoid repetition. The ternary always bugged me, and I think this is cleaner and more Laravel-ish.
This does not behave exactly the same as previously though: account here will share its timestamps, created_at and updated_at. I figured it wasn't a big deal in this case.
In PHP 8, and with arrow functions, this would be even cleaner:
Slightly related: there was a role property, but it was always null (I think?) because there were no accessor for it and it's not a column. It's used as a scope, but an accessor like this would be required for the previous code to return a value for role:
// app/Models/User.php
public function getRoleAttribute()
{
return $this->owner ? 'owner' : 'user';
}
I didn't add it and didn't add it in only either because it's not used in the Vue files.
This PR proposes to change the syntax of the
user
share to avoid repetition. The ternary always bugged me, and I think this is cleaner and more Laravel-ish.This does not behave exactly the same as previously though:
account
here will share its timestamps,created_at
andupdated_at
. I figured it wasn't a big deal in this case.In PHP 8, and with arrow functions, this would be even cleaner:
Slightly related: there was a
role
property, but it was alwaysnull
(I think?) because there were no accessor for it and it's not a column. It's used as a scope, but an accessor like this would be required for the previous code to return a value forrole
:I didn't add it and didn't add it in
only
either because it's not used in the Vue files.