adrema/app/Payment/Status.php

36 lines
885 B
PHP
Raw Normal View History

2021-07-04 16:56:07 +02:00
<?php
namespace App\Payment;
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
public static function default() {
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 -----------------------------------
public function scopeNeedsPayment($q) {
return $q->where(function($q) {
$q->where('is_bill', true)->orWhere('is_remember', true);
});
}
2021-07-04 16:56:07 +02:00
}