User Order step1

This commit is contained in:
Kevin Adametz 2020-08-07 16:02:03 +02:00
parent eb55b01b0d
commit a5db985ae8
90 changed files with 6439 additions and 421 deletions

71
app/Models/Logger.php Normal file
View file

@ -0,0 +1,71 @@
<?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
*/
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,77 @@
<?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)
* @mixin \Eloquent
*/
class PaymentMethod extends Model
{
protected $table = 'payment_methods';
protected $casts = [
'show_at' => 'int',
'pos' => 'int',
'active' => 'bool',
'default' => 'bool',
];
protected $fillable = [
'name',
'short',
'show_at',
'pos',
'default',
'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 function getShowAtType(){
return isset(self::$showATs[$this->show_at]) ? self::$showATs[$this->show_at] : '-';
}
public static function getDefaultAsArray(){
return PaymentMethod::where('active', true)->where('default', true)->pluck('id');
}
}

View file

@ -103,6 +103,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @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)
*/
class Product extends Model
{
@ -124,7 +126,9 @@ class Product extends Model
'trans_usage' => 'array',
'trans_ingredients' => 'array',
'action' => 'array',
'wp_number' => 'int'
'wp_number' => 'int',
'shipping_addon' => 'bool',
'active' => 'bool'
];
use Sluggable;
@ -155,6 +159,7 @@ class Product extends Model
'amount',
'active',
'show_at',
'shipping_addon',
'identifier',
'action',
'upgrade_to_id'
@ -235,20 +240,20 @@ class Product extends Model
}
public function setPriceAttribute( $value ) {
$value = $this->_format_number($value);
$this->attributes['price'] = floatval(str_replace(',', '.', $value));
$this->attributes['price'] = $value ? Util::reFormatNumber($value) : null;
}
public function setPriceEkAttribute( $value ) {
$value = $this->_format_number($value);
$this->attributes['price_ek'] = floatval(str_replace(',', '.', $value));
$this->attributes['price_ek'] = $value ? Util::reFormatNumber($value) : null;
}
public function setTaxAttribute( $value ) {
$value = $this->_format_number($value);
$this->attributes['tax'] = floatval(str_replace(',', '.', $value));
$this->attributes['tax'] = $value ? Util::reFormatNumber($value) : null;
}
public function setPriceOldAttribute( $value ) {
$value = $this->_format_number($value);
$this->attributes['price_old'] = floatval(str_replace(',', '.', $value));
$this->attributes['price_old'] = $value ? Util::reFormatNumber($value) : null;
}
public function getFormattedPrice()
@ -271,6 +276,34 @@ class Product extends Model
return isset($this->attributes['price_old']) ? Util::formatNumber($this->attributes['price_old']) : "";
}
/*price by user Factor*/
private function calcPriceUserFactor($price){
if(\Auth::user() && \Auth::user()->user_level){
$margin = ((\Auth::user()->user_level->margin -100)*-1) / 100;
$price = $price * $margin;
}
return $price;
}
/*price net*/
private function calcPriceNet($price){
$tax_rate = ($this->attributes['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;
$price = $ufactor ? $this->calcPriceUserFactor($price) : $price;
return $price;
}
/*out*/
public function getFormattedPriceWith(Bool $net = true, Bool $ufactor = true)
{
return isset($this->attributes['price']) ? Util::formatNumber($this->getPriceWith($net, $ufactor)) : "";
}
public function getBasePriceFormattedFull(){
if($price = $this->getBasePrice()){
$unit = $this->attributes['unit'];
@ -310,6 +343,10 @@ class Product extends Model
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 setPosAttribute($value){
$this->attributes['pos'] = is_numeric($value) ? $value : null;

View file

@ -29,6 +29,8 @@ use Illuminate\Database\Eloquent\Model;
* @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
*/
class Shipping extends Model
{

View file

@ -2,6 +2,7 @@
namespace App\Models;
use App\Services\Util;
use Illuminate\Database\Eloquent\Model;
/**
@ -34,13 +35,15 @@ use Illuminate\Database\Eloquent\Model;
* @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)
*/
class ShippingPrice extends Model
{
protected $table = 'shipping_prices';
protected $fillable = [
'shipping_id', 'price', 'tax_rate', 'factor', 'total_from', 'total_to', 'weight_from', 'weight_to',
'shipping_id', 'price', 'price_comp', 'tax_rate', 'factor', 'total_from', 'total_to', 'weight_from', 'weight_to',
];
public function shipping()
@ -49,115 +52,65 @@ class ShippingPrice extends Model
}
public function _format_number($value)
{
return preg_replace("/[^0-9,]/", "", $value);
}
public function setPriceAttribute($value)
{
$value = $this->_format_number($value);
$this->attributes['price'] = floatval(str_replace(',', '.', $value));
$this->attributes['price'] = $value ? Util::reFormatNumber($value) : null;
}
public function setPriceCompAttribute($value)
{
$this->attributes['price_comp'] = $value ? Util::reFormatNumber($value) : null;
}
public function setFactorAttribute($value)
{
$value = $this->_format_number($value);
if ($value == "") {
$this->attributes['factor'] = null;
} else {
$this->attributes['factor'] = floatval(str_replace(',', '.', $value));
}
$this->attributes['factor'] = $value ? Util::reFormatNumber($value) : null;
}
public function setTaxAttribute($value)
{
$value = $this->_format_number($value);
if ($value == "") {
$this->attributes['tax_rate'] = null;
} else {
$this->attributes['tax_rate'] = floatval(str_replace(',', '.', $value));
}
$this->attributes['tax_rate'] = $value ? Util::reFormatNumber($value) : null;
}
public function setTotalFromAttribute($value)
{
$value = $this->_format_number($value);
if ($value == "") {
$this->attributes['total_from'] = null;
} else {
$this->attributes['total_from'] = floatval(str_replace(',', '.', $value));
}
$this->attributes['total_from'] = $value ? Util::reFormatNumber($value) : null;
}
public function setTotalToAttribute($value)
{
$value = $this->_format_number($value);
if ($value == "") {
$this->attributes['total_to'] = null;
} else {
$this->attributes['total_to'] = floatval(str_replace(',', '.', $value));
}
$this->attributes['total_to'] = $value ? Util::reFormatNumber($value) : null;
}
public function getFormattedPrice()
{
if ($this->attributes['price'] === NULL) {
return $this->attributes['price'];
}
if (\App::getLocale() == "en") {
return number_format($this->attributes['price'], 2, '.', ',');
}
return number_format($this->attributes['price'], 2, ',', '.');
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()
{
if ($this->attributes['tax_rate'] === NULL) {
return $this->attributes['tax_rate'];
}
if (\App::getLocale() == "en") {
return number_format($this->attributes['tax_rate'], 2, '.', ',');
}
return number_format($this->attributes['tax_rate'], 2, ',', '.');
return isset($this->attributes['tax_rate']) ? Util::formatNumber($this->attributes['tax_rate']) : "";
}
public function getFormattedFactor()
{
if ($this->attributes['factor'] === NULL) {
return $this->attributes['factor'];
}
if (\App::getLocale() == "en") {
return number_format($this->attributes['factor'], 2, '.', ',');
}
return number_format($this->attributes['factor'], 2, ',', '.');
return isset($this->attributes['factor']) ? Util::formatNumber($this->attributes['factor']) : "";
}
public function getFormatTotalFrom()
{
if ($this->attributes['total_from'] === NULL) {
return $this->attributes['total_from'];
}
if (\App::getLocale() == "en") {
return number_format($this->attributes['total_from'], 2, '.', ',');
}
return number_format($this->attributes['total_from'], 2, ',', '.');
return isset($this->attributes['total_from']) ? Util::formatNumber($this->attributes['total_from']) : "";
}
public function getFormattedTotalTo()
{
if ($this->attributes['total_to'] === NULL) {
return $this->attributes['total_to'];
}
if (\App::getLocale() == "en") {
return number_format($this->attributes['total_to'], 2, '.', ',');
}
return number_format($this->attributes['total_to'], 2, ',', '.');
return isset($this->attributes['total_to']) ? Util::formatNumber($this->attributes['total_to']) : "";
}

View file

@ -67,6 +67,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @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
*/
class ShoppingOrder extends Model
{
@ -90,6 +91,7 @@ class ShoppingOrder extends Model
'weight',
'paid',
'txaction',
'wp_invoice_path',
'mode',
];
@ -101,7 +103,7 @@ class ShoppingOrder extends Model
public function country()
{
return $this->belongsTo('App\Models\Sh','country_id');
return $this->belongsTo('App\Models\ShippingCountry','country_id');
}
public function shipping_country()

View file

@ -32,6 +32,15 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @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
* @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()
*/
class ShoppingOrderItem extends Model
{

View file

@ -101,6 +101,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @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)
*/
class ShoppingUser extends Model
{

64
app/Models/SySetting.php Normal file
View file

@ -0,0 +1,64 @@
<?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
*/
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()
{
return [
'slug' => [
'source' => 'name'
]
];
}
public function getStatusType(){
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
}
}