first commit
This commit is contained in:
commit
0baac018a2
1011 changed files with 145854 additions and 0 deletions
91
app/Models/Attribute.php
Normal file
91
app/Models/Attribute.php
Normal 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)
|
||||
* @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
|
||||
*/
|
||||
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, ', ');
|
||||
}
|
||||
|
||||
}
|
||||
135
app/Models/Category.php
Normal file
135
app/Models/Category.php
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
<?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)
|
||||
* @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)
|
||||
* @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
|
||||
*/
|
||||
class Category extends Model
|
||||
{
|
||||
use Sluggable;
|
||||
|
||||
protected $table = 'categories';
|
||||
|
||||
protected $casts = ['trans_name' => 'array', 'trans_headline' => 'array'];
|
||||
|
||||
protected $fillable = [
|
||||
'parent_id', 'name', 'headline', 'pos', 'active',
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
{
|
||||
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');
|
||||
|
||||
}
|
||||
|
||||
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 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 getTranNames()
|
||||
{
|
||||
$ret = "";
|
||||
foreach ((array) $this->trans_name as $value){
|
||||
$ret .= $value.', ';
|
||||
}
|
||||
return rtrim($ret, ', ');
|
||||
}
|
||||
|
||||
public function getTranHeadlines()
|
||||
{
|
||||
$ret = "";
|
||||
foreach ((array) $this->trans_headline as $value){
|
||||
$ret .= $value.', ';
|
||||
}
|
||||
return rtrim($ret, ', ');
|
||||
}
|
||||
|
||||
}
|
||||
169
app/Models/Country.php
Normal file
169
app/Models/Country.php
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
<?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)
|
||||
* @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()
|
||||
* @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 string|null $trans_name
|
||||
* @property array|null $attr
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereAttr($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereTransName($value)
|
||||
* @property bool|null $switch
|
||||
* @property bool|null $own_eur
|
||||
* @property bool|null $currency
|
||||
* @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)
|
||||
*/
|
||||
class Country extends Model
|
||||
{
|
||||
protected $table = 'countries';
|
||||
|
||||
protected $casts = [
|
||||
'switch' => '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',
|
||||
];
|
||||
|
||||
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
|
||||
|
||||
if($val = $this->getTrans('name', $lang)){
|
||||
return $val;
|
||||
}
|
||||
return $this->de;
|
||||
}
|
||||
|
||||
public function getTrans($key, $lang)
|
||||
{
|
||||
$key = 'trans_' . $key;
|
||||
if (!empty($this->{$key}[$lang])) {
|
||||
return $this->{$key}[$lang];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public function getAttrByKey($key)
|
||||
{
|
||||
$name = 'attr';
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
73
app/Models/CountryPrice.php
Normal file
73
app/Models/CountryPrice.php
Normal 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)
|
||||
* @mixin \Eloquent
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereCCurrency($value)
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
84
app/Models/File.php
Normal file
84
app/Models/File.php
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
66
app/Models/Import.php
Normal file
66
app/Models/Import.php
Normal 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();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
80
app/Models/Ingredient.php
Normal file
80
app/Models/Ingredient.php
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
<?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)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Ingredient extends Model
|
||||
{
|
||||
protected $table = 'ingredients';
|
||||
|
||||
protected $casts = [
|
||||
'active' => 'bool',
|
||||
'pos' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'trans_name',
|
||||
'inci',
|
||||
'trans_inci',
|
||||
'effect',
|
||||
'trans_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');
|
||||
|
||||
}
|
||||
}
|
||||
77
app/Models/IqImage.php
Normal file
77
app/Models/IqImage.php
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
<?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)
|
||||
* @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)
|
||||
* @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)
|
||||
*/
|
||||
class IqImage extends Model
|
||||
{
|
||||
use Sluggable;
|
||||
|
||||
|
||||
protected $table = 'iq_images';
|
||||
|
||||
protected $fillable = [
|
||||
'filename', 'original_name', 'ext', 'mine', 'size'
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
102
app/Models/IqSite.php
Normal file
102
app/Models/IqSite.php
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
<?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){
|
||||
$ret[] = Product::findOrFail($product_id);
|
||||
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getProductSetModels(){
|
||||
$ret = [];
|
||||
foreach($this->set_products as $product_id){
|
||||
$ret[] = Product::findOrFail($product_id);
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
83
app/Models/Logger.php
Normal file
83
app/Models/Logger.php
Normal 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] : "";
|
||||
}
|
||||
|
||||
}
|
||||
77
app/Models/PaymentMethod.php
Normal file
77
app/Models/PaymentMethod.php
Normal 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($short=false){
|
||||
return PaymentMethod::where('active', true)->where('default', true)->pluck('id');
|
||||
}
|
||||
}
|
||||
75
app/Models/PaymentTransaction.php
Normal file
75
app/Models/PaymentTransaction.php
Normal 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)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $mode
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereMode($value)
|
||||
*/
|
||||
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');
|
||||
}
|
||||
}
|
||||
433
app/Models/Product.php
Normal file
433
app/Models/Product.php
Normal file
|
|
@ -0,0 +1,433 @@
|
|||
<?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()
|
||||
* @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)
|
||||
* @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-read \Illuminate\Database\Eloquent\Collection|\App\Models\Ingredient[] $p_ingredients
|
||||
* @property-read int|null $p_ingredients_count
|
||||
*/
|
||||
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',
|
||||
'action' => 'array',
|
||||
'wp_number' => 'int',
|
||||
'shipping_addon' => 'bool',
|
||||
'active' => 'bool'
|
||||
];
|
||||
use Sluggable;
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'title',
|
||||
'copy',
|
||||
'price',
|
||||
'price_ek',
|
||||
'tax',
|
||||
'price_old',
|
||||
'points',
|
||||
'weight',
|
||||
'contents',
|
||||
'contents_total',
|
||||
'unit',
|
||||
'number',
|
||||
'wp_number',
|
||||
'icons',
|
||||
'description',
|
||||
'usage',
|
||||
'ingredients',
|
||||
'pos',
|
||||
'amount',
|
||||
'active',
|
||||
'show_at',
|
||||
'shipping_addon',
|
||||
'identifier',
|
||||
'action',
|
||||
'upgrade_to_id'
|
||||
];
|
||||
|
||||
public $identifiers_types = [
|
||||
'' => '-',
|
||||
'show_upgrade' => 'Kann geupdatet werden',
|
||||
'show_order' => 'Wird immer als Option angezeigt',
|
||||
'upgrade' => 'Produktupgrade zur Produkt ID',
|
||||
'upgrade_member' => 'Beraterupgrade 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 $actions = [
|
||||
0 => 'payment_for_account',
|
||||
1 => 'payment_for_shop',
|
||||
2 => 'payment_for_shop_upgrade',
|
||||
4 => 'payment_for_lead_upgrade',
|
||||
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
'source' => 'name'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(){
|
||||
return $this->hasMany('App\Models\ProductAttribute', 'product_id', 'id');
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
public function imagesActive(){
|
||||
return $this->hasMany('App\Models\ProductImage', 'product_id', 'id')->where('active', true)->orderBy('pos');
|
||||
}
|
||||
|
||||
public function country_prices()
|
||||
{
|
||||
return $this->hasMany(CountryPrice::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 _format_number($value){
|
||||
return preg_replace("/[^0-9,]/", "", $value);
|
||||
}
|
||||
|
||||
public function setPriceAttribute( $value ) {
|
||||
|
||||
$this->attributes['price'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
public function setPriceEkAttribute( $value ) {
|
||||
|
||||
$this->attributes['price_ek'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
public function setTaxAttribute( $value ) {
|
||||
|
||||
$this->attributes['tax'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
public function setPriceOldAttribute( $value ) {
|
||||
|
||||
$this->attributes['price_old'] = $value ? 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 getFormattedTax()
|
||||
{
|
||||
return isset($this->attributes['tax']) ? Util::formatNumber($this->attributes['tax'], 0) : "";
|
||||
}
|
||||
|
||||
public function getFormattedPriceOld()
|
||||
{
|
||||
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 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 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 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, ', ');
|
||||
}
|
||||
|
||||
public function getCountryPrice($country_id){
|
||||
return $this->country_prices->where('country_id', '=', $country_id)->first() ?: new CountryPrice();
|
||||
}
|
||||
|
||||
public function getCPrice($country_id){
|
||||
return $this->getCountryPrice($country_id)->c_price;
|
||||
}
|
||||
public function getCTax($country_id){
|
||||
return $this->getCountryPrice($country_id)->c_tax;
|
||||
}
|
||||
public function getCPriceOld($country_id){
|
||||
return $this->getCountryPrice($country_id)->c_price_old;
|
||||
}
|
||||
public function getCCurrency($country_id){
|
||||
return $this->getCountryPrice($country_id)->c_currency;
|
||||
}
|
||||
|
||||
public function getRealPrice(Country $country){
|
||||
if($country->own_eur && $this->getCPrice($country->id)){
|
||||
return $this->getCPrice($country->id);
|
||||
}
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
44
app/Models/ProductAttribute.php
Normal file
44
app/Models/ProductAttribute.php
Normal 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)
|
||||
* @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 $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');
|
||||
}
|
||||
}
|
||||
45
app/Models/ProductCategory.php
Normal file
45
app/Models/ProductCategory.php
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?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)
|
||||
* @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()
|
||||
*/
|
||||
class ProductCategory extends Model
|
||||
{
|
||||
protected $table = 'product_categories';
|
||||
|
||||
protected $fillable = [
|
||||
'product_id', 'category_id',
|
||||
];
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Product', 'product_id');
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Category', 'category_id');
|
||||
}
|
||||
|
||||
}
|
||||
82
app/Models/ProductImage.php
Normal file
82
app/Models/ProductImage.php
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
<?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)
|
||||
* @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)
|
||||
* @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)
|
||||
*/
|
||||
class ProductImage extends Model
|
||||
{
|
||||
use Sluggable;
|
||||
|
||||
|
||||
protected $table = 'product_images';
|
||||
|
||||
protected $fillable = [
|
||||
'product_id', 'filename', 'original_name', 'ext', 'mine', 'size'
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
56
app/Models/ProductIngredient.php
Normal file
56
app/Models/ProductIngredient.php
Normal 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');
|
||||
}
|
||||
}
|
||||
81
app/Models/Shipping.php
Normal file
81
app/Models/Shipping.php
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
<?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)
|
||||
* @mixin \Eloquent
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShippingPrice[] $shipping_prices
|
||||
* @property-read int|null $shipping_prices_count
|
||||
*/
|
||||
class Shipping extends Model
|
||||
{
|
||||
protected $table = 'shippings';
|
||||
|
||||
protected $casts = [
|
||||
'trans_name' => 'array',
|
||||
];
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
53
app/Models/ShippingCountry.php
Normal file
53
app/Models/ShippingCountry.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
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)
|
||||
* @mixin \Eloquent
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShoppingOrder[] $shopping_orders
|
||||
* @property-read int|null $shopping_orders_count
|
||||
*/
|
||||
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');
|
||||
}
|
||||
|
||||
}
|
||||
121
app/Models/ShippingPrice.php
Normal file
121
app/Models/ShippingPrice.php
Normal 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)
|
||||
* @mixin \Eloquent
|
||||
* @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)
|
||||
*/
|
||||
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 ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
public function setPriceCompAttribute($value)
|
||||
{
|
||||
$this->attributes['price_comp'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
public function setFactorAttribute($value)
|
||||
{
|
||||
$this->attributes['factor'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
public function setTaxAttribute($value)
|
||||
{
|
||||
$this->attributes['tax_rate'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
public function setTotalFromAttribute($value)
|
||||
{
|
||||
$this->attributes['total_from'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
public function setTotalToAttribute($value)
|
||||
{
|
||||
$this->attributes['total_to'] = $value ? 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']) : "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
273
app/Models/ShoppingOrder.php
Normal file
273
app/Models/ShoppingOrder.php
Normal file
|
|
@ -0,0 +1,273 @@
|
|||
<?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)
|
||||
* @mixin \Eloquent
|
||||
* @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 array|null $wp_notice
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereWpNotice($value)
|
||||
*/
|
||||
class ShoppingOrder extends Model
|
||||
{
|
||||
protected $table = 'shopping_orders';
|
||||
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected $fillable = [
|
||||
'shopping_user_id',
|
||||
'auth_user_id',
|
||||
'member_id',
|
||||
'country_id',
|
||||
'user_shop_id',
|
||||
'total',
|
||||
'subtotal',
|
||||
'shipping',
|
||||
'shipping_net',
|
||||
'subtotal_ws',
|
||||
'tax',
|
||||
'total_shipping',
|
||||
'points',
|
||||
'weight',
|
||||
'paid',
|
||||
'txaction',
|
||||
'wp_invoice_path',
|
||||
'wp_notice',
|
||||
'mode',
|
||||
'shipped',
|
||||
'tracking'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'wp_notice' => 'array',
|
||||
];
|
||||
|
||||
public static $shippedTypes = [
|
||||
0 => 'offen',
|
||||
1 => 'in Bearbeitung',
|
||||
2 => 'versendet',
|
||||
3 => 'abgeschlossen',
|
||||
10 => 'storniert'
|
||||
];
|
||||
|
||||
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)',
|
||||
10 => 'cancel'
|
||||
];
|
||||
|
||||
public static $shippedColors = [
|
||||
0 => 'warning',
|
||||
1 => 'info',
|
||||
2 => 'success',
|
||||
3 => 'secondary',
|
||||
10 => 'danger',
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
//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 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 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 getShippedType(){
|
||||
return isset(self::$shippedTypes[$this->shipped]) ? self::$shippedTypes[$this->shipped] : "";
|
||||
}
|
||||
|
||||
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 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 getFormattedTax()
|
||||
{
|
||||
return formatNumber($this->attributes['tax']);
|
||||
}
|
||||
|
||||
public function getFormattedTotalShipping()
|
||||
{
|
||||
return formatNumber($this->attributes['total_shipping']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
100
app/Models/ShoppingOrderItem.php
Normal file
100
app/Models/ShoppingOrderItem.php
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
<?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)
|
||||
* @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()
|
||||
* @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)
|
||||
*/
|
||||
class ShoppingOrderItem extends Model
|
||||
{
|
||||
protected $table = 'shopping_order_items';
|
||||
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected $fillable = [
|
||||
'shopping_order_id',
|
||||
'row_id',
|
||||
'product_id',
|
||||
'comp',
|
||||
'qty',
|
||||
'price',
|
||||
'price_net',
|
||||
'tax_rate',
|
||||
'slug',
|
||||
];
|
||||
|
||||
|
||||
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 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']);
|
||||
}
|
||||
|
||||
}
|
||||
96
app/Models/ShoppingPayment.php
Normal file
96
app/Models/ShoppingPayment.php
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
<?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)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $mode
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereMode($value)
|
||||
*/
|
||||
class ShoppingPayment extends Model
|
||||
{
|
||||
protected $table = 'shopping_payments';
|
||||
|
||||
protected $fillable = [
|
||||
'shopping_order_id',
|
||||
'clearingtype',
|
||||
'wallettype',
|
||||
'onlinebanktransfertype',
|
||||
'reference',
|
||||
'amount',
|
||||
'currency',
|
||||
'mode'
|
||||
];
|
||||
|
||||
|
||||
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 === 'pp') {
|
||||
return 'PayPal';
|
||||
}
|
||||
if($this->clearingtype === 'cc') {
|
||||
return 'Kreditkarte';
|
||||
}
|
||||
if($this->clearingtype === 'vor') {
|
||||
return 'Vorkasse';
|
||||
}
|
||||
if($this->clearingtype === 'elv') {
|
||||
return 'SEPA Lastschrift';
|
||||
}
|
||||
if($this->clearingtype === 'sb') {
|
||||
return 'Sofort Überweisung';
|
||||
}
|
||||
if($this->clearingtype === 'fnc') {
|
||||
return 'Rechnung';
|
||||
}
|
||||
}
|
||||
|
||||
public function getPaymentAmount(){
|
||||
return Util::formatNumber($this->amount/100)." ".$this->currency;
|
||||
}
|
||||
}
|
||||
254
app/Models/ShoppingUser.php
Normal file
254
app/Models/ShoppingUser.php
Normal file
|
|
@ -0,0 +1,254 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
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)
|
||||
* @mixin \Eloquent
|
||||
* @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)
|
||||
*/
|
||||
class ShoppingUser extends Model
|
||||
{
|
||||
protected $table = 'shopping_users';
|
||||
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'auth_user_id',
|
||||
'member_id',
|
||||
'number',
|
||||
'is_like',
|
||||
'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',
|
||||
'mode',
|
||||
'is_for',
|
||||
'is_from',
|
||||
'shopping_user_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 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 getAPIShippedType() {
|
||||
if($this->shopping_order){
|
||||
return $this->shopping_order->getAPIShippedType();
|
||||
}
|
||||
return "free";
|
||||
}
|
||||
}
|
||||
77
app/Models/SySetting.php
Normal file
77
app/Models/SySetting.php
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
<?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)
|
||||
* @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()
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
'source' => 'name'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function getStatusType(){
|
||||
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
|
||||
}
|
||||
}
|
||||
221
app/Models/UserAccount.php
Normal file
221
app/Models/UserAccount.php
Normal file
|
|
@ -0,0 +1,221 @@
|
|||
<?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()
|
||||
* @mixin \Eloquent
|
||||
* @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)
|
||||
*/
|
||||
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', 'notice'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'payment_data' => 'array',
|
||||
'notice' => 'array',
|
||||
];
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
}
|
||||
137
app/Models/UserHistory.php
Normal file
137
app/Models/UserHistory.php
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
<?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)
|
||||
* @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)
|
||||
*/
|
||||
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',
|
||||
'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';
|
||||
}
|
||||
}
|
||||
107
app/Models/UserLevel.php
Normal file
107
app/Models/UserLevel.php
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* App\Models\UserLevel
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property array|null $trans_name
|
||||
* @property float|null $margin
|
||||
* @property int|null $pos
|
||||
* @property int $active
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @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 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 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)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereTransContent($value)
|
||||
*/
|
||||
class UserLevel extends Model
|
||||
{
|
||||
protected $table = 'user_levels';
|
||||
|
||||
protected $casts = ['trans_name' => 'array', 'trans_content' => 'array'];
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'content', 'pos', 'active',
|
||||
];
|
||||
|
||||
|
||||
/* 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 _format_number($value){
|
||||
return preg_replace("/[^0-9,]/", "", $value);
|
||||
}
|
||||
|
||||
public function setMarginAttribute( $value ) {
|
||||
$value = $this->_format_number($value);
|
||||
$this->attributes['margin'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
|
||||
public function getFormattedMargin()
|
||||
{
|
||||
if(!isset($this->attributes['margin'])){
|
||||
return "";
|
||||
}
|
||||
if(\App::getLocale() === "en"){
|
||||
return number_format($this->attributes['margin'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['margin'], 2, ',', '.');
|
||||
}
|
||||
|
||||
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, ', ');
|
||||
}
|
||||
}
|
||||
86
app/Models/UserMessage.php
Normal file
86
app/Models/UserMessage.php
Normal 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);
|
||||
}
|
||||
}
|
||||
36
app/Models/UserUpdateEmail.php
Normal file
36
app/Models/UserUpdateEmail.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
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()
|
||||
* @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)
|
||||
*/
|
||||
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');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue