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;
|
|
|
|
|
2023-12-16 20:35:06 +01:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
*/
|
2021-07-04 16:56:07 +02:00
|
|
|
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',
|
|
|
|
];
|
|
|
|
|
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
|
|
|
|
{
|
2022-03-11 20:19:17 +01:00
|
|
|
return false === $this->is_bill && false === $this->is_remember;
|
2021-07-04 17:03:56 +02:00
|
|
|
}
|
2021-07-04 21:47:20 +02:00
|
|
|
|
|
|
|
// ---------------------------------- Scopes -----------------------------------
|
2023-02-17 18:57:11 +01:00
|
|
|
/**
|
|
|
|
* @param Builder<self> $query
|
|
|
|
* @return Builder<self>
|
|
|
|
*/
|
2022-02-12 15:33:16 +01:00
|
|
|
public function scopeNeedsPayment(Builder $query): Builder
|
|
|
|
{
|
2022-03-11 20:19:17 +01:00
|
|
|
return $query->where(function (Builder $query): Builder {
|
2022-02-12 15:33:16 +01:00
|
|
|
return $query->where('is_bill', true)->orWhere('is_remember', true);
|
2021-07-04 21:47:20 +02:00
|
|
|
});
|
|
|
|
}
|
2023-10-13 15:48:29 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array<int, array{name: string, id: int}>
|
|
|
|
*/
|
|
|
|
public static function forSelect(): array
|
|
|
|
{
|
|
|
|
return static::select('name', 'id')->get()->toArray();
|
|
|
|
}
|
2021-07-04 16:56:07 +02:00
|
|
|
}
|