user shops + shipping
This commit is contained in:
parent
ccc2af4bf7
commit
d4f6a774d0
53 changed files with 2326 additions and 814 deletions
50
app/Models/Shipping.php
Normal file
50
app/Models/Shipping.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
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->attributes['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');
|
||||
}
|
||||
}
|
||||
25
app/Models/ShippingCountry.php
Normal file
25
app/Models/ShippingCountry.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
93
app/Models/ShippingPrice.php
Normal file
93
app/Models/ShippingPrice.php
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ShippingPrice extends Model
|
||||
{
|
||||
protected $table = 'shipping_prices';
|
||||
|
||||
protected $fillable = [
|
||||
'shipping_id', 'price', 'tax', 'factor', 'total_from', 'total_to', 'weight_from', 'weight_to',
|
||||
];
|
||||
|
||||
public function shipping()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shipping', 'shipping_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 setFactorAttribute( $value ) {
|
||||
$value = $this->_format_number($value);
|
||||
$this->attributes['factor'] = 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 setTotalFromAttribute( $value ) {
|
||||
$value = $this->_format_number($value);
|
||||
$this->attributes['total_from'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
public function setTotalToAttribute( $value ) {
|
||||
$value = $this->_format_number($value);
|
||||
$this->attributes['total_to'] = 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 getFormattedTax()
|
||||
{
|
||||
if(\App::getLocale() == "en"){
|
||||
return number_format($this->attributes['tax'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['tax'], 2, ',', '.');
|
||||
}
|
||||
|
||||
public function getFormattedFactor()
|
||||
{
|
||||
if(\App::getLocale() == "en"){
|
||||
return number_format($this->attributes['factor'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['factor'], 2, ',', '.');
|
||||
}
|
||||
|
||||
|
||||
public function getFormatTotalFrom()
|
||||
{
|
||||
if(\App::getLocale() == "en"){
|
||||
return number_format($this->attributes['total_from'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['total_from'], 2, ',', '.');
|
||||
}
|
||||
public function getFormattedTotalTo()
|
||||
{
|
||||
if(\App::getLocale() == "en"){
|
||||
return number_format($this->attributes['total_to'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['total_to'], 2, ',', '.');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@ class UserShop extends Model
|
|||
|
||||
public function getSubdomainStatus()
|
||||
{
|
||||
if($this->is_online != NULL){
|
||||
if($this->is_online !== NULL){
|
||||
return $this->is_online;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue