sarga/packages/Webkul/Core/src/Models/Channel.php

115 lines
2.3 KiB
PHP
Raw Normal View History

2018-07-24 11:11:32 +00:00
<?php
2018-08-21 10:58:55 +00:00
namespace Webkul\Core\Models;
2018-07-24 11:11:32 +00:00
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;
2019-02-18 07:30:40 +00:00
use Webkul\Category\Models\CategoryProxy;
use Webkul\Inventory\Models\InventorySourceProxy;
use Webkul\Core\Contracts\Channel as ChannelContract;
2018-07-24 11:11:32 +00:00
2019-02-18 07:30:40 +00:00
class Channel extends Model implements ChannelContract
2018-07-24 11:11:32 +00:00
{
2020-02-27 08:03:03 +00:00
protected $fillable = [
'code',
'name',
'description',
'theme',
'home_page_content',
'footer_content',
'hostname',
'default_locale_id',
'base_currency_id',
'root_category_id',
'home_seo',
2020-11-20 06:47:21 +00:00
'is_maintenance_on'
2020-02-27 08:03:03 +00:00
];
2018-07-24 11:11:32 +00:00
/**
* Get the channel locales.
*/
2018-07-27 06:22:12 +00:00
public function locales()
2018-07-24 11:11:32 +00:00
{
2019-02-18 07:30:40 +00:00
return $this->belongsToMany(LocaleProxy::modelClass(), 'channel_locales');
2018-07-24 11:11:32 +00:00
}
/**
* Get the default locale
*/
public function default_locale()
{
2019-02-18 07:30:40 +00:00
return $this->belongsTo(LocaleProxy::modelClass());
2018-07-24 11:11:32 +00:00
}
/**
* Get the channel locales.
*/
public function currencies()
{
2019-02-18 07:30:40 +00:00
return $this->belongsToMany(CurrencyProxy::modelClass(), 'channel_currencies');
2018-07-24 11:11:32 +00:00
}
/**
* Get the channel inventory sources.
*/
public function inventory_sources()
{
2019-02-18 07:30:40 +00:00
return $this->belongsToMany(InventorySourceProxy::modelClass(), 'channel_inventory_sources');
}
2018-07-24 11:11:32 +00:00
/**
* Get the base currency
*/
public function base_currency()
{
2019-02-18 07:30:40 +00:00
return $this->belongsTo(CurrencyProxy::modelClass());
2018-07-24 11:11:32 +00:00
}
2018-12-31 11:04:26 +00:00
/**
* Get the base currency
*/
public function root_category()
{
2019-02-18 07:30:40 +00:00
return $this->belongsTo(CategoryProxy::modelClass(), 'root_category_id');
2018-12-31 11:04:26 +00:00
}
/**
* Get logo image url.
*/
public function logo_url()
{
2020-02-19 12:26:12 +00:00
if (! $this->logo) {
2018-10-17 10:30:31 +00:00
return;
2020-02-19 12:26:12 +00:00
}
2018-10-17 10:30:31 +00:00
return Storage::url($this->logo);
}
/**
* Get logo image url.
*/
public function getLogoUrlAttribute()
{
return $this->logo_url();
}
/**
* Get favicon image url.
*/
public function favicon_url()
{
2020-02-19 12:26:12 +00:00
if (! $this->favicon) {
2018-10-17 10:30:31 +00:00
return;
2020-02-19 12:26:12 +00:00
}
2018-10-17 10:30:31 +00:00
return Storage::url($this->favicon);
}
/**
* Get favicon image url.
*/
public function getFaviconUrlAttribute()
{
return $this->favicon_url();
}
2018-07-24 11:11:32 +00:00
}