tighten / onramp

Easing the onramp for new or non-PHP developers to become Laravel devs.
https://onramp.dev/
MIT License
157 stars 56 forks source link

Renew Resource inside Nova #505

Closed tammytee closed 1 year ago

tammytee commented 1 year ago

Summary

FYI

  • [ ] Refresh detail view after an update so that the action menu is updated (this seems to be a long-standing issue that was supposedly resolved before?)

This PR allows renewing an expired resource inside the Nova admin dashboard. It also adds the ability to filter the Resources resource to view either expired or active resources only.

In order to view the "Renew Resource" action, the resource must:

To renew a resource, select the "Renew Resource" action:

Resource Expiration Date

A new migration was added to set the default value for the expiration_date column to NULL instead of now()->addMonths(6), as done in a previous migration. Using the Carbon helper inside the migration means every resource created that can_expire has a 6-month expiration_date from the day the migration was created. The new migration fixes this.

In addition to this change, closures for the creating and updating model events are registered on the Resource model to automatically set the resource's expiration_date based on if the resource can_expire.

⚠️ The expiration_date can no longer be manually set from within Nova.

Screenshots

Resource Index View - Only Expired
image
Renew Resource - Inline
image
Renew Resource - Detail
image
tammytee commented 1 year ago

I'm not sure if I like the quiet() helper since there's a createOneQuietly() and createQuietly() in Laravel.

@techenby I agree. I only created this helper because it didn't seem that you can apply the states from model factories using the methods Laravel provides. Unless there's a way to do it that you can share?

tammytee commented 1 year ago

Went ahead and removed the quiet macro I created for model factories. Must have placed createQuietly in the wrong order when attempting this before.