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.
willaengine/app/SpTemplate.php

81 lines
1.8 KiB

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SpTemplate extends Model
{
protected $fillable = ['name_en', 'name_fa', 'description', 'category_id', 'sp_master_template_id', 'user_id', 'rtl', 'ltr'];
public function pages()
{
return $this->hasMany('App\SpPage');
}
public function first_page()
{
return $this->hasOne('App\SpPage');
}
public function frames()
{
return $this->hasMany('App\SpFrame');
}
public function category()
{
return $this->belongsTo('App\Category');
}
public function user_templates()
{
return $this->hasMany('App\SpUserTemplate');
}
public function facilities()
{
return $this->belongsToMany('App\SpFacility', 'facility_template', 'template_id', 'facility_id');
}
public function images()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
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 files()
{
return $this->morphToMany('App\Gallery', 'uploadable');
}
public function master_template()
{
return $this->belongsTo('App\\SpMasterTemplate', 'sp_master_template_id');
}
public function getRtlAttribute($value) {
return json_decode($value, true);
}
public function getLtrAttribute($value) {
return json_decode($value, true);
}
// public function files()
// {
// return $this->morphToMany('App\Gallery', 'uploadable');
// }
}