First Commit

This commit is contained in:
Kevin Adametz 2018-10-29 09:39:31 +01:00
commit 610aa1e202
4204 changed files with 636764 additions and 0 deletions

View file

@ -0,0 +1,62 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\ProductImage
*
* @property int $id
* @property int|null $product_id
* @property string $filename
* @property string $original_name
* @property string $ext
* @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
* @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)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereFilename($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereMine($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereOriginalName($value)
* @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
*/
class ProductImage extends Model
{
protected $table = 'product_images';
protected $fillable = [
'product_id', 'filename', 'original_name', 'ext', 'mine', 'size'
];
public function product()
{
return $this->belongsTo('App\Models\Product', 'product_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;
}
}
}