-
Notifications
You must be signed in to change notification settings - Fork 30
feat: use scopes with other columns besides created_at #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi @aymanalhattami, thanks for your contribution. I'm not really happy with the API though. As you might know, there are two ways to tell the package which column to use for the date range queries: laravel-date-scopes/src/DateScopes.php Line 149 in 42dc649
First it checks if the model has a custom I would maybe move away from the This would introduce a breaking change and we would need a small migration guide. But it should be pretty simple to implement. I guess it would be simpler to create a new PR for that, instead of reverting your changes... What do you tink? Would that work for your needs? |
This package is great but right now is limited to only one column in the the table which is the custom column in the model's
I tried this configuration, but i need to use the same scopes with more datetime columns in the same table
It's nice to keep parameters as low as possible, but from my point of view, it's not right to limit it to only one column in the table.
I will make PR and it will be better if it's a method instead of property in order to add the ability to make some logic when necessary
My PR does not introduce breaking changes, and it still uses the column in the configuration file or in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @aymanalhattami, gotcha - thanks for your reply. Except for the one point, the PR looks good to me. When it's "fixed" we can merge it.
This PR introduces support for applying date scopes on custom columns, not just the default
created_at
, allowing for greater flexibility when using this package.Many applications involve models with multiple date fields, and limiting scopes to
created_at
restricts their usage. This update allows developers to:Example
Transaction::ofToday(column: 'approved_at')