Sh3ll
OdayForums


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_old/Modules/Pages/Models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/tradze/public_html/test.tradze.com/app_old/Modules/Pages/Models/Page.php
<?php
namespace App\Modules\Pages\Models;

use App\Modules\Pages\Scopes\ActiveScope;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Storage;

class Page extends Model
{

    use SoftDeletes;
    use Sluggable;

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table="pages";

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['parent_id', 'title','subtitle','slug','slug2','body','is_active','image_feature','image_logo','layout','partial','meta_title','meta_keywords','meta_description','link_title','link'];

    /**
     * Set sluggable attribute
     * @return array
     */
    public function sluggable()
    {
        return [
            'slug' => [
                'source' => 'slug'
            ]
        ];
    }

    /**
     * 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);
        }
        return $image;
    }

    public function getImageFeatureUrlAttribute()
    {
        $image = '';
        if ($this->image_feature && Storage::disk('public_images')->exists($this->image_feature)){
            $image = url('images/'.$this->image_feature);
        }
        return $image;
    }

    /**
     * Get logo image
     * @return string
     */
    public function getImageLogoFileAttribute()
    {
        $image = '';
        if ($this->image_logo){
            if (Storage::disk('public_images')->exists($this->image_logo)){
                $image = Storage::get($this->image_logo);
            }
        }

        return $image;
    }

    /**
     * The page url
     *
     * @return mixed null|string
     */
    public function getUrlAttribute()
    {
        return route('pages.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']),
                600
            );
        }
        return null;
    }

    /**
     * Get all of the banners for the page.
     *
     * @return \Illuminate\Database\Eloquent\Relations\MorphToMany
     */
    public function banners()
    {
        return $this->morphToMany('App\Modules\Banners\Models\Banner', 'bannerable');
    }

    /**
     * Fetch parent page
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function parent()
    {
        return $this->belongsTo(Page::class, 'parent_id');
    }

    /**
     * Fetch child pages
     *
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function children()
    {
        return $this->hasMany(Page::class, 'parent_id');
    }

    /**
     * Get page siblings
     *
     * @return mixed null|\Illuminate\Database\Eloquent\Collection
     */
    public function siblings()
    {
        if ($p = $this->parent) {
            return $p->children->filter(function ($item) {
                return $item->id !== $this->id;
            });
        }
        return null;
    }

    /**
     * Scopes Active
     */
    public function scopeActive($query)
    {
        return $query->where('is_active', 1);
    }

}

ZeroDay Forums Mini