R
R
Raccoon2019-12-20 10:06:17
ORM
Raccoon, 2019-12-20 10:06:17

Laravel. Is it possible to add dynamic parameters to GlobalScope?

Problem. I have an aggregation model consisting of data from several tables, part of the data is calculated in the query itself in the database. To be sure that the model will always have all the necessary data, you can use a global scope when calling the model, instead of writing a local scope (in which to pass parameters) each time the model is called.
But the question is how to throw dynamic parameters into the global scope itself? Perhaps there is a more convenient solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2019-12-20
@New_Horizons

https://laravel.com/docs/5.8/eloquent#global-scopes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question