13-05-2026 Waren Wirtschaft
This commit is contained in:
parent
9ce711d6b2
commit
ca3eb663fe
40 changed files with 1000 additions and 189 deletions
|
|
@ -4,6 +4,7 @@ namespace App\Models;
|
|||
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* App\Models\ProductImage
|
||||
|
|
@ -16,9 +17,10 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @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
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read 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)
|
||||
|
|
@ -29,45 +31,51 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @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)
|
||||
*
|
||||
* @property string|null $slug
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage findSimilarSlugs($attribute, $config, $slug)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage query()
|
||||
*
|
||||
* @property int|null $pos
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProductImage withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
*
|
||||
* @property int|null $user_wl_product_id
|
||||
* @property string|null $type
|
||||
* @property object|null $attributes
|
||||
* @property-read \App\Models\UserWhitelabelProduct|null $user_wl_product
|
||||
* @property-read UserWhitelabelProduct|null $user_wl_product
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProductImage whereAttributes($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProductImage whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProductImage whereUserWlProductId($value)
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ProductImage extends Model
|
||||
{
|
||||
use Sluggable;
|
||||
|
||||
|
||||
protected $table = 'product_images';
|
||||
|
||||
protected $casts = [
|
||||
'attributes' => 'object'
|
||||
'attributes' => 'object',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'product_id', 'user_wl_product_id', 'type', 'filename', 'original_name', 'ext', 'mine', 'size', 'attributes'
|
||||
'product_id', 'user_wl_product_id', 'type', 'filename', 'original_name', 'ext', 'mine', 'size', 'pos', 'active', 'attributes',
|
||||
];
|
||||
|
||||
public function sluggable(): array
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
'source' => 'original_name'
|
||||
]
|
||||
'source' => 'original_name',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -88,31 +96,31 @@ class ProductImage extends Model
|
|||
if ($size > 0) {
|
||||
$size = (int) $size;
|
||||
$base = log($size) / log(1024);
|
||||
$suffixes = array(' bytes', ' KB', ' MB', ' GB', ' TB');
|
||||
$suffixes = [' bytes', ' KB', ' MB', ' GB', ' TB'];
|
||||
|
||||
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
|
||||
return round(pow(1024, $base - floor($base)), $precision).$suffixes[floor($base)];
|
||||
} else {
|
||||
return $size;
|
||||
}
|
||||
}
|
||||
|
||||
public function getImagePath()
|
||||
{
|
||||
if($this->type === 'uwllogo'){
|
||||
return '/images/user_product/'.$this->user_wl_product_id .'/'.$this->filename;
|
||||
{
|
||||
if ($this->type === 'uwllogo') {
|
||||
return '/images/user_product/'.$this->user_wl_product_id.'/'.$this->filename;
|
||||
}
|
||||
if($this->type === 'product'){
|
||||
return '/images/product/'.$this->product_id .'/'.$this->filename;
|
||||
if ($this->type === 'product') {
|
||||
return '/images/product/'.$this->product_id.'/'.$this->filename;
|
||||
}
|
||||
if($this->type === 'wllogo'){
|
||||
return '/images/product/'.$this->product_id .'/'.$this->filename;
|
||||
if ($this->type === 'wllogo') {
|
||||
return '/images/product/'.$this->product_id.'/'.$this->filename;
|
||||
}
|
||||
|
||||
return '/images/product/'.$this->product_id .'/'.$this->filename;
|
||||
return '/images/product/'.$this->product_id.'/'.$this->filename;
|
||||
}
|
||||
|
||||
|
||||
public function getBaseImagePath(){
|
||||
return base_path()."/storage/app/public".$this->getImagePath();
|
||||
public function getBaseImagePath()
|
||||
{
|
||||
return base_path().'/storage/app/public'.$this->getImagePath();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class ProductIngredient extends Model
|
|||
'product_id' => 'int',
|
||||
'ingredient_id' => 'int',
|
||||
'pos' => 'int',
|
||||
'gram' => 'decimal:3',
|
||||
'gram' => 'decimal:6',
|
||||
'factor' => 'decimal:2',
|
||||
];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue