Promotion Frontend dynamic
This commit is contained in:
parent
c9e1545693
commit
1cc8e025a1
29 changed files with 551 additions and 163 deletions
|
|
@ -296,7 +296,13 @@ class Product extends Model
|
|||
return $this->hasMany(ProductIngredient::class, 'product_ingredients', 'id');
|
||||
}
|
||||
|
||||
|
||||
public function getShortCopy($clean = false, $len = false){
|
||||
$ret = $this->short_copy ? $this->short_copy : $this->description;
|
||||
if($len && $clean){
|
||||
return substr_ellipsis($ret, $len, $clean);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
public function getActionName($id = 0){
|
||||
if(isset($this->actions[$id])){
|
||||
return $this->actions[$id];
|
||||
|
|
|
|||
|
|
@ -125,6 +125,19 @@ class PromotionAdmin extends Model
|
|||
}
|
||||
}
|
||||
|
||||
public function isActive(){
|
||||
if($this->active){
|
||||
if($this->from && Carbon::parse($this->from)->gt(Carbon::now()->startOfDay())){
|
||||
return false;
|
||||
}
|
||||
if($this->to && Carbon::parse($this->to)->lt(Carbon::now()->startOfDay())){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getFromAttribute($value)
|
||||
{
|
||||
if(!$value){ return ""; }
|
||||
|
|
|
|||
|
|
@ -78,4 +78,8 @@ class Shipping extends Model
|
|||
public function shipping_prices(){
|
||||
return $this->hasMany('App\Models\ShippingPrice', 'shipping_id', 'id');
|
||||
}
|
||||
|
||||
public function getShippingPricesBy($shipping_for){
|
||||
return $this->hasMany('App\Models\ShippingPrice', 'shipping_id', 'id')->where('shipping_for', $shipping_for);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,8 +29,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
class ShippingCountry extends Model
|
||||
{
|
||||
protected $table = 'shipping_countries';
|
||||
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'shipping_id', 'country_id'
|
||||
];
|
||||
|
|
|
|||
|
|
@ -47,7 +47,12 @@ 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',
|
||||
'shipping_id', 'price', 'price_comp', 'num_comp', 'tax_rate', 'factor', 'total_from', 'total_to', 'weight_from', 'weight_to', 'shipping_for',
|
||||
];
|
||||
|
||||
public static $shippingForTypes = [
|
||||
1 => 'Berater Bestellungen',
|
||||
2 => 'Shop Bestellungen',
|
||||
];
|
||||
|
||||
public function shipping()
|
||||
|
|
@ -55,6 +60,9 @@ class ShippingPrice extends Model
|
|||
return $this->belongsTo('App\Models\Shipping', 'shipping_id');
|
||||
}
|
||||
|
||||
public function getShippingForType(){
|
||||
return isset(self::$shippingForTypes[$this->shipping_for]) ? self::$shippingForTypes[$this->shipping_for] : "";
|
||||
}
|
||||
|
||||
public function setPriceAttribute($value)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue