'array', 'trans_copy' => 'array', 'trans_info' => 'array', 'featured' => 'array', ]; protected $fillable = [ 'user_id', 'name', 'active', 'active_date', ]; use SoftDeletes; protected $dates = ['deleted_at']; use Sluggable; public function sluggable() { return [ 'slug' => [ 'source' => 'name' ] ]; } public function user() { return $this->belongsTo('App\User', 'user_id'); } public function getActiveDateFormat(){ if(!$this->attributes['active_date']){ return ""; } return Carbon::parse($this->attributes['active_date'])->format(\Util::formatDateTimeDB()); } public function getActiveDateFormatSmall(){ if(!$this->attributes['active_date']){ return ""; } return Carbon::parse($this->attributes['active_date'])->format("d.m.Y"); } public function getSubdomain() { return config('app.protocol').$this->attributes['slug'].".".config('app.domain'); } public function getSubdomainStatus() { if($this->is_online !== NULL){ return $this->is_online; } $kas = new KasController(); $domain = 'mivita.care'; $pra = array( 'subdomain_name' => $this->attributes['slug'].".".$domain, 'domain_name' => $this->attributes['slug'].".".$domain, ); //check if exisist $subdomain = $kas->action('get_subdomains', $pra); if(!empty($subdomain[0]['is_active']) && $subdomain[0]['is_active'] == 'Y'){ $this->is_online = true; return true; } $this->is_online = false; return false; } 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; } }