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/app/Modules/Vouchers/Models/ |
<?php
namespace App\Modules\Vouchers\Models;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Storage;
class VoucherPackage extends Model
{
use SoftDeletes;
use Sluggable;
/**
* The database table used by the model.
*
* @var string
*/
protected $table="vouchers_packages";
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['name','slug','excerpt','body','value','send_limit','usage_limit','is_active','counter','edited_by_id','image'];
/**
* Return the sluggable configuration array for this model.
*
* @return array
*/
public function sluggable() : array
{
return [
'slug' => [
'source' => 'name'
]
];
}
/**
* Get all of the voucher's codes.
*/
public function codes()
{
return $this->morphMany('App\Modules\Vouchers\Models\Voucher', 'parentable');
}
public function getImageFileAttribute()
{
$image = '';
if ($this->image){
if (Storage::disk('public_images')->exists($this->image)){
$image = Storage::disk('public_images')->get($this->image);
}
}
return $image;
}
public function getImageUrlFileAttribute()
{
$image = '';
if ($this->image){
if (Storage::disk('public_images')->exists($this->image)){
$image = "images/".$this->image;
}
}
return $image;
}
}