Feat: implement FilterTahunDipa for year filtering and update related…#172
Feat: implement FilterTahunDipa for year filtering and update related…#172laravelwebdev merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request refactors year-based filtering in Nova resources by introducing a reusable FilterTahunDipa filter class. The changes shift from hard-coded query scoping and policy-level year filtering to a user-facing UI filter, providing more flexibility in viewing data across different years.
- Implements a new
FilterTahunDipafilter class for consistent year filtering across Nova resources - Removes year-based authorization checks from policies (SkTranslokPolicy, KepkaMitraPolicy)
- Replaces
indexQuery()methods with the new filter in multiple Nova resources - Updates date validation in Dipa resource to accept December dates in both current and next year
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| app/Nova/Filters/FilterTahunDipa.php | New filter class implementing year-based filtering with configurable column name and default session year |
| app/Policies/SkTranslokPolicy.php | Removes withYear() calls from view, update, and delete methods |
| app/Policies/KepkaMitraPolicy.php | Removes withYear() calls from view, update, and delete methods |
| app/Nova/SkTranslok.php | Adds FilterTahunDipa to filters and removes custom indexQuery method |
| app/Nova/KepkaMitra.php | Adds FilterTahunDipa to filters and removes custom indexQuery method |
| app/Nova/Dipa.php | Adds FilterTahunDipa to filters, removes custom indexQuery, and updates Tanggal Nihil validation to allow next year |
| app/Nova/ShareLink.php | Adds FilterTahunDipa to filters and removes redundant parameter documentation |
| app/Helpers/Helper.php | Updates setOptionTahunDipa() with explicit string casting for array keys and adds return type declaration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return array_flip(Helper::setOptionTahunDipa()); | ||
| } | ||
|
|
||
| public function default() |
There was a problem hiding this comment.
The default() method is missing a return type declaration. Since this filter extends from Laravel Nova's Filter class and returns a session value, it should have an explicit return type for consistency and type safety. Consider adding a return type declaration such as mixed or a more specific type if the session always returns a specific type.
| public function default() | |
| public function default(): mixed |
| public function default() | ||
| { | ||
| return session('year'); | ||
| } |
There was a problem hiding this comment.
The default() method lacks documentation. Consider adding a PHPDoc comment to explain that this method returns the default year value from the session, following the documentation pattern used for other methods in this class.
|
|
||
| public function default() | ||
| { | ||
| return session('year'); |
There was a problem hiding this comment.
The default() method returns session('year') which may be an integer, but the filter options after array_flip(Helper::setOptionTahunDipa()) will have string values. This type mismatch could prevent the default value from being properly selected in the UI. Consider casting the return value to a string to match the option values, similar to how TriwulanFilter casts its default to string.
| return session('year'); | |
| return (string) session('year'); |
… resources