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

@ -3,6 +3,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Cviebrock\EloquentSluggable\Sluggable;
/**
* App\Models\Category
@ -29,6 +30,8 @@ use Illuminate\Database\Eloquent\Model;
*/
class Category extends Model
{
use Sluggable;
protected $table = 'categories';
protected $casts = ['trans_name' => 'array'];
@ -37,6 +40,14 @@ class Category extends Model
'parent_id', 'name', 'pos', 'active',
];
public function sluggable()
{
return [
'slug' => [
'source' => 'name'
]
];
}
public function parent()
{
@ -48,6 +59,12 @@ class Category extends Model
return $this->hasMany('App\Models\Category', 'parent_id', 'id');
}
public function product_categories()
{
return $this->hasMany('App\Models\ProductCategory', 'category_id', 'id');
}
public function setPosAttribute($value){
$this->attributes['pos'] = is_numeric($value) ? $value : null;

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, '.', ',');

View file

@ -2,6 +2,7 @@
namespace App\Models;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
/**
@ -32,12 +33,24 @@ use Illuminate\Database\Eloquent\Model;
*/
class ProductImage extends Model
{
use Sluggable;
protected $table = 'product_images';
protected $fillable = [
'product_id', 'filename', 'original_name', 'ext', 'mine', 'size'
];
public function sluggable()
{
return [
'slug' => [
'source' => 'original_name'
]
];
}
public function product()
{