belongsTo(Category::class, 'default_category'); } /** * Get the channels. */ public function channels() { return $this->belongsToMany(ChannelProxy::modelClass(), 'channels'); } /** * Get image url for the category image. * * @return string */ public function getSrcUrlAttribute() { if (! $this->src) { return; } return Storage::disk('blog_cdn')->url($this->src); } /** * Get image url for the m_src (mobile) image. * * @return string */ public function getMSrcUrlAttribute() { if (! $this->m_src) { return; } return Storage::disk('blog_cdn')->url($this->m_src); } public function getAssignCategorysAttribute() { $categorys = array(); $categories_ids = array_values( array_unique( array_merge( explode( ',', $this->default_category ), explode( ',', $this->categorys ) ) ) ); if ( is_array($categories_ids) && !empty($categories_ids) && count($categories_ids) > 0 ) { $categories = Category::whereIn('id', $categories_ids)->get(); $categorys = ( !empty($categories) && count($categories) > 0 ) ? $categories : array(); } return $categorys; } }