2021-07-04 16:56:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Payment;
|
|
|
|
|
2022-02-12 15:33:16 +01:00
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
2021-07-04 16:56:07 +02:00
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class Status extends Model
|
|
|
|
{
|
|
|
|
use HasFactory;
|
|
|
|
|
|
|
|
public $fillable = ['name', 'is_bill', 'is_remember'];
|
|
|
|
public $timestamps = false;
|
2021-07-04 17:03:56 +02:00
|
|
|
public $casts = [
|
|
|
|
'is_bill' => 'boolean',
|
|
|
|
'is_remember' => 'boolean',
|
|
|
|
];
|
|
|
|
|
2021-07-04 16:56:07 +02:00
|
|
|
|
2022-02-12 15:33:16 +01:00
|
|
|
public static function default(): int
|
|
|
|
{
|
2021-07-04 16:56:07 +02:00
|
|
|
return static::where('is_bill', true)->where('is_remember', true)->first()->id;
|
|
|
|
}
|
2021-07-04 17:03:56 +02:00
|
|
|
|
2022-01-02 12:32:57 +01:00
|
|
|
public function isAccepted(): bool
|
|
|
|
{
|
2021-07-04 17:03:56 +02:00
|
|
|
return $this->is_bill === false && $this->is_remember === false;
|
|
|
|
}
|
2021-07-04 21:47:20 +02:00
|
|
|
|
|
|
|
// ---------------------------------- Scopes -----------------------------------
|
2022-02-12 15:33:16 +01:00
|
|
|
public function scopeNeedsPayment(Builder $query): Builder
|
|
|
|
{
|
|
|
|
return $query->where(function(Builder $query): Builder {
|
|
|
|
return $query->where('is_bill', true)->orWhere('is_remember', true);
|
2021-07-04 21:47:20 +02:00
|
|
|
});
|
|
|
|
}
|
2021-07-04 16:56:07 +02:00
|
|
|
}
|