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/app/Modules/Events/Models/ |
<?php
namespace App\Modules\Events\Models;
use Carbon\Carbon;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Storage;
use Intervention\Image\Facades\Image;
class Zenevent extends Model
{
use SoftDeletes;
use Sluggable;
/**
* The database table used by the model.
*
* @var string
*/
protected $table="zenevents";
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['title','slug','body','is_active','image_feature','order','posted_at','meta_title','meta_keywords','meta_description'];
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = ['deleted_at','posted_at'];
/**
* Set sluggable attribute
* @return array
*/
public function sluggable()
{
return [
'slug' => [
'source' => 'slug'
]
];
}
/**
* Get all of the banners for the event.
*
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany
*/
public function banners()
{
return $this->morphToMany('App\Modules\Banners\Models\Banner', 'bannerable');
}
/**
* The files thaht belongs to banner
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function files()
{
return $this->hasMany('App\Modules\Events\Models\ZeneventFile');
}
/**
* Get feature image
* @return string
*/
public function getImageFeatureFileAttribute()
{
$image = '';
if ($this->image_feature && Storage::disk('public_images')->exists($this->image_feature)){
$image = Storage::disk('public_images')->get($this->image_feature);
// $img = Image::make(Storage::get($this->image_feature));
//
// return $img->response('jpg');
}
return $image;
}
public function getImageFeatureUrlAttribute()
{
$image = '';
if ($this->image_feature && Storage::disk('public_images')->exists($this->image_feature)){
$image = "images/".$this->image_feature;
}
return $image;
}
/**
* Get the posted at attribute
*
* @param string $value
* @return string
*/
public function getPostedAtAttribute($value)
{
$date = Carbon::createFromFormat('Y-m-d H:i:s',$value);
return $date->format('d F Y');
}
/**
* The page url
*
* @return mixed null|string
*/
public function getUrlAttribute()
{
return route('events.show', ['slug' => $this->slug]);
}
/**
* The pages short content
*
* @return mixed null|string
*/
public function getExcerptAttribute()
{
if (array_has($this->attributes, 'body')) {
return str_limit(
strip_tags($this->attributes['body']),
100
);
}
return null;
}
}