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/SpUserTemplate.php

79 lines
1.9 KiB

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SpUserTemplate extends Model{
public $timestamps = null;
protected $fillable = ['name_fa', 'description', 'sp_template_id', 'business_id','default_language_id'];
public function parent()
{
return $this->belongsTo('App\SpUserTemplate', 'parent_id');
}
public function children()
{
return $this->hasMany('App\SpUserTemplate', 'parent_id');
}
public function template()
{
return $this->belongsTo('App\SpTemplate', 'sp_template_id');
}
public function pages()
{
return $this->belongsToMany('App\SpPage','sp_user_pages');
}
public function user_pages()
{
return $this->hasMany('App\SpUserPage');
}
public function home_page()
{
return $this->hasOne('App\SpUserPage')->where('name_en', 'Home');
}
public function business()
{
return $this->belongsTo('App\Business');
}
public function user_facilities()
{
return $this->hasMany('App\SpUserFacility');
}
public function facilities()
{
return $this->belongsToMany('App\\SpFacility', 'sp_user_facilities', 'sp_user_template_id', 'sp_facility_id');
}
public function images() {
return $this->morphToMany( 'App\Gallery', 'uploadable' );
}
public function title_image() {
return $this->morphToMany( 'App\Gallery', 'uploadable' )->wherePivot( 'image_role', 'TitleImage' )->where('parent_id', null);;
}
public function gallery() {
return $this->morphToMany( 'App\Gallery', 'uploadable' )->wherePivot( 'image_role', 'Gallery' )->where('parent_id', null);;
}
public function language()
{
return $this->belongsTo('App\Language', 'default_language_id');
}
public function sites()
{
return $this->hasMany('App\Site');
}
}