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;
|
2018-12-26 10:00:23 +00:00
|
|
|
use Illuminate\Support\Facades\Storage;
|
2018-07-24 11:11:32 +00:00
|
|
|
use Webkul\Core\Models\Locale;
|
|
|
|
|
use Webkul\Core\Models\Currency;
|
2018-12-26 10:00:23 +00:00
|
|
|
use Webkul\Inventory\Models\InventorySource;
|
2018-07-24 11:11:32 +00:00
|
|
|
|
|
|
|
|
class Channel extends Model
|
|
|
|
|
{
|
2018-10-30 11:24:24 +00:00
|
|
|
protected $fillable = ['code', 'name', 'description', 'theme', 'home_page_content', 'footer_content', 'hostname', 'default_locale_id', 'base_currency_id'];
|
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
|
|
|
{
|
2018-07-27 06:22:12 +00:00
|
|
|
return $this->belongsToMany(Locale::class, 'channel_locales');
|
2018-07-24 11:11:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the default locale
|
|
|
|
|
*/
|
|
|
|
|
public function default_locale()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Locale::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the channel locales.
|
|
|
|
|
*/
|
|
|
|
|
public function currencies()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsToMany(Currency::class, 'channel_currencies');
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-26 10:00:23 +00:00
|
|
|
/**
|
|
|
|
|
* Get the channel inventory sources.
|
|
|
|
|
*/
|
|
|
|
|
public function inventory_sources()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsToMany(InventorySource::class, 'channel_inventory_sources');
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-21 10:58:55 +00:00
|
|
|
|
|
|
|
|
protected $with = ['base_currency'];
|
2018-10-17 09:45:18 +00:00
|
|
|
|
2018-07-24 11:11:32 +00:00
|
|
|
/**
|
|
|
|
|
* Get the base currency
|
|
|
|
|
*/
|
|
|
|
|
public function base_currency()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Currency::class);
|
|
|
|
|
}
|
2018-10-17 09:45:18 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get logo image url.
|
|
|
|
|
*/
|
|
|
|
|
public function logo_url()
|
|
|
|
|
{
|
2018-10-17 10:30:31 +00:00
|
|
|
if(!$this->logo)
|
|
|
|
|
return;
|
|
|
|
|
|
2018-10-17 09:45:18 +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()
|
|
|
|
|
{
|
2018-10-17 10:30:31 +00:00
|
|
|
if(!$this->favicon)
|
|
|
|
|
return;
|
|
|
|
|
|
2018-10-17 09:45:18 +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
|
|
|
}
|