mivita/app/Models/PaymentMethod.php
2020-08-21 18:20:40 +02:00

77 lines
2.5 KiB
PHP

<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class PaymentMethod
*
* @property int $id
* @property string $name
* @property string $short
* @property int $show_at
* @property int $pos
* @property bool $active
* @property bool $default
* @property Carbon $created_at
* @property Carbon $updated_at
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereDefault($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereShort($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereShowAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereUpdatedAt($value)
* @mixin \Eloquent
*/
class PaymentMethod extends Model
{
protected $table = 'payment_methods';
protected $casts = [
'show_at' => 'int',
'pos' => 'int',
'active' => 'bool',
'default' => 'bool',
];
protected $fillable = [
'name',
'short',
'show_at',
'pos',
'default',
'active'
];
public static $showATs = [
0 => 'Nur Kunden Shop',
1 => 'Nur Berater Shop',
2 => 'Kunden + Berater Shop',
3 => 'Nur Reg/Mitgliedschaft Berater',
4 => 'Kunden + Berater Shop + Reg/Mitgliedschaft',
5 => 'Berater Shop + Reg/Mitgliedschaft',
9 => 'überall',
];
public function getShowAtType(){
return isset(self::$showATs[$this->show_at]) ? self::$showATs[$this->show_at] : '-';
}
public static function getDefaultAsArray($short=false){
return PaymentMethod::where('active', true)->where('default', true)->pluck('id');
}
}