2022-01-25 06:54:15 +00:00
|
|
|
<?php namespace Sarga\Brand\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2022-01-26 14:14:22 +00:00
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
2022-01-25 06:54:15 +00:00
|
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
|
use Sarga\Brand\Contracts\Brand as BrandContract;
|
2022-01-26 14:14:22 +00:00
|
|
|
use Webkul\Category\Models\CategoryProxy;
|
|
|
|
|
use Webkul\Marketplace\Models\SellerProxy;
|
|
|
|
|
use Webkul\Product\Models\ProductProxy;
|
2022-01-25 11:16:22 +00:00
|
|
|
|
2022-01-25 06:54:15 +00:00
|
|
|
class Brand extends Model implements BrandContract
|
|
|
|
|
{
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'position',
|
|
|
|
|
'status',
|
|
|
|
|
'code',
|
|
|
|
|
'name'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get image url for the category image.
|
|
|
|
|
*/
|
|
|
|
|
public function image_url()
|
|
|
|
|
{
|
|
|
|
|
if (! $this->image) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Storage::url($this->image);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get image url for the category image.
|
|
|
|
|
*/
|
|
|
|
|
public function getImageUrlAttribute()
|
|
|
|
|
{
|
|
|
|
|
return $this->image_url();
|
|
|
|
|
}
|
2022-01-26 14:14:22 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The products that belong to the category.
|
|
|
|
|
*/
|
|
|
|
|
public function products(): BelongsToMany
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsToMany(ProductProxy::modelClass(), 'product_brands');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function sellers():BelongsToMany
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsToMany(SellerProxy::modelClass(), 'seller_brands');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function categories():BelongsToMany
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsToMany(CategoryProxy::modelClass(), 'category_brands');
|
|
|
|
|
}
|
2022-01-25 06:54:15 +00:00
|
|
|
}
|