#Include extra data when passing collections to the frontend
1 messages · Page 1 of 1 (latest)
Yea I thought about that too, but in models you can't use repositories or services either can you
U do not need to use service in model.
Might be u do not know use of that.
See documentation, and learn first
once u apply append to model u can use that it any where via model.
I don't think u understand my case
I need to check its availability by using a repository
there is no work arround for that
First of all, No one has time to read this long paragraphs, It's too way long. You can simply share your code. With model and repository. No one will still your code. 😃 with just 2 file of code who has only 2 function not event full file of code. 🤣 I hope you will undertood exactly what I am trying to say.
Let's move on your requirement,
- You just need a key in you model which you can append in your model. and Now you need to check how that key behave in your repository or not?
Kindly check let me know If I mis understood.
Thanks
What is inside the repository isn't related, it's all about being able to make use of ANY repository, for which you will need a constructor.
I need to grab the value of that key from my repository, yes. That is the complete issue here, I can put the extra value inside the model or transformer, that ain't an issue, but reading the value of this value is the issue, as that can only be done while making use of a repository.
anyone an idea on this?
Are you using transformers? Or Eloquent API resources?
in my try I tried to include it in the transformer
as I don't make use of api resources
Any particular reason? Since they do the same job as transformers?
because the project makes use of relations a lot which can be easily included and transformed using transformers
They can in Eloquent API resources, too.
well, in the beginning we choose not to, so the project has been builded using transformers
there might be other reasons for it which I am not aware off
is there actually no way to do this?