1 Answers
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’:
October CMS
OctoberDisclaimer
Techjockey’s software industry experts offer advice for educational and informational purposes only. A category or product query or issue posted, created, or compiled by Techjockey is not meant to replace your independent judgment.
20,000+ Software Listed
Best
Price Guaranteed
Free Expert
Consultation
2M+
Happy Customers