mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-07-31 14:16:57 -04:00
91 lines
2.5 KiB
PHP
91 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace Modules\StudioPlusWtiiabaddon\Entities;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Modules\RolePermission\Entities\Role;
|
|
use Modules\StudioPlus\Entities\ContentType;
|
|
use Modules\StudioPlus\Entities\ContentVariant;
|
|
use Modules\StudioPlus\Entities\StudioPlusVideoType;
|
|
use Modules\StudioPlus\Traits\ScopeTrait;
|
|
|
|
class StudioPlusIncentive extends Model
|
|
{
|
|
use HasFactory;
|
|
use ScopeTrait;
|
|
|
|
protected $fillable = [
|
|
'user_id',
|
|
'asin_id',
|
|
'incentive_category_id',
|
|
'title',
|
|
'description',
|
|
'target_rule',
|
|
'amount_value_earned',
|
|
];
|
|
|
|
protected $appends = [
|
|
'asin_values',
|
|
'role_names',
|
|
'content_type_names',
|
|
'content_variant_names',
|
|
'video_type_names',
|
|
];
|
|
|
|
public function asins()
|
|
{
|
|
return $this->belongsToMany(StudioPlusAsin::class, 'studio_plus_incentive_asins', 'studio_plus_incentive_id');
|
|
}
|
|
|
|
public function incentiveCategory()
|
|
{
|
|
return $this->belongsTo(StudioPlusIncentiveCategory::class, 'incentive_category_id');
|
|
}
|
|
|
|
public function videoTypes()
|
|
{
|
|
return $this->belongsToMany(StudioPlusVideoType::class, 'studio_plus_incentive_video_types', 'studio_plus_incentive_id', 'studio_plus_video_type_id');
|
|
}
|
|
|
|
public function roles()
|
|
{
|
|
return $this->belongsToMany(Role::class, 'studio_plus_incentive_roles', 'studio_plus_incentive_id', 'role_id');
|
|
}
|
|
|
|
public function contentTypes()
|
|
{
|
|
return $this->belongsToMany(ContentType::class, 'studio_plus_incentive_content_types', 'studio_plus_incentive_id', 'content_type_id');
|
|
}
|
|
|
|
public function contentVariants()
|
|
{
|
|
return $this->belongsToMany(ContentVariant::class, 'studio_plus_incentive_content_variants', 'studio_plus_incentive_id', 'content_variant_id');
|
|
}
|
|
|
|
public function getAsinValuesAttribute()
|
|
{
|
|
return $this->asins()->pluck('range_amount')->join(', ');
|
|
}
|
|
|
|
public function getRoleNamesAttribute()
|
|
{
|
|
return $this->roles()->pluck('name')->join(', ');
|
|
}
|
|
|
|
public function getContentTypeNamesAttribute()
|
|
{
|
|
return $this->contentTypes()->pluck('name')->join(', ');
|
|
}
|
|
|
|
public function getContentVariantNamesAttribute()
|
|
{
|
|
return $this->contentVariants()->pluck('name')->join(', ');
|
|
}
|
|
|
|
public function getVideoTypeNamesAttribute()
|
|
{
|
|
return $this->videoTypes()->pluck('name')->join(', ');
|
|
}
|
|
}
|