update 20.10.2025
This commit is contained in:
parent
8c11130b5d
commit
a939cd51ef
616 changed files with 84821 additions and 4121 deletions
96
dev/app-bak/Models/UserShopOnSite.php
Normal file
96
dev/app-bak/Models/UserShopOnSite.php
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* App\Models\UserShopOnSite
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_shop_id
|
||||
* @property string|null $filename
|
||||
* @property string|null $original_name
|
||||
* @property string|null $ext
|
||||
* @property string|null $mine
|
||||
* @property int|null $size
|
||||
* @property string $slug
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \App\Models\UserShop $product
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite findSimilarSlugs($attribute, $config, $slug)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereExt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereFilename($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereMine($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereOriginalName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereSize($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereUserShopId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserShopOnSite withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserShopOnSite extends Model
|
||||
{
|
||||
use Sluggable;
|
||||
|
||||
protected $table = 'user_shop_on_sites';
|
||||
|
||||
protected $fillable = [
|
||||
'user_shop_id', 'filename', 'original_name', 'ext', 'mine', 'size'
|
||||
];
|
||||
|
||||
public function sluggable() : array
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
'source' => 'original_name'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo('App\Models\UserShop', 'user_shop_id');
|
||||
}
|
||||
|
||||
public function formatBytes($precision = 2)
|
||||
{
|
||||
$size = $this->size;
|
||||
|
||||
if ($size > 0) {
|
||||
$size = (int) $size;
|
||||
$base = log($size) / log(1024);
|
||||
$suffixes = array(' bytes', ' KB', ' MB', ' GB', ' TB');
|
||||
|
||||
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
|
||||
} else {
|
||||
return $size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function isImage(){
|
||||
if(empty($this->attributes['filename']) || @$this->attributes['filename'] == null || @$this->attributes['filename'] == ""){
|
||||
return false;
|
||||
}
|
||||
if(!\Storage::disk('public')->has('images/shop/'.$this->filename)){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getImage(){
|
||||
if($this->isImage()){
|
||||
$link = 'images/shop/'.$this->filename;
|
||||
return '/storage/'.$link.'?=lm='.\Storage::disk('public')->lastModified($link);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue