Updates to 03-2025

This commit is contained in:
Kevin Adametz 2025-04-01 10:39:21 +02:00
parent 6167273a48
commit 9b54eb0512
348 changed files with 34535 additions and 5774 deletions

View file

@ -29,7 +29,6 @@ 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)
* @mixin \Eloquent
* @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)
@ -39,6 +38,14 @@ use Illuminate\Database\Eloquent\Model;
* @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
* @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
{
@ -47,11 +54,15 @@ class ProductImage extends Model
protected $table = 'product_images';
protected $fillable = [
'product_id', 'filename', 'original_name', 'ext', 'mine', 'size'
protected $casts = [
'attributes' => 'object'
];
public function sluggable()
protected $fillable = [
'product_id', 'user_wl_product_id', 'type', 'filename', 'original_name', 'ext', 'mine', 'size', 'attributes'
];
public function sluggable(): array
{
return [
'slug' => [
@ -65,6 +76,11 @@ class ProductImage extends Model
return $this->belongsTo('App\Models\Product', 'product_id');
}
public function user_wl_product()
{
return $this->belongsTo('App\Models\UserWhitelabelProduct', 'user_wl_product_id');
}
public function formatBytes($precision = 2)
{
$size = $this->size;
@ -80,4 +96,23 @@ class ProductImage extends Model
}
}
public function getImagePath()
{
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 === 'wllogo'){
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();
}
}