update 20.10.2025

This commit is contained in:
Kevin Adametz 2025-10-20 17:42:08 +02:00
parent 8c11130b5d
commit a939cd51ef
616 changed files with 84821 additions and 4121 deletions

View file

@ -0,0 +1,91 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\Attribute
*
* @property int $id
* @property int|null $parent_id
* @property string $name
* @property array|null $trans_name
* @property int|null $pos
* @property int $active
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Attribute[] $childrens
* @property-read \App\Models\Attribute|null $parent
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereParentId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereTransName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereUpdatedAt($value)
* @property string|null $slug
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute query()
* @property-read int|null $childrens_count
* @mixin \Eloquent
*/
class Attribute extends Model
{
protected $table = 'attributes';
protected $casts = ['trans_name' => 'array'];
protected $fillable = [
'parent_id', 'name', 'pos', 'active',
];
public function parent()
{
return $this->belongsTo('App\Models\Attribute', 'parent_id');
}
public function childrens()
{
return $this->hasMany('App\Models\Attribute', 'parent_id', 'id');
}
public function setPosAttribute($value){
$this->attributes['pos'] = is_numeric($value) ? $value : null;
}
public function getLang($key)
{
$lang = \App::getLocale();
if ($lang == 'de') {
return $this->{$key};
}
$trans = $this->getTrans($key, $lang);
if (!$trans || $trans == '') {
return $this->{$key};
}
return $trans;
}
public function getTrans($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 .= $value.', ';
}
return rtrim($ret, ', ');
}
}

View file

@ -0,0 +1,143 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Cviebrock\EloquentSluggable\Sluggable;
/**
* App\Models\Category
*
* @property int $id
* @property int|null $parent_id
* @property string $name
* @property array|null $trans_name
* @property int|null $pos
* @property int $active
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Category[] $childrens
* @property-read \App\Models\Category|null $parent
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereParentId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereTransName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereUpdatedAt($value)
* @property string|null $slug
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductCategory[] $product_categories
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category findSimilarSlugs($attribute, $config, $slug)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category query()
* @property string|null $headline
* @property int|null $headline_image_id
* @property array|null $trans_headline
* @property-read int|null $childrens_count
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Image[] $image
* @property-read int|null $image_count
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereHeadline($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereHeadlineImageId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereTransHeadline($value)
* @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
{
use Sluggable;
protected $table = 'categories';
protected $fillable = [
'parent_id', 'name', 'headline', 'pos', 'active',
];
public function sluggable() : array
{
return [
'slug' => [
'source' => 'name'
]
];
}
public function parent()
{
return $this->belongsTo('App\Models\Category', 'parent_id');
}
public function childrens()
{
return $this->hasMany('App\Models\Category', 'parent_id', 'id');
}
public function product_categories()
{
return $this->hasMany('App\Models\ProductCategory', 'category_id', 'id')->orderBy('pos', 'DESC');
}
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');
}
public function setPosAttribute($value){
$this->attributes['pos'] = is_numeric($value) ? $value : null;
}
public function translations()
{
return $this->hasMany(TransCategory::class, 'categorie_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

@ -0,0 +1,162 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use PHPUnit\Framework\Constraint\Count;
/**
* App\Models\Country
*
* @property int $id
* @property string $code
* @property string $phone
* @property string $en
* @property string $de
* @property string $es
* @property string $fr
* @property string $it
* @property string $ru
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCode($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereDe($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereEn($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereEs($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereFr($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereIt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country wherePhone($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereRu($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country query()
* @property int|null $active
* @property array|null $trans
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereActive($value)
* @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 array|null $attr
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereAttr($value)
* @property bool|null $switch
* @property bool|null $own_eur
* @property bool|null $currency
* @property string|null $currency_unit
* @property bool|null $currency_calc
* @property float|null $currency_faktor
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCurrency($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCurrencyCalc($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCurrencyFaktor($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCurrencyName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereOwnEur($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereSwitch($value)
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\CountryPrice[] $country_prices
* @property-read int|null $country_prices_count
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCurrencyUnit($value)
* @property bool|null $eu_country
* @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
{
protected $table = 'countries';
protected $casts = [
'switch' => 'bool',
'translate' => 'bool',
'supply_country' => 'bool',
'eu_country' => 'bool',
'own_eur' => 'bool',
'currency' => 'bool',
'currency_calc' => 'bool',
'attr' => 'array'
];
protected $fillable = [
'code', 'phone', 'en', 'de', 'es', 'fr', 'it', 'ru',
'supply_country', 'eu_country', 'switch', 'translate', 'own_eur', 'currency', 'currency_unit', 'currency_calc', 'currency_faktor',
'active', 'attr',
];
public function country_prices()
{
return $this->hasMany(CountryPrice::class, 'country_id');
}
public function getLocated($lang = false){
if(!$lang){
$lang = \App::getLocale();
}
if($lang === 'de'){
return $this->de;
}
if($lang === 'en'){
return $this->en;
}
if($lang === 'es'){
return $this->es;
}
if($lang === 'fr'){
return $this->fr;
}
if($lang === 'it'){
return $this->it;
}
if($lang === 'ru'){
return $this->ru;
}
//search by trans
return $this->de;
}
public function getAttrByKey($key)
{
$name = 'attr';
if (!empty($this->{$name}[$key])) {
return $this->{$name}[$key];
}
return "";
}
public static function getCountryIdByCode($code){
if($code == null){
return null;
}
$r = Country::where('code', '=', $code)->first();
if($r){
return $r->id;
}
return null;
}
public static function getCountryIdByCodeOrOne($code){
if($code == null){
return 1;
}
$r = Country::where('code', '=', $code)->first();
if($r){
return $r->id;
}
return 1;
}
public static function getCountryIdByPhone($phone){
if($phone == null){
return null;
}
$r = Country::where('phone', '=', $phone)->first();
if($r){
return $r->id;
}
return null;
}
}

View file

@ -0,0 +1,73 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class CountryPrice
*
* @property int $id
* @property int $country_id
* @property int $product_id
* @property float $c_price
* @property float $c_tax
* @property float $c_price_old
* @property float $c_currency
* @property Carbon $created_at
* @property Carbon $updated_at
* @property Country $country
* @property Product $product
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereCOwnEur($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereCPrice($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereCPriceOld($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereCTax($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereCCurrency($value)
* @mixin \Eloquent
*/
class CountryPrice extends Model
{
protected $table = 'country_prices';
protected $casts = [
'country_id' => 'int',
'product_id' => 'int',
'c_price' => 'float',
'c_tax' => 'float',
'c_price_old' => 'float',
'c_currency' => 'float'
];
protected $fillable = [
'country_id',
'product_id',
'c_price',
'c_tax',
'c_price_old',
'c_currency'
];
public function country()
{
return $this->belongsTo(Country::class);
}
public function product()
{
return $this->belongsTo(Product::class);
}
}

View file

@ -0,0 +1,72 @@
<?php
namespace App\Models;
use App\User;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable; // Wichtig!
/**
* @property int $id
* @property string|null $name
* @property string $email
* @property int|null $shopping_user_id
* @property int|null $member_id
* @property int|null $number
* @property string|null $language
* @property string|null $mode
* @property string|null $remember_token
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read User|null $member
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection<int, \Illuminate\Notifications\DatabaseNotification> $notifications
* @property-read int|null $notifications_count
* @property-read \App\Models\ShoppingUser|null $shoppingUser
* @method static \Illuminate\Database\Eloquent\Builder<static>|Customer newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Customer newQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Customer query()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Customer whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Customer whereEmail($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Customer whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Customer whereLanguage($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Customer whereMemberId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Customer whereMode($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Customer whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Customer whereNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Customer whereRememberToken($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Customer whereShoppingUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Customer whereUpdatedAt($value)
* @mixin \Eloquent
*/
class Customer extends Authenticatable // Erbt von Authenticatable
{
use HasFactory, Notifiable;
protected $table = 'customers';
protected $fillable = [
'name',
'email',
'shopping_user_id',
'member_id',
'number',
'language',
'mode',
];
// Wichtig: Laravel Auth benötigt dies, auch wenn kein Passwort verwendet wird
protected $hidden = [
'remember_token',
];
public function shoppingUser()
{
return $this->belongsTo(ShoppingUser::class, 'shopping_user_id');
}
public function member()
{
return $this->belongsTo(User::class, 'member_id');
}
}

View file

@ -0,0 +1,40 @@
<?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
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup query()
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup whereAddrType($value)
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup whereCountry($value)
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup whereIpEnd($value)
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup whereIpStart($value)
* @mixin \Eloquent
*/
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,40 @@
<?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
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup2 newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup2 newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup2 query()
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup2 whereAddrType($value)
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup2 whereCountry($value)
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup2 whereIpEnd($value)
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup2 whereIpStart($value)
* @mixin \Eloquent
*/
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,40 @@
<?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
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup3 newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup3 newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup3 query()
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup3 whereAddrType($value)
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup3 whereCountry($value)
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup3 whereIpEnd($value)
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup3 whereIpStart($value)
* @mixin \Eloquent
*/
class DbipLookup3 extends Model
{
protected $table = 'dbip_lookup_3';
public $incrementing = false;
public $timestamps = false;
protected $fillable = [
'addr_type',
'ip_start',
'ip_end',
'country'
];
}

View file

@ -0,0 +1,65 @@
<?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
* @property bool $active
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory findSimilarSlugs(string $attribute, array $config, string $slug)
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory query()
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
* @mixin \Eloquent
*/
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() : array
{
return [
'slug' => [
'source' => 'name'
]
];
}
}

View file

@ -0,0 +1,206 @@
<?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
* @property-read int|null $dc_file_tags_count
* @property-read Collection<int, \App\Models\DcFileTag> $fileTag
* @property-read int|null $file_tag_count
* @property-read Collection<int, \App\Models\DcTag> $tags
* @property-read int|null $tags_count
* @method static \Illuminate\Database\Eloquent\Builder|DcFile newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|DcFile newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|DcFile query()
* @method static \Illuminate\Database\Eloquent\Builder|DcFile whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcFile whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcFile whereExt($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcFile whereFilename($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcFile whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcFile whereMine($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcFile whereOriginalName($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcFile whereSize($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcFile whereUpdatedAt($value)
* @mixin \Eloquent
*/
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';
}
}

View file

@ -0,0 +1,56 @@
<?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
* @method static \Illuminate\Database\Eloquent\Builder|DcFileTag newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|DcFileTag newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|DcFileTag query()
* @method static \Illuminate\Database\Eloquent\Builder|DcFileTag whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcFileTag whereFileId($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcFileTag whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcFileTag whereTagId($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcFileTag whereUpdatedAt($value)
* @mixin \Eloquent
*/
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');
}
}

View file

@ -0,0 +1,77 @@
<?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
* @property bool $active
* @property-read int|null $dc_file_tags_count
* @method static \Illuminate\Database\Eloquent\Builder|DcTag findSimilarSlugs(string $attribute, array $config, string $slug)
* @method static \Illuminate\Database\Eloquent\Builder|DcTag newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|DcTag newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|DcTag query()
* @method static \Illuminate\Database\Eloquent\Builder|DcTag whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcTag whereCategoryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcTag whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcTag whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcTag whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcTag wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcTag whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcTag whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|DcTag withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
* @mixin \Eloquent
*/
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() : array
{
return [
'slug' => [
'source' => 'name'
]
];
}
public function dc_file_tags()
{
return $this->hasMany(DcFileTag::class, 'tag_id');
}
}

View file

@ -0,0 +1,407 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Support\Carbon;
/**
* DHL Shipment Model
*
* Represents a DHL shipment for a shopping order, including both outbound and return shipments.
*
* @property int $id
* @property int $shopping_order_id
* @property string|null $shipment_number DHL shipment number
* @property string|null $tracking_number DHL tracking number
* @property string $type Type: 'outbound' or 'return'
* @property int|null $related_shipment_id For returns: reference to original shipment
* @property float $weight Package weight in kg
* @property int|null $length Package length in cm
* @property int|null $width Package width in cm
* @property int|null $height Package height in cm
* @property string $product_code DHL product code (e.g., V01PAK)
* @property array|null $services Additional DHL services
* @property string|null $label_path Path to generated label file
* @property string $label_format Label format (PDF or ZPL)
* @property bool $label_printed Whether label has been printed
* @property string $status Shipment status
* @property string|null $tracking_status Current tracking status from DHL
* @property string|null $tracking_details Detailed tracking information (JSON)
* @property Carbon|null $last_tracked_at Last tracking update
* @property string $recipient_name Recipient name
* @property string|null $recipient_company Recipient company
* @property string $recipient_street Recipient street
* @property string $recipient_street_number Recipient street number
* @property string $recipient_postal_code Recipient postal code
* @property string $recipient_city Recipient city
* @property string|null $recipient_state Recipient state
* @property string $recipient_country Recipient country code
* @property string|null $recipient_email Recipient email
* @property string|null $recipient_phone Recipient phone
* @property array|null $api_request_data API request data for debugging
* @property array|null $api_response_data API response data for debugging
* @property string|null $api_errors API error messages
* @property float|null $shipping_cost Shipping cost
* @property string $currency Currency code
* @property string|null $notes Internal notes
* @property array|null $metadata Additional metadata
* @property Carbon|null $shipped_at When the package was shipped
* @property Carbon|null $delivered_at When the package was delivered
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property-read ShoppingOrder $shoppingOrder
* @property-read DhlShipment|null $relatedShipment
* @property-read DhlShipment|null $returnShipment
* @property-read string|null $dimensions
* @property-read string|null $label_url
* @property-read string $recipient_address
* @property-read string $status_label
* @property-read string $type_label
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment active()
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment newQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment outbound()
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment query()
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment returns()
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment trackable()
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereApiErrors($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereApiRequestData($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereApiResponseData($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereCurrency($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereDeliveredAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereHeight($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereLabelFormat($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereLabelPath($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereLabelPrinted($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereLastTrackedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereLength($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereMetadata($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereNotes($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereProductCode($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereRecipientCity($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereRecipientCompany($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereRecipientCountry($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereRecipientEmail($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereRecipientName($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereRecipientPhone($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereRecipientPostalCode($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereRecipientState($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereRecipientStreet($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereRecipientStreetNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereRelatedShipmentId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereServices($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereShipmentNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereShippedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereShippingCost($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereShoppingOrderId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereTrackingDetails($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereTrackingNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereTrackingStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereType($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereWeight($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|DhlShipment whereWidth($value)
* @mixin \Eloquent
*/
class DhlShipment extends Model
{
use HasFactory;
/**
* The table associated with the model.
*/
protected $table = 'dhl_shipments';
/**
* The attributes that are mass assignable.
*/
protected $fillable = [
'shopping_order_id',
'shipment_number',
'tracking_number',
'type',
'related_shipment_id',
'weight',
'length',
'width',
'height',
'product_code',
'services',
'label_path',
'label_format',
'label_printed',
'status',
'tracking_status',
'tracking_details',
'last_tracked_at',
'recipient_name',
'recipient_company',
'recipient_street',
'recipient_street_number',
'recipient_postal_code',
'recipient_city',
'recipient_state',
'recipient_country',
'recipient_email',
'recipient_phone',
'api_request_data',
'api_response_data',
'api_errors',
'shipping_cost',
'currency',
'notes',
'metadata',
'shipped_at',
'delivered_at',
];
/**
* The attributes that should be cast.
*/
protected $casts = [
'weight' => 'float',
'length' => 'integer',
'width' => 'integer',
'height' => 'integer',
'services' => 'array',
'label_printed' => 'boolean',
'tracking_details' => 'array',
'last_tracked_at' => 'datetime',
'api_request_data' => 'array',
'api_response_data' => 'array',
'shipping_cost' => 'decimal:2',
'metadata' => 'array',
'shipped_at' => 'datetime',
'delivered_at' => 'datetime',
];
/**
* Shipment types
*/
public const TYPE_OUTBOUND = 'outbound';
public const TYPE_RETURN = 'return';
/**
* Shipment statuses
*/
public const STATUS_CREATED = 'created';
public const STATUS_SUBMITTED = 'submitted';
public const STATUS_IN_TRANSIT = 'in_transit';
public const STATUS_DELIVERED = 'delivered';
public const STATUS_RETURNED = 'returned';
public const STATUS_CANCELLED = 'cancelled';
public const STATUS_FAILED = 'failed';
/**
* Get the shopping order that owns the shipment
*/
public function shoppingOrder(): BelongsTo
{
return $this->belongsTo(ShoppingOrder::class, 'shopping_order_id');
}
/**
* Get the related shipment (for returns)
*/
public function relatedShipment(): BelongsTo
{
return $this->belongsTo(DhlShipment::class, 'related_shipment_id');
}
/**
* Get the return shipment (for outbound shipments)
*/
public function returnShipment(): HasOne
{
return $this->hasOne(DhlShipment::class, 'related_shipment_id');
}
/**
* Scope for outbound shipments
*/
public function scopeOutbound($query)
{
return $query->where('type', self::TYPE_OUTBOUND);
}
/**
* Scope for return shipments
*/
public function scopeReturns($query)
{
return $query->where('type', self::TYPE_RETURN);
}
/**
* Scope for active shipments (not cancelled or failed)
*/
public function scopeActive($query)
{
return $query->whereNotIn('status', [self::STATUS_CANCELLED, self::STATUS_FAILED]);
}
/**
* Scope for trackable shipments (have tracking number)
*/
public function scopeTrackable($query)
{
return $query->whereNotNull('tracking_number');
}
/**
* Check if shipment is outbound
*/
public function isOutbound(): bool
{
return $this->type === self::TYPE_OUTBOUND;
}
/**
* Check if shipment is return
*/
public function isReturn(): bool
{
return $this->type === self::TYPE_RETURN;
}
/**
* Check if shipment can be cancelled
*/
public function canBeCancelled(): bool
{
return in_array($this->status, [
self::STATUS_CREATED,
self::STATUS_SUBMITTED,
]);
}
/**
* Check if shipment is delivered
*/
public function isDelivered(): bool
{
return $this->status === self::STATUS_DELIVERED;
}
/**
* Check if shipment has tracking information
*/
public function hasTracking(): bool
{
return !empty($this->tracking_number);
}
/**
* Check if label is available
*/
public function hasLabel(): bool
{
return !empty($this->label_path) && file_exists(storage_path('app/' . $this->label_path));
}
/**
* Get full recipient address as formatted string
*/
public function getRecipientAddressAttribute(): string
{
$address = $this->recipient_name;
if ($this->recipient_company) {
$address .= "\n" . $this->recipient_company;
}
$address .= "\n" . $this->recipient_street . ' ' . $this->recipient_street_number;
$address .= "\n" . $this->recipient_postal_code . ' ' . $this->recipient_city;
if ($this->recipient_state) {
$address .= "\n" . $this->recipient_state;
}
$address .= "\n" . $this->recipient_country;
return $address;
}
/**
* Get package dimensions as formatted string
*/
public function getDimensionsAttribute(): ?string
{
if (!$this->length || !$this->width || !$this->height) {
return null;
}
return $this->length . ' x ' . $this->width . ' x ' . $this->height . ' cm';
}
/**
* Get human-readable status
*/
public function getStatusLabelAttribute(): string
{
return match($this->status) {
self::STATUS_CREATED => 'Erstellt',
self::STATUS_SUBMITTED => 'Übertragen',
self::STATUS_IN_TRANSIT => 'Unterwegs',
self::STATUS_DELIVERED => 'Zugestellt',
self::STATUS_RETURNED => 'Zurückgeschickt',
self::STATUS_CANCELLED => 'Storniert',
self::STATUS_FAILED => 'Fehler',
default => 'Unbekannt',
};
}
/**
* Get human-readable type
*/
public function getTypeLabelAttribute(): string
{
return match($this->type) {
self::TYPE_OUTBOUND => 'Versand',
self::TYPE_RETURN => 'Retoure',
default => 'Unbekannt',
};
}
/**
* Get label file URL for download
*/
public function getLabelUrlAttribute(): ?string
{
if (!$this->hasLabel()) {
return null;
}
return route('admin.dhl.shipments.label', $this->id);
}
/**
* Boot the model
*/
protected static function boot()
{
parent::boot();
static::creating(function ($shipment) {
// Set default values
if (empty($shipment->currency)) {
$shipment->currency = config('dhl.defaults.currency', 'EUR');
}
if (empty($shipment->product_code)) {
$shipment->product_code = config('dhl.defaults.product', 'V01PAK');
}
if (empty($shipment->label_format)) {
$shipment->label_format = config('dhl.labels.format', 'PDF');
}
});
}
}

View file

@ -0,0 +1,84 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use App\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class File
*
* @property int $id
* @property int $user_id
* @property string $filename
* @property string $dir
* @property string $original_name
* @property string $ext
* @property string $mine
* @property int $size
* @property Carbon $created_at
* @property Carbon $updated_at
* @property User $user
* @package App\Models
* @property string $identifier
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereDir($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereExt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereFilename($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereIdentifier($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereMine($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereOriginalName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereSize($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\File whereUserId($value)
* @mixin \Eloquent
*/
class File extends Model
{
protected $table = 'files';
protected $casts = [
'user_id' => 'int',
'size' => 'int'
];
protected $fillable = [
'user_id',
'identifier',
'filename',
'dir',
'original_name',
'ext',
'mine',
'size'
];
public function user()
{
return $this->belongsTo(User::class);
}
public function formatBytes($precision = 2)
{
$size = $this->size;
if ($size > 0) {
$size = (int) $size;
$base = log($size) / log(1024);
$suffixes = array(' bytes', ' KB', ' MB', ' GB', ' TB');
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
} else {
return $size;
}
}
}

View file

@ -0,0 +1,234 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use App\Models\Country;
use Illuminate\Database\Eloquent\Model;
use PHPUnit\Framework\Constraint\Count;
use Illuminate\Database\Eloquent\Collection;
/**
* Class Homeparty
*
* @property int $id
* @property Carbon $date
* @property string $name
* @property string $place
* @property string $description
* @property int $pos
* @property int $completed
* @property int $status
* @property bool $order_to
* @property bool $active
* @property bool $default
* @property Carbon $created_at
* @property Carbon $updated_at
* @property Collection|User[] $users
* @package App\Models
* @property int|null $auth_user_id
* @property-read \App\User|null $auth_user
* @property-read \App\Models\HomepartyUser|null $homeparty_host
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\HomepartyUser[] $homeparty_users
* @property-read int|null $homeparty_users_count
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereAuthUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereCompleted($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereDefault($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereOrderTo($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty wherePlace($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereUpdatedAt($value)
* @property string|null $token
* @property bool|null $token_active
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\HomepartyUser[] $homeparty_guests
* @property-read int|null $homeparty_guests_count
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereToken($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereTokenActive($value)
* @property int|null $country_id
* @property int|null $step
* @property array|null $settings
* @property array|null $order
* @property array|null $card_info
* @property-read Country|null $country
* @property-read Collection|\App\Models\HomepartyUserOrderItem[] $homeparty_order_items
* @property-read int|null $homeparty_order_items_count
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereCardInfo($value)
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereOrder($value)
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereSettings($value)
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereStep($value)
* @property array|null $trans_description
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereTransDescription($value)
* @mixin \Eloquent
*/
class Homeparty extends Model
{
protected $table = 'homeparties';
protected $casts = [
'pos' => 'int',
'completed' => 'int',
'status' => 'int',
'step' => 'int',
'country_id' => 'int',
'order_to' => 'bool',
'active' => 'bool',
'default' => 'bool',
'token_active' => 'bool',
'settings' => 'array',
'order' => 'array',
'card_info' => 'array',
'trans_description' => 'array',
];
protected $dates = [
'date'
];
protected $hidden = [
'token'
];
protected $fillable = [
'auth_user_id',
'date',
'name',
'place',
'country_id',
'pos',
'completed',
'status',
'step',
'order_to',
'active',
'default',
'token',
'token_active',
'settings',
'order',
'card_info'
];
private $user_country;
public function auth_user()
{
return $this->belongsTo('App\User', 'auth_user_id');
}
public function country()
{
return $this->belongsTo('App\Models\Country', 'country_id');
}
public function homeparty_users()
{
return $this->hasMany('App\Models\HomepartyUser', 'homeparty_id');
}
public function homeparty_host()
{
return $this->hasOne('App\Models\HomepartyUser', 'homeparty_id')->where('is_host', true);
}
public function homeparty_guests()
{
return $this->hasMany('App\Models\HomepartyUser', 'homeparty_id')->where('is_host', false);
}
public function homeparty_order_items(){
return $this->hasMany('App\Models\HomepartyUserOrderItem','homeparty_id');
}
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) {
return "";
}
return Carbon::parse($value)->format(\Util::formatDateDB());
}
public function setDateAttribute($value)
{
$this->attributes['date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
}
public function getTokenLink(){
return url('homeparty/'.$this->token);
}
public function getCardInfo($key)
{
return isset($this->card_info[$key]) ? $this->card_info[$key] : null;
}
public function getUserCountry(){
if(!$this->user_country){
if($user_country_id = $this->getCardInfo('user_country_id')){
$this->user_country = Country::findOrFail($user_country_id);
}
}
return $this->user_country;
}
public function isPriceCurrency()
{
$user_country = $this->getUserCountry();
return ($user_country && $user_country->currency) ? true : false;
}
public function getPriceCurrencyUnit()
{
$user_country = $this->getUserCountry();
return ($user_country && $user_country->currency) ? $user_country->currency_unit : false;
}
}

View file

@ -0,0 +1,224 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use App\Services\HomepartyUserCart;
use App\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class HomepartyUser
*
* @property int $id
* @property int $homeparty_id
* @property int $auth_user_id
* @property bool $is_host
* @property string $billing_salutation
* @property string $billing_company
* @property string $billing_firstname
* @property string $billing_lastname
* @property string $billing_address
* @property string $billing_address_2
* @property string $billing_zipcode
* @property string $billing_city
* @property int $billing_country_id
* @property string $billing_phone
* @property string $billing_email
* @property bool $same_as_billing
* @property string $shipping_salutation
* @property string $shipping_company
* @property string $shipping_firstname
* @property string $shipping_lastname
* @property string $shipping_address
* @property string $shipping_address_2
* @property string $shipping_zipcode
* @property string $shipping_city
* @property int $shipping_country_id
* @property string $shipping_phone
* @property string $shipping_email
* @property bool $has_buyed
* @property bool $subscribed
* @property string $token
* @property bool $token_active
* @property string $notice
* @property string $mode
* @property Carbon $created_at
* @property Carbon $updated_at
* @property string $deleted_at
* @property Carbon $user_deleted_at
* @property User $user
* @property Country $country
* @property Homeparty $homeparty
* @package App\Models
* @property-read \App\User $auth_user
* @property-read \App\Models\Country $billing_country
* @property-read \App\Models\Country $shipping_country
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser newQuery()
* @method static \Illuminate\Database\Query\Builder|\App\Models\HomepartyUser onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereAuthUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereBillingAddress($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereBillingAddress2($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereBillingCity($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereBillingCompany($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereBillingCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereBillingEmail($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereBillingFirstname($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereBillingLastname($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereBillingPhone($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereBillingSalutation($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereBillingZipcode($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereHasBuyed($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereHomepartyId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereIsHost($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereMode($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereNotice($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereSameAsBilling($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereShippingAddress($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereShippingAddress2($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereShippingCity($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereShippingCompany($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereShippingCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereShippingEmail($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereShippingFirstname($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereShippingLastname($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereShippingPhone($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereShippingSalutation($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereShippingZipcode($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereSubscribed($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereToken($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereTokenActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereUserDeletedAt($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\HomepartyUser withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\Models\HomepartyUser withoutTrashed()
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\HomepartyUserOrderItem[] $homeparty_user_order_items
* @property-read int|null $homeparty_user_order_items_count
* @property string|null $delivery
* @property array|null $settings
* @method static \Illuminate\Database\Eloquent\Builder|HomepartyUser whereDelivery($value)
* @method static \Illuminate\Database\Eloquent\Builder|HomepartyUser whereSettings($value)
* @mixin \Eloquent
*/
class HomepartyUser extends Model
{
use SoftDeletes;
protected $userCart = null;
protected $table = 'homeparty_users';
protected $casts = [
'homeparty_id' => 'int',
'auth_user_id' => 'int',
'is_host' => 'bool',
'billing_country_id' => 'int',
'same_as_billing' => 'bool',
'shipping_country_id' => 'int',
'has_buyed' => 'bool',
'subscribed' => 'bool',
'settings' => 'array',
];
protected $dates = [
'user_deleted_at'
];
protected $fillable = [
'homeparty_id',
'auth_user_id',
'is_host',
'billing_salutation',
'billing_company',
'billing_firstname',
'billing_lastname',
'billing_address',
'billing_address_2',
'billing_zipcode',
'billing_city',
'billing_country_id',
'billing_phone',
'billing_email',
'same_as_billing',
'shipping_salutation',
'shipping_company',
'shipping_firstname',
'shipping_lastname',
'shipping_address',
'shipping_address_2',
'shipping_zipcode',
'shipping_city',
'shipping_country_id',
'shipping_phone',
'shipping_email',
'has_buyed',
'subscribed',
'notice',
'mode',
'settings',
'delivery',
'user_deleted_at'
];
public function homeparty()
{
return $this->belongsTo(Homeparty::class);
}
public function auth_user()
{
return $this->belongsTo(User::class, 'auth_user_id');
}
public function billing_country()
{
return $this->belongsTo('App\Models\Country','billing_country_id');
}
public function shipping_country()
{
return $this->belongsTo('App\Models\Country','shipping_country_id');
}
public function homeparty_user_order_items(){
return $this->hasMany('App\Models\HomepartyUserOrderItem','homeparty_user_id');
}
public function isAddress(){
if($this->billing_firstname !== null && $this->billing_country_id !== null){
return true;
}
return false;
}
public function getDelivery(){
return $this->delivery === 'direct' ? 'direct' : 'host';
}
public function getShipping(){
if($this->same_as_billing){
$country_id = $this->billing_country_id != null ? $this->billing_country_id : 1;
}else{
$country_id = $this->shipping_country_id != null ? $this->shipping_country_id : 1;
}
$shippingCountry = ShippingCountry::whereCountryId($country_id)->first();
if(!$shippingCountry){
return null;
}
return $shippingCountry->shipping;
}
}

View file

@ -0,0 +1,218 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class HomepartyUserOrderItem
*
* @property int $id
* @property int $homeparty_id
* @property int $homeparty_user_id
* @property int $product_id
* @property int $qty
* @property float $price
* @property float $price_net
* @property float $tax_rate
* @property int $points
* @property float $margin
* @property float $ek_price
* @property string $slug
* @property Carbon $created_at
* @property Carbon $updated_at
* @property Homeparty $homeparty
* @property HomepartyUser $homeparty_user
* @property Product $product
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereEkPrice($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereHomepartyId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereHomepartyUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereMargin($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem wherePoints($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem wherePrice($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem wherePriceNet($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereQty($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereTaxRate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereUpdatedAt($value)
* @property float|null $ek_price_net
* @method static \Illuminate\Database\Eloquent\Builder|HomepartyUserOrderItem whereEkPriceNet($value)
* @mixin \Eloquent
*/
class HomepartyUserOrderItem extends Model
{
protected $table = 'homeparty_user_order_items';
protected $casts = [
'homeparty_id' => 'int',
'homeparty_user_id' => 'int',
'product_id' => 'int',
'qty' => 'int',
'price' => 'float',
'price_net' => 'float',
'tax_rate' => 'float',
'points' => 'int',
'margin' => 'float',
'ek_price' => 'float',
'ek_price_net' => 'float'
];
protected $fillable = [
'homeparty_id',
'homeparty_user_id',
'product_id',
'qty',
'price',
'price_net',
'tax_rate',
'points',
'margin',
'ek_price',
'ek_price_net',
'slug'
];
public function homeparty()
{
return $this->belongsTo(Homeparty::class);
}
public function homeparty_user()
{
return $this->belongsTo(HomepartyUser::class);
}
public function product()
{
return $this->belongsTo(Product::class);
}
public function getFormattedPrice()
{
return formatNumber($this->attributes['price']);
}
public function getFormattedTotalPrice()
{
return formatNumber($this->attributes['price'] * $this->attributes['qty']);
}
public function getFormattedPriceNet()
{
return formatNumber($this->attributes['price_net']);
}
public function getFormattedTotalPriceNet()
{
return formatNumber($this->attributes['price_net'] * $this->attributes['qty']);
}
public function getFormattedEKPrice()
{
return formatNumber($this->attributes['ek_price']);
}
public function getFormattedTotalEKPrice()
{
return formatNumber($this->attributes['ek_price'] * $this->attributes['qty']);
}
public function getFormattedEKPriceNet()
{
return formatNumber($this->attributes['ek_price_net']);
}
public function getFormattedTotalEKPriceNet()
{
return formatNumber($this->attributes['ek_price_net'] * $this->attributes['qty']);
}
public function getFormattedIncomePrice()
{
return formatNumber($this->attributes['price'] - $this->attributes['ek_price']);
}
public function getFormattedTotalIncomePrice()
{
return formatNumber(($this->attributes['price'] - $this->attributes['ek_price']) * $this->attributes['qty']);
}
public function getFormattedTotalPoints()
{
return formatNumber($this->attributes['points'] * $this->attributes['qty'], 0);
}
public function getTotalPrice()
{
return (float) ($this->attributes['price'] * $this->attributes['qty']);
}
public function getTotalPoints()
{
return ($this->attributes['points'] * $this->attributes['qty']);
}
public function geTotalPriceNet()
{
return (float) ($this->attributes['price_net'] * $this->attributes['qty']);
}
public function geTotalEKPrice()
{
return (float) ($this->attributes['ek_price'] * $this->attributes['qty']);
}
public function geTotalEKPriceNet()
{
return (float) ($this->attributes['ek_price_net'] * $this->attributes['qty']);
}
public function getIncomePrice()
{
return (float) ($this->attributes['price'] - $this->attributes['ek-ek_price']);
}
public function geTotalIncomePrice()
{
return (float) (($this->attributes['price'] - $this->attributes['ek_price']) * $this->attributes['qty']);
}
public function getCurrencyByKey($key)
{
$rNumber = 0;
if($this->homeparty && $this->homeparty->isPriceCurrency()){
$user_country = $this->homeparty->getUserCountry();
$faktor = isset($user_country->currency_faktor) ? $user_country->currency_faktor : 1;
switch ($key) {
case 'TotalIncomePrice':
$rNumber = $this->geTotalIncomePrice() * $faktor;
break;
case 'TotalPrice':
$rNumber = $this->getTotalPrice() * $faktor;
break;
case 'TotalEKPrice':
$rNumber = $this->geTotalEKPrice() * $faktor;
break;
}
}
return formatNumber($rNumber);
}
}

View file

@ -0,0 +1,66 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\Import
*
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Import newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Import newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Import query()
* @mixin \Eloquent
*/
class Import extends Model
{
public static $start;
public static $max_time;
public static $rules = [
'file' => 'required|mimes:xls,xlsx'
];
public static $messages = [
'file.mimes' => 'Datei ist kein Excel Format',
'file.required' => 'Excel is required'
];
protected static $row = [];
public static function setRow($row){
// self::checkTime();
self::$row[] = $row;
}
public static function checkTime(){
if(round((microtime(true) - self::$start), 2) > 29){
echo 'Total execution time in seconds: ' . round((microtime(true) - self::$start), 2);
die();
return true;
}
return false;
}
public static function countRows(){
return count(self::$row);
}
public static function break(){
echo count(self::$row)."<br>";
echo 'Total execution time in seconds: ' . round((microtime(true) - self::$start), 2);
die();
}
}

View file

@ -0,0 +1,101 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* Class Ingredient
*
* @property int $id
* @property string $name
* @property string $trans_name
* @property string $inci
* @property string $trans_inci
* @property string $effect
* @property string $trans_effect
* @property bool $active
* @property int $pos
* @property Carbon $created_at
* @property Carbon $updated_at
* @property Collection|Product[] $products
* @package App\Models
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductIngredient[] $product_ingredients
* @property-read int|null $product_ingredients_count
* @property-read int|null $products_count
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereEffect($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereInci($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereTransEffect($value)
* @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
{
protected $table = 'ingredients';
protected $casts = [
'active' => 'bool',
'pos' => 'int'
];
protected $fillable = [
'name',
'inci',
'effect',
'active',
'pos'
];
public function products()
{
return $this->belongsToMany(Product::class, 'product_ingredients')
->withPivot('id')
->withTimestamps();
}
public function product_ingredients()
{
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

@ -0,0 +1,78 @@
<?php
namespace App\Models;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\ProductImage
*
* @property int $id
* @property int|null $product_id
* @property string $filename
* @property string $original_name
* @property string $ext
* @property string $mine
* @property int $size
* @property int $active
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\Product|null $product
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereExt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereFilename($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereMine($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereOriginalName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereSize($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereUpdatedAt($value)
* @property string|null $slug
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage findSimilarSlugs($attribute, $config, $slug)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage query()
* @property int|null $pos
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqImage wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|IqImage withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
* @mixin \Eloquent
*/
class IqImage extends Model
{
use Sluggable;
protected $table = 'iq_images';
protected $fillable = [
'filename', 'original_name', 'ext', 'mine', 'size'
];
public function sluggable() : array
{
return [
'slug' => [
'source' => 'original_name'
]
];
}
public function formatBytes($precision = 2)
{
$size = $this->size;
if ($size > 0) {
$size = (int) $size;
$base = log($size) / log(1024);
$suffixes = array(' bytes', ' KB', ' MB', ' GB', ' TB');
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
} else {
return $size;
}
}
}

View file

@ -0,0 +1,109 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\IqSite
*
* @property int $id
* @property string $slug
* @property string|null $headline
* @property string|null $copy
* @property array|null $products
* @property array|null $set_products
* @property int|null $iq_image_id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\IqImage|null $iq_image
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereCopy($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereHeadline($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereIqImageId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereProducts($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereSetProducts($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqSite whereUpdatedAt($value)
* @mixin \Eloquent
*/
class IqSite extends Model
{
protected $table = 'iq_sites';
protected $casts = ['products' => 'array', 'set_products' => 'array'];
protected $fillable = [
'slug', 'headline', 'copy', 'products', 'set_products',
];
public function iq_image()
{
return $this->belongsTo('App\Models\IqImage', 'iq_image_id');
}
public function getLang($key)
{
$lang = \App::getLocale();
if ($lang == 'de') {
return $this->{$key};
}
$trans = $this->getTrans($key, $lang);
if (!$trans || $trans == '') {
return $this->{$key};
}
return $trans;
}
public function getTrans($key, $lang)
{
$key = 'trans_' . $key;
if (!empty($this->{$key}[$lang])) {
return $this->{$key}[$lang];
}
return "";
}
public function getProductModels(){
$ret = [];
foreach($this->products as $product_id){
$product = Product::findOrFail($product_id);
if($product->active){
$ret[] = $product;
}
}
return $ret;
}
public function getProductSetModels(){
$ret = [];
foreach($this->set_products as $product_id){
$product = Product::findOrFail($product_id);
if($product->active){
$ret[] = $product;
}
}
return $ret;
}
public function hasImage(){
if($this->iq_image_id){
if($this->iq_image && isset($this->iq_image->slug) && $this->iq_image->active){
return true;
}
}
return false;
}
}

View file

@ -0,0 +1,83 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use App\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class Logger
*
* @property int $id
* @property int $user_id
* @property int $model_id
* @property string $model
* @property string $action
* @property string $channel
* @property string $message
* @property int $level
* @property Carbon $created_at
* @property Carbon $updated_at
* @property User $user
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereAction($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereChannel($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereLevel($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereMessage($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereModel($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereModelId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Logger whereUserId($value)
* @mixin \Eloquent
*/
class Logger extends Model
{
protected $table = 'loggers';
protected $casts = [
'user_id' => 'int',
'model_id' => 'int',
'level' => 'int'
];
protected $fillable = [
'user_id',
'model_id',
'model',
'action',
'channel',
'message',
'level'
];
public $levelTypes = [
1 => 'debug',
2 => 'info',
3 => 'notice',
4 => 'warning',
5 => 'error',
6 => 'critical',
7 => 'alert',
];
public function user()
{
return $this->belongsTo(User::class);
}
public function getLevelType(){
return isset($this->levelTypes[$this->level]) ? $this->levelTypes[$this->level] : "";
}
}

View file

@ -0,0 +1,108 @@
<?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)
* @property bool $is_abo
* @method static \Illuminate\Database\Eloquent\Builder|PaymentMethod whereIsAbo($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');
}
}

View file

@ -0,0 +1,75 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\PaymentTransaction
*
* @property int $id
* @property int $shopping_payment_id
* @property string $request
* @property int|null $txid
* @property int|null $userid
* @property string|null $status
* @property string|null $key
* @property string|null $txaction
* @property array|null $transmitted_data
* @property int|null $errorcode
* @property string|null $errormessage
* @property string|null $customermessage
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\ShoppingPayment $shopping_payment
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereCustomermessage($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereErrorcode($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereErrormessage($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereKey($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereRequest($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereShoppingPaymentId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereTransmittedData($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereTxaction($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereTxid($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereUserid($value)
* @property string|null $mode
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereMode($value)
* @mixin \Eloquent
*/
class PaymentTransaction extends Model
{
protected $table = 'payment_transactions';
protected $casts = [
'transmitted_data' => 'array'
];
protected $fillable = [
'shopping_payment_id',
'request',
'txid',
'userid',
'status',
'key',
'txaction',
'transmitted_data',
'errorcode',
'errormessage',
'customermessage',
'mode',
];
public function shopping_payment()
{
return $this->belongsTo('App\Models\ShoppingPayment','shopping_payment_id');
}
}

View file

@ -0,0 +1,629 @@
<?php
namespace App\Models;
use App\Services\Util;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* App\Models\Product
*
* @property int $id
* @property string $name
* @property array|null $trans_name
* @property string $title
* @property array|null $trans_title
* @property string|null $copy
* @property array|null $trans_copy
* @property float|null $price
* @property float|null $price_ek
* @property float|null $tax
* @property float|null $price_old
* @property string|null $contents
* @property string|null $number
* @property array|null $icons
* @property string|null $description
* @property array|null $trans_description
* @property string|null $usage
* @property array|null $trans_usage
* @property string|null $ingredients
* @property array|null $trans_ingredients
* @property int|null $pos
* @property int $active
* @property int|null $amount
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductAttribute[] $attributes
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductCategory[] $categories
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductImage[] $images
* @property-write mixed $price_vk
* @method static bool|null forceDelete()
* @method static \Illuminate\Database\Query\Builder|\App\Models\Product onlyTrashed()
* @method static bool|null restore()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereAmount($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereContents($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereCopy($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereIcons($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereIngredients($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product wherePrice($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product wherePriceEk($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product wherePriceOld($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereTax($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereTransCopy($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereTransDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereTransIngredients($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereTransName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereTransTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereTransUsage($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereUsage($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\Product withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\Models\Product withoutTrashed()
* @property string|null $slug
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product findSimilarSlugs($attribute, $config, $slug)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product query()
* @property int|null $weight
* @property int|null $show_at
* @property array|null $action
* @property-read int|null $attributes_count
* @property-read int|null $categories_count
* @property-read int|null $images_count
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereAction($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereShowAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereWeight($value)
* @property int|null $points
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductImage[] $imagesActive
* @property-read int|null $images_active_count
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product wherePoints($value)
* @property string|null $identifier
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereIdentifier($value)
* @property int|null $upgrade_to_id
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereUpgradeToId($value)
* @property int|null $contents_total
* @property int|null $unit
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereContentsTotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereUnit($value)
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\CountryPrice[] $country_prices
* @property-read int|null $country_prices_count
* @property int|null $wp_number
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereWpNumber($value)
* @property bool|null $shipping_addon
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereShippingAddon($value)
* @property-read int|null $ingredients_count
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductIngredient[] $product_ingredients
* @property-read int|null $product_ingredients_count
* @property bool|null $no_commission
* @property array|null $show_on
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Ingredient[] $p_ingredients
* @property-read int|null $p_ingredients_count
* @method static \Illuminate\Database\Eloquent\Builder|Product whereNoCommission($value)
* @method static \Illuminate\Database\Eloquent\Builder|Product whereShowOn($value)
* @method static \Illuminate\Database\Eloquent\Builder|Product withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
* @property string|null $ean
* @method static \Illuminate\Database\Eloquent\Builder|Product whereEan($value)
* @property bool|null $no_free_shipping
* @property bool|null $buying_restriction
* @property int|null $buying_restriction_amount
* @method static \Illuminate\Database\Eloquent\Builder|Product whereBuyingRestriction($value)
* @method static \Illuminate\Database\Eloquent\Builder|Product whereBuyingRestrictionAmount($value)
* @method static \Illuminate\Database\Eloquent\Builder|Product whereNoFreeShipping($value)
* @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
{
/*identifiers
show_upgrade # in membership payment can upgrade this package to show order
show_order # in membership payment show always
upgrade # need upgrade_to_id set user->payment_order_id to the package in the payment api
*/
protected $table = 'products';
protected $casts = [
'trans_name' => 'array',
'trans_title' => 'array',
'trans_copy' => 'array',
'icons' => 'array',
'trans_description' => 'array',
'trans_usage' => 'array',
'trans_ingredients' => 'array',
'show_on' => 'array',
'action' => 'array',
'wp_number' => 'int',
'shipping_addon' => 'bool',
'active' => 'bool',
'no_commission' => 'bool',
'no_free_shipping' => 'bool',
'buying_restriction' => 'bool',
'buying_restriction_amount' => 'int',
'sponsor_buying_points' => 'bool',
'sponsor_buying_points_amount' => 'int',
];
use Sluggable;
use SoftDeletes;
protected $dates = ['deleted_at'];
protected $fillable = [
'name',
'title',
'copy',
'price',
'price_ek',
'tax',
'price_old',
'points',
'weight',
'no_commission',
'no_free_shipping',
'contents',
'contents_total',
'unit',
'number',
'ean',
'wp_number',
'icons',
'description',
'usage',
'ingredients',
'pos',
'amount',
'active',
'show_at',
'show_on',
'shipping_addon',
'buying_restriction',
'buying_restriction_amount',
'sponsor_buying_points',
'sponsor_buying_points_amount',
'identifier',
'action',
'upgrade_to_id'
];
public $identifiers_types = [
'' => '-',
'show_upgrade' => 'Kann geupdatet werden',
'show_order' => 'Wird immer als Option angezeigt',
'upgrade_product' => 'Produkt upgrade zur Produkt ID',
'upgrade_member' => 'Berater upgrade zur Karriere ID',
'proportional_voucher' => 'Anteiliger Gutschein Berater',
];
public $unitTypes = [
0 => '',
1 => 'ml',
2 => 'g',
3 => 'liter',
4 => 'kg',
];
public $showATs = [
0 => 'Nur Kunden Shop',
1 => 'Kunden + Berater Shop',
2 => 'Nur Berater Shop',
3 => 'Registrierung / Mitgliedschaft Berater',
4 => 'Nur Mitgliedschaft Berater',
5 => 'Onboarding Berater',
6 => 'Onboarding Berater + Berater Shop',
7 => 'zur internen Berechnung',
];
public $showONs = [
1 => 'ShopKunde',
2 => 'ShopBerater',
3 => 'ShopBeraterKunden',
4 => 'Auszeitparty',
7 => 'Registrierung Berater',
8 => 'Mitgliedschaft Berater',
9 => 'Onboarding Berater',
10 => 'zur internen Berechnung',
12 => 'Abo-BasisProdukt',
13 => 'Abo-AddonProdukt',
];
public $actions = [
0 => 'payment_for_account',
1 => 'payment_for_shop',
2 => 'payment_for_shop_upgrade',
4 => 'payment_for_lead_upgrade',
];
public $actionNames = [
0 => 'Zahlung für Mitgliedschaft',
1 => 'Zahlung für Mitgliedschaft + Shop',
2 => 'Bei Zahlung Shop upgrade auf ID',
4 => 'Bei Zahlung Karriere upgrade auf ID',
];
/************* ✨ Codeium Command ⭐ *************/
/**
* Configure the model for auto-generating a slug.
*
* This method returns an array defining the attributes used
* to generate the slug for the model. In this case, the 'name'
* attribute is used as the source for generating the slug.
*
* @return array Configuration for slug generation.
*/
/****** e935bd41-f49b-4736-9603-2da86dc27f25 *******/ public function sluggable() : array
{
return [
'slug' => [
'source' => 'name'
]
];
}
public function product_buyings(){
return $this->hasMany('App\Models\ProductBuying', 'product_id', 'id');
}
public function attributes(){
return $this->hasMany('App\Models\ProductAttribute', 'product_id', 'id');
}
public function categories(){
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');
}
public function imagesActive(){
return $this->hasMany('App\Models\ProductImage', 'product_id', 'id')->where('active', true)->orderBy('pos');
}
public function getImageUrl(){
if(count($this->imagesActive)){
return route('product_image', [$this->imagesActive->first()->slug]);
}
return "";
}
public function getProductUrl(){
return 'https://mivita.shop/produkte/alle-produkte/'.$this->slug;
}
public function country_prices()
{
return $this->hasMany(CountryPrice::class, 'product_id');
}
public function translations()
{
return $this->hasMany(TransProduct::class, 'product_id');
}
public function p_ingredients()
{
return $this->belongsToMany(Ingredient::class, 'product_ingredients')
->withPivot('id')
->withTimestamps();
}
public function product_ingredients()
{
return $this->hasMany(ProductIngredient::class, 'product_ingredients', 'id');
}
public function getActionName($id = 0){
if(isset($this->actions[$id])){
return $this->actions[$id];
}
return false;
}
public function getUpgradeToIdName($from){
if($from === 'payment_for_shop_upgrade'){
$value = Product::find($this->upgrade_to_id);
}
if($from === 'payment_for_lead_upgrade'){
$value = UserLevel::find($this->upgrade_to_id);
}
if($value){
return $value->name;
}
return "not found";
}
public function _format_number($value){
return preg_replace("/[^0-9,]/", "", $value);
}
public function setPriceAttribute( $value ) {
$this->attributes['price'] = $value !== null ? Util::reFormatNumber($value) : null;
}
public function setPriceEkAttribute( $value ) {
$this->attributes['price_ek'] = $value !== null ? Util::reFormatNumber($value) : null;
}
public function setTaxAttribute( $value ) {
$this->attributes['tax'] = $value !== null ? Util::reFormatNumber($value) : null;
}
public function setPriceOldAttribute( $value ) {
$this->attributes['price_old'] = $value !== null ? Util::reFormatNumber($value) : null;
}
public function getFormattedPrice()
{
return isset($this->attributes['price']) ? Util::formatNumber($this->attributes['price']) : "";
}
public function getFormattedPriceEk()
{
return isset($this->attributes['price_ek']) ? Util::formatNumber($this->attributes['price_ek']) : "";
}
public function getFormattedPriceOld()
{
return isset($this->attributes['price_old']) ? Util::formatNumber($this->attributes['price_old']) : "";
}
/*price by user Factor*/
private function calcPriceUserFactor($price, $user=null){
if($this->no_commission){
return $price;
}
$user = $user ? $user : \Auth::user();
if($user && $user->user_level){
$margin = (($user->user_level->margin -100)*-1) / 100;
$price = $price * $margin;
}
return $price;
}
private function calcPriceUserCommission($price, $user){
if($this->no_commission){
return $price;
}
$user = $user ? $user : \Auth::user();
if($user && $user->user_level){
$margin = $user->user_level->margin;
$price = $price / 100 * $margin;
}
return $price;
}
/*price net*/
private function calcPriceNet($price, $country=null){
$tax = $this->getTaxWith($country);
$tax_rate = ($tax + 100) / 100;
return $price / $tax_rate;
}
//price calu with
public function getPriceWith(Bool $net = true, Bool $ufactor = true, $country = null, $commission=false, $user = null){
$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, $user) : $price;
$price = $commission ? $this->calcPriceUserCommission($price, $user) : $price;
return round($price, 2);
}
/*out*/
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, $commission)) : "";
}
public function getTaxWith($country = null){
$tax = isset($this->attributes['tax']) ? $this->attributes['tax'] : null;
$ctax = $country ? $this->getCTax($country) : null;
return $ctax !== null ? $ctax : $tax;
}
public function getFormattedPriceOldWith(Bool $net = true, Bool $ufactor = true, $country = null)
{
$price = isset($this->attributes['price_old']) ? $this->attributes['price_old'] : null;
$cprice = $country ? $this->getCPriceOld($country) : null;
$price = $cprice ? $cprice : $price;
$price = $net ? $this->calcPriceNet($price, $country) : $price;
$price = $ufactor ? $this->calcPriceUserFactor($price) : $price;
$price = round($price, 2);
return isset($price) ? Util::formatNumber($price) : "";
}
public function getFormattedTax($country = null)
{
return isset($this->attributes['tax']) ? Util::formatNumber($this->getTaxWith($country), 0) : "";
}
public function getBasePriceFormattedFullWith(Bool $net = true, Bool $ufactor = true, $country = null){
$price = $this->getPriceWith($net, $ufactor, $country);
if($price = $this->getBasePriceWith($price)){
$unit = $this->attributes['unit'];
//ml g
if($unit === 1 || $unit === 2){
return Util::formatNumber($price) . ' € / 100 '.$this->getUnitType();
}
//l kg
if($unit === 3 || $unit === 4){
return Util::formatNumber($price) . ' € / 1 '.$this->getUnitType();
}
}
return "";
}
public function getBasePriceWith($price){
if(isset($this->attributes['unit']) && isset($this->attributes['contents_total']) && $this->attributes['contents_total'] != 0){
$unit = $this->attributes['unit'];
//ml g
if($unit === 1 || $unit === 2){
return $price * 100 / $this->attributes['contents_total'];
}
//l kg
if($unit === 3 || $unit === 4){
return $price * 1000 / $this->attributes['contents_total'];
}
}
return "";
}
public function getBasePriceFormattedFull(){
if($price = $this->getBasePrice()){
$unit = $this->attributes['unit'];
//ml g
if($unit === 1 || $unit === 2){
return Util::formatNumber($price) . ' € / 100 '.$this->getUnitType();
}
//l kg
if($unit === 3 || $unit === 4){
return Util::formatNumber($price) . ' € / 1 '.$this->getUnitType();
}
}
return "";
}
public function getBasePriceFormatted(){
if($price = $this->getBasePrice()){
return Util::formatNumber($price);
}
return "";
}
public function getBasePrice(){
if(isset($this->attributes['unit']) && isset($this->attributes['contents_total']) && $this->attributes['contents_total'] != 0){
$unit = $this->attributes['unit'];
//ml g
if($unit === 1 || $unit === 2){
return $this->attributes['price'] * 100 / $this->attributes['contents_total'];
}
//l kg
if($unit === 3 || $unit === 4){
return $this->attributes['price'] * 1000 / $this->attributes['contents_total'];
}
}
return "";
}
public function getUnitType(){
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] : '-';
}
public function getShowOnTypes(){
$ret = [];
if($this->show_on && is_array($this->show_on)){
foreach($this->show_on as $show){
$ret[] = isset($this->showONs[$show]) ? $this->showONs[$show] : '-';
}
}
return $ret;
}
public function setPosAttribute($value){
$this->attributes['pos'] = is_numeric($value) ? $value : null;
}
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 : '';
}
public function getTranNames()
{
$ret = "";
foreach ((array) $this->trans_name as $value){
$ret .= $value.', ';
}
return rtrim($ret, ', ');
}
public function getCountryPrice(Country $country){
if($country->own_eur){
return $this->country_prices->where('country_id', '=', $country->id)->first() ?: new CountryPrice();
}
return new CountryPrice();
}
public function getCPrice(Country $country){
return $this->getCountryPrice($country)->c_price;
}
public function getCTax(Country $country){
return $this->getCountryPrice($country)->c_tax;
}
public function getCPriceOld(Country $country){
return $this->getCountryPrice($country)->c_price_old;
}
public function getCCurrency(Country $country){
return $this->getCountryPrice($country)->c_currency;
}
public function getRealPrice(Country $country){
if($country->own_eur && $this->getCPrice($country)){
return $this->getCPrice($country);
}
return $this->price;
}
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, $commission);
$ret = formatNumber($price * $country->currency_faktor)." ".$country->currency_unit;
return '<br><span class="small">~'.$ret.'<span>';
}
return "" ;
}
}

View file

@ -0,0 +1,44 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\ProductAttribute
*
* @property int $id
* @property int $product_id
* @property int $attribute_id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\Attribute $attribute
* @property-read \App\Models\Product $product
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute whereAttributeId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute query()
* @mixin \Eloquent
*/
class ProductAttribute extends Model
{
protected $table = 'product_attributes';
protected $fillable = [
'product_id', 'attribute_id',
];
public function product()
{
return $this->belongsTo('App\Models\Product', 'product_id');
}
public function attribute()
{
return $this->belongsTo('App\Models\Attribute', 'attribute_id');
}
}

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;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class ProductBuying
*
* @property int $id
* @property int $user_id
* @property int $product_id
* @property int $amount
* @property string|null $deleted_at
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Product $product
* @property User $user
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|ProductBuying newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ProductBuying newQuery()
* @method static \Illuminate\Database\Query\Builder|ProductBuying onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|ProductBuying query()
* @method static \Illuminate\Database\Eloquent\Builder|ProductBuying whereAmount($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProductBuying whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProductBuying whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProductBuying whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProductBuying whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProductBuying whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProductBuying whereUserId($value)
* @method static \Illuminate\Database\Query\Builder|ProductBuying withTrashed()
* @method static \Illuminate\Database\Query\Builder|ProductBuying withoutTrashed()
* @mixin \Eloquent
*/
class ProductBuying extends Model
{
use SoftDeletes;
protected $table = 'product_buyings';
protected $casts = [
'user_id' => 'int',
'product_id' => 'int',
'amount' => 'int'
];
protected $fillable = [
'user_id',
'product_id',
'amount'
];
public function product()
{
return $this->belongsTo(Product::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
}

View file

@ -0,0 +1,47 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\ProductCategory
*
* @property int $id
* @property int $product_id
* @property int $category_id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\Category $category
* @property-read \App\Models\Product $product
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory whereCategoryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory query()
* @property int|null $pos
* @method static \Illuminate\Database\Eloquent\Builder|ProductCategory wherePos($value)
* @mixin \Eloquent
*/
class ProductCategory extends Model
{
protected $table = 'product_categories';
protected $fillable = [
'product_id', 'category_id', 'pos'
];
public function product()
{
return $this->belongsTo('App\Models\Product', 'product_id');
}
public function category()
{
return $this->belongsTo('App\Models\Category', 'category_id');
}
}

View file

@ -0,0 +1,83 @@
<?php
namespace App\Models;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\ProductImage
*
* @property int $id
* @property int|null $product_id
* @property string $filename
* @property string $original_name
* @property string $ext
* @property string $mine
* @property int $size
* @property int $active
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\Product|null $product
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereExt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereFilename($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereMine($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereOriginalName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereSize($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereUpdatedAt($value)
* @property string|null $slug
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage findSimilarSlugs($attribute, $config, $slug)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage query()
* @property int|null $pos
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProductImage withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
* @mixin \Eloquent
*/
class ProductImage extends Model
{
use Sluggable;
protected $table = 'product_images';
protected $fillable = [
'product_id', 'filename', 'original_name', 'ext', 'mine', 'size'
];
public function sluggable() : array
{
return [
'slug' => [
'source' => 'original_name'
]
];
}
public function product()
{
return $this->belongsTo('App\Models\Product', 'product_id');
}
public function formatBytes($precision = 2)
{
$size = $this->size;
if ($size > 0) {
$size = (int) $size;
$base = log($size) / log(1024);
$suffixes = array(' bytes', ' KB', ' MB', ' GB', ' TB');
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
} else {
return $size;
}
}
}

View file

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

View file

@ -0,0 +1,144 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class Setting
*
* @property int $id
* @property string|null $identifier
* @property string $slug
* @property int $referenz
* @property string|null $action
* @property string|null $object
* @property string|null $full_text
* @property string|null $text
* @property int|null $int
* @property int $status
* @property string|null $type
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|Setting newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Setting newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Setting query()
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereAction($value)
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereFullText($value)
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereIdentifier($value)
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereInt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereObject($value)
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereReferenz($value)
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereText($value)
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereType($value)
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereUpdatedAt($value)
* @mixin \Eloquent
*/
class Setting extends Model
{
protected $table = 'settings';
protected $casts = [
'referenz' => 'int',
'status' => 'int',
'int' => 'int',
'object' => 'array'
];
protected $fillable = [
'identifier',
'slug',
'referenz',
'action',
'object',
'full_text',
'text',
'int',
'status',
'type'
];
protected static $types = [
'object' => 'Object',
'full_text' => 'Full Text',
'text' => 'Text',
'int' => 'Zahl',
'bool' => 'Bool',
];
public function sluggable() : array
{
return [
'slug' => [
'source' => 'name'
]
];
}
public static function getContentBySlug($slug){
$content = self::whereSlug(trim($slug))->first();
if($content){
switch ($content->type){
case 'object':
return $content->object;
break;
case 'full_text':
return $content->full_text;
break;
case 'text':
return $content->text;
break;
case 'int':
return $content->int;
break;
case 'bool':
return $content->int === 1 ? true : false;
break;
}
}
return false;
}
public static function setContentBySlug($slug, $value, $type = "full_text"){
$content = self::whereSlug(trim($slug))->first();
if(!$content) {
$content = self::create([
'slug' => $slug,
'type' => $type,
]);
}
$content->type = $type;
switch ($content->type){
case 'object':
$content->object = $value ? $value : null;;
break;
case 'full_text':
$content->full_text = $value ? $value : null;;
break;
case 'text':
$content->text = $value ? $value : null;;
break;
case 'int':
$content->int = (int) $value;
break;
case 'bool':
$content->int = $value ? 1 : 0;
break;
}
$content->save();
return $content;
}
}

View file

@ -0,0 +1,100 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\Shipping
*
* @property int $id
* @property string $name
* @property array|null $trans_name
* @property float|null $free
* @property int $active
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShippingCountry[] $countries
* @property-read int|null $countries_count
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShippingPrice[] $prices
* @property-read int|null $prices_count
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping whereFree($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping whereTransName($value)
* @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 $fillable = [
'name', 'active', 'free'
];
public function _format_number($value){
return preg_replace("/[^0-9,]/", "", $value);
}
public function setFreeAttribute( $value ) {
if($value == ""){
$this->attributes['free'] = null;
}else{
$value = $this->_format_number($value);
$this->attributes['free'] = floatval(str_replace(',', '.', $value));
}
}
public function getFormattedFree()
{
if($this->free === null) {
return "";
}
if(\App::getLocale() == "en"){
return number_format($this->attributes['free'], 2, '.', ',');
}
return number_format($this->attributes['free'], 2, ',', '.');
}
public function countries(){
return $this->hasMany('App\Models\ShippingCountry', 'shipping_id', 'id');
}
public function prices(){
return $this->hasMany('App\Models\ShippingPrice', 'shipping_id', 'id');
}
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

@ -0,0 +1,72 @@
<?php
namespace App\Models;
use App\Models\ShippingCountry as ModelsShippingCountry;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\ShippingCountry
*
* @property int $id
* @property int $shipping_id
* @property int|null $country_id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\Country|null $country
* @property-read \App\Models\Shipping $shipping
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingCountry newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingCountry newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingCountry query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingCountry whereCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingCountry whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingCountry whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingCountry whereShippingId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingCountry whereUpdatedAt($value)
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShoppingOrder[] $shopping_orders
* @property-read int|null $shopping_orders_count
* @mixin \Eloquent
*/
class ShippingCountry extends Model
{
protected $table = 'shipping_countries';
protected $fillable = [
'shipping_id', 'country_id'
];
public function shipping()
{
return $this->belongsTo('App\Models\Shipping', 'shipping_id');
}
public function country()
{
return $this->belongsTo('App\Models\Country', 'country_id');
}
public function shopping_orders()
{
return $this->hasMany('App\Models\ShoppingOrder', 'country_id');
}
public function hasShoppingOrders()
{
return $this->shopping_orders()->exists();
}
public static function getActiveShippingCountries(){
$ret = [];
$ShippingCountries = ShippingCountry::all();
foreach($ShippingCountries as $ShippingCountry){
if($ShippingCountry->shipping->active){
$ret[$ShippingCountry->country_id] = $ShippingCountry->country->getLocated();
}
}
return $ret;
}
}

View file

@ -0,0 +1,121 @@
<?php
namespace App\Models;
use App\Services\Util;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\ShippingPrice
*
* @property int $id
* @property int $shipping_id
* @property float|null $price
* @property float|null $tax_rate
* @property float|null $factor
* @property float|null $total_from
* @property float|null $total_to
* @property int|null $weight_from
* @property int|null $weight_to
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\Shipping $shipping
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereFactor($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice wherePrice($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereShippingId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereTax($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereTotalFrom($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereTotalTo($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereWeightFrom($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereWeightTo($value)
* @property-write mixed $tax
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereTaxRate($value)
* @property float|null $price_comp
* @property int|null $num_comp
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereNumComp($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice wherePriceComp($value)
* @mixin \Eloquent
*/
class ShippingPrice extends Model
{
protected $table = 'shipping_prices';
protected $fillable = [
'shipping_id', 'price', 'price_comp', 'num_comp', 'tax_rate', 'factor', 'total_from', 'total_to', 'weight_from', 'weight_to',
];
public function shipping()
{
return $this->belongsTo('App\Models\Shipping', 'shipping_id');
}
public function setPriceAttribute($value)
{
$this->attributes['price'] = $value !== null ? Util::reFormatNumber($value) : null;
}
public function setPriceCompAttribute($value)
{
$this->attributes['price_comp'] = $value !== null ? Util::reFormatNumber($value) : null;
}
public function setFactorAttribute($value)
{
$this->attributes['factor'] = $value !== null ? Util::reFormatNumber($value) : null;
}
public function setTaxRateAttribute($value)
{
$this->attributes['tax_rate'] = $value !== null ? Util::reFormatNumber($value) : null;
}
public function setTotalFromAttribute($value)
{
$this->attributes['total_from'] = $value !== null ? Util::reFormatNumber($value) : null;
}
public function setTotalToAttribute($value)
{
$this->attributes['total_to'] = $value !== null ? Util::reFormatNumber($value) : null;
}
public function getFormattedPrice()
{
return isset($this->attributes['price']) ? Util::formatNumber($this->attributes['price']) : "";
}
public function getFormattedPriceComp()
{
return isset($this->attributes['price_comp']) ? Util::formatNumber($this->attributes['price_comp']) : "";
}
public function getFormattedTaxRate()
{
return isset($this->attributes['tax_rate']) ? Util::formatNumber($this->attributes['tax_rate']) : "";
}
public function getFormattedFactor()
{
return isset($this->attributes['factor']) ? Util::formatNumber($this->attributes['factor']) : "";
}
public function getFormatTotalFrom()
{
return isset($this->attributes['total_from']) ? Util::formatNumber($this->attributes['total_from']) : "";
}
public function getFormattedTotalTo()
{
return isset($this->attributes['total_to']) ? Util::formatNumber($this->attributes['total_to']) : "";
}
}

View file

@ -0,0 +1,208 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
use App\User;
/**
* Class ShoppingCollectOrder
*
* @property int $id
* @property int $user_id
* @property int|null $shopping_order_id
* @property float|null $shipping
* @property float|null $shipping_net
* @property float|null $shipping_tax
* @property float|null $price_total_net
* @property float|null $price_total
* @property float|null $tax_total
* @property int $qty_total
* @property int|null $points
* @property string|null $tax_split
* @property AsArrayObject|null $orders
* @property AsArrayObject|null $shop_items
* @property int $status
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property ShoppingOrder|null $shopping_order
* @property User $user
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder query()
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder whereOrders($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder wherePoints($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder wherePriceTotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder wherePriceTotalNet($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder whereQtyTotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder whereShipping($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder whereShippingNet($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder whereShippingTax($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder whereShopItems($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder whereShoppingOrderId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder whereTaxSplit($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder whereTaxTotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder whereUserId($value)
* @property array|null $net_split
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder whereNetSplit($value)
* @mixin \Eloquent
*/
class ShoppingCollectOrder extends Model
{
protected $table = 'shopping_collect_orders';
protected $casts = [
'user_id' => 'int',
'shopping_order_id' => 'int',
'shipping' => 'float',
'shipping_net' => 'float',
'shipping_tax' => 'float',
'price_total_net' => 'float',
'price_total' => 'float',
'tax_total' => 'float',
'qty_total' => 'int',
'points' => 'int',
'status' => 'int',
'tax_split' => 'array',
'net_split' => 'array',
'orders' => AsArrayObject::class,
'shop_items' => AsArrayObject::class,
];
protected $fillable = [
'user_id',
'shopping_order_id',
//'identifier',
'shipping',
'shipping_net',
'shipping_tax',
'price_total_net',
'price_total',
'tax_total',
'qty_total',
'points',
'tax_split',
'net_split',
'orders',
'shop_items',
'status'
];
public static $statusTypes = [
0 => '',
1 => 'store / pre',
2 => 'order',
];
public function shopping_order()
{
return $this->belongsTo(ShoppingOrder::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
public function addTaxToSplit($tax_rate, $add_tax)
{
$tax_split = $this->tax_split;
$add_tax = round($add_tax, 2);
$existing_value = isset($tax_split[$tax_rate]) ? $this->parseNumericValue($tax_split[$tax_rate]) : 0;
$tax_split[$tax_rate] = round($existing_value + $add_tax, 2);
$this->tax_split = $tax_split;
}
public function addNetToSplit($tax_rate, $add_net)
{
$net_split = $this->net_split;
$add_net = round($add_net, 2);
$existing_value = isset($net_split[$tax_rate]) ? $this->parseNumericValue($net_split[$tax_rate]) : 0;
$net_split[$tax_rate] = round($existing_value + $add_net, 2);
$this->net_split = $net_split;
}
/**
* Parst verschiedene Zahlenformate zu einem float-Wert
* Unterstützt: 19.50, 1234.56, 1.234,56, 1,234.56
*/
private function parseNumericValue($value)
{
// Bereits eine Zahl? Direkt zurückgeben
if (is_numeric($value)) {
return (float)$value;
}
// String zu String konvertieren für weitere Verarbeitung
$value = (string)$value;
// Entferne Leerzeichen
$value = trim($value);
// Prüfe verschiedene Formate
if (preg_match('/^-?\d{1,3}(\.\d{3})*,\d{2}$/', $value)) {
// Deutsches Format: 1.234,56 oder 1.234.567,89
return (float)str_replace(',', '.', str_replace('.', '', $value));
} elseif (preg_match('/^-?\d{1,3}(,\d{3})*\.\d{2}$/', $value)) {
// Amerikanisches Format: 1,234.56 oder 1,234,567.89
return (float)str_replace(',', '', $value);
} else {
// Einfaches Format: 19.50, 123.45, etc.
// Nur Kommas durch Punkte ersetzen
return (float)str_replace(',', '.', $value);
}
}
public function addShopItem($shop_item_id, $shop_item)
{
$numberFields = [
'user_price_net',
'user_price_total_net',
'user_tax',
'user_tax_total'
];
$intFields = [
'points_total',
'points'
];
foreach ($numberFields as $field) {
if (isset($shop_item->$field)) {
$shop_item->$field = number_format($shop_item->$field, 2);
}
}
foreach ($intFields as $field) {
if (isset($shop_item->$field)) {
$shop_item->$field = intval($shop_item->$field);
}
}
$this->shop_items[$shop_item_id] = $shop_item;
}
public function addOrder($order)
{
$this->orders[] = $order;
}
public function initShoppingOrder($order)
{
$order['shopping_order'] = ShoppingOrder::findOrFail($order['order_id']);
return $order;
}
}

View file

@ -0,0 +1,109 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\ShoppingInstance
*
* @property string $identifier
* @property int $user_shop_id
* @property int|null $auth_user_id
* @property int $country_id
* @property string $subdomain
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\User|null $auth_user
* @property-read \App\Models\Country $country
* @property-read \App\Models\UserShop $user_shop
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance whereAuthUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance whereCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance whereIdentifier($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance whereSubdomain($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance whereUserShopId($value)
* @property int|null $payment
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance wherePayment($value)
* @property array|null $shopping_data
* @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)
* @property int|null $status
* @property float|null $amount
* @property int|null $shopping_user_id
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingInstance whereAmount($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingInstance whereShoppingUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingInstance whereStatus($value)
* @mixin \Eloquent
*/
class ShoppingInstance extends Model
{
public $paymentTypes = [
1 => 'Customer Shop',
2 => 'Berater Shop',
3 => 'Berater Membership',
4 => 'Berater Wizard',
5 => 'Berater Homeparty',
6 => 'Berater Shop to Customer Shop',
];
public $statuses = [
0 => 'link_sent',
1 => 'link_openly',
2 => 'link_check',
3 => 'link_pending',
4 => 'link_appointed',
5 => 'link_failed',
6 => 'link_canceled',
10 => 'link_paid',
];
protected $table = 'shopping_instances';
protected $casts = ['shopping_data' => 'array', 'amount' => 'float'];
protected $fillable = [
'identifier', 'user_shop_id', 'auth_user_id', 'status', 'payment', 'subdomain', 'language', 'country_id', 'amount', 'shopping_user_id', 'shopping_data', 'back'
];
public function getStatus(){
return isset($this->statuses[$this->status]) ? $this->statuses[$this->status] : 'link_sent';
}
public function getLocale(){
return $this->language ? $this->language : \App::getLocale();
}
public function user_shop()
{
return $this->belongsTo('App\Models\UserShop', 'user_shop_id');
}
public function country()
{
return $this->belongsTo('App\Models\Country', 'country_id');
}
//can null
public function auth_user()
{
return $this->belongsTo('App\User','auth_user_id');
}
public function getAmountFormatted(){
return formatNumber($this->amount);
}
}

View file

@ -0,0 +1,689 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* App\Models\ShoppingOrder
*
* @property int $id
* @property int $shopping_user_id
* @property int|null $auth_user_id
* @property int $country_id
* @property int $user_shop_id
* @property float|null $total
* @property float|null $shipping
* @property float|null $subtotal
* @property float|null $tax_rate
* @property float|null $tax
* @property float|null $total_shipping
* @property int|null $weight
* @property int|null $paid
* @property string|null $txaction
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\User|null $auth_user
* @property-read \App\Models\Country $country
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShoppingOrderItem[] $shopping_order_items
* @property-read int|null $shopping_order_items_count
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShoppingPayment[] $shopping_payments
* @property-read int|null $shopping_payments_count
* @property-read \App\Models\ShoppingUser $shopping_user
* @property-read \App\Models\UserShop $user_shop
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereAuthUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder wherePaid($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereShipping($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereShoppingUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereSubtotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereTax($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereTaxRate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereTotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereTotalShipping($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereTxaction($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereUserShopId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereWeight($value)
* @property int|null $payment_for
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder wherePaymentFor($value)
* @property int|null $member_id
* @property string|null $mode
* @property-read \App\User|null $member
* @property-read \App\Models\UserHistory|null $user_history
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereMemberId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereMode($value)
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property string|null $user_deleted_at
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingOrder onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereUserDeletedAt($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingOrder withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingOrder withoutTrashed()
* @property-read \App\Models\ShippingCountry $shipping_country
* @property float|null $shipping_net
* @property float|null $subtotal_ws
* @property int|null $points
* @property int|null $shipped
* @property string|null $tracking
* @property string|null $wp_invoice_path
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder wherePoints($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereShipped($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereShippingNet($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereSubtotalWs($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereTracking($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereWpInvoicePath($value)
* @property int|null $homeparty_id
* @property array|null $api_notice
* @property int|null $api_status
* @property-read \App\Models\Homeparty|null $homeparty
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereHomepartyId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereWpNotice($value)
* @property array|null $tax_split
* @property-read \App\Models\UserInvoice|null $user_invoice
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserSalesVolume[] $user_sales_volume
* @property-read int|null $user_sales_volume_count
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereTaxSplit($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereApiNotice($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereApiStatus($value)
* @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)
* @property bool|null $is_abo
* @property int|null $abo_interval
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereAboInterval($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereIsAbo($value)
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\DhlShipment> $dhlOutboundShipments
* @property-read int|null $dhl_outbound_shipments_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\DhlShipment> $dhlReturnShipments
* @property-read int|null $dhl_return_shipments_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\DhlShipment> $dhlShipments
* @property-read int|null $dhl_shipments_count
* @mixin \Eloquent
*/
class ShoppingOrder extends Model
{
protected $table = 'shopping_orders';
use SoftDeletes;
protected $dates = ['deleted_at'];
protected $fillable = [
'shopping_user_id',
'auth_user_id',
'member_id',
'homeparty_id',
'payment_for',
'country_id',
'language',
'user_shop_id',
'total',
'subtotal',
'shipping',
'shipping_net',
'subtotal_ws',
'tax',
'tax_split',
'net_split',
'total_shipping',
'points',
'weight',
'paid',
'is_abo',
'abo_interval',
'txaction',
'wp_invoice_path',
'api_notice',
'api_status',
'mode',
'shipped',
'tracking'
];
protected $casts = [
'api_notice' => 'array',
'tax_split' => 'array',
'net_split' => 'array',
'abo_interval' => 'int',
'is_abo' => 'bool',
];
public static $shippedTypes = [
0 => 'open',
1 => 'in_process',
2 => 'shipped',
3 => 'completed',
4 => 'trade_fair',
10 => 'cancelled'
];
public static $apiShippedTypes = [
0 => 'open', //(Fullfilment durch Händler)',
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 => 'ordered',
1 => 'in_process',
2 => 'paid',
5 => 'removed',
];
public static $apiStatusColors = [
0 => 'warning',
1 => 'warning',
2 => 'success',
5 => 'danger',
];
public static $shippedColors = [
0 => 'warning',
1 => 'info',
2 => 'success',
3 => 'secondary',
4 => 'secondary',
10 => 'danger',
];
public static $paymentForTypes = [
0 => '',
1 => 'registration',
2 => 'membership',
3 => 'order',
4 => 'customer_order',
5 => 'homeparty',
6 => 'shop',
7 => 'external',
8 => 'collective_invoice',
10 => '',
];
public static $paymentForColors = [
0 => 'default',
1 => 'warning',
2 => 'warning',
3 => 'secondary',
4 => 'info',
5 => 'dark',
6 => 'secondary',
7 => 'dark',
8 => 'info',
9 => 'default',
10 => 'info',
11 => 'default'
];
public function shopping_user()
{
return $this->belongsTo('App\Models\ShoppingUser', 'shopping_user_id');
}
public function country()
{
return $this->belongsTo('App\Models\ShippingCountry', 'country_id');
}
public function shipping_country()
{
return $this->belongsTo('App\Models\ShippingCountry', 'country_id');
}
public function homeparty()
{
return $this->belongsTo('App\Models\Homeparty', 'homeparty_id');
}
public function user_shop()
{
return $this->belongsTo('App\Models\UserShop', 'user_shop_id');
}
//can null
public function member()
{
return $this->belongsTo('App\User', 'member_id');
}
//can null
public function auth_user()
{
return $this->belongsTo('App\User', 'auth_user_id');
}
public function user_history()
{
return $this->hasOne('App\Models\UserHistory', 'shopping_order_id')->latest();
}
public function user_invoice()
{
return $this->hasOne('App\Models\UserInvoice', 'shopping_order_id', '');
}
public function shopping_collect_order()
{
return $this->hasOne('App\Models\ShoppingCollectOrder', 'shopping_order_id', '');
}
public function shopping_order_items()
{
return $this->hasMany('App\Models\ShoppingOrderItem', 'shopping_order_id');
}
public function shopping_payments()
{
return $this->hasMany('App\Models\ShoppingPayment', 'shopping_order_id');
}
public function user_sales_volume()
{
return $this->hasOne('App\Models\UserSalesVolume', 'shopping_order_id');
}
public function user_sales_volume_no_userid()
{
return $this->hasOne('App\Models\UserSalesVolume', 'shopping_order_id')->where('user_id', '=', NULL)->first();
}
public function getUserAbo()
{
$UserAboOrder = UserAboOrder::where('shopping_order_id', $this->id)->first();
if ($UserAboOrder && $UserAboOrder->user_abo) {
return $UserAboOrder->user_abo;
}
return null;
}
public function getLocale()
{
return $this->language ? $this->language : \App::getLocale();
}
public function setUserHistoryValue($values = [])
{
if ($user_history = $this->user_history) {
foreach ($values as $key => $val) {
$user_history->{$key} = $val;
}
$user_history->save();
}
}
public function getLastShoppingPayment($key = false)
{
$shopping_payment = $this->shopping_payments->last();
if ($shopping_payment) {
if ($key === 'getPaymentType') {
return $shopping_payment->getPaymentType();
}
if ($key === 'reference') {
return $shopping_payment->reference;
}
}
return "";
}
public function getLastShoppingPaymentTransaction()
{
if ($this->shopping_payments) {
$shopping_payment = $this->shopping_payments->last();
if ($shopping_payment) {
$payt = $shopping_payment->payment_transactions->last();
if ($payt) {
return $payt;
}
}
}
return false;
}
public function getShippedType()
{
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()
{
return isset(self::$apiShippedTypes[$this->shipped]) ? self::$apiShippedTypes[$this->shipped] : "free";
}
public function getShippedColor()
{
return isset(self::$shippedColors[$this->shipped]) ? self::$shippedColors[$this->shipped] : "default";
}
public function getAPIStatusType()
{
return isset(self::$apiStatusTypes[$this->api_status]) ? __('payment.' . self::$apiStatusTypes[$this->api_status]) : "bestellt";
}
public function getAPIStatusColor()
{
return isset(self::$apiStatusColors[$this->api_status]) ? self::$apiStatusColors[$this->api_status] : "warning";
}
public function getFormattedTotal()
{
return formatNumber($this->attributes['total']);
}
public function getFormattedSubtotal()
{
return formatNumber($this->attributes['subtotal']);
}
public function getFormattedShipping()
{
return formatNumber($this->attributes['shipping']);
}
public function getFormattedShippingNet()
{
return formatNumber($this->attributes['shipping_net']);
}
public function getFormattedSubtotalWs()
{
return formatNumber($this->attributes['subtotal_ws']);
}
public function getFormattedSubtotalShipping()
{
return formatNumber($this->attributes['subtotal_shipping']);
}
public function getFormattedTax()
{
return formatNumber($this->attributes['tax']);
}
public function getFormattedTotalShipping()
{
return formatNumber($this->attributes['total_shipping']);
}
public function getPriceVkNetBy($product_id)
{
if ($product = Product::find($product_id)) {
if ($this->shipping_country && $this->shipping_country->country) {
return $product->getPriceWith(true, false, $this->shipping_country->country);
}
}
return 0;
}
public function getPaymentForType()
{
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] : "";
}
public function getUserDiscount()
{
if ($this->auth_user && $this->auth_user->user_level) {
return $this->auth_user->user_level->getFormattedMargin();
}
if ($this->member && $this->member->user_level) {
return $this->member->user_level->getFormattedMargin();
}
return 0;
}
public function getItemsCount()
{
$count = 0;
if ($this->shopping_order_items) {
foreach ($this->shopping_order_items as $shopping_order_item) {
$count += $shopping_order_item->qty;
}
}
return $count;
}
public function isInvoice()
{
return $this->user_invoice ? true : false;
}
public function getStatusByOrder()
{
if ($this->payment_for) {
if ($this->payment_for === 6) { //Kunde-Shop
return 2;
}
return 1;
}
return 0;
}
public function makeHomepartyTaxSplit()
{
$tax_split = [];
$net_split = [];
if ($this->homeparty) {
foreach ($this->homeparty->homeparty_order_items as $item) {
$tax_rate = intval($item->tax_rate);
if ($tax_rate > 0) {
$vk_tax = round((($item->price - $item->price_net) * $item->qty), 2);
$ek_tax = round((($item->ek_price - $item->ek_price_net) * $item->qty), 2);
$vk_net = round(($item->price_net * $item->qty), 2);
$ek_net = round(($item->ek_price_net * $item->qty), 2);
if (isset($tax_split[$tax_rate])) {
$tax_split[$tax_rate]['vk_tax'] = round($tax_split[$tax_rate]['vk_tax'] + $vk_tax, 2);
$tax_split[$tax_rate]['ek_tax'] = round($tax_split[$tax_rate]['ek_tax'] + $ek_tax, 2);
$net_split[$tax_rate]['vk_net'] = round($net_split[$tax_rate]['vk_net'] + $vk_net, 2);
$net_split[$tax_rate]['ek_net'] = round($net_split[$tax_rate]['ek_net'] + $ek_net, 2);
} else {
$tax_split[$tax_rate] = ['vk_tax' => $vk_tax, 'ek_tax' => $ek_tax];
$net_split[$tax_rate] = ['vk_net' => $vk_net, 'ek_net' => $ek_net];
}
}
}
$order_vk_tax = 0;
$order_ek_tax = 0;
$order_vk_net = 0;
$order_ek_net = 0;
if ($this->homeparty->order) {
if (isset($this->homeparty->order['ek_price_net'])) {
$order_vk_tax = round((($this->homeparty->order['price'] - $this->homeparty->order['price_net'])), 2);
$order_ek_tax = round((($this->homeparty->order['ek_price'] - $this->homeparty->order['ek_price_net'])), 2);
$order_vk_net = $this->homeparty->order['price_net'];
$order_ek_net = $this->homeparty->order['ek_price_net'];
}
}
if (isset($tax_split[16])) {
$tax_split[16] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
$net_split[16] = ['vk_net' => $order_vk_net, 'ek_net' => $order_ek_net];
}
if (isset($tax_split[19])) {
$tax_split[19] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
$net_split[19] = ['vk_net' => $order_vk_net, 'ek_net' => $order_ek_net];
}
if (isset($tax_split[5])) {
if (!isset($tax_split[16])) {
$tax_split[16] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
$net_split[16] = ['vk_net' => $order_vk_net, 'ek_net' => $order_ek_net];
}
$tax_split[16]['vk_tax'] = round($tax_split[16]['vk_tax'] - $tax_split[5]['vk_tax'], 2);
$tax_split[16]['ek_tax'] = round($tax_split[16]['ek_tax'] - $tax_split[5]['ek_tax'], 2);
$net_split[16]['vk_net'] = round($net_split[16]['vk_net'] - $net_split[5]['vk_net'], 2);
$net_split[16]['ek_net'] = round($net_split[16]['ek_net'] - $net_split[5]['ek_net'], 2);
}
if (isset($tax_split[7])) {
if (!isset($tax_split[19])) {
$tax_split[19] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
$net_split[19] = ['vk_net' => $order_vk_net, 'ek_net' => $order_ek_net];
}
$tax_split[19]['vk_tax'] = round($tax_split[19]['vk_tax'] - $tax_split[7]['vk_tax'], 2);
$tax_split[19]['ek_tax'] = round($tax_split[19]['ek_tax'] - $tax_split[7]['ek_tax'], 2);
$net_split[19]['vk_net'] = round($net_split[19]['vk_net'] - $net_split[7]['vk_net'], 2);
$net_split[19]['ek_net'] = round($net_split[19]['ek_net'] - $net_split[7]['ek_net'], 2);
}
foreach ($tax_split as $key => $value) {
$tax_split[$key]['vk_tax'] = number_format($value['vk_tax'], 2);
$tax_split[$key]['ek_tax'] = number_format($value['ek_tax'], 2);
}
foreach ($net_split as $key => $value) {
$net_split[$key]['vk_net'] = number_format($value['vk_net'], 2);
$net_split[$key]['ek_net'] = number_format($value['ek_net'], 2);
}
}
if (!isset($tax_split[16]) && !isset($tax_split[19])) {
$tax_split = NULL;
}
if (!isset($net_split[16]) && !isset($net_split[19])) {
$net_split = NULL;
}
$this->tax_split = $tax_split;
$this->net_split = $net_split;
$this->save();
}
public function makeTaxSplit()
{
$tax_split = NULL;
$net_split = NULL;
if ($this->tax > 0) {
$tax_split = [];
$net_split = [];
foreach ($this->shopping_order_items as $item) {
$tax_rate = intval($item->tax_rate);
if ($tax_rate > 0) {
$tax_split[$tax_rate] = isset($tax_split[$tax_rate]) ?
round($tax_split[$tax_rate] + ($item->tax * $item->qty), 2) :
round(($item->tax * $item->qty), 2);
$net_split[$tax_rate] = isset($net_split[$tax_rate]) ?
round($net_split[$tax_rate] + ($item->price_net * $item->qty), 2) :
round(($item->price_net * $item->qty), 2);
}
}
if (isset($tax_split[16])) {
$tax_split[16] = $this->tax;
$net_split[16] = $this->subtotal_ws;
}
if (isset($tax_split[19])) {
$tax_split[19] = $this->tax;
$net_split[19] = $this->subtotal_ws;
}
if (isset($tax_split[5])) {
if (!isset($tax_split[16])) {
$tax_split[16] = $this->tax;
$net_split[16] = $this->subtotal_ws;
}
$tax_split[16] = round($tax_split[16] - $tax_split[5], 2);
$net_split[16] = round($net_split[16] - $net_split[5], 2);
}
if (isset($tax_split[7])) {
if (!isset($tax_split[19])) {
$tax_split[19] = $this->tax;
$net_split[19] = $this->subtotal_ws;
}
$tax_split[19] = round($tax_split[19] - $tax_split[7], 2);
$net_split[19] = round($net_split[19] - $net_split[7], 2);
}
foreach ($tax_split as $key => $value) {
$tax_split[$key] = number_format($value, 2);
}
foreach ($net_split as $key => $value) {
$net_split[$key] = number_format($value, 2);
}
}
$this->tax_split = $tax_split;
$this->net_split = $net_split;
$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;
}
/**
* Get DHL shipments for this order
*/
public function dhlShipments()
{
return $this->hasMany('App\Models\DhlShipment', 'shopping_order_id');
}
/**
* Get outbound DHL shipments only
*/
public function dhlOutboundShipments()
{
return $this->hasMany('App\Models\DhlShipment', 'shopping_order_id')->where('type', 'outbound');
}
/**
* Get return DHL shipments only
*/
public function dhlReturnShipments()
{
return $this->hasMany('App\Models\DhlShipment', 'shopping_order_id')->where('type', 'return');
}
/**
* Check if order has DHL shipments
*/
public function hasDhlShipments(): bool
{
return $this->dhlShipments()->exists();
}
/**
* Get latest DHL shipment
*/
public function getLatestDhlShipment()
{
return $this->dhlShipments()->latest()->first();
}
}

View file

@ -0,0 +1,152 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* App\Models\ShoppingOrderItem
*
* @property int $id
* @property int $shopping_order_id
* @property string|null $row_id
* @property int $product_id
* @property int|null $qty
* @property float|null $price
* @property string|null $slug
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\Product $product
* @property-read \App\Models\ShoppingOrder $shopping_order
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem wherePrice($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereQty($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereRowId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereShoppingOrderId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereUpdatedAt($value)
* @property float|null $tax_rate
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property string|null $user_deleted_at
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingOrderItem onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereTaxRate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereUserDeletedAt($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingOrderItem withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingOrderItem withoutTrashed()
* @property int|null $comp
* @property float|null $price_net
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereComp($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem wherePriceNet($value)
* @property int|null $homeparty_id
* @property-read \App\Models\Homeparty|null $homeparty
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderItem whereHomepartyId($value)
* @property string|null $tax
* @property string|null $price_vk_net
* @property string|null $discount
* @property int|null $points
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderItem whereDiscount($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderItem wherePoints($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderItem wherePriceVkNet($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderItem whereTax($value)
* @property int|null $shopping_collect_order_id
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderItem whereShoppingCollectOrderId($value)
* @mixin \Eloquent
*/
class ShoppingOrderItem extends Model
{
protected $table = 'shopping_order_items';
use SoftDeletes;
protected $dates = ['deleted_at'];
protected $fillable = [
'shopping_order_id',
'row_id',
'product_id',
'homeparty_id',
'shopping_collect_order_id',
'comp',
'qty',
'price',
'price_net',
'tax_rate',
'tax',
'price_vk_net',
'discount',
'points',
'slug',
];
protected $casts = [
'qty' => 'int',
'price' => 'float',
'price_net' => 'float',
'tax_rate' => 'float',
'tax' => 'float',
'price_vk_net' => 'float',
'discount' => 'float',
'points' => 'int',
];
public function shopping_order()
{
return $this->belongsTo('App\Models\ShoppingOrder','shopping_order_id');
}
public function product()
{
return $this->belongsTo('App\Models\Product','product_id');
}
public function homeparty()
{
return $this->belongsTo('App\Models\Homeparty','homeparty_id');
}
public function getFormattedPrice()
{
return formatNumber($this->attributes['price']);
}
public function getFormattedTotalPrice()
{
return formatNumber($this->attributes['price'] * $this->attributes['qty']);
}
public function getFormattedPriceNet()
{
return formatNumber($this->attributes['price_net']);
}
public function getFormattedPriceVkNet()
{
return formatNumber($this->attributes['price_vk_net']);
}
public function getFormattedTaxRate()
{
return cleanNumberFormat($this->attributes['tax_rate']);
}
public function getTaxRate()
{
return formatNumber($this->attributes['tax']);
}
public function getFormattedDiscount()
{
return cleanNumberFormat($this->attributes['discount']);
}
public function getFormattedTotalPriceNet()
{
return formatNumber($this->attributes['price_net'] * $this->attributes['qty']);
}
}

View file

@ -0,0 +1,119 @@
<?php
namespace App\Models;
use App\Services\Util;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\ShoppingPayment
*
* @property int $id
* @property int $shopping_order_id
* @property string $clearingtype
* @property string|null $wallettype
* @property string|null $onlinebanktransfertype
* @property string $reference
* @property int $amount
* @property string $currency
* @property string|null $status
* @property string|null $txaction
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\PaymentTransaction[] $payment_transactions
* @property-read int|null $payment_transactions_count
* @property-read \App\Models\ShoppingOrder $shopping_order
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereAmount($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereClearingtype($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereCurrency($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereOnlinebanktransfertype($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereReference($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereShoppingOrderId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereTxaction($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereWallettype($value)
* @property string|null $mode
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereMode($value)
* @property array|null $carddata
* @property int|null $is_abo
* @property int|null $abo_interval
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingPayment whereAboInterval($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingPayment whereCarddata($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingPayment whereIsAbo($value)
* @property string|null $identifier
* @method static \Illuminate\Database\Eloquent\Builder<static>|ShoppingPayment whereIdentifier($value)
* @mixin \Eloquent
*/
class ShoppingPayment extends Model
{
protected $table = 'shopping_payments';
protected $casts = [
'carddata' => 'array',
];
protected $fillable = [
'shopping_order_id',
'clearingtype',
'wallettype',
'onlinebanktransfertype',
'carddata',
'reference',
'amount',
'currency',
'mode',
'is_abo',
'abo_interval',
'identifier',
];
public function shopping_order()
{
return $this->belongsTo('App\Models\ShoppingOrder','shopping_order_id');
}
public function payment_transactions()
{
return $this->hasMany('App\Models\PaymentTransaction','shopping_payment_id');
}
public function getPaymentType(){
if($this->clearingtype === 'wlt') {
if ($this->wallettype === 'PPE') {
return __('payment.paypal');
}
}
if($this->clearingtype === 'cc') {
return __('payment.credit_card');
}
if($this->clearingtype === 'vor') {
return __('payment.prepayment');
}
if($this->clearingtype === 'elv') {
return __('payment.sepa_direct_debit');
}
if($this->clearingtype === 'sb') {
if ($this->onlinebanktransfertype === 'PNT') {
return __('payment.sofort_bank_transfer');
}
}
if($this->clearingtype === 'fnc') {
if ($this->onlinebanktransfertype === 'MIV') {
return __('payment.purchase_on_account');
}
}
return __('payment.unknown');
}
public function getPaymentAmount(){
return Util::formatNumber($this->amount/100)." ".$this->currency;
}
}

View file

@ -0,0 +1,339 @@
<?php
namespace App\Models;
use App\Services\ShoppingUserService;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* App\Models\ShoppingUser
*
* @property int $id
* @property int|null $auth_user_id
* @property string|null $billing_salutation
* @property string|null $billing_company
* @property string|null $billing_firstname
* @property string|null $billing_lastname
* @property string|null $billing_address
* @property string|null $billing_address_2
* @property string|null $billing_zipcode
* @property string|null $billing_city
* @property int $billing_country_id
* @property string|null $billing_phone
* @property string|null $billing_email
* @property int $accepted_data_checkbox
* @property int $same_as_billing
* @property string|null $shipping_salutation
* @property string|null $shipping_company
* @property string|null $shipping_firstname
* @property string|null $shipping_lastname
* @property string|null $shipping_address
* @property string|null $shipping_address_2
* @property string|null $shipping_zipcode
* @property string|null $shipping_city
* @property int $shipping_country_id
* @property string|null $shipping_phone
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShoppingOrder[] $Shopping_orders
* @property-read int|null $shopping_orders_count
* @property-read \App\Models\Country $billing_country
* @property-read \App\Models\Country $shipping_country
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereAcceptedDataCheckbox($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereAuthUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingAddress($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingAddress2($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingCity($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingCompany($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingEmail($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingFirstname($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingLastname($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingPhone($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingSalutation($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingZipcode($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereSameAsBilling($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingAddress($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingAddress2($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingCity($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingCompany($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingFirstname($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingLastname($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingPhone($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingSalutation($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingZipcode($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereUpdatedAt($value)
* @property int|null $orders
* @property-read \App\Models\ShoppingOrder $shopping_order
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShoppingOrder[] $shopping_orders
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereOrders($value)
* @property int|null $abo_options
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereAboOptions($value)
* @property int|null $member_id
* @property int|null $number
* @property bool $is_like
* @property array|null $notice
* @property-read \App\User|null $auth_user
* @property-read \App\User|null $member
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereIsLike($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereMemberId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereNotice($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereNumber($value)
* @property bool|null $has_buyed
* @property bool|null $subscribed
* @property int|null $wp_order_number
* @property string|null $wp_order_date
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereHasBuyed($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereSubscribed($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereWpOrderDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereWpOrderNumber($value)
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property string|null $user_deleted_at
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingUser onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereUserDeletedAt($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingUser withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingUser withoutTrashed()
* @property string|null $mode
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereMode($value)
* @property bool|null $faker_mail
* @property string|null $shipping_email
* @property string|null $is_for
* @property string|null $is_from
* @property int|null $shopping_user_id
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereFakerMail($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereIsFor($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereIsFrom($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingEmail($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShoppingUserId($value)
* @property int|null $homeparty_id
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUser whereHomepartyId($value)
* @property int|null $shopping_collect_order_id
* @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
{
protected $table = 'shopping_users';
use SoftDeletes;
protected $dates = ['deleted_at'];
protected $fillable = [
'auth_user_id',
'member_id',
'number',
'is_like',
'language',
'billing_salutation',
'billing_company',
'billing_firstname',
'billing_lastname',
'billing_address',
'billing_address_2',
'billing_zipcode',
'billing_city',
'billing_country_id',
'billing_phone',
'billing_email',
'faker_mail',
'shipping_email',
'accepted_data_checkbox',
'same_as_billing',
'shipping_salutation',
'shipping_company',
'shipping_firstname',
'shipping_lastname',
'shipping_address',
'shipping_address_2',
'shipping_zipcode',
'shipping_city',
'shipping_country_id',
'shipping_phone',
'has_buyed',
'subscribed',
'notice',
'remarks',
'mode',
'is_for',
'is_from',
'shopping_user_id',
'homeparty_id',
'shopping_collect_order_id',
'wp_order_number',
'wp_order_date',
];
protected $casts = [
'notice' => 'array',
'is_like' => 'bool',
'faker_mail' => 'bool',
'accepted_data_checkbox' => 'bool',
'same_as_billing' => 'bool',
'has_buyed' => 'bool',
'subscribed' => 'bool',
'wp_order_number' => 'int',
];
//can null
public function member()
{
return $this->belongsTo('App\User','member_id');
}
public function auth_user()
{
return $this->belongsTo('App\User','auth_user_id');
}
public function billing_country()
{
return $this->belongsTo('App\Models\Country','billing_country_id');
}
public function shipping_country()
{
return $this->belongsTo('App\Models\Country','shipping_country_id');
}
public function shopping_orders()
{
return $this->hasMany('App\Models\ShoppingOrder','shopping_user_id');
}
public function shopping_order()
{
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;
$this->notice = $notice;
$this->save();
}
public function getNotice($key){
return isset($this->notice[$key]) ? $this->notice[$key] : false;
}
public function removeNotice($key){
$notice = $this->notice;
if(isset($notice[$key])){
unset($notice[$key]);
}
$this->notice = $notice;
$this->save();
}
public function firstEntryByNumber(){
if($this->number>0){
if($shopping_user = ShoppingUser::where('number', $this->number)->orderBy('created_at', 'ASC')->first()){
return $shopping_user;
}
}
return $this;
}
public function lastEntryByNumber(){
if($this->number>0){
if($shopping_user = ShoppingUser::where('number', $this->number)->orderBy('created_at', 'DESC')->first()){
return $shopping_user;
}
}
return $this;
}
public function getOrderPaymentFor() {
switch($this->is_from){
case 'wizard':
return 1;
case 'membership':
return 2;
case 'user_order':
return ($this->is_for === 'me' || $this->is_for === 'abo_me') ? 3 : 4;
case 'homeparty':
return 5;
case 'shopping':
return 6;
case 'extern':
return 7;
case 'collection':
return 8;
}
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){
return $this->shopping_order->getAPIShippedType();
}
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,
];
}
public function getAllOrdersByMember(){
return ShoppingUserService::getAllOrdersByMember($this);
}
public function getDeliveryCountry($get_country = false){
if($this->same_as_billing == 1){
if($this->billing_country_id){
if($get_country){
return $this->billing_country;
}
return $this->billing_country->getLocated();
}
}else{
if($this->shipping_country_id){
if($get_country){
return $this->shipping_country;
}
return $this->shipping_country->getLocated();
}
}
return 'not set';
}
}

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,78 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
/**
* Class SySetting
*
* @property int $id
* @property string $name
* @property string $slug
* @property string $message
* @property string $action
* @property int $status
* @property bool $active
* @property Carbon $created_at
* @property Carbon $updated_at
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting findSimilarSlugs($attribute, $config, $slug)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting whereAction($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting whereMessage($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|SySetting withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
* @mixin \Eloquent
*/
class SySetting extends Model
{
use Sluggable;
protected $table = 'sy_settings';
protected $casts = [
'status' => 'int',
'active' => 'bool'
];
protected $fillable = [
'name',
'slug',
'message',
'action',
'status',
'active'
];
public static $statusTypes = [
1 => 'default',
];
public function sluggable() : array
{
return [
'slug' => [
'source' => 'name'
]
];
}
public function getStatusType(){
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
}
}

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);
}
}

View file

@ -0,0 +1,238 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use App\User;
use Carbon\Carbon;
use App\Services\Util;
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 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
* @property int|null $member_id
* @property int $shopping_user_id
* @property string|null $email
* @property string|null $is_for
* @property array|null $carddata
* @property \Illuminate\Support\Carbon|null $start_date
* @property \Illuminate\Support\Carbon|null $last_date
* @property \Illuminate\Support\Carbon|null $next_date
* @property-read User|null $member
* @property-read \App\Models\ShoppingUser $shopping_user
* @property-read Collection<int, \App\Models\UserAboItem> $user_abo_items
* @property-read int|null $user_abo_items_count
* @property-read int|null $user_abo_orders_count
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo query()
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereAboInterval($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereAmount($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereCancelDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereCarddata($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereClearingtype($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereEmail($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereIsFor($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereLastDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereMemberId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereNextDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo wherePayoneUserid($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereShoppingUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereStartDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereUserDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereWallettype($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo withTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo withoutTrashed()
* @mixin \Eloquent
*/
class UserAbo extends Model
{
use SoftDeletes;
protected $table = 'user_abos';
protected $casts = [
'user_id' => 'int',
'member_id' => 'int',
'shopping_user_id' => 'int',
'payone_userid' => 'int',
'active' => 'bool',
'status' => 'int',
'abo_interval' => 'int',
'amount' => 'int',
'start_date' => 'datetime',
'last_date' => 'datetime',
'next_date' => 'datetime',
'cancel_date' => 'datetime',
'user_deleted_at' => 'datetime',
'carddata' => 'array'
];
protected $fillable = [
'user_id',
'member_id',
'shopping_user_id',
'is_for',
'email',
'payone_userid',
'clearingtype',
'wallettype',
'carddata',
'amount',
'active',
'status',
'abo_interval',
'start_date',
'last_date',
'next_date',
'cancel_date',
'user_deleted_at'
];
public static $aboDeliveryDays = [5, 10, 20, 25];
public static $statusTypes = [
0 => 'abo_new',
1 => 'abo_new',
2 => 'abo_okay',
3 => 'abo_hold',
4 => 'abo_cancel',
5 => 'abo_finish',
6 => 'abo_inactive',
7 => 'abo_grace'
];
public static $statusColors = [
0 => 'success',
1 => 'success',
2 => 'secondary',
3 => 'warning',
4 => 'danger',
5 => 'info',
6 => 'warning',
7 => 'danger'
];
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
public function member()
{
return $this->belongsTo(User::class, 'member_id');
}
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 user_abo_items()
{
return $this->hasMany(UserAboItem::class);
}
public function getCountOrders(){
//sind bezahlte Bestellungen
return $this->user_abo_orders->where('status', '>=', 2)->count();
}
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()) : '';
}
public function getFormattedAmount()
{
return isset($this->attributes['amount']) ? Util::formatNumber($this->attributes['amount']/100) : "";
}
public function getIsForFormated()
{
return $this->attributes['is_for'] === 'me' ? '<span class="badge badge-outline-warning-dark">'.__('tables.adviser').'</span>' : '<span class="badge badge-outline-info">'.__('tables.customer').'</span>';
}
public function getStatusFormated(){
return '<span class="badge badge-pill badge-'.$this->getStatusColor().'">'.$this->getStatusType().'</span>';
}
public function getStatusType(){
return isset(self::$statusTypes[$this->status]) ? __('abo.'.self::$statusTypes[$this->status]) : "";
}
public function getStatusColor(){
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default";
}
public function getPaymentType(){
return $this->clearingtype === 'wlt' ? __('payment.paypal') : __('payment.credit_card');
}
}

View file

@ -0,0 +1,90 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use App\Services\Util;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Yard;
/**
* Class UserAboItem
*
* @property int $id
* @property int $user_abo_id
* @property int $product_id
* @property int|null $comp
* @property int $qty
* @property int $status
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Product $product
* @property UserAbo $user_abo
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem query()
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem whereComp($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem whereQty($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem whereUserAboId($value)
* @mixin \Eloquent
*/
class UserAboItem extends Model
{
protected $table = 'user_abo_items';
protected $casts = [
'user_abo_id' => 'int',
'product_id' => 'int',
'comp' => 'int',
'qty' => 'int',
'status' => 'int'
];
protected $fillable = [
'user_abo_id',
'product_id',
'comp',
'qty',
'status'
];
public function product()
{
return $this->belongsTo(Product::class);
}
public function user_abo()
{
return $this->belongsTo(UserAbo::class);
}
public function getPrice()
{
$ufactor = $this->user_abo->is_for === 'me' ? true : false;
$tax_free = $ufactor ? true : Yard::instance('shopping')->getUserTaxFree();
$userCountry = Yard::instance('shopping')->getUserCountry();
return $this->product->getPriceWith($tax_free, $ufactor, $userCountry);
}
public function getFormattedPrice(){
/** der Preis wird für den User berechnet */
return Util::formatNumber($this->getPrice());
}
public function getFormattedTotalPrice(){
/** der Preis wird für den User berechnet */
return Util::formatNumber($this->getPrice() * $this->qty);
}
}

View file

@ -0,0 +1,99 @@
<?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
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder query()
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder whereShoppingOrderId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder whereUserAboId($value)
* @mixin \Eloquent
*/
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 static $statusTypes = [
0 => 'abo_new',
1 => 'abo_new',
2 => 'abo_okay',
3 => 'abo_hold',
4 => 'abo_cancel',
5 => 'abo_finish',
6 => 'abo_inactive',
7 => 'abo_grace'
];
public static $statusColors = [
0 => 'success',
1 => 'success',
2 => 'secondary',
3 => 'warning',
4 => 'danger',
5 => 'info',
6 => 'warning',
7 => 'danger'
];
public function shopping_order()
{
return $this->belongsTo(ShoppingOrder::class);
}
public function user_abo()
{
return $this->belongsTo(UserAbo::class);
}
public function getStatusFormated(){
return '<span class="badge badge-pill badge-'.$this->getStatusColor().'">'.$this->getStatusType().'</span>';
}
public function getStatusType(){
return isset(self::$statusTypes[$this->status]) ? __('abo.'.self::$statusTypes[$this->status]) : "";
}
public function getStatusColor(){
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default";
}
}

View file

@ -0,0 +1,269 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Carbon\Carbon;
/**
* App\Models\UserAccount
*
* @property-read \App\Models\Country $company_country
* @property-read \App\Models\Country $company_pre_phone
* @property-read \App\Models\Country $country
* @property mixed $birthday
* @property-read mixed $company
* @property-read \App\Models\Country $pre_mobil
* @property-read \App\Models\Country $pre_phone
* @property-read \App\User $user
* @method static bool|null forceDelete()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount newQuery()
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserAccount onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount query()
* @method static bool|null restore()
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserAccount withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserAccount withoutTrashed()
* @property int $id
* @property string|null $salutation
* @property string|null $first_name
* @property string|null $last_name
* @property string|null $address
* @property string|null $address_2
* @property string|null $zipcode
* @property string|null $city
* @property int $country_id
* @property int|null $pre_phone_id
* @property string|null $phone
* @property int|null $pre_mobil_id
* @property string|null $mobil
* @property string|null $tax_number
* @property string|null $tax_identification_number
* @property int $same_as_billing
* @property string|null $shipping_salutation
* @property string|null $shipping_company
* @property string|null $shipping_firstname
* @property string|null $shipping_lastname
* @property string|null $shipping_address
* @property string|null $shipping_address_2
* @property string|null $shipping_zipcode
* @property string|null $shipping_city
* @property int $shipping_country_id
* @property int|null $shipping_pre_phone_id
* @property string|null $shipping_phone
* @property string|null $website
* @property string|null $facebook
* @property string|null $facebook_fanpage
* @property string|null $instagram
* @property string|null $data_protection
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property-read \App\Models\Country $shipping_country
* @property-read \App\Models\Country|null $shipping_pre_phone
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereAddress($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereAddress2($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereBirthday($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereCity($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereCompany($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereDataProtection($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereFacebook($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereFacebookFanpage($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereFirstName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereInstagram($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereLastName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereMobil($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount wherePhone($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount wherePreMobilId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount wherePrePhoneId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereSalutation($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereSameAsBilling($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereShippingAddress($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereShippingAddress2($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereShippingCity($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereShippingCompany($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereShippingCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereShippingFirstname($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereShippingLastname($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereShippingPhone($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereShippingPrePhoneId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereShippingSalutation($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereShippingZipcode($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereTaxIdentificationNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereTaxNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereWebsite($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereZipcode($value)
* @property string|null $m_account
* @property string|null $m_salutation
* @property string|null $m_first_name
* @property string|null $m_last_name
* @property string|null $m_notes
* @property int|null $taxable_sales
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereMAccount($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereMFirstName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereMLastName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereMNotes($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereMSalutation($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereTaxableSales($value)
* @property array|null $payment_data
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount wherePaymentData($value)
* @property string|null $accepted_contract
* @property array|null $notice
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereAcceptedContract($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereNotice($value)
* @property int $reverse_charge
* @property string|null $reverse_charge_code
* @property string|null $reverse_charge_valid
* @method static \Illuminate\Database\Eloquent\Builder|UserAccount whereReverseCharge($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAccount whereReverseChargeCode($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAccount whereReverseChargeValid($value)
* @property string|null $bank_owner
* @property string|null $bank_iban
* @property string|null $bank_bic
* @method static \Illuminate\Database\Eloquent\Builder|UserAccount whereBankBic($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAccount whereBankIban($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserAccount whereBankOwner($value)
* @mixin \Eloquent
*/
class UserAccount extends Model
{
protected $table = 'user_accounts';
protected $fillable = [
'm_account', 'm_salutation', 'm_first_name', 'm_last_name', 'm_notes', 'company', 'salutation', 'first_name', 'last_name', 'address', 'address_2', 'zipcode', 'city', 'country_id', 'pre_phone_id', 'phone', 'pre_mobil_id', 'mobil',
'tax_number', 'tax_identification_number', 'taxable_sales', 'same_as_billing',
'shipping_salutation', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_country_id', 'shipping_pre_phone_id', 'shipping_phone',
'birthday', 'website', 'facebook', 'facebook_fanpage', 'instagram', 'bank_owner', 'bank_iban', 'bank_bic', 'notice'
];
//'reverse_charge', 'reverse_charge_valid'
protected $casts = [
'payment_data' => 'array',
'notice' => 'array',
//'reverse_charge' => 'bool'
];
use SoftDeletes;
protected $dates = ['deleted_at'];
public function user()
{
return $this->hasOne('App\User', 'account_id');
}
public function country()
{
return $this->belongsTo('App\Models\Country', 'country_id');
}
public function shipping_country()
{
return $this->belongsTo('App\Models\Country', 'shipping_country_id');
}
public function pre_phone()
{
return $this->belongsTo('App\Models\Country', 'pre_phone_id');
}
public function pre_mobil()
{
return $this->belongsTo('App\Models\Country', 'pre_mobil_id');
}
public function shipping_pre_phone()
{
return $this->belongsTo('App\Models\Country', 'shipping_pre_phone_id');
}
public function getBirthdayAttribute($value)
{
if(!$value){
return "";
}
return Carbon::parse($value)->format(\Util::formatDateDB());
}
public function setBirthdayAttribute( $value ) {
$this->attributes['birthday'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
}
public function getDataProtectionFormat(){
if(!$this->attributes['data_protection']){ return ""; }
return Carbon::parse($this->attributes['data_protection'])->format(\Util::formatDateTimeDB());
}
public function getAcceptContractFormat(){
if(!$this->attributes['accept_contract']){ return ""; }
return Carbon::parse($this->attributes['accept_contract'])->format(\Util::formatDateTimeDB());
}
public function getReverseChargeValidFormat(){
if(!$this->attributes['reverse_charge_valid']){ return ""; }
return Carbon::parse($this->attributes['reverse_charge_valid'])->format(\Util::formatDateTimeDB());
}
public function getCountryAttrAs($attr, $as = false){
if($this->country){
$val = $this->country->getAttrByKey($attr);
if($val){
if($as){
return $as;
}
return true;
}
}
return "";
}
public function setNotice($key, $value){
$notice = $this->notice;
$notice[$key] = $value;
$this->notice = $notice;
$this->save();
}
public function getNotice($key){
return isset($this->notice[$key]) ? $this->notice[$key] : false;
}
public function getPhoneNumber(){
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

@ -0,0 +1,248 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use App\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
/**
* App\Models\UserBusiness
*
* @property int $id
* @property int $user_id
* @property int $month
* @property int $year
* @property int|null $b_structure_id
* @property int|null $m_level_id
* @property int|null $m_sponsor_id
* @property object|null $sponsor
* @property string|null $m_sponsor_name
* @property string|null $user_level_name
* @property bool $active_account
* @property \Illuminate\Support\Carbon|null $payment_account_date
* @property \Illuminate\Support\Carbon|null $active_date
* @property int|null $m_account
* @property string|null $email
* @property string|null $first_name
* @property string|null $last_name
* @property int|null $sales_volume_points
* @property int|null $sales_volume_points_shop
* @property int|null $sales_volume_points_sum
* @property float|null $sales_volume_total
* @property float|null $sales_volume_total_shop
* @property float|null $sales_volume_total_sum
* @property int|null $margin
* @property int|null $margin_shop
* @property int|null $qual_kp
* @property int|null $qual_pp
* @property int|null $total_pp
* @property int|null $total_qual_pp
* @property string|null $commission_lines_total
* @property float|null $commission_shop_sales
* @property float|null $commission_pp_total
* @property mixed|null $business_lines
* @property mixed|null $user_items
* @property array|null $qual_user_level
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\UserBusinessStructure|null $user_business_structure
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness query()
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereActiveAccount($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereActiveDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereBStructureId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereBusinessLines($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereCommissionLinesTotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereCommissionShopSales($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereCommissionTeamTotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereEmail($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereFirstName($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereLastName($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereMAccount($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereMLevelId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereMSponsorId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereMSponsorName($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereMargin($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereMarginShop($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereMonth($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness wherePaymentAccountDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereQualKp($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereQualTp($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereQualUserLevel($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereSalesVolumePoints($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereSalesVolumePointsShop($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereSalesVolumePointsSum($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereSalesVolumeTotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereSalesVolumeTotalShop($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereSalesVolumeTotalSum($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereSponsor($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereTotalQualTp($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereTotalTp($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereUserItems($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereUserLevelName($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereYear($value)
* @property array|null $next_qual_user_level
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereNextQualUserLevel($value)
* @property-read User $user
* @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)
* @property string|null $user_birthday
* @property string|null $user_phone
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereUserBirthday($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereUserPhone($value)
* @mixin \Eloquent
*/
class UserBusiness extends Model
{
protected $table = 'user_businesses';
protected $casts = [
'user_id' => 'int',
'month' => 'int',
'year' => 'int',
'b_structure_id' => 'int',
'm_level_id' => 'int',
'active_account' => 'bool',
'm_account' => 'int',
'sales_volume_KP_points' => 'int',
'sales_volume_TP_points' => 'int',
'sales_volume_points_shop' => 'int',
'sales_volume_points_KP_sum' => 'int',
'sales_volume_points_TP_sum' => 'int',
'sales_volume_total' => 'float',
'sales_volume_total_shop' => 'float',
'sales_volume_total_sum' => 'float',
'payline_points' => 'int',
'payline_points_qual_kp' => 'int',
'margin' => 'float',
'margin_shop' => 'float',
'qual_kp' => 'int',
'qual_pp' => 'int',
'total_pp' => 'int',
'total_qual_pp' => 'int',
'commission_pp_total' => 'float',
'commission_growth_total' => 'float',
'commission_shop_sales' => 'float',
'qual_user_level' => 'array',
'qual_user_level_next' => 'array',
'next_qual_user_level' => 'array',
'next_can_user_level' => 'array',
'sponsor' => 'object',
'business_lines' => AsArrayObject::class,
'user_items' => AsArrayObject::class,
'version' => 'int',
];
protected $dates = [
'payment_account_date',
'active_date'
];
protected $fillable = [
'user_id',
'month',
'year',
'b_structure_id',
'm_level_id',
'sponsor',
'user_level_name',
'active_account',
'payment_account_date',
'active_date',
'm_account',
'email',
'first_name',
'last_name',
'user_birthday',
'user_phone',
'sales_volume_KP_points',
'sales_volume_TP_points',
'sales_volume_points_shop',
'sales_volume_points_KP_sum',
'sales_volume_points_TP_sum',
'sales_volume_total',
'sales_volume_total_shop',
'sales_volume_total_sum',
'payline_points',
'payline_points_qual_kp',
'margin',
'margin_shop',
'qual_kp',
'qual_pp',
'qual_user_level',
'qual_user_level_next',
'next_qual_user_level',
'next_can_user_level',
'total_pp',
'total_qual_pp',
'commission_shop_sales',
'commission_pp_total',
'commission_growth_total',
'business_lines',
'user_items',
'version',
];
public function user()
{
return $this->belongsTo(User::class);
}
public function user_business_structure()
{
return $this->belongsTo(UserBusinessStructure::class, 'b_structure_id');
}
public function isSave(){
return $this->id !== null ? true : false;
}
public function setPaymentAccountDateAttribute( $value ) {
$this->attributes['payment_account_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
}
public function setActiveDateAttribute( $value ) {
$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,73 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
/**
* Class UserBusinessStructure
*
* @property int $id
* @property int|null $month
* @property int|null $year
* @property object|null $structure
* @property object|null $parentless
* @property array|null $users
* @property bool $completed
* @property int $status
* @package App\Models
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserBusiness[] $user_businesses
* @property-read int|null $user_businesses_count
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure query()
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereCompleted($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereMonth($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereParentless($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereStructure($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereUsers($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserBusinessStructure whereYear($value)
* @mixin \Eloquent
*/
class UserBusinessStructure extends Model
{
protected $table = 'user_business_structures';
protected $casts = [
'month' => 'int',
'year' => 'int',
'completed' => 'bool',
'status' => 'int',
'structure' => 'object',
'parentless' => 'object',
'users' => 'array',
];
protected $fillable = [
'month',
'year',
'structure',
'parentless',
'users',
'completed',
'status'
];
public function user_businesses()
{
return $this->hasMany(UserBusiness::class, 'b_structure_id');
}
}

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

@ -0,0 +1,220 @@
<?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 UserCredit
*
* @property int $id
* @property int $user_id
* @property int|null $month
* @property int|null $year
* @property Carbon|null $date
* @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 $filename
* @property string|null $dir
* @property string|null $disk
* @property array|null $infos
* @property bool $paid_out
* @property Carbon|null $paid_out_date
* @property bool $cancellation
* @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 $user
* @property Collection|UserCreditItem[] $user_credit_items
* @package App\Models
* @property bool $taxable
* @property-read int|null $user_credit_items_count
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit newQuery()
* @method static \Illuminate\Database\Query\Builder|UserCredit onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit query()
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereCancellation($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereCancellationDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereCancellationId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereDir($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereDisk($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereFilename($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereFullNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereInfos($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereMonth($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereNet($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit wherePaidOut($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit wherePaidOutDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereTax($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereTaxRate($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereTaxable($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereTotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereYear($value)
* @method static \Illuminate\Database\Query\Builder|UserCredit withTrashed()
* @method static \Illuminate\Database\Query\Builder|UserCredit withoutTrashed()
* @mixin \Eloquent
*/
class UserCredit extends Model
{
use SoftDeletes;
protected $table = 'user_credits';
protected $casts = [
'user_id' => 'int',
'month' => 'int',
'year' => 'int',
'number' => 'int',
'net' => 'float',
'tax_rate' => 'float',
'tax' => 'float',
'taxable' => 'int',
'total' => 'float',
'paid_out' => 'bool',
'cancellation' => 'bool',
'cancellation_id' => 'int',
'status' => 'int',
'infos' => 'array'
];
protected $dates = [
'date',
'paid_out_date',
'cancellation_date'
];
protected $fillable = [
'user_id',
'month',
'year',
'date',
'full_number',
'number',
'net',
'tax_rate',
'tax',
'total',
'taxable',
'filename',
'dir',
'disk',
'infos',
'paid_out',
'paid_out_date',
'cancellation',
'cancellation_id',
'cancellation_date',
'status'
];
public static $statusTypes = [
0 => 'open',
1 => 'paid',
2 => 'check',
10 => 'cancelled'
];
public static $statusColors = [
0 => 'warning',
1 => 'success',
2 => 'secondary',
10 => 'danger',
];
public static $taxableTypes = [
0 => '',
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
];
public function user()
{
return $this->belongsTo(User::class);
}
public function user_credit_items()
{
return $this->hasMany(UserCreditItem::class);
}
public function isCredit(){
return $this->filename ? true : false;
}
public function getDateAttribute($value)
{
return $value ? Carbon::parse($value)->format(\Util::formatDateDB()) : "";
}
public function setDateAttribute( $value ) {
$this->attributes['date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
}
public function getDateRaw(){
return isset($this->attributes['date']) ? $this->attributes['date'] : NULL;
}
public function getFormattedTax()
{
return formatNumber($this->attributes['tax']);
}
public function getFormattedNet()
{
return formatNumber($this->attributes['net']);
}
public function getFormattedTotal()
{
return formatNumber($this->attributes['total']);
}
public function getStatusType(){
//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;
}
return \Storage::disk($this->disk)->path($this->dir.$this->filename);
}
}

View file

@ -0,0 +1,142 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use App\Services\HTMLHelper;
use App\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class UserCreditItem
*
* @property int $id
* @property int $user_id
* @property int|null $user_credit_id
* @property float|null $credit
* @property string|null $message
* @property int $status
* @property bool $paid
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property UserCredit|null $user_credit
* @property User $user
* @package App\Models
* @property int|null $user_business_id
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem query()
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem whereCredit($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem whereMessage($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem wherePaid($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem whereUserBusinessId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem whereUserCreditId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem whereUserId($value)
* @property int|null $from_month
* @property int|null $from_year
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem whereFromMonth($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem whereFromYear($value)
* @mixin \Eloquent
*/
class UserCreditItem extends Model
{
public static $statusTypes = [
1 => 'commission_shop',
2 => 'commission_payline',
3 => 'credit_added',
4 => 'commission',
5 => 'commission_growth_bonus',
];
public static $statusColors = [
0 => 'warning',
1 => 'success',
2 => 'secondary',
3 => 'warning',
4 => 'info',
5 => 'secondary',
10 => 'danger',
];
protected $table = 'user_credit_items';
protected $casts = [
'user_id' => 'int',
'user_credit_id' => 'int',
'user_business_id' => 'int',
'credit' => 'float',
'status' => 'int',
'from_month' => 'int',
'from_year' => 'int',
'paid' => 'bool'
];
protected $fillable = [
'user_id',
'user_credit_id',
'user_business_id',
'credit',
'message',
'status',
'from_month',
'from_year',
'paid'
];
public function user_credit()
{
return $this->belongsTo(UserCredit::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
public function deleteTime(){
$time = '+100 min';
if(Carbon::parse($this->created_at)->modify($time)->gt(Carbon::now())){
return Carbon::now()->diffInMinutes(Carbon::parse($this->created_at)->modify($time));
}
return false;
}
public function getStatusType(){
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

@ -0,0 +1,140 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use App\User;
/**
* Class UserHistory
*
* @property int $id
* @property int $user_id
* @property int $shopping_order_id
* @property int $product_id
* @property string $action
* @property int $referenz
* @property int $status
* @property Carbon $created_at
* @property Carbon $updated_at
* @property Product $product
* @property ShoppingOrder $shopping_order
* @property User $user
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory whereAction($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory whereReferenz($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory whereShoppingOrderId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory whereUserId($value)
* @property string|null $identifier
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory whereIdentifier($value)
* @property int|null $abo_options
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory whereAboOptions($value)
* @property int|null $is_abo
* @method static \Illuminate\Database\Eloquent\Builder|UserHistory whereIsAbo($value)
* @mixin \Eloquent
*/
class UserHistory extends Model
{
protected $table = 'user_histories';
protected $status_types = [
0 => 'info',
1 => 'store_payment',
2 => 'checkout_payment',
3 => 'payment_error',
4 => 'payment_redirect',
5 => 'payment_approved',
6 => 'txaction_failed',
7 => 'txaction_appointed',
8 => 'txaction_paid',
9 => 'success_payment',
10 => 'success',
21 => 'payment_not_found',
22 => 'checkout_cancel',
23 => 'checkout_error',
31 => 'reminder_first',
32 => 'reminder_first_sepa',
33 => 'reminder_sec',
34 => 'reminder_last',
35 => 'reminder_deaktiv',
36 => 'reminder_deaktiv_sepa',
37 => 'reminder_collect_sepa',
50 => 'delete_membership'
];
protected $status_colors = [
0 => 'info',
1 => 'warning',
2 => 'warning',
3 => 'danger',
4 => 'warning',
5 => 'warning',
6 => 'danger',
7 => 'warning',
8 => 'success',
9 => 'secondary',
10 => 'success',
21 => 'danger',
22 => 'danger',
23 => 'danger',
];
protected $casts = [
'user_id' => 'int',
'shopping_order_id' => 'int',
'product_id' => 'int',
'referenz' => 'int',
'status' => 'int'
];
protected $fillable = [
'user_id',
'shopping_order_id',
'product_id',
'action',
'referenz',
'identifier',
'abo_options',
'is_abo',
'status'
];
public function product()
{
return $this->belongsTo(Product::class);
}
public function shopping_order()
{
return $this->belongsTo(ShoppingOrder::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
public function getStatusType(){
if(isset($this->status_types[$this->status])){
return $this->status_types[$this->status];
}
}
public function getStatusColor(){
if(isset($this->status_colors[$this->status])){
return $this->status_colors[$this->status];
}
return 'default';
}
}

View file

@ -0,0 +1,208 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class UserInvoice
*
* @property int $id
* @property int $shopping_order_id
* @property int|null $month
* @property int|null $year
* @property Carbon|null $date
* @property string|null $full_number
* @property int|null $number
* @property string|null $file
* @property string|null $infos
* @property bool $paid
* @property Carbon|null $paid_date
* @property bool $cancellation
* @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 ShoppingOrder $shopping_order
* @package App\Models
* @property string|null $filename
* @property string|null $dir
* @property string|null $delivery_filename
* @property string|null $delivery_dir
* @property string|null $disk
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice newQuery()
* @method static \Illuminate\Database\Query\Builder|UserInvoice onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice query()
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereCancellation($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereCancellationDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereCancellationId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereDeliveryDir($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereDeliveryFilename($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereDir($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereDisk($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereFilename($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereFullNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereInfos($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereMonth($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice wherePaid($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice wherePaidDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereShoppingOrderId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereYear($value)
* @method static \Illuminate\Database\Query\Builder|UserInvoice withTrashed()
* @method static \Illuminate\Database\Query\Builder|UserInvoice withoutTrashed()
* @mixin \Eloquent
*/
class UserInvoice extends Model
{
use SoftDeletes;
protected $table = 'user_invoices';
protected $casts = [
'shopping_order_id' => 'int',
'month' => 'int',
'year' => 'int',
'number' => 'int',
'paid' => 'bool',
'cancellation' => 'bool',
'cancellation_id' => 'int',
'status' => 'int',
'infos' => 'array',
];
protected $dates = [
'date',
'paid_date',
'cancellation_date'
];
protected $fillable = [
'shopping_order_id',
'month',
'year',
'date',
'full_number',
'number',
'filename',
'dir',
'delivery_filename',
'delivery_dir',
'disk',
'infos',
'paid',
'paid_date',
'cancellation',
'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 => '-',
1 => 'Bestellung',
2 => 'Shop',
11 => 'storniert B.',
12 => 'storniert Shop',
];
public static $statusColors = [
0 => 'warning',
1 => 'success',
2 => 'secondary',
11 => 'danger',
12 => 'danger',
];
public function shopping_order(){
return $this->belongsTo(ShoppingOrder::class);
}
public function getDateAttribute($value){
return $this->attributes['date'] ? Carbon::parse($this->attributes['date'])->format(\Util::formatDateDB()) : '';
}
public function setDateAttribute( $value ) {
$this->attributes['date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
}
public function getDateRaw(){
return isset($this->attributes['date']) ? $this->attributes['date'] : NULL;
}
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";
}
public function getDownloadPath($full = false){
if(!$full){
return $this->dir.$this->filename;
}
return \Storage::disk($this->disk)->path($this->dir.$this->filename);
}
public function getDownloadPathDelivery($full = false){
if(!$full){
return $this->delivery_dir.$this->delivery_filename;
}
return \Storage::disk($this->disk)->path($this->delivery_dir.$this->delivery_filename);
}
}

View file

@ -0,0 +1,133 @@
<?php
namespace App\Models;
use App\Services\Util;
use Illuminate\Database\Eloquent\Model;
use App\Models\UserLevel as ModelsUserLevel;
/**
* App\Models\UserLevel
*
* @property int $id
* @property string $name
* @property float|null $margin
* @property int|null $pos
* @property int $active
* @property int $default
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\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()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereDefault($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereId($value)
* @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 whereUpdatedAt($value)
* @property int|null $next_id
* @property int|null $margin_shop
* @property int|null $qual_kp
* @property int|null $qual_pp
* @property string|null $growth_bonus
* @property int|null $pr_line_1
* @property int|null $pr_line_2
* @property int|null $pr_line_3
* @property int|null $pr_line_4
* @property int|null $pr_line_5
* @property int|null $pr_line_6
* @property int|null $pr_line_7
* @property int|null $pr_line_8
* @property-read UserLevel|null $next_user_level
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereGrowthBonus($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereMarginShop($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereNextId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine1($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine2($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine3($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine4($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine5($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine6($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereQualKp($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereQualTp($value)
* @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 $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',
];
public function next_user_level()
{
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();
return [0 => '-> Keinen Karriere Level'] + $ret;
}
public function setPosAttribute($value){
$this->attributes['pos'] = is_numeric($value) ? $value : null;
}
public function setGrowthBonusAttribute($value)
{
$this->attributes['growth_bonus'] = $value !== null ? Util::reFormatNumber($value) : null;
}
public function getFormattedGrowthBonus()
{
return isset($this->attributes['growth_bonus']) ? Util::formatNumber($this->attributes['growth_bonus'],1) : "";
}
public function getFormattedMargin()
{
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') {
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

@ -0,0 +1,86 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use App\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class UserMessage
*
* @property int $id
* @property int $user_id
* @property int $send_user_id
* @property string $email
* @property string $subject
* @property string $message
* @property bool $send
* @property bool $fail
* @property string $error
* @property Carbon $sent_at
* @property Carbon $scheduled_at
* @property Carbon $delivered_at
* @property Carbon $created_at
* @property Carbon $updated_at
* @property User $user
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserMessage newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserMessage newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserMessage query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserMessage whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserMessage whereDeliveredAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserMessage whereEmail($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserMessage whereError($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserMessage whereFail($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserMessage whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserMessage whereMessage($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserMessage whereScheduledAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserMessage whereSend($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserMessage whereSendUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserMessage whereSentAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserMessage whereSubject($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserMessage whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserMessage whereUserId($value)
* @mixin \Eloquent
*/
class UserMessage extends Model
{
protected $table = 'user_messages';
protected $casts = [
'user_id' => 'int',
'send_user_id' => 'int',
'send' => 'bool',
'fail' => 'bool'
];
protected $dates = [
'sent_at',
'scheduled_at',
'delivered_at'
];
protected $fillable = [
'user_id',
'send_user_id',
'email',
'subject',
'message',
'send',
'fail',
'error',
'sent_at',
'scheduled_at',
'delivered_at'
];
public function user()
{
return $this->belongsTo(User::class);
}
}

View file

@ -0,0 +1,273 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use App\Models\ShoppingOrder;
use App\User;
/**
* Class UserSalesVolume
*
* @property int $id
* @property int $user_id
* @property int|null $shopping_order_id
* @property int|null $month
* @property int|null $year
* @property Carbon|null $date
* @property int|null $points
* @property int|null $month_points
* @property int $status_points
* @property float|null $total_net
* @property float|null $month_total_net
* @property string|null $message
* @property string|null $info
* @property int $status
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property ShoppingOrder|null $shopping_order
* @property User $user
* @package App\Models
* @property int|null $user_invoice_id
* @property int|null $month_shop_points
* @property float|null $month_shop_total_net
* @property-read \App\Models\UserInvoice|null $user_invoice
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume query()
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereMessage($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereMonth($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereMonthPoints($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereMonthShopPoints($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereMonthShopTotalNet($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereMonthTotalNet($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume wherePoints($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereShoppingOrderId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereTotalNet($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereUserInvoiceId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereYear($value)
* @property array|null $syslog
* @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
{
protected $table = 'user_sales_volumes';
protected $casts = [
'user_id' => 'int',
'shopping_order_id' => 'int',
'user_invoice_id' => 'int',
'month' => 'int',
'year' => 'int',
'points' => 'int',
'month_KP_points' => 'int',
'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',
'status' => 'int',
'syslog' => 'array'
];
protected $dates = [
'date'
];
protected $fillable = [
'user_id',
'shopping_order_id',
'user_invoice_id',
'month',
'year',
'date',
'points',
'month_KP_points',
'month_TP_points',
'month_shop_points',
'status_points',
'status_turnover',
'total_net',
'month_total_net',
'month_shop_total_net',
'message',
'info',
'status',
'syslog'
];
public static $statusPointsTypes = [
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 => '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 = [
0 => 'warning',
1 => 'success',
2 => 'secondary',
3 => 'warning',
4 => 'info',
5 => 'info',
10 => 'danger',
];
public function shopping_order()
{
return $this->belongsTo(ShoppingOrder::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
public function user_invoice()
{
return $this->belongsTo(UserInvoice::class);
}
public function getDateAttribute(){
return $this->attributes['date'] ? Carbon::parse($this->attributes['date'])->format(\Util::formatDateDB()) : '';
}
public function setDateAttribute( $value ) {
$this->attributes['date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
}
public function getDateRaw(){
return isset($this->attributes['date']) ? $this->attributes['date'] : NULL;
}
public function getPointsKPSum(){
return $this->month_KP_points + $this->month_shop_points; //only KP für SUM - KP is for User
}
public function getPointsTPSum(){
return $this->month_TP_points + $this->month_shop_points; //only TP für SUM - TP is only for Payline
}
public function getTotalNetSum(){
return $this->month_total_net + $this->month_shop_total_net;
}
public function getStatusType(){
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(){
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default";
}
public function getStatusPointsType(){
return isset(self::$statusPointsTypes[$this->status_points]) ? self::$statusPointsTypes[$this->status_points] : "";
}
public function getStatusPointsColor(){
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;
}
public function isCurrentMonthYear(){
if($this->month === intval(date('m')) && $this->year === intval(date('Y'))){
return true;
}
return false;
}
public function caluCommissonTotalNet($margin){
if($this->total_net > 0 && $margin > 0){
return $this->total_net / 100 * $margin;
}
return 0;
}
}

View file

@ -0,0 +1,256 @@
<?php
namespace App\Models;
use App\Http\Controllers\Api\KasController;
use App\Http\Controllers\Api\KasSLLController;
use Carbon\Carbon;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* App\Models\UserShop
*
* @property int $id
* @property int $user_id
* @property string $name
* @property string $slug
* @property int $active
* @property int|null $set_defaults
* @property string|null $active_date
* @property string|null $title
* @property string|null $contact
* @property string|null $accessibility
* @property string|null $about
* @property array|null $featured
* @property string|null $filename
* @property string|null $originalname
* @property string|null $ext
* @property string|null $mine
* @property int|null $size
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserShopOnSite[] $on_sites
* @property-read int|null $on_sites_count
* @property-read \App\User $user
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop findSimilarSlugs($attribute, $config, $slug)
* @method static bool|null forceDelete()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop newQuery()
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserShop onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop query()
* @method static bool|null restore()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereAbout($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereAccessibility($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereActiveDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereContact($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereExt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereFeatured($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereFilename($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereMine($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereOriginalname($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereSetDefaults($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereSize($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereUserId($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserShop withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserShop withoutTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|UserShop withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
* @property array|null $trans
* @method static \Illuminate\Database\Eloquent\Builder|UserShop whereTrans($value)
* @mixin \Eloquent
*/
class UserShop extends Model
{
protected $table = 'user_shops';
private $is_online = NULL;
private $ssl_certificate_sni = NULL;
private $ssl_certificate_sni_is_active = NULL;
protected $casts = [
'featured' => 'array',
'trans' => 'array',
];
protected $fillable = [
'user_id', 'name', 'active', 'active_date',
];
use SoftDeletes;
protected $dates = ['deleted_at'];
use Sluggable;
public function sluggable() : array
{
return [
'slug' => [
'source' => 'name'
]
];
}
public function user()
{
return $this->belongsTo('App\User', 'user_id');
}
public function on_sites(){
return $this->hasMany('App\Models\UserShopOnSite', 'user_shop_id', 'id');
}
public function getActiveDateFormat(){
if(!$this->attributes['active_date']){ return ""; }
return Carbon::parse($this->attributes['active_date'])->format(\Util::formatDateTimeDB());
}
public function getActiveDateFormatSmall(){
if(!$this->attributes['active_date']){ return ""; }
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')){
return \Session::get('user_shop_domain');
}
return config('app.protocol').$this->attributes['slug'].".".config('app.domain').config('app.tld_care');
}
public function getSubdomainStatus()
{
if($this->is_online !== NULL){
return $this->is_online;
}
$kas = new KasController();
$domain = 'mivita.care';
$pra = array(
'subdomain_name' => $this->attributes['slug'].".".$domain,
'domain_name' => $domain,
);
//check if exisist
$subdomain = $kas->action('get_subdomains', $pra);
if(is_soap_fault($subdomain)){
return false;
}
if(!empty($subdomain[0]['is_active']) && $subdomain[0]['is_active'] == 'Y'){
$this->is_online = true;
}else{
$this->is_online = false;
}
if(!empty($subdomain[0]['ssl_certificate_sni']) && $subdomain[0]['ssl_certificate_sni'] == 'Y'){
$this->ssl_certificate_sni = true;
}else{
$this->ssl_certificate_sni = false;
$this->userShopAddSSL($subdomain[0]['subdomain_name']);
}
if(!empty($subdomain[0]['ssl_certificate_sni_is_active']) && $subdomain[0]['ssl_certificate_sni_is_active'] == 'j'){
$this->ssl_certificate_sni_is_active = true;
}else{
$this->ssl_certificate_sni_is_active = false;
}
return $this->is_online;
}
public function userShopAddSSL($full_subdomain_name)
{
$kas = new KasController();
$ssl = KasSLLController::getApiSSLParameter();
$pra = array(
'hostname' => $full_subdomain_name
);
$pra = array_merge($pra, $ssl);
$value = $kas->action('update_ssl', $pra);
return $value;
}
public function getSubdomainSslSin ()
{
return $this->ssl_certificate_sni;
}
public function getSubdomainSslSinActive ()
{
return $this->ssl_certificate_sni_is_active;
}
public function getSubdomainAvailable ()
{
$rCurlHandle = curl_init ( $this->attributes['slug'].".mivita.care" );
curl_setopt ( $rCurlHandle, CURLOPT_CONNECTTIMEOUT, 10 );
curl_setopt ( $rCurlHandle, CURLOPT_HEADER, TRUE );
curl_setopt ( $rCurlHandle, CURLOPT_NOBODY, TRUE );
curl_setopt ( $rCurlHandle, CURLOPT_RETURNTRANSFER, TRUE );
$strResponse = curl_exec ( $rCurlHandle );
curl_close ( $rCurlHandle );
if ( !$strResponse )
{
return FALSE;
}
$url = "http://".$this->attributes['slug'].".mivita.care/domain/check";
if(@file_get_contents($url) != 'checked'){
return FALSE;
}
return TRUE;
}
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;
}
}

View file

@ -0,0 +1,96 @@
<?php
namespace App\Models;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\UserShopOnSite
*
* @property int $id
* @property int $user_shop_id
* @property string|null $filename
* @property string|null $original_name
* @property string|null $ext
* @property string|null $mine
* @property int|null $size
* @property string $slug
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\UserShop $product
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite findSimilarSlugs($attribute, $config, $slug)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereExt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereFilename($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereMine($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereOriginalName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereSize($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereUserShopId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserShopOnSite withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
* @mixin \Eloquent
*/
class UserShopOnSite extends Model
{
use Sluggable;
protected $table = 'user_shop_on_sites';
protected $fillable = [
'user_shop_id', 'filename', 'original_name', 'ext', 'mine', 'size'
];
public function sluggable() : array
{
return [
'slug' => [
'source' => 'original_name'
]
];
}
public function product()
{
return $this->belongsTo('App\Models\UserShop', 'user_shop_id');
}
public function formatBytes($precision = 2)
{
$size = $this->size;
if ($size > 0) {
$size = (int) $size;
$base = log($size) / log(1024);
$suffixes = array(' bytes', ' KB', ' MB', ' GB', ' TB');
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
} else {
return $size;
}
}
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;
}
}

View file

@ -0,0 +1,36 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\UserUpdateEmail
*
* @property-read \App\User $user
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserUpdateEmail newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserUpdateEmail newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserUpdateEmail query()
* @property int $user_id
* @property string $email
* @property string $token
* @property \Illuminate\Support\Carbon $created_at
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserUpdateEmail whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserUpdateEmail whereEmail($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserUpdateEmail whereToken($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserUpdateEmail whereUserId($value)
* @mixin \Eloquent
*/
class UserUpdateEmail extends Model
{
protected $table = 'user_update_emails';
protected $fillable = [
'user_id', 'email', 'token',
];
public function user()
{
return $this->belongsTo('App\User', 'user_id');
}
}