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.
63 lines
1.4 KiB
63 lines
1.4 KiB
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Portfolio extends Model
|
|
{
|
|
|
|
protected $fillable = [
|
|
'title', 'description', 'category_id', 'business_id', 'path' , 'data_class'
|
|
];
|
|
|
|
public function business()
|
|
{
|
|
return $this->belongsTo('App\Business');
|
|
}
|
|
|
|
public function category()
|
|
{
|
|
return $this->belongsTo('App\Category');
|
|
}
|
|
|
|
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 gallery()
|
|
{
|
|
return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'Gallery')->where('parent_id', null);
|
|
}
|
|
|
|
public function images()
|
|
{
|
|
return $this->morphToMany('App\Gallery', 'uploadable');
|
|
}
|
|
|
|
public function tags()
|
|
{
|
|
return $this->morphToMany('App\Tag', 'taggable');
|
|
}
|
|
|
|
public function getThumbnailAttribute()
|
|
{
|
|
if ($this->title_image->isNotEmpty()) {
|
|
return $this->title_image->first()->path;
|
|
}
|
|
return 'WM-Main/Assets/NoPreview/preview.png';
|
|
}
|
|
|
|
public function setDetailLink($value)
|
|
{
|
|
$this->linkToDetail = "{$value}/{$this->id}";
|
|
}
|
|
|
|
}
|