alajusticia / laravel-expirable Goto Github PK
View Code? Open in Web Editor NEWMake Eloquent models expirable ๐
License: MIT License
Make Eloquent models expirable ๐
License: MIT License
Please can you add laravel 10 support
expirable()
blueprint method, but no opposite (removeExpirable()
or similar):
public function removeExpirable()
{
return function ($columnName = 'expires_at') {
return $this->dropColumn($columnName);
};
}
Expirable
trait is missing docs for macro/extension/magic methods (as an example, see laravel's SoftDeletes
trait):
/**
* @mixin ExpirableEloquentQueryBuilder <- this works because of completely overwriting query builder
*/
bootExpirable
(which is a laravel feature) - this is also how SoftDeletes
trait does itSoftDeletingScope
by adding macro methods:
class ExpirationScope implements Scope
{
public function apply(Builder $builder, Model $model)
{
...
}
public function extend(Builder $builder)
{
$builder->macro('onlyExpired', function (Builder $builder) {
return $builder->withoutGlobalScope(ExpirationScope::class)
->where($this->model->getExpirationAttribute(), '<=', Carbon::now());
});
...
/** @method static static|EloquentBuilder|QueryBuilder onlyExpired() */
for point 2$subscriptions->expiredOnly()
is more idiomatic/correct, for examplePurgeCommand
and other internal classes)composer.json
(*) this shows the problem with traits - methods in the same level cannot be overridden and in case of conflicts, you're forced to choose an implementation and you can't later on call the other methods, unlike class inheritance where you can call the parent method
The first 3 points are the most 'painful' and point 4 would be a BC break.
If I get some time later, I might try opening a PR..
On a different point, there's another competing package that solves some of the issues above, but has its own problems: mvdnbrk/laravel-model-expires - maybe you guys could join efforts into one solution that works well with the best of both?
Hello can you add laravel 9 support?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.