You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.5 KiB
57 lines
1.5 KiB
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class SpecialContentOption extends Model
|
|
{
|
|
|
|
protected $fillable = ['name_fa', 'optionable_type', 'optionable_id', 'details', 'special_content_id'];
|
|
|
|
|
|
public function special_content()
|
|
{
|
|
return $this->belongsTo('App\SpecialContent');
|
|
}
|
|
// public function getDetailsAttribute()
|
|
// {
|
|
// return json_decode($this->attributes['details']);
|
|
// }
|
|
// public function setDetailsAttribute($value)
|
|
// {
|
|
// $this->attributes['details'] = json_encode($value, JSON_UNESCAPED_UNICODE);
|
|
// }
|
|
|
|
public function optionable()
|
|
{
|
|
return $this->morphTo();
|
|
}
|
|
|
|
public function files()
|
|
{
|
|
return $this->morphMany('App\Upload', 'uploadable')->select('id', 'uploadable_id', 'uploadable_type', 'user_id', 'path');
|
|
}
|
|
|
|
public function gallery()
|
|
{
|
|
return $this->morphMany('App\Upload', 'uploadable')->wherePivot('image_role', 'Gallery')->where('parent_id', null);
|
|
}
|
|
|
|
public function orginalTitleImage()
|
|
{
|
|
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TitleImage')->where('parent_id', null);
|
|
}
|
|
|
|
public function title_image()
|
|
{
|
|
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TitleImage')->where('parent_id', null);
|
|
}
|
|
|
|
public function images()
|
|
{
|
|
return $this->morphToMany('App\Gallery', 'uploadable');
|
|
}
|
|
|
|
}
|