Server : Apache System : Linux 145.162.205.92.host.secureserver.net 5.14.0-611.45.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Apr 1 05:56:53 EDT 2026 x86_64 User : tradze ( 1001) PHP Version : 8.1.34 Disable Function : NONE Directory : /home/tradze/public_html/test.tradze.com/Backup25feb2025/app/Modules/Banners/Models/ |
<?php
namespace App\Modules\Banners\Models;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;
class Banner extends Model
{
use Sluggable;
/**
* The database table used by the model.
*
* @var string
*/
protected $table="banners";
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['name','slug','position'];
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = ['deleted_at'];
/**
* Available display relations
*
* @var array
*/
public $display = ['pages','zenevents'];
/**
* Return the sluggable configuration array for this model.
*
* @return array
*/
public function sluggable()
{
return [
'slug' => [
'source' => 'name'
]
];
}
/**
* The files thaht belongs to banner
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function files()
{
return $this->hasMany('App\Modules\Banners\Models\BannerFile');
}
/**
* Get all of the pages that are assigned this banner.
*/
public function pages()
{
return $this->morphedByMany('App\Modules\Pages\Models\Page', 'bannerable')->withTimestamps();
}
/**
* Get all of the pages that are assigned this banner.
*/
public function zenevents()
{
return $this->morphedByMany('App\Modules\Events\Models\Zenevent', 'bannerable')->withTimestamps();
}
/**
* The page url
*
* @return mixed null|string
*/
public function getUrlAttribute()
{
$url = $this->url?$this->url:'#';
return $url;
}
}