linkedin
  • Become a Seller

How to add default query condition on model in October CMS?

shibam das . Oct 16, 2024

A:

To add a default query condition to a model in October CMS, you can use the ‘boot()’ method in your model to apply a global scope. To do this follow the steps given below:

Find the model you want to apply the default query condition to, typically located in

/models

.

Add a ‘boot()’ method in the model to apply the condition:

Test the Condition: Query the model to ensure the default condition status = 'active' is applied automatically:

If you need to query without this condition, use ‘withoutGlobalScope’:

Oct 16, 2024

Was this helpful? upvote icon 0 downvote icon 0
img

Did not find the question you are looking for?

Get fast answers from real users and our software experts

menlaptop

Have a Question in Mind?

Get answers directly from verified users and our software experts

Software icon representing 20,000+ Software Listed 20,000+ Software Listed

Price tag icon for best price guarantee Best Price Guaranteed

Expert consultation icon Free Expert Consultation

Happy customer icon representing 2 million+ customers 2M+ Happy Customers