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

54 lines
1.3 KiB

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Appended\Classes\Specials\Assets\Traits\StaticImage;
use App\Appended\Classes\Specials\Assets\Traits\StaticLink;
use App\Appended\Classes\Specials\Assets\Traits\SetStaticData;
class SpUserElement extends Model {
use StaticImage, SetStaticData, StaticLink;
public $timestamps = false;
public function business_item() {
return $this->belongsTo('App\BusinessItem', 'element_id')->where('element_type', '=', 'App\BusinessItem');
}
public function categories()
{
return $this->belongsTo('App\BusinessItem', 'element_id')->where('element_type', '=', 'App\Category');
}
public function userFrame() {
return $this->belongsTo('App\SpUserFrame', 'sp_user_frame_id');
}
public function images() {
return $this->morphToMany('App\Gallery', 'uploadable')->withPivot('id', 'image_role');
}
public function links()
{
return $this->morphMany('App\SpLink', 'linkable');
}
public function getDataAttribute($value)
{
return json_decode($value, true);
}
public function getLanguageIdAttribute() {
return $this->userFrame->language_id;
}
public function setDataAttribute($value)
{
$this->attributes['data'] = json_encode($value, JSON_UNESCAPED_UNICODE);
}
}