Skip to content
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

Possibility to set withArchived() as default instead of withoutArchived() #13

Closed
zaheer15351 opened this issue Jan 26, 2023 · 1 comment

Comments

@zaheer15351
Copy link

Is there any way of changing the default behaviour of this package where withoutArchived() is used as a default scope, to change it to something else that is supported i.e. withArchived() ?

@joelbutcher
Copy link
Owner

I would extend the ArchivableScope class and modify the apply method as you need. You'll then need to create a new trait with the same bootArchived method which loads in the new extended scope class:

trait Archivable
{
    public static function bootArchivable()
    {
        self::addGlobalScope(new ExtendedArchivableScope());
    }
}

Then in your model do something like this:

namespace App\Models;

use App\Concerns\Archivable;
use LaravelArchivable\Archivable as BaseArchivable;

class Post extend Model
{
    use Archivable, BaseArchivable {
        Archivable::bootArchivable insteadof BaseArchivable;
    }
}

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

No branches or pull requests

2 participants