parent
f03862b523
commit
1a43060996
42 changed files with 1160 additions and 83 deletions
|
|
@ -43,6 +43,8 @@ use Cviebrock\EloquentSluggable\Sluggable;
|
|||
* @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
|
||||
{
|
||||
|
|
@ -93,7 +95,7 @@ class Category extends Model
|
|||
public function getLang($key)
|
||||
{
|
||||
$lang = \App::getLocale();
|
||||
if ($lang == 'de') {
|
||||
if ($lang === 'de') {
|
||||
return $this->{$key};
|
||||
}
|
||||
$trans = $this->getTrans($key, $lang);
|
||||
|
|
|
|||
|
|
@ -30,37 +30,80 @@ use PHPUnit\Framework\Constraint\Count;
|
|||
* @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)
|
||||
*/
|
||||
class Country extends Model
|
||||
{
|
||||
protected $table = 'countries';
|
||||
|
||||
protected $casts = ['trans_name' => 'array', 'attr' => 'array'];
|
||||
|
||||
public function getLocated($lang = 'de'){
|
||||
protected $fillable = [
|
||||
'code', 'phone', 'en', 'de', 'es', 'fr', 'it', 'ru', 'active', 'trans_name', 'attr'
|
||||
];
|
||||
|
||||
$lang = \App::getLocale();
|
||||
public function getLocated($lang = false){
|
||||
|
||||
if($lang == 'de'){
|
||||
if(!$lang){
|
||||
$lang = \App::getLocale();
|
||||
|
||||
}
|
||||
if($lang === 'de'){
|
||||
return $this->de;
|
||||
}
|
||||
if($lang == 'en'){
|
||||
if($lang === 'en'){
|
||||
return $this->en;
|
||||
}
|
||||
if($lang == 'es'){
|
||||
if($lang === 'es'){
|
||||
return $this->es;
|
||||
}
|
||||
if($lang == 'fr'){
|
||||
if($lang === 'fr'){
|
||||
return $this->fr;
|
||||
}
|
||||
if($lang == 'it'){
|
||||
if($lang === 'it'){
|
||||
return $this->it;
|
||||
}
|
||||
if($lang == 'ru'){
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,6 +5,33 @@ 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
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @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)
|
||||
*/
|
||||
class Product extends Model
|
||||
{
|
||||
|
|
@ -117,6 +121,7 @@ class Product extends Model
|
|||
'price_ek',
|
||||
'tax',
|
||||
'price_old',
|
||||
'points',
|
||||
'weight',
|
||||
'contents',
|
||||
'number',
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ class ShoppingOrder extends Model
|
|||
|
||||
public function getFormattedShipping()
|
||||
{
|
||||
if (\App::getLocale() == "en") {
|
||||
if (\App::getLocale() === "en") {
|
||||
return number_format($this->attributes['shipping'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['shipping'], 2, ',', '.');
|
||||
|
|
@ -118,7 +118,7 @@ class ShoppingOrder extends Model
|
|||
|
||||
public function getFormattedTotalShipping()
|
||||
{
|
||||
if (\App::getLocale() == "en") {
|
||||
if (\App::getLocale() === "en") {
|
||||
return number_format($this->attributes['total_shipping'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['total_shipping'], 2, ',', '.');
|
||||
|
|
@ -127,7 +127,7 @@ class ShoppingOrder extends Model
|
|||
|
||||
public function getFormattedPrice()
|
||||
{
|
||||
if (\App::getLocale() == "en") {
|
||||
if (\App::getLocale() === "en") {
|
||||
return number_format($this->attributes['price'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['price'], 2, ',', '.');
|
||||
|
|
|
|||
|
|
@ -105,11 +105,9 @@ use Carbon\Carbon;
|
|||
class UserAccount extends Model
|
||||
{
|
||||
protected $table = 'user_accounts';
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'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', 'same_as_billing',
|
||||
'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'
|
||||
];
|
||||
|
|
@ -166,6 +164,22 @@ class UserAccount extends Model
|
|||
}
|
||||
|
||||
|
||||
public function getCountryAttrAs($attr, $as = false){
|
||||
if($this->country){
|
||||
$val = $this->country->getAttrByKey($attr);
|
||||
|
||||
if($val){
|
||||
if($as){
|
||||
return $as;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
79
app/Models/UserLevel.php
Normal file
79
app/Models/UserLevel.php
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserLevel extends Model
|
||||
{
|
||||
protected $table = 'user_levels';
|
||||
|
||||
protected $casts = ['trans_name' => 'array'];
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'margin', '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, ', ');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue