Skip to content

Feat: implement FilterTahunDipa for year filtering and update related…#172

Merged
laravelwebdev merged 1 commit intomainfrom
v4
Dec 28, 2025
Merged

Feat: implement FilterTahunDipa for year filtering and update related…#172
laravelwebdev merged 1 commit intomainfrom
v4

Conversation

@laravelwebdev
Copy link
Owner

… resources

Copilot AI review requested due to automatic review settings December 28, 2025 05:28
@laravelwebdev laravelwebdev merged commit d2e488d into main Dec 28, 2025
6 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 FilterTahunDipa filter 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()
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
public function default()
public function default(): mixed

Copilot uses AI. Check for mistakes.
Comment on lines +46 to +49
public function default()
{
return session('year');
}
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.

public function default()
{
return session('year');
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
return session('year');
return (string) session('year');

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments