Skip to content

Instantly share code, notes, and snippets.

@rachids
Created December 8, 2021 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rachids/1c9c42636ce6546c6303eeafa88869c4 to your computer and use it in GitHub Desktop.
Save rachids/1c9c42636ce6546c6303eeafa88869c4 to your computer and use it in GitHub Desktop.
Bunny Custom Builder
<?php
namespace App\Builders;
use Illuminate\Database\Eloquent\Builder;
class BunnyBuilder extends Builder
{
public function old(): self
{
return $this->where('birth_date', '<=', now()->subYears(5));
}
public function oldAndFluffy(): self
{
return $this->old()->where('fluffiness', '>', 75);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment