Skip to content

Instantly share code, notes, and snippets.

@rachids
Created December 8, 2021 20:48
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/f7497ccda4aeed3c89c627f0545ab952 to your computer and use it in GitHub Desktop.
Save rachids/f7497ccda4aeed3c89c627f0545ab952 to your computer and use it in GitHub Desktop.
Bunny Model
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Bunny extends Model
{
use HasFactory;
public function scopeOld(Builder $query): Builder
{
return $query->where('birth_date', '<=', now()->subYears(5));
}
public function scopeOldAndFluffy(Builder $query): Builder
{
return $query->old()->where('fluffiness', '>', 75);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment