40 lines
903 B
PHP
Executable File
40 lines
903 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class DepositMoney extends Model
|
|
{
|
|
protected $fillable = [
|
|
'user_id',
|
|
'barbershop_id',
|
|
'amount',
|
|
'description',
|
|
];
|
|
|
|
public function scopeBarbershop(Builder $query): Builder
|
|
{
|
|
return $query->where('barbershop_id', Auth::user()->barbershop_id);
|
|
}
|
|
|
|
public function scopeToday(Builder $query): Builder
|
|
{
|
|
return $query->whereDate('created_at', Carbon::today());
|
|
}
|
|
|
|
public function scopeYesterday(Builder $query): Builder
|
|
{
|
|
return $query->whereDate('created_at', Carbon::yesterday());
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
}
|