106 lines
3.4 KiB
PHP
106 lines
3.4 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)
|
|
* @property array|null $show_on
|
|
* @method static \Illuminate\Database\Eloquent\Builder|PaymentMethod whereShowOn($value)
|
|
* @mixin \Eloquent
|
|
*/
|
|
class PaymentMethod extends Model
|
|
{
|
|
|
|
protected $table = 'payment_methods';
|
|
|
|
protected $casts = [
|
|
'show_at' => 'int',
|
|
'pos' => 'int',
|
|
'active' => 'bool',
|
|
'default' => 'bool',
|
|
'is_abo' => 'bool',
|
|
'show_on' => 'array',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'short',
|
|
'show_at',
|
|
'show_on',
|
|
'pos',
|
|
'default',
|
|
'is_abo',
|
|
'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 static $showONs = [
|
|
1 => 'KundenShop',
|
|
2 => 'BeraterShop',
|
|
3 => 'Auszeitparty',
|
|
4 => 'Registrierung Berater',
|
|
5 => 'Mitgliedschaft Berater',
|
|
//6 => 'Onboarding Berater',
|
|
10 => 'überall',
|
|
];
|
|
|
|
public function getShowAtType(){
|
|
return isset(self::$showATs[$this->show_at]) ? self::$showATs[$this->show_at] : '-';
|
|
}
|
|
|
|
public function getShowOnTypes(){
|
|
$ret = [];
|
|
if($this->show_on && is_array($this->show_on)){
|
|
foreach($this->show_on as $show){
|
|
$ret[] = isset(self::$showONs[$show]) ? self::$showONs[$show] : '-';
|
|
}
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
public static function getDefaultAsArray($is_abo=false){
|
|
if($is_abo){
|
|
return PaymentMethod::where('active', true)->where('default', true)->where('is_abo', $is_abo)->pluck('id');
|
|
}
|
|
return PaymentMethod::where('active', true)->where('default', true)->pluck('id');
|
|
}
|
|
}
|