Partnercenter: Rollen-Flags fuer Einzelprovision und interne Rollen
- exclude_single_commission: Rollen (z. B. Barkunde 0 %) ziehen den produktseitigen Kunden-Einzelrabatt (single_commission/value_commission) nicht mehr ab. Behebt: 0-%-Rolle zog trotzdem die Produktprovision. - hide_registration: interne Rollen (z. B. Mitarbeiter) werden im Wizard und der Mitgliedschafts-Auswahl ausgeblendet, bleiben im Admin/Lead (HTMLHelper) weiter zuweisbar. - Migration 2026_09_11_100000 (beide Flags, Default false), Model-casts/ fillable, Admin-Formular (2 Checkboxen), Warenkorb-Gate in Yard. - Test tests/Feature/UserLevelSingleCommissionTest.php. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
ef19dc2ced
commit
5e55fa63bb
8 changed files with 752 additions and 521 deletions
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* App\Models\UserLevel
|
||||
|
|
@ -13,8 +15,9 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property float|null $margin
|
||||
* @property int|null $pos
|
||||
* @property int $active
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel query()
|
||||
|
|
@ -26,36 +29,44 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereTransName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereUpdatedAt($value)
|
||||
*
|
||||
* @property string|null $content
|
||||
* @property array|null $trans_content
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereContent($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereTransContent($value)
|
||||
*
|
||||
* @property bool $partner_provision
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserLevelMargin[] $user_level_margins
|
||||
* @property-read Collection|UserLevelMargin[] $user_level_margins
|
||||
* @property-read int|null $user_level_margins_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserLevelMargin[] $user_level_margins_re
|
||||
* @property-read Collection|UserLevelMargin[] $user_level_margins_re
|
||||
* @property-read int|null $user_level_margins_re_count
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePartnerProvision($value)
|
||||
*
|
||||
* @property bool $payment_year
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePaymentYear($value)
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserLevel extends Model
|
||||
{
|
||||
protected $table = 'user_levels';
|
||||
|
||||
protected $casts = ['trans_name' => 'array',
|
||||
'trans_content' => 'array',
|
||||
'partner_provision'=>'bool',
|
||||
'payment_year' => 'bool',
|
||||
];
|
||||
protected $casts = ['trans_name' => 'array',
|
||||
'trans_content' => 'array',
|
||||
'partner_provision' => 'bool',
|
||||
'payment_year' => 'bool',
|
||||
'exclude_single_commission' => 'bool',
|
||||
'hide_registration' => 'bool',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'content', 'pos', 'payment_year', 'active', 'partner_provision',
|
||||
'exclude_single_commission', 'hide_registration',
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function user_level_margins()
|
||||
{
|
||||
return $this->hasMany('App\Models\UserLevelMargin', 'user_level_id', 'id');
|
||||
|
|
@ -66,28 +77,32 @@ class UserLevel extends Model
|
|||
return $this->hasMany('App\Models\UserLevelMargin', 'user_level_id', 'id')->orderBy('price_from', 'DESC');
|
||||
}
|
||||
|
||||
public function setPosAttribute($value){
|
||||
public function setPosAttribute($value)
|
||||
{
|
||||
$this->attributes['pos'] = is_numeric($value) ? $value : null;
|
||||
|
||||
}
|
||||
|
||||
public function _format_number($value){
|
||||
return preg_replace("/[^0-9,]/", "", $value);
|
||||
public function _format_number($value)
|
||||
{
|
||||
return preg_replace('/[^0-9,]/', '', $value);
|
||||
}
|
||||
|
||||
public function setMarginAttribute( $value ) {
|
||||
public function setMarginAttribute($value)
|
||||
{
|
||||
$value = $this->_format_number($value);
|
||||
$this->attributes['margin'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
|
||||
public function getFormattedMargin()
|
||||
{
|
||||
if(!isset($this->attributes['margin'])){
|
||||
return "";
|
||||
if (! isset($this->attributes['margin'])) {
|
||||
return '';
|
||||
}
|
||||
if(\App::getLocale() === "en"){
|
||||
if (\App::getLocale() === 'en') {
|
||||
return number_format($this->attributes['margin'], 2, '.', ',');
|
||||
}
|
||||
|
||||
return number_format($this->attributes['margin'], 2, ',', '.');
|
||||
}
|
||||
|
||||
|
|
@ -98,26 +113,28 @@ class UserLevel extends Model
|
|||
return $this->{$key};
|
||||
}
|
||||
$trans = $this->getTrans($key, $lang);
|
||||
if (!$trans || $trans == '') {
|
||||
if (! $trans || $trans == '') {
|
||||
return $this->{$key};
|
||||
}
|
||||
|
||||
return $trans;
|
||||
}
|
||||
|
||||
public function getTrans($key, $lang)
|
||||
{
|
||||
$key = 'trans_' . $key;
|
||||
if (!empty($this->{$key}[$lang])) {
|
||||
$key = 'trans_'.$key;
|
||||
if (! empty($this->{$key}[$lang])) {
|
||||
return $this->{$key}[$lang];
|
||||
}
|
||||
}
|
||||
|
||||
public function getTranNames()
|
||||
{
|
||||
$ret = "";
|
||||
foreach ((array) $this->trans_name as $value){
|
||||
$ret = '';
|
||||
foreach ((array) $this->trans_name as $value) {
|
||||
$ret .= $value.', ';
|
||||
}
|
||||
|
||||
return rtrim($ret, ', ');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue