This commit is contained in:
Kevin Adametz 2024-08-05 12:05:24 +02:00
parent 04d677d37a
commit bfa3bb1df4
1191 changed files with 637397 additions and 10619 deletions

View file

@ -45,6 +45,8 @@ use Cviebrock\EloquentSluggable\Sluggable;
* @property-read \App\Models\IqImage|null $iq_image
* @property-read int|null $product_categories_count
* @method static \Illuminate\Database\Eloquent\Builder|Category withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\TransCategory> $translations
* @property-read int|null $translations_count
* @mixin \Eloquent
*/
class Category extends Model
@ -53,7 +55,6 @@ class Category extends Model
protected $table = 'categories';
protected $casts = ['trans_name' => 'array', 'trans_headline' => 'array'];
protected $fillable = [
'parent_id', 'name', 'headline', 'pos', 'active',
@ -84,6 +85,27 @@ class Category extends Model
}
public function productCategoriesCountActive()
{
$category_id = $this->id;
return Product::where('active', true)->whereHas('product_categories', function ($query) use ($category_id) {
$query->where('category_id', $category_id); //
})->orderBy('pos', 'ASC')->count();
}
public function productCategoriesCountActiveOn($show_on = ['1'])
{
$category_id = $this->id;
return Product::where('active', true)->whereJsonContains('show_on', $show_on)
->whereHas('product_categories', function ($query) use ($category_id) {
$query->where('category_id', $category_id); //
})->orderBy('pos', 'ASC')->count();
}
public function iq_image()
{
return $this->belongsTo('App\Models\IqImage', 'headline_image_id');
@ -93,44 +115,29 @@ class Category extends Model
$this->attributes['pos'] = is_numeric($value) ? $value : null;
}
public function getLang($key)
public function translations()
{
return $this->hasMany(TransCategory::class, 'categorie_id');
}
public function getLang($key)
{
$lang = \App::getLocale();
if ($lang === 'de') {
if ($lang == 'de') {
return $this->{$key};
}
$trans = $this->getTrans($key, $lang);
if (!$trans || $trans == '') {
return $this->{$key};
}
return $trans;
return $trans != '' ? $trans : $this->{$key};
}
public function getTrans($key, $lang)
{
$key = 'trans_' . $key;
if (!empty($this->{$key}[$lang])) {
return $this->{$key}[$lang];
}
return "";
}
public function getTranNames()
{
$ret = "";
foreach ((array) $this->trans_name as $value){
$ret .= $value.', ';
}
return rtrim($ret, ', ');
}
public function getTranHeadlines()
{
$ret = "";
foreach ((array) $this->trans_headline as $value){
$ret .= $value.', ';
}
return rtrim($ret, ', ');
$trans = $this->translations->where('language','=', $lang)->where('key', $key)->first();
return $trans ? $trans->value : '';
}
}

View file

@ -37,10 +37,8 @@ use PHPUnit\Framework\Constraint\Count;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereTrans($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereUpdatedAt($value)
* @property string|null $trans_name
* @property array|null $attr
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereAttr($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereTransName($value)
* @property bool|null $switch
* @property bool|null $own_eur
* @property bool|null $currency
@ -60,6 +58,8 @@ use PHPUnit\Framework\Constraint\Count;
* @property bool|null $supply_country
* @method static \Illuminate\Database\Eloquent\Builder|Country whereEuCountry($value)
* @method static \Illuminate\Database\Eloquent\Builder|Country whereSupplyCountry($value)
* @property bool|null $translate
* @method static \Illuminate\Database\Eloquent\Builder|Country whereTranslate($value)
* @mixin \Eloquent
*/
class Country extends Model
@ -68,19 +68,19 @@ class Country extends Model
protected $casts = [
'switch' => 'bool',
'translate' => 'bool',
'supply_country' => 'bool',
'eu_country' => 'bool',
'own_eur' => 'bool',
'currency' => 'bool',
'currency_calc' => 'bool',
'trans_name' => 'array',
'attr' => 'array'
];
protected $fillable = [
'code', 'phone', 'en', 'de', 'es', 'fr', 'it', 'ru',
'supply_country', 'eu_country', 'switch', 'own_eur', 'currency', 'currency_unit', 'currency_calc', 'currency_faktor',
'active', 'trans_name', 'attr',
'supply_country', 'eu_country', 'switch', 'translate', 'own_eur', 'currency', 'currency_unit', 'currency_calc', 'currency_faktor',
'active', 'attr',
];
public function country_prices()
@ -92,7 +92,6 @@ class Country extends Model
if(!$lang){
$lang = \App::getLocale();
}
if($lang === 'de'){
return $this->de;
@ -114,22 +113,10 @@ class Country extends Model
}
//search by trans
if($val = $this->getTrans('name', $lang)){
return $val;
}
return $this->de;
}
public function getTrans($key, $lang)
{
$key = 'trans_' . $key;
if (!empty($this->{$key}[$lang])) {
return $this->{$key}[$lang];
}
return "";
}
public function getAttrByKey($key)
{
$name = 'attr';

33
app/Models/DbipLookup.php Normal file
View file

@ -0,0 +1,33 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Class DbipLookup
*
* @property string $addr_type
* @property string $ip_start
* @property string $ip_end
* @property string $country
*
* @package App\Models
*/
class DbipLookup extends Model
{
protected $table = 'dbip_lookup';
public $incrementing = false;
public $timestamps = false;
protected $fillable = [
'addr_type',
'ip_start',
'ip_end',
'country'
];
}

View file

@ -0,0 +1,33 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Class DbipLookup
*
* @property string $addr_type
* @property string $ip_start
* @property string $ip_end
* @property string $country
*
* @package App\Models
*/
class DbipLookup2 extends Model
{
protected $table = 'dbip_lookup_2';
public $incrementing = false;
public $timestamps = false;
protected $fillable = [
'addr_type',
'ip_start',
'ip_end',
'country'
];
}

View file

@ -0,0 +1,33 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Class DbipLookup
*
* @property string $addr_type
* @property string $ip_start
* @property string $ip_end
* @property string $country
*
* @package App\Models
*/
class DbipLookup3 extends Model
{
protected $table = 'dbip_lookup_3';
public $incrementing = false;
public $timestamps = false;
protected $fillable = [
'addr_type',
'ip_start',
'ip_end',
'country'
];
}

52
app/Models/DcCategory.php Normal file
View file

@ -0,0 +1,52 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Cviebrock\EloquentSluggable\Sluggable;
/**
* Class DcCategory
*
* @property int $id
* @property string $name
* @property int $pos
* @property string $slug
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
*
* @package App\Models
*/
class DcCategory extends Model
{
use Sluggable;
protected $table = 'dc_categories';
protected $casts = [
'pos' => 'int',
'active' => 'bool'
];
protected $fillable = [
'name',
'pos',
'slug',
'active'
];
public function sluggable()
{
return [
'slug' => [
'source' => 'name'
]
];
}
}

190
app/Models/DcFile.php Normal file
View file

@ -0,0 +1,190 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* Class DcFile
*
* @property int $id
* @property string $filename
* @property string $original_name
* @property string $ext
* @property string $mine
* @property int|null $size
* @property int|null $active
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
*
* @property Collection|DcFileTag[] $dc_file_tags
*
* @package App\Models
*/
class DcFile extends Model
{
protected $table = 'dc_files';
protected $casts = [
'size' => 'int',
'active' => 'int'
];
protected $fillable = [
'filename',
'original_name',
'ext',
'mine',
'size',
'active'
];
public function dc_file_tags()
{
return $this->hasMany(DcFileTag::class, 'file_id');
}
public function tags(){
return $this->belongsToMany(DcTag::class, 'dc_file_tags', 'file_id', 'tag_id');
}
public function fileTag(){
return $this->hasMany(DcFileTag::class, 'file_id');
}
public function hasTags()
{
if($this->fileTag()->count()){
return true;
}
return false;
}
//path /storage/app/dc/ ...
/*public function isImage(){
if(empty($this->attributes['filename']) || @$this->attributes['filename'] == null || @$this->attributes['filename'] == ""){
return false;
}
if(!\Storage::disk('public')->has('images/shop/'.$this->filename)){
return false;
}
return true;
}
public function getImage(){
if($this->isImage()){
$link = 'images/shop/'.$this->filename;
return '/storage/'.$link.'?=lm='.\Storage::disk('public')->lastModified($link);
}
return false;
}*/
public function hasThumb(){
if(\Storage::disk('public')->exists('dc/thumb/'.$this->filename) || \Storage::disk('public')->exists('dc/thumb/'.$this->filename.".jpg")){
return true;
}
return false;
}
public function hasBig(){
if(\Storage::disk('public')->exists('dc/big/'.$this->filename) || \Storage::disk('public')->exists('dc/big/'.$this->filename.".jpg")){
return true;
}
return false;
}
public function hasFile(){
if(\Storage::disk('public')->exists('dc/files/'.$this->filename) || \Storage::disk('public')->exists('dc/files/'.$this->filename.".jpg")){
return true;
}
return false;
}
public function getThumb($full = false){
$link = 'dc/thumb/'.$this->filename;
if(\Storage::disk('public')->exists($link)){
return $full ? \Storage::disk('public')->path($link) : $link;
}
$link.=".jpg";
if(\Storage::disk('public')->exists($link)){
return $full ? \Storage::disk('public')->path($link) : $link;
}
return false;
}
public function getBig($full = false){
$link = 'dc/big/'.$this->filename;
if(\Storage::disk('public')->exists($link)){
return $full ? \Storage::disk('public')->path($link) : $link;
}
$link.=".jpg";
if(\Storage::disk('public')->exists($link)){
return $full ? \Storage::disk('public')->path($link) : $link;
}
return false;
}
public function getFile($full = false){
$link = 'dc/files/'.$this->filename;
if(\Storage::disk('public')->exists($link)){
return $full ? \Storage::disk('public')->path($link) : $link;
}
$link.=".jpg";
if(\Storage::disk('public')->exists($link)){
return $full ? \Storage::disk('public')->path($link) : $link;
}
return false;
}
public function getLastModified($type = 'thumb'){
if($type == 'thumb'){
$link = $this->getThumb();
}
if($type == 'big'){
$link = $this->getBig();
}
if($type == 'file'){
$link = $this->getFile();
}
return \Storage::disk('public')->lastModified($link);
}
public function getTags(){
$tags = $this->tags;
$tagArray = [];
foreach($tags as $tag){
$tagArray[] = $tag->name;
}
return implode(', ', $tagArray);
}
public function thumb(){
$ext = $this->ext;
$ext = strtolower($ext);
if($ext == 'pdf'){
return 'pdf.png';
}
if($ext == 'doc' || $ext == 'docx'){
return 'doc.png';
}
if($ext == 'xls' || $ext == 'xlsx'){
return 'xls.png';
}
if($ext == 'ppt' || $ext == 'pptx'){
return 'ppt.png';
}
if($ext == 'zip' || $ext == 'rar'){
return 'zip.png';
}
if($ext == 'jpg' || $ext == 'jpeg' || $ext == 'png' || $ext == 'gif'){
return $this->filename;
}
return 'file.png';
}
}

49
app/Models/DcFileTag.php Normal file
View file

@ -0,0 +1,49 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class DcFileTag
*
* @property int $id
* @property int $file_id
* @property int $tag_id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
*
* @property DcFile $dc_file
* @property DcTag $dc_tag
*
* @package App\Models
*/
class DcFileTag extends Model
{
protected $table = 'dc_file_tags';
protected $casts = [
'file_id' => 'int',
'tag_id' => 'int'
];
protected $fillable = [
'file_id',
'tag_id'
];
public function dc_file()
{
return $this->belongsTo(DcFile::class, 'file_id');
}
public function dc_tag()
{
return $this->belongsTo(DcTag::class, 'tag_id');
}
}

63
app/Models/DcTag.php Normal file
View file

@ -0,0 +1,63 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Cviebrock\EloquentSluggable\Sluggable;
/**
* Class DcTag
*
* @property int $id
* @property int|null $category_id
* @property string $name
* @property int $pos
* @property string $slug
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
*
* @property Collection|DcFileTag[] $dc_file_tags
*
* @package App\Models
*/
class DcTag extends Model
{
use Sluggable;
protected $table = 'dc_tags';
protected $casts = [
'category_id' => 'int',
'pos' => 'int',
'active' => 'bool'
];
protected $fillable = [
'category_id',
'name',
'pos',
'slug',
'active'
];
public function sluggable()
{
return [
'slug' => [
'source' => 'name'
]
];
}
public function dc_file_tags()
{
return $this->hasMany(DcFileTag::class, 'tag_id');
}
}

View file

@ -90,6 +90,7 @@ class Homeparty extends Model
'settings' => 'array',
'order' => 'array',
'card_info' => 'array',
'trans_description' => 'array',
];
protected $dates = [
@ -106,7 +107,6 @@ class Homeparty extends Model
'name',
'place',
'country_id',
'description',
'pos',
'completed',
'status',
@ -152,6 +152,39 @@ class Homeparty extends Model
}
public function getLang($key, $default = true)
{
$lang = \App::getLocale();
if ($lang == 'de') {
return $this->{$key};
}
return $this->getTrans($key, $lang, $default);
}
public function getTrans($key, $lang, $default = true)
{
if ($lang == 'de') {
return $this->{$key};
}
if($key === 'description' && !empty($this->trans_description[$lang])){
return $this->trans_description[$lang];
}
if($default){
return !empty($this->{$key}) ? $this->{$key} : '';
}
return "";
}
public function getLangOrDefault($key, $default = true)
{
$dkey = 'default_'.$key;
$value = $this->getLang($key, $default);
if(!$value || $value == ""){
return __('homeparty.welcome_copy');
}
return $value;
}
public function getDateAttribute($value)
{
if (!$value) {

View file

@ -43,6 +43,8 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereTransInci($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereTransName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereUpdatedAt($value)
* @property-read Collection<int, \App\Models\TransIngredient> $translations
* @property-read int|null $translations_count
* @mixin \Eloquent
*/
class Ingredient extends Model
@ -56,11 +58,8 @@ class Ingredient extends Model
protected $fillable = [
'name',
'trans_name',
'inci',
'trans_inci',
'effect',
'trans_effect',
'active',
'pos'
];
@ -77,4 +76,26 @@ class Ingredient extends Model
return $this->hasMany(ProductIngredient::class, 'product_ingredients', 'id');
}
public function translations()
{
return $this->hasMany(TransIngredient::class, 'ingredient_id');
}
public function getLang($key)
{
$lang = \App::getLocale();
if ($lang == 'de') {
return $this->{$key};
}
$trans = $this->getTrans($key, $lang);
return $trans != '' ? $trans : $this->{$key};
}
public function getTrans($key, $lang)
{
$trans = $this->translations->where('language','=', $lang)->where('key', $key)->first();
return $trans ? $trans->value : '';
}
}

View file

@ -1,223 +0,0 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class UserInvoiceCredit
*
* @property int $id
* @property int|null $auth_user_id
* @property int|null $shopping_order_id
* @property int|null $shopping_user_id
* @property string $type
* @property string|null $full_number
* @property int|null $number
* @property float|null $net
* @property float|null $tax_rate
* @property float|null $tax
* @property float|null $total
* @property string|null $file
* @property string|null $contents
* @property string|null $infos
* @property string|null $subject
* @property string|null $address
* @property bool $paid
* @property Carbon|null $paid_date
* @property int|null $cancellation_id
* @property Carbon|null $cancellation_date
* @property int $status
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string|null $deleted_at
* @property User|null $user
* @property UserInvoiceCredit|null $user_invoice_credit
* @property ShoppingOrder|null $shopping_order
* @property ShoppingUser|null $shopping_user
* @property Collection|UserInvoiceCredit[] $user_invoice_credits
* @package App\Models
* @property-read int|null $user_invoice_credits_count
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit newQuery()
* @method static \Illuminate\Database\Query\Builder|UserInvoiceCredit onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit query()
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereAddress($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereAuthUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereCancellationDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereCancellationId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereContents($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereFile($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereFullNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereInfos($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereNet($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit wherePaid($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit wherePaidDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereShoppingOrderId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereShoppingUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereSubject($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereTax($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereTaxRate($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereTotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereType($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereUpdatedAt($value)
* @method static \Illuminate\Database\Query\Builder|UserInvoiceCredit withTrashed()
* @method static \Illuminate\Database\Query\Builder|UserInvoiceCredit withoutTrashed()
* @mixin \Eloquent
*/
class UserInvoiceCredit extends Model
{
use SoftDeletes;
protected $table = 'user_invoice_credits';
protected $casts = [
'auth_user_id' => 'int',
'shopping_order_id' => 'int',
'shopping_user_id' => 'int',
'number' => 'int',
'year' => 'int',
'month' => 'int',
'net' => 'float',
'tax_rate' => 'float',
'tax' => 'float',
'total' => 'float',
'paid' => 'bool',
'cancellation_id' => 'int',
'status' => 'int',
'file' => 'array',
'contents' => 'array',
'infos' => 'array',
];
protected $dates = [
'paid_date',
'cancellation_date'
];
protected $fillable = [
'auth_user_id',
'shopping_order_id',
'shopping_user_id',
'type',
'year',
'month',
'full_number',
'number',
'net',
'tax_rate',
'tax',
'total',
'file',
'contents',
'infos',
'subject',
'address',
'paid',
'paid_date',
'cancellation_id',
'cancellation_date',
'status'
];
public static $monthNames = [
1 => 'Januar',
2 => 'Februar',
3 => 'März',
4 => 'April',
5 => 'Mai',
6 => 'Juni',
7 => 'Juli',
8 => 'August',
9 => 'September',
10 => 'Oktober',
11 => 'November',
12 => 'Dezember'
];
public static $statusTypes = [
0 => 'offen',
1 => 'bezahlt',
2 => 'prüfen',
10 => 'storniert'
];
public static $statusColors = [
0 => 'warning',
1 => 'success',
2 => 'secondary',
10 => 'danger',
];
public function user()
{
return $this->belongsTo(\App\User::class, 'auth_user_id');
}
public function user_invoice_credit()
{
return $this->belongsTo(UserInvoiceCredit::class, 'cancellation_id');
}
public function shopping_order()
{
return $this->belongsTo(ShoppingOrder::class);
}
public function shopping_user()
{
return $this->belongsTo(ShoppingUser::class);
}
public function user_invoice_credits()
{
return $this->hasMany(UserInvoiceCredit::class, 'cancellation_id');
}
public function getPaidDateAttribute($value){
return $this->attributes['paid_date'] ? Carbon::parse($this->attributes['paid_date'])->format(\Util::formatDateDB()) : '';
}
public function setPaidDateAttribute( $value ) {
$this->attributes['paid_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
}
public function getPaidDateRaw(){
return isset($this->attributes['paid_date']) ? $this->attributes['paid_date'] : NULL;
}
public function getCancellationDateAttribute($value){
return $this->attributes['cancellation_date'] ? Carbon::parse($this->attributes['cancellation_date'])->format(\Util::formatDateDB()) : '';
}
public function setCancellationDateAttribute( $value ) {
$this->attributes['cancellation_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
}
public function getCancellationDateRaw(){
return isset($this->attributes['cancellation_date']) ? $this->attributes['cancellation_date'] : NULL;
}
public static function getMonthName($month)
{
return isset(self::$monthNames[$month]) ? self::$monthNames[$month] : $month;
}
public function getStatusType(){
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
}
public function getStatusColor(){
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default";
}
}

View file

@ -48,6 +48,7 @@ class PaymentMethod extends Model
'pos' => 'int',
'active' => 'bool',
'default' => 'bool',
'is_abo' => 'bool',
'show_on' => 'array',
];
@ -58,6 +59,7 @@ class PaymentMethod extends Model
'show_on',
'pos',
'default',
'is_abo',
'active'
];
@ -95,7 +97,10 @@ class PaymentMethod extends Model
return $ret;
}
public static function getDefaultAsArray($short=false){
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');
}
}

View file

@ -125,6 +125,16 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ProductBuying> $product_buyings
* @property-read int|null $product_buyings_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ProductBuying> $product_buyings
* @property bool|null $sponsor_buying_points
* @property int|null $sponsor_buying_points_amount
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ProductBuying> $product_buyings
* @method static \Illuminate\Database\Eloquent\Builder|Product whereSponsorBuyingPoints($value)
* @method static \Illuminate\Database\Eloquent\Builder|Product whereSponsorBuyingPointsAmount($value)
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ProductBuying> $product_buyings
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\TransProduct> $translations
* @property-read int|null $translations_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ProductCategory> $product_categories
* @property-read int|null $product_categories_count
* @mixin \Eloquent
*/
class Product extends Model
@ -215,8 +225,8 @@ class Product extends Model
0 => '',
1 => 'ml',
2 => 'g',
3 => 'Liter',
4 => 'KG',
3 => 'liter',
4 => 'kg',
];
public $showATs = [
@ -239,6 +249,9 @@ class Product extends Model
8 => 'Mitgliedschaft Berater',
9 => 'Onboarding Berater',
10 => 'zur internen Berechnung',
12 => 'Abo-ShopBerater',
13 => 'Abo-ShopBeraterKunden',
];
public $actions = [
@ -278,6 +291,10 @@ class Product extends Model
return $this->hasMany('App\Models\ProductCategory', 'product_id', 'id')->orderBy('pos', 'DESC');
}
public function product_categories(){
return $this->hasMany('App\Models\ProductCategory', 'product_id', 'id')->orderBy('pos', 'DESC');
}
public function images(){
return $this->hasMany('App\Models\ProductImage', 'product_id', 'id')->orderBy('pos');
}
@ -302,6 +319,10 @@ class Product extends Model
return $this->hasMany(CountryPrice::class, 'product_id');
}
public function translations()
{
return $this->hasMany(TransProduct::class, 'product_id');
}
public function p_ingredients()
{
@ -382,6 +403,19 @@ class Product extends Model
}
return $price;
}
private function calcPriceUserCommission($price){
if($this->no_commission){
return $price;
}
if(\Auth::user() && \Auth::user()->user_level){
$margin = \Auth::user()->user_level->margin;
$price = $price / 100 * $margin;
}
return $price;
}
/*price net*/
private function calcPriceNet($price, $country=null){
$tax = $this->getTaxWith($country);
@ -389,18 +423,21 @@ class Product extends Model
return $price / $tax_rate;
}
//price calu with
public function getPriceWith(Bool $net = true, Bool $ufactor = true, $country = null){
public function getPriceWith(Bool $net = true, Bool $ufactor = true, $country = null, $commission=false){
$price = isset($this->attributes['price']) ? $this->attributes['price'] : null;
$cprice = $country ? $this->getCPrice($country) : null;
$price = $cprice ? $cprice : $price;
$price = $net ? $this->calcPriceNet($price, $country) : $price;
$price = $ufactor ? $this->calcPriceUserFactor($price) : $price;
$price = $commission ? $this->calcPriceUserCommission($price) : $price;
return round($price, 2);
}
/*out*/
public function getFormattedPriceWith(Bool $net = true, Bool $ufactor = true, $country = null)
public function getFormattedPriceWith(Bool $net = true, Bool $ufactor = true, $country = null, $commission=false)
{
return isset($this->attributes['price']) ? Util::formatNumber($this->getPriceWith($net, $ufactor, $country)) : "";
return isset($this->attributes['price']) ? Util::formatNumber($this->getPriceWith($net, $ufactor, $country, $commission)) : "";
}
public function getTaxWith($country = null){
@ -496,7 +533,7 @@ class Product extends Model
public function getUnitType(){
return isset($this->unitTypes[$this->unit]) ? $this->unitTypes[$this->unit] : '-';
return isset($this->unitTypes[$this->unit]) ? __($this->unitTypes[$this->unit]) : '-';
}
public function getShowAtType(){
return isset($this->showATs[$this->show_at]) ? $this->showATs[$this->show_at] : '-';
@ -523,18 +560,13 @@ class Product extends Model
return $this->{$key};
}
$trans = $this->getTrans($key, $lang);
if (!$trans || $trans == '') {
return $this->{$key};
}
return $trans;
return $trans != '' ? $trans : $this->{$key};
}
public function getTrans($key, $lang)
{
$key = 'trans_' . $key;
if (!empty($this->{$key}[$lang])) {
return $this->{$key}[$lang];
}
$trans = $this->translations->where('language','=', $lang)->where('key', $key)->first();
return $trans ? $trans->value : '';
}
public function getTranNames()
@ -573,10 +605,10 @@ class Product extends Model
return $this->price;
}
public function getFormattedPriceCurrencyWith(Bool $net = true, Bool $ufactor = true, Country $country = null){
public function getFormattedPriceCurrencyWith(Bool $net = true, Bool $ufactor = true, Country $country = null, $commission = false){
$ret = "";
if($country && isset($country->currency) && $country->currency){
$price = $this->getPriceWith($net, $ufactor, $country);
$price = $this->getPriceWith($net, $ufactor, $country, $commission);
$ret = formatNumber($price * $country->currency_faktor)." ".$country->currency_unit;
return '<br><span class="small">~'.$ret.'<span>';
}

View file

@ -30,16 +30,14 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping whereUpdatedAt($value)
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShippingPrice[] $shipping_prices
* @property-read int|null $shipping_prices_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\TransShipping> $translations
* @property-read int|null $translations_count
* @mixin \Eloquent
*/
class Shipping extends Model
{
protected $table = 'shippings';
protected $casts = [
'trans_name' => 'array',
];
protected $fillable = [
'name', 'active', 'free'
];
@ -78,4 +76,25 @@ class Shipping extends Model
public function shipping_prices(){
return $this->hasMany('App\Models\ShippingPrice', 'shipping_id', 'id');
}
public function translations()
{
return $this->hasMany(TransShipping::class, 'shipping_id');
}
public function getLang($key)
{
$lang = \App::getLocale();
if ($lang == 'de') {
return $this->{$key};
}
$trans = $this->getTrans($key, $lang);
return $trans != '' ? $trans : $this->{$key};
}
public function getTrans($key, $lang)
{
$trans = $this->translations->where('language','=', $lang)->where('key', $key)->first();
return $trans ? $trans->value : '';
}
}

View file

@ -118,7 +118,8 @@ class ShoppingCollectOrder extends Model
public function addTaxToSplit($tax_rate, $add_tax)
{
$tax_split = $this->tax_split;
$tax_split[$tax_rate] = isset($tax_split[$tax_rate]) ? round($tax_split[$tax_rate] += $add_tax, 2) : round($add_tax, 2);
$add_tax = round($add_tax, 2);
$tax_split[$tax_rate] = isset($tax_split[$tax_rate]) ? round($tax_split[$tax_rate] += $add_tax, 2) : $add_tax;
foreach($tax_split as $key=>$value){
$tax_split[$key] = number_format($value, 2);
@ -129,7 +130,8 @@ class ShoppingCollectOrder extends Model
public function addNetToSplit($tax_rate, $add_net)
{
$net_split = $this->net_split;
$net_split[$tax_rate] = isset($net_split[$tax_rate]) ? round($net_split[$tax_rate] += $add_net, 2) : round($add_net, 2);
$add_net = round($add_net, 2);
$net_split[$tax_rate] = isset($net_split[$tax_rate]) ? round($net_split[$tax_rate] += $add_net, 2) : $add_net;
foreach($net_split as $key=>$value){
$net_split[$key] = number_format($value, 2);

View file

@ -33,17 +33,21 @@ use Illuminate\Database\Eloquent\Model;
* @property string|null $back
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance whereBack($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance whereShoppingData($value)
* @property string|null $language
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingInstance whereLanguage($value)
* @mixin \Eloquent
*/
class ShoppingInstance extends Model
{
public $paymentTypes = [
1 => 'User Shop',
1 => 'Customer Shop',
2 => 'Berater Shop',
3 => 'Berater Membership',
4 => 'Berater Wizard',
5 => 'Berater Homeparty',
6 => 'Berater Shop to Customer Shop',
];
protected $table = 'shopping_instances';
@ -51,9 +55,13 @@ class ShoppingInstance extends Model
protected $casts = ['shopping_data' => 'array'];
protected $fillable = [
'identifier', 'user_shop_id', 'auth_user_id', 'payment', 'subdomain', 'country_id', 'shopping_data', 'back'
'identifier', 'user_shop_id', 'auth_user_id', 'payment', 'subdomain', 'language', 'country_id', 'shopping_data', 'back'
];
public function getLocale(){
return $this->language ? $this->language : \App::getLocale();
}
public function user_shop()
{
return $this->belongsTo('App\Models\UserShop', 'user_shop_id');

View file

@ -95,6 +95,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property-read \App\Models\ShoppingCollectOrder|null $shopping_collect_order
* @property array|null $net_split
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereNetSplit($value)
* @property string|null $language
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereLanguage($value)
* @mixin \Eloquent
*/
class ShoppingOrder extends Model
@ -111,6 +113,7 @@ class ShoppingOrder extends Model
'homeparty_id',
'payment_for',
'country_id',
'language',
'user_shop_id',
'total',
'subtotal',
@ -124,6 +127,8 @@ class ShoppingOrder extends Model
'points',
'weight',
'paid',
'is_abo',
'abo_interval',
'txaction',
'wp_invoice_path',
'api_notice',
@ -137,15 +142,17 @@ class ShoppingOrder extends Model
'api_notice' => 'array',
'tax_split' => 'array',
'net_split' => 'array',
'abo_interval' => 'int',
'is_abo' => 'bool',
];
public static $shippedTypes = [
0 => 'offen',
1 => 'in Bearbeitung',
2 => 'versendet',
3 => 'abgeschlossen',
10 => 'storniert'
0 => 'open',
1 => 'in_process',
2 => 'shipped',
3 => 'completed',
4 => 'trade_fair',
10 => 'cancelled'
];
public static $apiShippedTypes = [
@ -153,14 +160,15 @@ class ShoppingOrder extends Model
1 => 'process', //(Fullfilment durch MIVITA: nicht Versand)
2 => 'sent', //(Fullfilment durch MIVITA: Versand erfolgt)'
3 => 'close', //(Fullfilment durch MIVITA: Versand erfolgt)',
4 => 'trade', //(Fullfilment durch MIVITA: Versand erfolgt)',
10 => 'cancel'
];
public static $apiStatusTypes = [
0 => 'bestellt',
1 => 'im Prozess',
2 => 'bezahlt',
5 => 'entfernt',
0 => 'ordered',
1 => 'in_process',
2 => 'paid',
5 => 'removed',
];
public static $apiStatusColors = [
0 => 'warning',
@ -173,19 +181,20 @@ class ShoppingOrder extends Model
1 => 'info',
2 => 'success',
3 => 'secondary',
4 => 'secondary',
10 => 'danger',
];
public static $paymentForTypes = [
0 => '',
1 => 'Registrierung',
2 => 'Mitgliedschaft',
3 => 'Bestellung',
4 => 'Kundenbestellung',
5 => 'Homeparty',
6 => 'Shop',
7 => 'extern',
8 => 'Sammelrechnung',
1 => 'registration',
2 => 'membership',
3 => 'order',
4 => 'customer_order',
5 => 'homeparty',
6 => 'shop',
7 => 'external',
8 => 'collective_invoice',
10 => '',
];
@ -273,7 +282,9 @@ class ShoppingOrder extends Model
}
public function getLocale(){
return $this->language ? $this->language : \App::getLocale();
}
public function setUserHistoryValue($values = []){
if($user_history = $this->user_history){
@ -311,7 +322,14 @@ class ShoppingOrder extends Model
}
public function getShippedType(){
return isset(self::$shippedTypes[$this->shipped]) ? self::$shippedTypes[$this->shipped] : "";
return isset(self::$shippedTypes[$this->shipped]) ? __('payment.'.self::$shippedTypes[$this->shipped]) : "";
}
public static function getTransShippedType(){
$ret = [];
foreach(self::$shippedTypes as $key=>$val){
$ret[$key] = trans('payment.'.$val);
}
return $ret;
}
public function getAPIShippedType(){
@ -323,7 +341,7 @@ class ShoppingOrder extends Model
}
public function getAPIStatusType(){
return isset(self::$apiStatusTypes[$this->api_status]) ? self::$apiStatusTypes[$this->api_status] : "bestellt";
return isset(self::$apiStatusTypes[$this->api_status]) ? __('payment.'.self::$apiStatusTypes[$this->api_status]) : "bestellt";
}
public function getAPIStatusColor(){
@ -381,7 +399,7 @@ class ShoppingOrder extends Model
}
public function getPaymentForType(){
return isset(self::$paymentForTypes[$this->payment_for]) ? self::$paymentForTypes[$this->payment_for] : "";
return isset(self::$paymentForTypes[$this->payment_for]) ? __('payment.'.self::$paymentForTypes[$this->payment_for]) : "";
}
public function getPaymentForColor(){
return isset(self::$paymentForColors[$this->payment_for]) ? self::$paymentForColors[$this->payment_for] : "";
@ -579,6 +597,19 @@ class ShoppingOrder extends Model
$this->save();
}
public function getShoppingUserFullName(){
if($this->shopping_user){
$fullname = $this->shopping_user->getFullNameAsArray();
$ret = "";
$ret .= $fullname['company'] ? $fullname['company'].' | ' : '';
$ret .= $fullname['salutation'] ? \App\Services\HTMLHelper::getSalutationLang($fullname['salutation']).' ' : '';
$ret .= $fullname['firstname'] ? $fullname['firstname'].' ' : '';
$ret .= $fullname['lastname'] ? $fullname['lastname'] : '';
$ret .= $fullname['email'] ? ' | '.$fullname['email'].'' : '';
}
return $ret;
}
}

View file

@ -54,7 +54,9 @@ class ShoppingPayment extends Model
'reference',
'amount',
'currency',
'mode'
'mode',
'is_abo',
'abo_interval',
];
@ -72,26 +74,26 @@ class ShoppingPayment extends Model
if($this->clearingtype === 'wlt') {
if ($this->wallettype === 'PPE') {
return 'PayPal';
return __('payment.paypal');
}
}
if($this->clearingtype === 'cc') {
return 'Kreditkarte';
return __('payment.credit_card');
}
if($this->clearingtype === 'vor') {
return 'Vorkasse';
return __('payment.prepayment');
}
if($this->clearingtype === 'elv') {
return 'SEPA Lastschrift';
return __('payment.sepa_direct_debit');
}
if($this->clearingtype === 'sb') {
if ($this->onlinebanktransfertype === 'PNT') {
return 'Sofort Überweisung';
return __('payment.sofort_bank_transfer');
}
}
if($this->clearingtype === 'fnc') {
if ($this->onlinebanktransfertype === 'MIV') {
return 'Rechnung';
return __('payment.purchase_on_account');
}
}
}

View file

@ -118,6 +118,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUser whereShoppingCollectOrderId($value)
* @property string|null $remarks
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUser whereRemarks($value)
* @property string|null $language
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUser whereLanguage($value)
* @mixin \Eloquent
*/
class ShoppingUser extends Model
@ -134,6 +136,7 @@ class ShoppingUser extends Model
'member_id',
'number',
'is_like',
'language',
'billing_salutation',
'billing_company',
'billing_firstname',
@ -215,6 +218,10 @@ class ShoppingUser extends Model
return $this->hasOne('App\Models\ShoppingOrder','shopping_user_id');
}
public function getLocale(){
return $this->language ? $this->language : \App::getLocale();
}
public function setNotice($key, $value){
$notice = $this->notice;
$notice[$key] = $value;
@ -262,7 +269,7 @@ class ShoppingUser extends Model
case 'membership':
return 2;
case 'user_order':
return $this->is_for === 'me' ? 3 : 4;
return ($this->is_for === 'me' || $this->is_for === 'abo_me') ? 3 : 4;
case 'homeparty':
return 5;
case 'shopping':
@ -275,6 +282,18 @@ class ShoppingUser extends Model
return 0;
}
public function setIsForAttribute($value){
if($value === 'abo-me' || $value === 'me'){
$this->attributes['is_for'] = 'me';
return;
}
if($value === 'ot-member' || $value === 'ot-customer' || $value === 'abo-ot-member' || $value === 'abo-ot-customer'){
$this->attributes['is_for'] = 'ot';
return;
}
$this->attributes['is_for'] = $value;
}
public function getAPIShippedType() {
if($this->shopping_order){
@ -282,4 +301,15 @@ class ShoppingUser extends Model
}
return "free";
}
public function getFullNameAsArray() {
return [
'company' => $this->billing_company,
'salutation' => $this->billing_salutation,
'firstname' => $this->billing_firstname,
'lastname' => $this->billing_lastname,
'email' => $this->billing_email,
];
}
}

View file

@ -0,0 +1,69 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use App\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class ShoppingUserMemberLog
*
* @property int $id
* @property int $pre_member_id
* @property int $shopping_user_id
* @property int $new_member_id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property User $user
* @property ShoppingUser $shopping_user
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUserMemberLog newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUserMemberLog newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUserMemberLog query()
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUserMemberLog whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUserMemberLog whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUserMemberLog whereNewMemberId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUserMemberLog wherePreMemberId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUserMemberLog whereShoppingUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUserMemberLog whereUpdatedAt($value)
* @property-read User $new_member
* @property-read User $pre_member
* @mixin \Eloquent
*/
class ShoppingUserMemberLog extends Model
{
protected $table = 'shopping_user_member_logs';
protected $casts = [
'pre_member_id' => 'int',
'shopping_user_id' => 'int',
'new_member_id' => 'int'
];
protected $fillable = [
'pre_member_id',
'shopping_user_id',
'new_member_id'
];
public function pre_member()
{
return $this->belongsTo(User::class, 'pre_member_id');
}
public function new_member()
{
return $this->belongsTo(User::class, 'new_member_id');
}
public function shopping_user()
{
return $this->belongsTo(ShoppingUser::class);
}
}

View file

@ -0,0 +1,55 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class TransCategory
*
* @property int $id
* @property string $language
* @property int $categorie_id
* @property string|null $key
* @property string|null $value
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Category $category
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|TransCategory newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|TransCategory newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|TransCategory query()
* @method static \Illuminate\Database\Eloquent\Builder|TransCategory whereCategorieId($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransCategory whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransCategory whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransCategory whereKey($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransCategory whereLanguage($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransCategory whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransCategory whereValue($value)
* @mixin \Eloquent
*/
class TransCategory extends Model
{
protected $table = 'trans_categories';
protected $casts = [
'categorie_id' => 'int'
];
protected $fillable = [
'language',
'categorie_id',
'key',
'value'
];
public function category()
{
return $this->belongsTo(Category::class, 'categorie_id');
}
}

View file

@ -0,0 +1,55 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class TransIngredient
*
* @property int $id
* @property string $language
* @property int $ingredient_id
* @property string|null $key
* @property string|null $value
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Ingredient $ingredient
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|TransIngredient newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|TransIngredient newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|TransIngredient query()
* @method static \Illuminate\Database\Eloquent\Builder|TransIngredient whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransIngredient whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransIngredient whereIngredientId($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransIngredient whereKey($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransIngredient whereLanguage($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransIngredient whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransIngredient whereValue($value)
* @mixin \Eloquent
*/
class TransIngredient extends Model
{
protected $table = 'trans_ingredients';
protected $casts = [
'ingredient_id' => 'int'
];
protected $fillable = [
'language',
'ingredient_id',
'key',
'value'
];
public function ingredient()
{
return $this->belongsTo(Ingredient::class);
}
}

View file

@ -0,0 +1,57 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class TransProduct
*
* @property int $id
* @property int $language_id
* @property int $product_id
* @property string|null $key
* @property string|null $value
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property TransLanguage $trans_language
* @property Product $product
* @package App\Models
* @property string|null $language
* @method static \Illuminate\Database\Eloquent\Builder|TransProduct newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|TransProduct newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|TransProduct query()
* @method static \Illuminate\Database\Eloquent\Builder|TransProduct whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransProduct whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransProduct whereKey($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransProduct whereLanguage($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransProduct whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransProduct whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransProduct whereValue($value)
* @mixin \Eloquent
*/
class TransProduct extends Model
{
protected $table = 'trans_products';
protected $casts = [
'product_id' => 'int'
];
protected $fillable = [
'language',
'product_id',
'key',
'value'
];
public function product()
{
return $this->belongsTo(Product::class);
}
}

View file

@ -0,0 +1,55 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class TransShipping
*
* @property int $id
* @property string $language
* @property int $shipping_id
* @property string|null $key
* @property string|null $value
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Shipping $shipping
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|TransShipping newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|TransShipping newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|TransShipping query()
* @method static \Illuminate\Database\Eloquent\Builder|TransShipping whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransShipping whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransShipping whereKey($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransShipping whereLanguage($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransShipping whereShippingId($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransShipping whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransShipping whereValue($value)
* @mixin \Eloquent
*/
class TransShipping extends Model
{
protected $table = 'trans_shippings';
protected $casts = [
'shipping_id' => 'int'
];
protected $fillable = [
'language',
'shipping_id',
'key',
'value'
];
public function shipping()
{
return $this->belongsTo(Shipping::class);
}
}

View file

@ -0,0 +1,55 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class TransUserLevel
*
* @property int $id
* @property string $language
* @property int $user_level_id
* @property string|null $key
* @property string|null $value
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property UserLevel $user_level
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|TransUserLevel newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|TransUserLevel newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|TransUserLevel query()
* @method static \Illuminate\Database\Eloquent\Builder|TransUserLevel whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransUserLevel whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransUserLevel whereKey($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransUserLevel whereLanguage($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransUserLevel whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransUserLevel whereUserLevelId($value)
* @method static \Illuminate\Database\Eloquent\Builder|TransUserLevel whereValue($value)
* @mixin \Eloquent
*/
class TransUserLevel extends Model
{
protected $table = 'trans_user_levels';
protected $casts = [
'user_level_id' => 'int'
];
protected $fillable = [
'language',
'user_level_id',
'key',
'value'
];
public function user_level()
{
return $this->belongsTo(UserLevel::class);
}
}

131
app/Models/UserAbo.php Normal file
View file

@ -0,0 +1,131 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use App\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class UserAbo
*
* @property int $id
* @property int $user_id
* @property int $payone_userid
* @property string $clearingtype
* @property string|null $wallettype
* @property int $amount
* @property string $currency
* @property bool $active
* @property int $status
* @property int $abo_interval
* @property Carbon|null $abo_date
* @property Carbon|null $next_abo_date
* @property Carbon|null $cancel_date
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string|null $deleted_at
* @property Carbon|null $user_deleted_at
*
* @property User $user
* @property Collection|UserAboOrder[] $user_abo_orders
*
* @package App\Models
*/
class UserAbo extends Model
{
use SoftDeletes;
protected $table = 'user_abos';
protected $casts = [
'user_id' => 'int',
'shopping_user_id' => 'int',
'payone_userid' => 'int',
'amount' => 'int',
'active' => 'bool',
'status' => 'int',
'abo_interval' => 'int',
'start_date' => 'datetime',
'last_date' => 'datetime',
'next_date' => 'datetime',
'cancel_date' => 'datetime',
'count' => 'int',
'user_deleted_at' => 'datetime'
];
protected $fillable = [
'user_id',
'shopping_user_id',
'is_for',
'payone_userid',
'clearingtype',
'wallettype',
'amount',
'currency',
'active',
'status',
'abo_interval',
'start_date',
'last_date',
'next_date',
'cancel_date',
'count',
'user_deleted_at'
];
public function user()
{
return $this->belongsTo(User::class);
}
public function shopping_user()
{
return $this->belongsTo('App\Models\ShoppingUser','shopping_user_id');
}
public function user_abo_orders()
{
return $this->hasMany(UserAboOrder::class);
}
public function setStartDateAttribute( $value ) {
$this->attributes['start_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
}
public function getStartDateAttribute()
{
return $this->attributes['start_date'] ? Carbon::parse($this->attributes['start_date'])->format(\Util::formatDateDB()) : '';
}
public function setLastDateAttribute( $value ) {
$this->attributes['last_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
}
public function getLastDateAttribute()
{
return $this->attributes['last_date'] ? Carbon::parse($this->attributes['last_date'])->format(\Util::formatDateDB()) : '';
}
public function setNextDateAttribute( $value ) {
$this->attributes['next_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
}
public function getNextDateAttribute()
{
return $this->attributes['next_date'] ? Carbon::parse($this->attributes['next_date'])->format(\Util::formatDateDB()) : '';
}
public function setCancelDateAttribute( $value ) {
$this->attributes['cancel_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
}
public function getCancelDateAttribute()
{
return $this->attributes['cancel_date'] ? Carbon::parse($this->attributes['cancel_date'])->format(\Util::formatDateDB()) : '';
}
}

View file

@ -0,0 +1,54 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use App\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class UserAboOrder
*
* @property int $id
* @property int $user_abo_id
* @property int $shopping_order_id
* @property int $status
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
*
* @property ShoppingOrder $shopping_order
* @property UserAbo $user_abo
*
* @package App\Models
*/
class UserAboOrder extends Model
{
protected $table = 'user_abo_orders';
protected $casts = [
'user_abo_id' => 'int',
'shopping_order_id' => 'int',
'status' => 'int'
];
protected $fillable = [
'user_abo_id',
'user_id',
'shopping_order_id',
'status'
];
public function shopping_order()
{
return $this->belongsTo(ShoppingOrder::class);
}
public function user_abo()
{
return $this->belongsTo(UserAbo::class);
}
}

View file

@ -237,11 +237,33 @@ class UserAccount extends Model
}
public function getPhoneNumber(){
if($this->phone && $this->phone !== ""){
return ($this->pre_phone ? $this->pre_phone->phone : '')." ".$this->phone;
}
if($this->mobil && $this->mobil !== ""){
return ($this->pre_mobil ? $this->pre_mobil->phone : '')." ".$this->mobil;
}
if($this->phone && $this->phone !== ""){
return ($this->pre_phone ? $this->pre_phone->phone : '')." ".$this->phone;
}
}
public function getPhoneFull(){
if($this->phone && $this->phone !== ""){
return ($this->pre_phone ? $this->pre_phone->phone : '')." ".$this->phone;
}
return "";
}
public function getMobilFull(){
if($this->mobil && $this->mobil !== ""){
return ($this->pre_mobil ? $this->pre_mobil->phone : '')." ".$this->mobil;
}
return "";
}
public function getShippingPhoneFull(){
if($this->shipping_phone && $this->shipping_phone !== ""){
return ($this->shipping_pre_phone ? $this->shipping_pre_phone->phone : '')." ".$this->shipping_phone;
}
return "";
}
}

View file

@ -98,6 +98,27 @@ use Illuminate\Database\Eloquent\Casts\AsArrayObject;
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereQualPp($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereTotalPp($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereTotalQualPp($value)
* @property int|null $sales_volume_KP_points
* @property int|null $sales_volume_TP_points
* @property int|null $sales_volume_points_KP_sum
* @property int|null $sales_volume_points_TP_sum
* @property int|null $payline_points
* @property int|null $payline_points_qual_kp
* @property float|null $commission_growth_total
* @property array|null $qual_user_level_next
* @property array|null $next_can_user_level
* @property int $version
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereCommissionGrowthTotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereCommissionPpTotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereNextCanUserLevel($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness wherePaylinePoints($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness wherePaylinePointsQualKp($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereQualUserLevelNext($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereSalesVolumeKPPoints($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereSalesVolumePointsKPSum($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereSalesVolumePointsTPSum($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereSalesVolumeTPPoints($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereVersion($value)
* @mixin \Eloquent
*/
class UserBusiness extends Model
@ -161,6 +182,8 @@ class UserBusiness extends Model
'email',
'first_name',
'last_name',
'user_birthday',
'user_phone',
'sales_volume_KP_points',
'sales_volume_TP_points',
'sales_volume_points_shop',
@ -212,6 +235,10 @@ class UserBusiness extends Model
$this->attributes['active_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
}
public function getSalesVolumeTotalMargin(){
return $this->sales_volume_total / 100 * $this->margin;
}
}

View file

@ -0,0 +1,68 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use App\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class UserCleanUp
*
* @property int $id
* @property int $inactive_sponsor_id
* @property int $child_user_id
* @property int $new_sponsor_id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property User $user
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|UserCleanUpLog newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserCleanUpLog newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserCleanUpLog query()
* @method static \Illuminate\Database\Eloquent\Builder|UserCleanUpLog whereChildUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCleanUpLog whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCleanUpLog whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCleanUpLog whereInactiveSponsorId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCleanUpLog whereNewSponsorId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCleanUpLog whereUpdatedAt($value)
* @property-read User $child_user
* @property-read User $inactive_sponsor
* @property-read User $new_sponsor
* @mixin \Eloquent
*/
class UserCleanUpLog extends Model
{
protected $table = 'user_clean_up_logs';
protected $casts = [
'inactive_sponsor_id' => 'int',
'child_user_id' => 'int',
'new_sponsor_id' => 'int'
];
protected $fillable = [
'inactive_sponsor_id',
'child_user_id',
'new_sponsor_id'
];
public function inactive_sponsor()
{
return $this->belongsTo(User::class, 'inactive_sponsor_id');
}
public function child_user()
{
return $this->belongsTo(User::class, 'child_user_id');
}
public function new_sponsor()
{
return $this->belongsTo(User::class, 'new_sponsor_id');
}
}

View file

@ -130,10 +130,10 @@ class UserCredit extends Model
];
public static $statusTypes = [
0 => 'offen',
1 => 'bezahlt',
2 => 'prüfen',
10 => 'storniert'
0 => 'open',
1 => 'paid',
2 => 'check',
10 => 'cancelled'
];
public static $statusColors = [
@ -145,9 +145,9 @@ class UserCredit extends Model
public static $taxableTypes = [
0 => '',
1 => 'umsatzsteuerpflichtig / DE',
2 => 'nicht umsatzsteuerpflichtig / DE',
3 => 'nicht umsatzsteuerpflichtig / Ausland'
1 => 'umsatzsteuerpflichtig / DE', //payment.to_sales_tax_de
2 => 'nicht umsatzsteuerpflichtig / DE', //payment.not_to_sales_tax_de
3 => 'nicht umsatzsteuerpflichtig / Ausland' //payment.not_to_sales_tax_foreign
];
@ -195,13 +195,22 @@ class UserCredit extends Model
public function getStatusType(){
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
//trans('payment.cancelled')
return isset(self::$statusTypes[$this->status]) ? __('payment.'.self::$statusTypes[$this->status]) : "";
}
public function getStatusColor(){
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default";
}
public static function getTransStatusType(){
$ret = [];
foreach(self::$statusTypes as $key=>$val){
$ret[$key] = trans('payment.'.$val);
}
return $ret;
}
public function getDownloadPath($full = false){
if(!$full){
return $this->dir.$this->filename;

View file

@ -6,6 +6,7 @@
namespace App\Models;
use App\Services\HTMLHelper;
use App\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
@ -46,11 +47,11 @@ class UserCreditItem extends Model
public static $statusTypes = [
1 => 'Provision Shop',
2 => 'Provision Payline',
3 => 'Guthaben hinzugefügt',
4 => 'commission ...',
5 => 'Provision Wachstumsbonus',
1 => 'commission_shop',
2 => 'commission_payline',
3 => 'credit_added',
4 => 'commission',
5 => 'commission_growth_bonus',
];
@ -73,6 +74,8 @@ class UserCreditItem extends Model
'user_business_id' => 'int',
'credit' => 'float',
'status' => 'int',
'from_month' => 'int',
'from_year' => 'int',
'paid' => 'bool'
];
@ -83,6 +86,8 @@ class UserCreditItem extends Model
'credit',
'message',
'status',
'from_month',
'from_year',
'paid'
];
@ -106,12 +111,28 @@ class UserCreditItem extends Model
}
public function getStatusType(){
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
return isset(self::$statusTypes[$this->status]) ? __('payment.'.self::$statusTypes[$this->status]) : "";
}
public function getStatusColor(){
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default";
}
public function getTransMessage(){
$ret = "";
if(strpos($this->message, '#')){
$em = explode("#", $this->message);
if(isset($em[0])){ //Provision
$ret .= trans($em[0])." ";
}
if(isset($em[1])){ //month
$ret .= HTMLHelper::getMonth($em[1])." ";
}
if(isset($em[2])){ //year
$ret .= $em[2];
}
}
return $ret;
}
}

View file

@ -105,6 +105,7 @@ class UserHistory extends Model
'referenz',
'identifier',
'abo_options',
'is_abo',
'status'
];

View file

@ -11,7 +11,6 @@ use App\Models\UserLevel as ModelsUserLevel;
*
* @property int $id
* @property string $name
* @property array|null $trans_name
* @property float|null $margin
* @property int|null $pos
* @property int $active
@ -28,7 +27,6 @@ use App\Models\UserLevel as ModelsUserLevel;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereMargin($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereName($value)
* @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 int|null $next_id
* @property int|null $margin_shop
@ -58,14 +56,18 @@ use App\Models\UserLevel as ModelsUserLevel;
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine7($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine8($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereQualPp($value)
* @property int|null $paylines
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePaylines($value)
* @property string|null $trans_name
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\TransUserLevel> $translations
* @property-read int|null $translations_count
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereTransName($value)
* @mixin \Eloquent
*/
class UserLevel extends Model
{
protected $table = 'user_levels';
protected $casts = ['trans_name' => 'array'];
protected $fillable = [
'next_id', 'name', 'margin', 'margin_shop', 'qual_kp', 'qual_pp', 'growth_bonus', 'pr_line_1', 'pr_line_2', 'pr_line_3', 'pr_line_4', 'pr_line_5', 'pr_line_6', 'pr_line_7', 'pr_line_8', 'paylines', 'pos', 'active', 'default',
];
@ -76,6 +78,11 @@ class UserLevel extends Model
return $this->belongsTo('App\Models\UserLevel', 'next_id', 'id');
}
public function translations()
{
return $this->hasMany(TransUserLevel::class, 'user_level_id');
}
public function getNextUserLevels(){
//$ret = [0=>'Keinen'];
$ret = UserLevel::where('active', true)->where('id', '!=', $this->id)->orderBy('pos', 'asc')->get()->pluck('name', 'id')->toArray();
@ -98,37 +105,29 @@ class UserLevel extends Model
public function getFormattedMargin()
{
return isset($this->attributes['margin']) ? $this->attributes['margin'] : "";
return isset($this->attributes['margin']) ? Util::formatNumber($this->attributes['margin'], 1) : "";
}
public function getFormattedMarginShop()
{
return isset($this->attributes['margin_shop']) ? Util::formatNumber($this->attributes['margin_shop'], 1) : "";
}
public function getLang($key)
{
$lang = \App::getLocale();
if ($lang === 'de') {
if ($lang == 'de') {
return $this->{$key};
}
$trans = $this->getTrans($key, $lang);
if (!$trans || $trans == '') {
return $this->{$key};
}
return $trans;
return $trans != '' ? $trans : $this->{$key};
}
public function getTrans($key, $lang)
{
$key = 'trans_' . $key;
if (!empty($this->{$key}[$lang])) {
return $this->{$key}[$lang];
}
$trans = $this->translations->where('language','=', $lang)->where('key', $key)->first();
return $trans ? $trans->value : '';
}
public function getTranNames()
{
$ret = "";
foreach ((array) $this->trans_name as $value){
$ret .= $value.', ';
}
return rtrim($ret, ', ');
}
}

View file

@ -61,6 +61,12 @@ use App\User;
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereSyslog($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereInfo($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereStatusPoints($value)
* @property int|null $month_KP_points
* @property int|null $month_TP_points
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereMonthKPPoints($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereMonthTPPoints($value)
* @property int|null $status_turnover
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereStatusTurnover($value)
* @mixin \Eloquent
*/
class UserSalesVolume extends Model
@ -78,6 +84,7 @@ class UserSalesVolume extends Model
'month_TP_points' => 'int',
'month_shop_points' => 'int',
'status_points' => 'int',
'status_turnover' => 'int',
'total_net' => 'float',
'month_total_net' => 'float',
'month_shop_total_net' => 'float',
@ -101,6 +108,7 @@ class UserSalesVolume extends Model
'month_TP_points',
'month_shop_points',
'status_points',
'status_turnover',
'total_net',
'month_total_net',
'month_shop_total_net',
@ -112,18 +120,23 @@ class UserSalesVolume extends Model
public static $statusPointsTypes = [
1 => 'KP + TP', //Eigene + Team
2 => 'KP', //nur Eigene nicht Team
1 => 'KU + TP', //Eigene + Team
2 => 'KU', //nur Eigene nicht Team
];
public static $statusTurnoverTypes = [
1 => 'advisor_order', //hinzugefügt aus
2 => 'shoporder', //hinzugefügt aus
];
public static $statusTypes = [
0 => 'nicht zugewiesen',
1 => 'Beraterbestellung', //hinzugefügt aus
2 => 'Shopbestellung', //hinzugefügt aus
3 => 'Shopbestellung / pending', //hinzugefügt aus
4 => 'Gutschrift', //hinzugefügt aus
5 => 'Registrierung', //hinzugefügt aus
10 => ''
0 => 'not_assigned',
1 => 'advisor_order', //hinzugefügt aus
2 => 'shoporder', //hinzugefügt aus
3 => 'shoporder_pending', //hinzugefügt aus
4 => 'credit', //hinzugefügt aus
5 => 'registration', //hinzugefügt aus
// 10 => ''
];
public static $statusColors = [
@ -173,7 +186,23 @@ class UserSalesVolume extends Model
}
public function getStatusType(){
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
return isset(self::$statusTypes[$this->status]) ? __('payment.'.self::$statusTypes[$this->status]) : "";
}
public static function getTransStatusType(){
$ret = [];
foreach(self::$statusTypes as $key=>$val){
$ret[$key] = trans('payment.'.$val);
}
return $ret;
}
public static function getTransTurnoverTypes(){
$ret = [];
foreach(self::$statusTurnoverTypes as $key=>$val){
$ret[$key] = trans('payment.'.$val);
}
return $ret;
}
public function getStatusColor(){
@ -187,6 +216,43 @@ class UserSalesVolume extends Model
return isset(self::$statusColors[$this->status_points]) ? self::$statusColors[$this->status_points] : "default";
}
public function getStatusTurnoverType(){
switch ($this->status) {
case 1: //Bestellung Berater
return 'E';
case 2: //Shop
return 'S';
case 4: //Gutschrift
if($this->status_turnover === 2){
return 'S';
}else{
return 'E';
}
case 5: //Registrierung
return 'E';
}
return "";
}
public function getStatusTurnoverColor(){
switch ($this->status) {
case 1: //Bestellung Berater
return 'success';
case 2: //Shop
return 'secondary';
case 4: //Gutschrift
if($this->status_turnover === 2){
return 'secondary';
}else{
return 'success';
}
case 5: //Registrierung
return 'success';
}
return "default";
}
public function getFormatedMonthYear(){
return str_pad($this->month, 2, "0", STR_PAD_LEFT)."/".$this->year;
}
@ -197,4 +263,11 @@ class UserSalesVolume extends Model
}
return false;
}
public function caluCommissonTotalNet($margin){
if($this->total_net > 0 && $margin > 0){
return $this->total_net / 100 * $margin;
}
return 0;
}
}

View file

@ -76,6 +76,7 @@ class UserShop extends Model
protected $casts = [
'featured' => 'array',
'trans' => 'array',
];
protected $fillable = [
@ -114,6 +115,29 @@ class UserShop extends Model
return Carbon::parse($this->attributes['active_date'])->format("d.m.Y");
}
public function getLang($key, $default = true)
{
$lang = \App::getLocale();
if ($lang == 'de') {
return $this->{$key};
}
return $this->getTrans($key, $lang, $default);
}
public function getTrans($key, $lang, $default = true)
{
if ($lang == 'de') {
return $this->{$key};
}
if(!empty($this->trans[$lang][$key])){
return $this->trans[$lang][$key];
}
if($default){
return !empty($this->{$key}) ? $this->{$key} : '';
}
return "";
}
public function getSubdomain($session=true)
{
if($session && \Session::has('user_shop_domain')){