First Commit
This commit is contained in:
commit
610aa1e202
4204 changed files with 636764 additions and 0 deletions
134
app/Models/Account.php
Normal file
134
app/Models/Account.php
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
|
||||
/**
|
||||
* App\Models\Account
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property int $company
|
||||
* @property string|null $company_name
|
||||
* @property string|null $company_street
|
||||
* @property string|null $company_postal_code
|
||||
* @property string|null $company_city
|
||||
* @property int|null $company_pre_phone_id
|
||||
* @property string|null $company_phone
|
||||
* @property string|null $company_homepage
|
||||
* @property int|null $company_country_id
|
||||
* @property string|null $salutation
|
||||
* @property string|null $title
|
||||
* @property string|null $first_name
|
||||
* @property string|null $last_name
|
||||
* @property string|null $street
|
||||
* @property string|null $postal_code
|
||||
* @property string|null $city
|
||||
* @property int|null $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 $birthday
|
||||
* @property string|null $website
|
||||
* @property string|null $facebook
|
||||
* @property string|null $facebook_fanpage
|
||||
* @property string|null $instagram
|
||||
* @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|null $company_country
|
||||
* @property-read \App\Models\Country|null $company_pre_phone
|
||||
* @property-read \App\Models\Country|null $country
|
||||
* @property-read \App\Models\Country|null $pre_mobil
|
||||
* @property-read \App\Models\Country|null $pre_phone
|
||||
* @property-read \App\User $user
|
||||
* @method static bool|null forceDelete()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Account onlyTrashed()
|
||||
* @method static bool|null restore()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereBirthday($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCity($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompany($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyCity($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyCountryId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyHomepage($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyPhone($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyPostalCode($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyPrePhoneId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyStreet($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCountryId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereFacebook($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereFacebookFanpage($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereFirstName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereInstagram($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereLastName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereMobil($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account wherePhone($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account wherePostalCode($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account wherePreMobilId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account wherePrePhoneId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereSalutation($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereStreet($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereTitle($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereWebsite($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Account withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Account withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Account extends Model
|
||||
{
|
||||
protected $table = 'accounts';
|
||||
|
||||
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\User');
|
||||
}
|
||||
|
||||
|
||||
public function company_country()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Country', 'company_country_id');
|
||||
}
|
||||
|
||||
public function country()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Country', 'country_id');
|
||||
}
|
||||
|
||||
public function company_pre_phone()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Country', 'company_pre_phone_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 getCompanyAttribute(){
|
||||
|
||||
if(empty($this->attributes['company']) && @$this->attributes['company'] !== 0){
|
||||
return 1;
|
||||
}
|
||||
return $this->attributes['company'];
|
||||
}
|
||||
}
|
||||
85
app/Models/Attribute.php
Normal file
85
app/Models/Attribute.php
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
<?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
|
||||
*/
|
||||
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, ', ');
|
||||
}
|
||||
|
||||
}
|
||||
85
app/Models/Category.php
Normal file
85
app/Models/Category.php
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
class Category extends Model
|
||||
{
|
||||
protected $table = 'categories';
|
||||
|
||||
protected $casts = ['trans_name' => 'array'];
|
||||
|
||||
protected $fillable = [
|
||||
'parent_id', 'name', 'pos', 'active',
|
||||
];
|
||||
|
||||
|
||||
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 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, ', ');
|
||||
}
|
||||
|
||||
}
|
||||
83
app/Models/Country.php
Normal file
83
app/Models/Country.php
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<?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
|
||||
*/
|
||||
class Country extends Model
|
||||
{
|
||||
protected $table = 'countries';
|
||||
|
||||
|
||||
public function getLocated($lang = 'de'){
|
||||
|
||||
$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;
|
||||
}
|
||||
return $this->de;
|
||||
}
|
||||
|
||||
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 getCountryIdByPhone($phone){
|
||||
if($phone == null){
|
||||
return null;
|
||||
}
|
||||
$r = Country::where('phone', '=', $phone)->first();
|
||||
if($r){
|
||||
return $r->id;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
194
app/Models/Product.php
Normal file
194
app/Models/Product.php
Normal file
|
|
@ -0,0 +1,194 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
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
|
||||
*/
|
||||
class Product extends Model
|
||||
{
|
||||
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'
|
||||
];
|
||||
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
|
||||
public function _format_number($value){
|
||||
return preg_replace("/[^0-9,]/", "", $value);
|
||||
}
|
||||
|
||||
public function setPriceAttribute( $value ) {
|
||||
$value = $this->_format_number($value);
|
||||
$this->attributes['price'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
public function setPriceVkAttribute( $value ) {
|
||||
$value = $this->_format_number($value);
|
||||
$this->attributes['price_ek'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
public function setTaxAttribute( $value ) {
|
||||
$value = $this->_format_number($value);
|
||||
$this->attributes['tax'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
public function setPriceOldAttribute( $value ) {
|
||||
$value = $this->_format_number($value);
|
||||
$this->attributes['price_old'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
|
||||
public function getFormattedPrice()
|
||||
{
|
||||
if(\App::getLocale() == "en"){
|
||||
return number_format($this->attributes['price'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['price'], 2, ',', '.');
|
||||
}
|
||||
|
||||
public function getFormattedPriceVk()
|
||||
{
|
||||
if(\App::getLocale() == "en"){
|
||||
return number_format($this->attributes['price_ek'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['price_ek'], 2, ',', '.');
|
||||
}
|
||||
|
||||
public function getFormattedTax()
|
||||
{
|
||||
if(\App::getLocale() == "en"){
|
||||
return number_format($this->attributes['tax'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['tax'], 2, ',', '.');
|
||||
}
|
||||
|
||||
public function getFormattedPriceOld()
|
||||
{
|
||||
if(\App::getLocale() == "en"){
|
||||
return number_format($this->attributes['price_old'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['price_old'], 2, ',', '.');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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, ', ');
|
||||
}
|
||||
}
|
||||
41
app/Models/ProductAttribute.php
Normal file
41
app/Models/ProductAttribute.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?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
|
||||
*/
|
||||
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');
|
||||
}
|
||||
}
|
||||
42
app/Models/ProductCategory.php
Normal file
42
app/Models/ProductCategory.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?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
|
||||
*/
|
||||
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');
|
||||
}
|
||||
|
||||
}
|
||||
62
app/Models/ProductImage.php
Normal file
62
app/Models/ProductImage.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
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
|
||||
*/
|
||||
class ProductImage extends Model
|
||||
{
|
||||
protected $table = 'product_images';
|
||||
|
||||
protected $fillable = [
|
||||
'product_id', 'filename', 'original_name', 'ext', 'mine', 'size'
|
||||
];
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
25
app/Models/UserUpdateEmail.php
Normal file
25
app/Models/UserUpdateEmail.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* App\Models\UserUpdateEmail
|
||||
*
|
||||
* @property-read \App\User $user
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserUpdateEmail extends Model
|
||||
{
|
||||
protected $table = 'users_update_email';
|
||||
|
||||
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