I am thinking of making a payment system and that through it there are 3 plans (Basic, Featured and super featured). I already have the payment gateways, I designed the logic of the subscription plan and I still need how to highlight these publications.
Basically I have the idea of putting together the following tables:
Now to show the publications I have a search engine and it returns everything found based on what was searched:
$publicaciones = Publication::search($request->get('termino'))->get();
Can you enlighten me how I can show the paid publications first and then the ones that do not have exposure?
One way to achieve this is
ORDER BY
by using the following:Basically the ordering criteria will be guided by whether or not the publication is in the subscriptions table, in this case, it will first show those that are.
With this
subquery
you get the id of the publications that have subscription (paid).Here is a working example.
Since you're using orderByRaw
Eloquent
, you can help yourself . You haven't shown how you do the query but here's an example: