Computed attribute redundancy when using multiple times #885
Unanswered
rudolfbruder
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I would like to ask a question regarding php attributes like #[Computed] used in spatie data.
Is there a way how to write it more efficiently? I have to specify it every time above each variable which can get tedious if you data has 30 computed attributes.
This is how I am doing it now:
![image](https://private-user-images.githubusercontent.com/56951790/376108121-395230bd-d4b5-4d73-9074-e1ad14091692.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2NzIzODAsIm5iZiI6MTczOTY3MjA4MCwicGF0aCI6Ii81Njk1MTc5MC8zNzYxMDgxMjEtMzk1MjMwYmQtZDRiNS00ZDczLTkwNzQtZTFhZDE0MDkxNjkyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDAyMTQ0MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI5YzU0ZDMwZTAwYmI2ZDQ0YWVlMmY1MjMzNTM0MmFmN2ViOGNkYjIxNTFmYWQzMTUwYTkxNzJmYTllNGQ0MDcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.xiiYhLbX4_zVplMCbeEIeYQTAS2bHwT0WSguhOJUzyY)
How to achieve something like this - so that computed has to be defined only once?
![image](https://private-user-images.githubusercontent.com/56951790/376108173-9bd4c055-2239-40f3-9ca3-3d9901d5c5bd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2NzIzODAsIm5iZiI6MTczOTY3MjA4MCwicGF0aCI6Ii81Njk1MTc5MC8zNzYxMDgxNzMtOWJkNGMwNTUtMjIzOS00MGYzLTljYTMtM2Q5OTAxZDVjNWJkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDAyMTQ0MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE2ZTNhYWQ2OTQ4ZDk3YzI3ZWExZGViNzNhYzE3Njc1ZDBiYmMyMDI0NDNmY2VhYmRlNzQ5MjRjMWIzZTQ0OWUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.fyBVWPjW8-EiFuj1nj5LXPbv_imWo1Tqnsl5CEyPbmM)
I guess its a php thing not spatie data thing but maybe some of you figured it out.
Beta Was this translation helpful? Give feedback.
All reactions