Answer the question
In order to leave comments, you need to log in
How to make such a query to the database?
There is a table of services and payment for the service, you need to find all the services that fit the parameters, and then select from these services only those that have made the payment.
$services = \DB::table('services_to')
->whereRaw('json_contains(categoriesId, \''.$categoryId.'\')')
->where('active', '=', 'Y')
->where('moderate', '=', 'Y')
->leftJoin('services_pay', function ($join)
{
$join->on('services_pay.service_id', '=', 'services_to.id')
->where('pay_date', '<', strtotime(date('Y-m-d H:i:s')))
->where('finish_date', '>', strtotime(date('Y-m-d H:i:s')));
})
->take(20)
->get();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question