feat(purchase): menambahkan scope di model
This commit is contained in:
parent
be9816fde2
commit
9a5a7661da
@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Scope;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@ -24,6 +26,18 @@ protected function casts(): array
|
||||
];
|
||||
}
|
||||
|
||||
#[Scope]
|
||||
public function today(Builder $query): void
|
||||
{
|
||||
$query->whereDate('created_at', today());
|
||||
}
|
||||
|
||||
#[Scope]
|
||||
public function yesterday(Builder $query): void
|
||||
{
|
||||
$query->whereDate('created_at', today()->subDay());
|
||||
}
|
||||
|
||||
public function outlet(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Outlet::class);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user