17 Nov - Static Sites to laravel

This commit is contained in:
Kevin Adametz 2018-11-17 02:01:22 +01:00
parent 610aa1e202
commit 5ff57a21a7
3661 changed files with 569001 additions and 771 deletions

View file

@ -2,6 +2,7 @@
namespace App\Models;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@ -84,10 +85,39 @@ class Product extends Model
'trans_usage' => 'array',
'trans_ingredients' => 'array'
];
use Sluggable;
use SoftDeletes;
protected $dates = ['deleted_at'];
protected $fillable = [
'name',
'title',
'copy',
'price',
'price_ek',
'tax',
'price_old',
'contents',
'number',
'icons',
'description',
'usage',
'ingredients',
'pos',
'amount',
'active'
];
public function sluggable()
{
return [
'slug' => [
'source' => 'name'
]
];
}
public function attributes(){
return $this->hasMany('App\Models\ProductAttribute', 'product_id', 'id');
@ -101,6 +131,35 @@ class Product extends Model
return $this->hasMany('App\Models\ProductImage', 'product_id', 'id');
}
/*
public function isImageAfter(){
if(empty($this->attributes['filename_after']) || @$this->attributes['filename_after'] == null || @$this->attributes['filename_after'] == ""){
return false;
}
if(!\Storage::disk('public')->has('images/'.$this->id.'/'.$this->filename_after)){
return false;
}
return true;
}
public function getImage($file){
if($file == "before" && $this->isImageBefore()){
$link = 'images/'.$this->id.'/'.$this->filename_before;
return '/storage/'.$link.'?=lm='.\Storage::disk('public')->lastModified($link);
}
if($file == "after" && $this->isImageAfter()){
$link = 'images/'.$this->id.'/'.$this->filename_after;
return '/storage/'.$link.'?=lm='.\Storage::disk('public')->lastModified($link);
}
return false;
}
*/
public function _format_number($value){
return preg_replace("/[^0-9,]/", "", $value);
@ -110,7 +169,7 @@ class Product extends Model
$value = $this->_format_number($value);
$this->attributes['price'] = floatval(str_replace(',', '.', $value));
}
public function setPriceVkAttribute( $value ) {
public function setPriceEkAttribute( $value ) {
$value = $this->_format_number($value);
$this->attributes['price_ek'] = floatval(str_replace(',', '.', $value));
}
@ -131,7 +190,7 @@ class Product extends Model
return number_format($this->attributes['price'], 2, ',', '.');
}
public function getFormattedPriceVk()
public function getFormattedPriceEk()
{
if(\App::getLocale() == "en"){
return number_format($this->attributes['price_ek'], 2, '.', ',');