Updates to 03-2025

This commit is contained in:
Kevin Adametz 2025-04-01 10:39:21 +02:00
parent 6167273a48
commit 9b54eb0512
348 changed files with 34535 additions and 5774 deletions

View file

@ -2,6 +2,7 @@
namespace App\Models;
use App\Services\Util;
use Illuminate\Database\Eloquent\Model;
/**
@ -25,39 +26,66 @@ use Illuminate\Database\Eloquent\Model;
* @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)
* @mixin \Eloquent
* @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
* @property int $attribute_type_id
* @property string|null $value
* @property-read \App\Models\AttributeType $attribute_type
* @method static \Illuminate\Database\Eloquent\Builder|Attribute whereAttributeTypeId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Attribute whereValue($value)
* @mixin \Eloquent
*/
class Attribute extends Model
{
protected $table = 'attributes';
protected $casts = ['trans_name' => 'array'];
protected $fillable = [
'parent_id', 'name', 'pos', 'active',
protected $casts = [
'parent_id' => 'int',
'pos' => 'int',
'active' => 'bool',
'trans_name' => 'array',
];
protected $fillable = [
'parent_id',
'attribute_type_id',
'name',
'value',
'trans_name',
'pos',
'active',
'slug'
];
public function attribute_type()
{
return $this->belongsTo(AttributeType::class, 'attribute_type_id');
}
public function parent()
{
return $this->belongsTo('App\Models\Attribute', 'parent_id');
return $this->belongsTo(Attribute::class, 'parent_id');
}
public function childrens()
{
return $this->hasMany('App\Models\Attribute', 'parent_id', 'id');
return $this->hasMany(Attribute::class, 'parent_id', 'id');
}
public function setPosAttribute($value){
$this->attributes['pos'] = is_numeric($value) ? $value : null;
}
public function getFormattedValue()
{
// return isset($this->attributes['value']) ? Util::formatNumber($this->attributes['value']) : "";
}
public function getLang($key)
{
$lang = \App::getLocale();

View file

@ -0,0 +1,111 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* Class AttributeType
*
* @property int $id
* @property int|null $parent_id
* @property string $name
* @property string|null $trans_name
* @property int|null $pos
* @property bool $active
* @property string $slug
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Attribute|null $attribute
* @property Collection|Attribute[] $attributes
* @package App\Models
* @property string|null $description
* @property-read Collection<int, \App\Models\Attribute> $childrens
* @property-read int|null $childrens_count
* @property-read \App\Models\Attribute|null $parent
* @method static \Illuminate\Database\Eloquent\Builder|AttributeType newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|AttributeType newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|AttributeType query()
* @method static \Illuminate\Database\Eloquent\Builder|AttributeType whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|AttributeType whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|AttributeType whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|AttributeType whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|AttributeType whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|AttributeType whereParentId($value)
* @method static \Illuminate\Database\Eloquent\Builder|AttributeType wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|AttributeType whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|AttributeType whereTransName($value)
* @method static \Illuminate\Database\Eloquent\Builder|AttributeType whereUpdatedAt($value)
* @mixin \Eloquent
*/
class AttributeType extends Model
{
protected $table = 'attribute_types';
protected $casts = [
'parent_id' => 'int',
'pos' => 'int',
'active' => 'bool',
'trans_name' => 'array'
];
protected $fillable = [
'parent_id',
'name',
'description',
'trans_name',
'pos',
'active',
'slug'
];
public function parent()
{
return $this->belongsTo(Attribute::class, 'parent_id');
}
public function childrens()
{
return $this->hasMany(Attribute::class, '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

@ -3,6 +3,7 @@
namespace App\Models;
use App\Services\Type;
use App\Models\Product;
use Illuminate\Database\Eloquent\Model;
use Cviebrock\EloquentSluggable\Sluggable;
@ -27,7 +28,6 @@ use Cviebrock\EloquentSluggable\Sluggable;
* @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)
* @mixin \Eloquent
* @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)
@ -47,6 +47,9 @@ use Cviebrock\EloquentSluggable\Sluggable;
* @property-read \App\Models\IqImage|null $iq_image
* @property-read int|null $product_categories_count
* @method static \Illuminate\Database\Eloquent\Builder|Category withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
* @property array|null $show_on
* @method static \Illuminate\Database\Eloquent\Builder|Category whereShowOn($value)
* @mixin \Eloquent
*/
class Category extends Model
{
@ -60,7 +63,7 @@ class Category extends Model
'parent_id', 'name', 'headline', 'pos', 'active', 'show_on'
];
public function sluggable()
public function sluggable(): array
{
return [
'slug' => [
@ -134,15 +137,21 @@ class Category extends Model
return rtrim($ret, ', ');
}
public function getShowOnTypes(){
public function getShowOnTypes($seperator = false){
$ret = [];
if($this->show_on && is_array($this->show_on)){
foreach($this->show_on as $show){
$ret[] = isset(Type::$showONs[$show]) ? Type::$showONs[$show] : '-';
}
}
return $ret;
return $seperator ? implode($seperator, $ret) : $ret;
}
public function getProductsCountOn($show_on = ['8']){
$category_id = $this->id;
return Product::where('active', true)->whereJsonContains('show_on', $show_on)
->whereHas('categories', function ($query) use ($category_id) {
$query->where('category_id', $category_id); //
})->orderBy('pos', 'ASC')->count();
}
}

View file

@ -26,7 +26,6 @@ use PHPUnit\Framework\Constraint\Count;
* @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)
* @mixin \Eloquent
* @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()
@ -57,6 +56,13 @@ use PHPUnit\Framework\Constraint\Count;
* @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 $translate
* @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)
* @method static \Illuminate\Database\Eloquent\Builder|Country whereTranslate($value)
* @mixin \Eloquent
*/
class Country extends Model
{
@ -64,17 +70,19 @@ class Country extends Model
protected $casts = [
'switch' => 'bool',
'translate' => 'bool',
'supply_country' => 'bool',
'eu_country' => 'bool',
'own_eur' => 'bool',
'currency' => 'bool',
'currency_calc' => 'bool',
'trans_name' => 'array',
'attr' => 'array'
];
protected $fillable = [
'code', 'phone', 'en', 'de', 'es', 'fr', 'it', 'ru',
'switch', 'own_eur', 'currency', 'currency_unit', 'currency_calc', 'currency_faktor',
'active', 'trans_name', 'attr',
'supply_country', 'eu_country', 'switch', 'translate', 'own_eur', 'currency', 'currency_unit', 'currency_calc', 'currency_faktor',
'active', 'attr',
];
public function country_prices()

View file

@ -36,8 +36,8 @@ use Illuminate\Database\Eloquent\Model;
* @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)
* @mixin \Eloquent
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereCCurrency($value)
* @mixin \Eloquent
*/
class CountryPrice extends Model
{

View file

@ -29,7 +29,6 @@ use Illuminate\Database\Eloquent\Model;
* @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)
* @mixin \Eloquent
* @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)
@ -39,6 +38,7 @@ use Illuminate\Database\Eloquent\Model;
* @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
{
@ -51,7 +51,7 @@ class IqImage extends Model
'filename', 'original_name', 'ext', 'mine', 'size'
];
public function sluggable()
public function sluggable(): array
{
return [
'slug' => [

43
app/Models/LeadType.php Normal file
View file

@ -0,0 +1,43 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class LeadType
*
* @property int $id
* @property string $name
* @property bool $active
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|LeadType newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|LeadType newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|LeadType query()
* @method static \Illuminate\Database\Eloquent\Builder|LeadType whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|LeadType whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|LeadType whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|LeadType whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|LeadType whereUpdatedAt($value)
* @mixin \Eloquent
*/
class LeadType extends Model
{
protected $table = 'lead_type';
protected $casts = [
'active' => 'bool'
];
protected $fillable = [
'name',
'active'
];
}

View file

@ -36,11 +36,11 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereShort($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereShowAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereUpdatedAt($value)
* @mixin \Eloquent
* @property string|null $max_price
* @method static \Illuminate\Database\Eloquent\Builder|PaymentMethod whereMaxPrice($value)
* @property array $show_on
* @method static \Illuminate\Database\Eloquent\Builder|PaymentMethod whereShowOn($value)
* @mixin \Eloquent
*/
class PaymentMethod extends Model
{
@ -71,14 +71,14 @@ class PaymentMethod extends Model
return isset(Type::$payShowATs[$this->show_at]) ? Type::$payShowATs[$this->show_at] : '-';
}
public function getShowOnTypes(){
public function getShowOnTypes($seperator = false){
$ret = [];
if($this->show_on && is_array($this->show_on)){
foreach($this->show_on as $show){
$ret[] = isset(Type::$payShowONs[$show]) ? Type::$payShowONs[$show] : '-';
}
}
return $ret;
return $seperator ? implode($seperator, $ret) : $ret;
}
public static function getDefaultAsArray($short=false){
@ -105,6 +105,9 @@ class PaymentMethod extends Model
$payment_method = PaymentMethod::whereShort($short)->first();
if($payment_method && $payment_method->active){
if(!$user_payment_methods || !is_array($user_payment_methods)){
abort(403, 'Fehler: Es sind keine Zahlungsmethoden hinterlegt');
}
if(in_array($payment_method->id, $user_payment_methods)){
if($total > 0 && $payment_method->max_price > 0){
if($payment_method->max_price >= $total){

View file

@ -39,9 +39,9 @@ use Illuminate\Database\Eloquent\Model;
* @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)
* @mixin \Eloquent
* @property string|null $mode
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereMode($value)
* @mixin \Eloquent
*/
class PaymentTransaction extends Model
{

View file

@ -72,7 +72,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @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()
* @mixin \Eloquent
* @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)
@ -130,6 +129,17 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property array|null $show_on
* @method static \Illuminate\Database\Eloquent\Builder|Product whereShortCopy($value)
* @method static \Illuminate\Database\Eloquent\Builder|Product whereShowOn($value)
* @property bool $exclude_stats_sales
* @property bool|null $whitelabel
* @property string|null $whitelabel_name
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ProductAttribute> $attribute_variants
* @property-read int|null $attribute_variants_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ProductImage> $whitelabel_images
* @property-read int|null $whitelabel_images_count
* @method static \Illuminate\Database\Eloquent\Builder|Product whereExcludeStatsSales($value)
* @method static \Illuminate\Database\Eloquent\Builder|Product whereWhitelabel($value)
* @method static \Illuminate\Database\Eloquent\Builder|Product whereWhitelabelName($value)
* @mixin \Eloquent
*/
class Product extends Model
{
@ -155,10 +165,12 @@ class Product extends Model
'wp_number' => 'int',
'single_commission' => 'bool',
'amount_commission' => 'bool',
'exclude_stats_sales' => 'bool',
'active' => 'bool',
'shipping_addon' => 'bool',
'max_buy' => 'bool',
'max_buy_num' => 'int'
'max_buy_num' => 'int',
'whitelabel' => 'bool',
];
use Sluggable;
@ -168,6 +180,8 @@ class Product extends Model
protected $fillable = [
'name',
'whitelabel',
'whitelabel_name',
'title',
'copy',
'short_copy',
@ -195,12 +209,14 @@ class Product extends Model
'amount_commission',
'value_commission',
'partner_commission',
'exclude_stats_sales',
'identifier',
'action',
'upgrade_to_id',
'shipping_addon',
'max_buy',
'max_buy_num'
];
public $identifiers_types = [
@ -219,9 +235,6 @@ class Product extends Model
4 => 'KG',
];
public $actions = [
0 => 'payment_for_account',
1 => 'charging_credits',
@ -231,7 +244,7 @@ class Product extends Model
];
public function sluggable()
public function sluggable(): array
{
return [
'slug' => [
@ -241,19 +254,28 @@ class Product extends Model
}
public function attributes(){
return $this->hasMany('App\Models\ProductAttribute', 'product_id', 'id');
return $this->hasMany(ProductAttribute::class, 'product_id', 'id')->where('type_id','!=', 1);
}
public function attribute_variants(){
return $this->hasMany(ProductAttribute::class, 'product_id', 'id')->where('type_id','=', 1);
}
public function categories(){
return $this->hasMany('App\Models\ProductCategory', 'product_id', 'id');
}
public function images(){
return $this->hasMany('App\Models\ProductImage', 'product_id', 'id')->orderBy('pos');
return $this->hasMany(ProductImage::class, 'product_id', 'id')->where('type','=', 'product')->orderBy('pos');
}
public function imagesActive(){
return $this->hasMany('App\Models\ProductImage', 'product_id', 'id')->where('active', true)->orderBy('pos');
return $this->hasMany(ProductImage::class, 'product_id', 'id')->where('type','=', 'product')->where('active', true)->orderBy('pos');
}
public function whitelabel_images(){
return $this->hasMany(ProductImage::class, 'product_id', 'id')->where('type','=', 'wllogo')->orderBy('pos');
}
public function country_prices()
@ -291,6 +313,11 @@ class Product extends Model
}
return false;
}
public function getWhiteLableName($id = 0){
return $this->whitelabel_name ? $this->whitelabel_name : $this->name;
}
public function _format_number($value){
return preg_replace("/[^0-9,]/", "", $value);
}
@ -330,9 +357,9 @@ class Product extends Model
return isset($this->attributes['price_ek']) ? Util::formatNumber($this->attributes['price_ek']) : "";
}
public function getFormattedTax()
public function getFormattedTax($country = null)
{
return isset($this->attributes['tax']) ? Util::formatNumber($this->attributes['tax'], 0) : "";
return isset($this->attributes['tax']) ? Util::formatNumber($this->getTaxWith($country), 0) : "";
}
public function getFormattedPriceOld()
@ -362,24 +389,38 @@ class Product extends Model
return $price;
}
/*price net*/
private function calcPriceNet($price){
$tax_rate = ($this->attributes['tax'] + 100) / 100;
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){
$price = $this->attributes['price'];
$price = $net ? $this->calcPriceNet($price) : $price;
public function getPriceWith(Bool $net = true, Bool $ufactor = true, $country = null, $commission=false){
$price = isset($this->attributes['price']) ? $this->attributes['price'] : null;
/*$cprice = $country ? $this->getCPrice($country) : null; //eigener Preis für Land
$price = $cprice ? $cprice : $price; */
$price = $net ? $this->calcPriceNet($price, $country) : $price;
$price = $ufactor ? $this->calcPriceUserFactor($price) : $price;
$price = $commission ? $this->calcPriceUserCommission($price) : $price;
return round($price, 2);
}
/*out*/
public function getFormattedPriceWith(Bool $net = true, Bool $ufactor = true)
{
return isset($this->attributes['price']) ? Util::formatNumber($this->getPriceWith($net, $ufactor)) : "";
}
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 getBasePriceFormattedFull(){
if($price = $this->getBasePrice()){
@ -424,14 +465,14 @@ class Product extends Model
return isset(Type::$showATs[$this->show_at]) ? Type::$showATs[$this->show_at] : '-';
}
public function getShowOnTypes(){
public function getShowOnTypes($seperator = false){
$ret = [];
if($this->show_on && is_array($this->show_on)){
foreach($this->show_on as $show){
$ret[] = isset(Type::$showONs[$show]) ? Type::$showONs[$show] : '-';
}
}
return $ret;
return $seperator ? implode($seperator, $ret) : $ret;
}
@ -493,5 +534,15 @@ class Product extends Model
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

@ -1,44 +1,66 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\ProductAttribute
* Class 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)
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Attribute $attribute
* @property Product $product
* @package App\Models
* @property int $type_id
* @property-read \App\Models\AttributeType $attribute_type
* @method static \Illuminate\Database\Eloquent\Builder|ProductAttribute newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ProductAttribute newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ProductAttribute query()
* @method static \Illuminate\Database\Eloquent\Builder|ProductAttribute whereAttributeId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProductAttribute whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProductAttribute whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProductAttribute whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProductAttribute whereTypeId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProductAttribute whereUpdatedAt($value)
* @mixin \Eloquent
* @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()
*/
class ProductAttribute extends Model
{
protected $table = 'product_attributes';
protected $table = 'product_attributes';
protected $fillable = [
'product_id', 'attribute_id',
];
protected $casts = [
'product_id' => 'int',
'type_id' => 'int',
'attribute_id' => 'int'
];
public function product()
{
return $this->belongsTo('App\Models\Product', 'product_id');
}
protected $fillable = [
'product_id',
'type_id',
'attribute_id'
];
public function attribute()
{
return $this->belongsTo('App\Models\Attribute', 'attribute_id');
}
public function attribute()
{
return $this->belongsTo(Attribute::class);
}
public function attribute_type()
{
return $this->belongsTo(AttributeType::class);
}
public function product()
{
return $this->belongsTo(Product::class);
}
}

View file

@ -20,10 +20,14 @@ use Illuminate\Database\Eloquent\Model;
* @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)
* @mixin \Eloquent
* @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
* @property array|null $show_on
* @method static \Illuminate\Database\Eloquent\Builder|ProductCategory wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProductCategory whereShowOn($value)
* @mixin \Eloquent
*/
class ProductCategory extends Model
{
@ -47,14 +51,14 @@ class ProductCategory extends Model
return $this->belongsTo('App\Models\Category', 'category_id');
}
public function getShowOnTypes(){
public function getShowOnTypes($seperator = false){
$ret = [];
if($this->show_on && is_array($this->show_on)){
foreach($this->show_on as $show){
$ret[] = isset(Type::$showONs[$show]) ? Type::$showONs[$show] : '-';
}
}
return $ret;
return $seperator ? implode($seperator, $ret) : $ret;
}
}

View file

@ -29,7 +29,6 @@ use Illuminate\Database\Eloquent\Model;
* @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)
* @mixin \Eloquent
* @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)
@ -39,6 +38,14 @@ use Illuminate\Database\Eloquent\Model;
* @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)
* @property int|null $user_wl_product_id
* @property string|null $type
* @property object|null $attributes
* @property-read \App\Models\UserWhitelabelProduct|null $user_wl_product
* @method static \Illuminate\Database\Eloquent\Builder|ProductImage whereAttributes($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProductImage whereType($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProductImage whereUserWlProductId($value)
* @mixin \Eloquent
*/
class ProductImage extends Model
{
@ -47,11 +54,15 @@ class ProductImage extends Model
protected $table = 'product_images';
protected $fillable = [
'product_id', 'filename', 'original_name', 'ext', 'mine', 'size'
protected $casts = [
'attributes' => 'object'
];
public function sluggable()
protected $fillable = [
'product_id', 'user_wl_product_id', 'type', 'filename', 'original_name', 'ext', 'mine', 'size', 'attributes'
];
public function sluggable(): array
{
return [
'slug' => [
@ -65,6 +76,11 @@ class ProductImage extends Model
return $this->belongsTo('App\Models\Product', 'product_id');
}
public function user_wl_product()
{
return $this->belongsTo('App\Models\UserWhitelabelProduct', 'user_wl_product_id');
}
public function formatBytes($precision = 2)
{
$size = $this->size;
@ -80,4 +96,23 @@ class ProductImage extends Model
}
}
public function getImagePath()
{
if($this->type === 'uwllogo'){
return '/images/user_product/'.$this->user_wl_product_id .'/'.$this->filename;
}
if($this->type === 'product'){
return '/images/product/'.$this->product_id .'/'.$this->filename;
}
if($this->type === 'wllogo'){
return '/images/product/'.$this->product_id .'/'.$this->filename;
}
return '/images/product/'.$this->product_id .'/'.$this->filename;
}
public function getBaseImagePath(){
return base_path()."/storage/app/public".$this->getImagePath();
}
}

View file

@ -44,7 +44,6 @@ use Illuminate\Database\Eloquent\Collection;
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin whereTo($value)
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin whereUpdatedAt($value)
* @mixin \Eloquent
* @property int|null $type
* @property bool $shop
* @property-read Collection|\App\Models\PromotionAdminProduct[] $promotion_admin_products
@ -57,6 +56,7 @@ use Illuminate\Database\Eloquent\Collection;
* @property string|null $user_about
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin whereUserAbout($value)
* @method static \Illuminate\Database\Eloquent\Builder|PromotionAdmin whereUserDescription($value)
* @mixin \Eloquent
*/
class PromotionAdmin extends Model
{

View file

@ -44,7 +44,6 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser whereUrl($value)
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser whereUsedBudgetTotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser whereUserDeletedAt($value)
* @mixin \Eloquent
* @property int $user_id
* @property string|null $user_address
* @property-read Collection|\App\Models\PromotionUserProduct[] $promotion_user_products
@ -60,6 +59,9 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser whereAboutYou($value)
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser whereInternalDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUser whereInternalName($value)
* @property-read Collection<int, \App\Models\PromotionUserOrder> $promotion_user_orders
* @property-read int|null $promotion_user_orders_count
* @mixin \Eloquent
*/
class PromotionUser extends Model
{
@ -71,7 +73,7 @@ class PromotionUser extends Model
'pick_up' => 'bool',
'used_budget_total' => 'float',
'sell_items_total' => 'int',
'active' => 'bool'
'active' => 'bool',
];
protected $dates = [
@ -132,7 +134,6 @@ class PromotionUser extends Model
}
public function getUrlPreview()
{
return $this->url ? config('app.promo_url')."/".$this->url : "";

View file

@ -53,6 +53,8 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUserOrder whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUserOrder whereTaxRate($value)
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUserOrder whereUpdatedAt($value)
* @property bool|null $pick_up
* @method static \Illuminate\Database\Eloquent\Builder|PromotionUserOrder wherePickUp($value)
* @mixin \Eloquent
*/
class PromotionUserOrder extends Model

View file

@ -43,10 +43,10 @@ use Illuminate\Database\Eloquent\Model;
* @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
* @property int|null $int
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereInt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Setting withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
* @mixin \Eloquent
*/
class Setting extends Model
{
@ -84,7 +84,7 @@ class Setting extends Model
];
public function sluggable()
public function sluggable(): array
{
return [
'slug' => [

View file

@ -28,9 +28,9 @@ use Illuminate\Database\Eloquent\Model;
* @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)
* @mixin \Eloquent
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShippingPrice[] $shipping_prices
* @property-read int|null $shipping_prices_count
* @mixin \Eloquent
*/
class Shipping extends Model
{

View file

@ -22,9 +22,9 @@ use Illuminate\Database\Eloquent\Model;
* @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)
* @mixin \Eloquent
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShoppingOrder[] $shopping_orders
* @property-read int|null $shopping_orders_count
* @mixin \Eloquent
*/
class ShippingCountry extends Model
{

View file

@ -34,7 +34,6 @@ use Illuminate\Database\Eloquent\Model;
* @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)
* @mixin \Eloquent
* @property-write mixed $tax
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereTaxRate($value)
* @property float|null $price_comp
@ -43,6 +42,7 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice wherePriceComp($value)
* @property int|null $shipping_for
* @method static \Illuminate\Database\Eloquent\Builder|ShippingPrice whereShippingFor($value)
* @mixin \Eloquent
*/
class ShippingPrice extends Model
{
@ -54,7 +54,8 @@ class ShippingPrice extends Model
public static $shippingForTypes = [
1 => 'Berater Bestellungen',
2 => 'Shop Bestellungen',
2 => 'Promotion Bestellungen',
3 => 'Shop Bestellungen',
];
public function shipping()

View file

@ -51,7 +51,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @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)
* @mixin \Eloquent
* @property int|null $payment_for
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder wherePaymentFor($value)
* @property int|null $member_id
@ -104,6 +103,9 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property-read \App\Models\PromotionUser|null $promotion_user
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder wherePromotionUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereShippingOption($value)
* @property array|null $delivery
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereDelivery($value)
* @mixin \Eloquent
*/
class ShoppingOrder extends Model
{
@ -116,10 +118,10 @@ class ShoppingOrder extends Model
'shopping_user_id',
'auth_user_id',
'promotion_user_id',
'user_shop_id',
'member_id',
'payment_for',
'country_id',
'user_shop_id',
'total',
'subtotal_full',
'discount',
@ -135,6 +137,7 @@ class ShoppingOrder extends Model
'weight',
'paid',
'invoice',
'delivery',
'invoice_number',
'txaction',
'wp_invoice_path',
@ -149,6 +152,7 @@ class ShoppingOrder extends Model
protected $casts = [
'wp_notice' => 'array',
'invoice' => 'array',
'delivery' => 'array',
'shipped_at' => 'datetime',
];
@ -196,10 +200,10 @@ class ShoppingOrder extends Model
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 => 'pick_up', //(Fullfilment durch MIVITA: Versand erfolgt)',
1 => 'process', //(Fullfilment: nicht Versand)
2 => 'sent', //(Fullfilment: Versand erfolgt)'
3 => 'close', //(Fullfilment: Versand erfolgt)',
4 => 'pick_up', //(Fullfilment: Versand erfolgt)',
10 => 'cancel'
];
@ -232,6 +236,11 @@ class ShoppingOrder extends Model
return $this->belongsTo('App\Models\PromotionUser','promotion_user_id');
}
public function user_shop()
{
return $this->belongsTo('App\Models\UserShop','user_shop_id');
}
//can null
public function member()
{
@ -367,6 +376,11 @@ class ShoppingOrder extends Model
}
return $count;
}
public function isInvoice(){
return $this->user_invoice ? true : false;
}
public function isPickUp(){
return $this->shipping_option === 'pick_up' ? true : false;
}

View file

@ -31,7 +31,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @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)
* @mixin \Eloquent
* @property float|null $tax_rate
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property string|null $user_deleted_at
@ -48,6 +47,9 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property int|null $free_product_id
* @property-read \App\Models\PromotionUserProduct|null $promotion_user_product
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderItem whereFreeProductId($value)
* @property bool|null $handle
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderItem whereHandle($value)
* @mixin \Eloquent
*/
class ShoppingOrderItem extends Model
{

View file

@ -51,7 +51,6 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereUserId($value)
* @mixin \Eloquent
* @property \Illuminate\Support\Carbon|null $partner_commission_pending_to
* @property bool|null $partner_commission_paid
* @property-read User|null $m_sponsor
@ -59,6 +58,7 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin wherePartnerCommissionPendingTo($value)
* @property int|null $user_credit_id
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereUserCreditId($value)
* @mixin \Eloquent
*/
class ShoppingOrderMargin extends Model
{
@ -73,10 +73,13 @@ class ShoppingOrderMargin extends Model
'from_payment_credit' => 'float',
'm_sponsor_id' => 'int',
'net_partner_commission' => 'float',
'paid' => 'bool',
'cancellation' => 'bool',
'status' => 'int',
'partner_commission_pending_to' => 'datetime',
'order_paid' => 'bool', //ist die Bestellung bezahlt?
'out_paid' => 'bool', //ist die Provision Marge ausgezahlt?
'cancellation' => 'bool', //ist die Stornierung beantragt?
'status' => 'int', //status der Bestellung
'margin_pending_to' => 'datetime',
'margin_paid' => 'bool',
'partner_commission_pending_to' => 'datetime',
'partner_commission_paid' => 'bool',
'user_credit_id' => 'int',
];
@ -95,15 +98,29 @@ class ShoppingOrderMargin extends Model
'm_sponsor_id',
'net_partner_commission',
'from',
'paid',
'order_paid',
'out_paid',
'cancellation',
'status',
'margin_pending_to',
'margin_paid',
'partner_commission_pending_to',
'partner_commission_paid',
'user_credit_id',
'content'
];
public static $statusTypes = [
0 => 'user order',
1 => '',
7 => 'from promotion',
8 => 'from shop',
9 => 'storniert'
];
private $storedContent;
public function user()
{
return $this->belongsTo(User::class, 'user_id');
@ -131,4 +148,33 @@ class ShoppingOrderMargin extends Model
}
return false;
}
public function getFormattedNetDiscount()
{
return formatNumber($this->attributes['net_discount']);
}
public function getFormattedNetPartnerCommission()
{
return formatNumber($this->attributes['net_partner_commission']);
}
public function getRestoreContent($key = false)
{
if(!$this->storedContent){
$this->storedContent = unserialize($this->attributes['content']);
}
if (is_array($this->storedContent)) {
switch ($key) {
case 'items':
return $this->storedContent['items'];
break;
case 'commission':
return $this->storedContent['commission'];
break;
}
return $this->storedContent;
}
}
}

View file

@ -38,9 +38,9 @@ use Illuminate\Database\Eloquent\Model;
* @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)
* @mixin \Eloquent
* @property string|null $mode
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereMode($value)
* @mixin \Eloquent
*/
class ShoppingPayment extends Model
{

View file

@ -69,7 +69,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @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)
* @mixin \Eloquent
* @property int|null $orders
* @property-read \App\Models\ShoppingOrder $shopping_order
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShoppingOrder[] $shopping_orders
@ -113,6 +112,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @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)
* @mixin \Eloquent
*/
class ShoppingUser extends Model
{
@ -274,7 +274,7 @@ class ShoppingUser extends Model
}
return 0;
case 'shopping':
return $this->is_for === 'pr' ? 7 : 8; //7 Promotion
return $this->is_for === 'pr' ? 7 : 8; //7 Promotion //8 Shop
case 'extern':
return 10;
}

View file

@ -36,8 +36,8 @@ use Illuminate\Database\Eloquent\Model;
* @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)
* @mixin \Eloquent
* @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
{
@ -63,7 +63,7 @@ class SySetting extends Model
1 => 'default',
];
public function sluggable()
public function sluggable(): array
{
return [
'slug' => [

View file

@ -26,7 +26,6 @@ use Carbon\Carbon;
* @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()
* @mixin \Eloquent
* @property int $id
* @property string|null $salutation
* @property string|null $first_name
@ -121,6 +120,13 @@ use Carbon\Carbon;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereNotice($value)
* @property string|null $about_you
* @method static \Illuminate\Database\Eloquent\Builder|UserAccount whereAboutYou($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)
* @mixin \Eloquent
*/
class UserAccount extends Model
{
@ -196,6 +202,12 @@ class UserAccount extends Model
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 getPaymentData($key)
{
return isset($this->payment_data[$key]) ? $this->payment_data[$key] : '';

View file

@ -44,13 +44,13 @@ use Illuminate\Database\Eloquent\Model;
* @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 whereUserMargins($value)
* @mixin \Eloquent
* @property string|null $credit_number
* @property string|null $date
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereCreditNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereDate($value)
* @property object|null $user_credits
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereUserCredits($value)
* @mixin \Eloquent
*/
class UserCredit extends Model
{

View file

@ -6,6 +6,7 @@
namespace App\Models;
use App\Services\Util;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
@ -33,9 +34,9 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin whereUserId($value)
* @mixin \Eloquent
* @property int|null $user_credit_id
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin whereUserCreditId($value)
* @mixin \Eloquent
*/
class UserCreditMargin extends Model
{
@ -75,4 +76,8 @@ class UserCreditMargin extends Model
}
return false;
}
public function getFormattedCredit(){
return Util::formatNumber($this->credit);
}
}

View file

@ -38,11 +38,11 @@ use App\User;
* @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)
* @mixin \Eloquent
* @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)
* @mixin \Eloquent
*/
class UserHistory extends Model
{

View file

@ -26,7 +26,6 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereTransName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereUpdatedAt($value)
* @mixin \Eloquent
* @property string|null $content
* @property array|null $trans_content
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereContent($value)
@ -37,6 +36,9 @@ use Illuminate\Database\Eloquent\Model;
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserLevelMargin[] $user_level_margins_re
* @property-read int|null $user_level_margins_re_count
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePartnerProvision($value)
* @property bool $payment_year
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePaymentYear($value)
* @mixin \Eloquent
*/
class UserLevel extends Model
{

View file

@ -0,0 +1,45 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class UserRegister
*
* @property string $identifier
* @property string $instance
* @property string $content
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|UserRegister newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserRegister newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserRegister query()
* @method static \Illuminate\Database\Eloquent\Builder|UserRegister whereContent($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserRegister whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserRegister whereIdentifier($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserRegister whereInstance($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserRegister whereUpdatedAt($value)
* @mixin \Eloquent
*/
class UserRegister extends Model
{
protected $table = 'user_registers';
public $incrementing = false;
protected $casts = [
'content' => 'object'
];
protected $fillable = [
'identifier', 'instance', 'content'
];
}

132
app/Models/UserShop.php Normal file
View file

@ -0,0 +1,132 @@
<?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 UserShop
*
* @property int $id
* @property int $user_id
* @property string|null $url
* @property string|null $name
* @property string|null $description
* @property string|null $about_you
* @property string|null $user_address
* @property string|null $trans
* @property bool $pick_up
* @property bool $active
* @property Carbon|null $active_date
* @property string|null $featured
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string|null $deleted_at
* @property User $user
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|UserShop newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserShop newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserShop onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|UserShop query()
* @method static \Illuminate\Database\Eloquent\Builder|UserShop whereAboutYou($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserShop whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserShop whereActiveDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserShop whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserShop whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserShop whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserShop whereFeatured($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserShop whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserShop whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserShop wherePickUp($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserShop whereTrans($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserShop whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserShop whereUrl($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserShop whereUserAddress($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserShop whereUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserShop withTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|UserShop withoutTrashed()
* @mixin \Eloquent
*/
class UserShop extends Model
{
use SoftDeletes;
protected $table = 'user_shops';
protected $casts = [
'user_id' => 'int',
'pick_up' => 'bool',
'active' => 'bool',
'featured' => 'array',
'trans' => 'array',
];
protected $dates = [
'active_date'
];
protected $fillable = [
'user_id',
'url',
'name',
'description',
'about_you',
'user_address',
'trans',
'pick_up',
'active',
'active_date',
'featured'
];
public function user()
{
return $this->belongsTo(User::class);
}
public function getUrlPreview()
{
return $this->url ? config('app.shop_url')."/".$this->url : "";
}
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 isActive(){
if($this->active){
return true;
}
return false;
}
public function getSubdomain(){
return "";
}
}

View file

@ -8,7 +8,6 @@ use Illuminate\Database\Eloquent\Model;
* App\Models\UserUpdateEmail
*
* @property-read \App\User $user
* @mixin \Eloquent
* @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()
@ -20,6 +19,7 @@ use Illuminate\Database\Eloquent\Model;
* @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
{

View file

@ -0,0 +1,79 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use App\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class UserWhitelabelProduct
*
* @property int $id
* @property int $user_id
* @property int $product_id
* @property string|null $info
* @property string|null $attributes
* @property string|null $options
* @property bool $active
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Product $product
* @property User $user
* @package App\Models
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ProductImage> $whitelabel_images
* @property-read int|null $whitelabel_images_count
* @method static \Illuminate\Database\Eloquent\Builder|UserWhitelabelProduct newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserWhitelabelProduct newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|UserWhitelabelProduct query()
* @method static \Illuminate\Database\Eloquent\Builder|UserWhitelabelProduct whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserWhitelabelProduct whereAttributes($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserWhitelabelProduct whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserWhitelabelProduct whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserWhitelabelProduct whereInfo($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserWhitelabelProduct whereOptions($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserWhitelabelProduct whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserWhitelabelProduct whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|UserWhitelabelProduct whereUserId($value)
* @mixin \Eloquent
*/
class UserWhitelabelProduct extends Model
{
protected $table = 'user_whitelabel_products';
protected $casts = [
'user_id' => 'int',
'product_id' => 'int',
'active' => 'bool',
'attributes' => 'object',
'options' => 'object'
];
protected $fillable = [
'user_id',
'product_id',
'info',
'attributes',
'options',
'active'
];
public function product()
{
return $this->belongsTo(Product::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
public function whitelabel_images(){
return $this->hasMany(ProductImage::class, 'user_wl_product_id', 'id')->where('type','=', 'uwllogo')->orderBy('pos');
}
}