HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/www.shooperm.com/vendor/van-ons/laraberg/src/Models/Gutenbergable.php
<?php

namespace VanOns\Laraberg\Models;

use VanOns\Laraberg\Models\Content;
use VanOns\Laraberg\Events\ContentCreated;
use VanOns\Laraberg\Events\ContentUpdated;

trait Gutenbergable
{
    /**
     * Delete content when model gets deleted
     */
    protected static function bootGutenbergable()
    {
        // Persisting laraberg contents only when the current model has been updated
        self::saved(function ($model) {
            if ($content = $model->larabergContent) {
                $content->contentable()
                        ->associate($model)->save();
            }
        });

        // Permanently deleting laravel content when this model has been deleted
        self::deleted(function ($model) {
            $model->larabergContent()->delete();
        });
    }

    /**
     * Relationship to the lb_contents table.
     *
     * @return mixed
     */
    public function larabergContent()
    {
        return $this->morphOne(Content::class, 'contentable');
    }

    /**
     * Get the rendered content.
     *
     * @return string
     */
    public function getLbContentAttribute()
    {
        return $this->larabergContent ? $this->larabergContent->render() : '';
    }

    /**
     * Set the laraberg content.
     *
     * @param $content
     */
    public function setLbContentAttribute($content)
    {
        if (! $this->larabergContent) {
            $this->setRelation('larabergContent', new Content);
        }

        $this->larabergContent->setContent($content);
    }

    /**
     * Get the raw laraberg content.
     */
    public function getLbRawContentAttribute()
    {
        if (! $this->larabergContent) {
            return '';
        };

        return $this->larabergContent->raw_content;
    }

    /**
     * Returns the raw content that came out of Gutenberg
     *
     * @return String
     * @deprecated
     */
    public function getRawContent()
    {
        return $this->getLbRawContentAttribute();
    }

    /**
     * Returns the Gutenberg content with some initial rendering done to it
     *
     * @return String
     * @deprecated
     */
    public function getRenderedContent()
    {
        return $this->larabergContent->rendered_content;
    }

    /**
     * Sets the content object using the raw editor content
     *
     * @param String $content
     * @param String $save - Calls .save() on the Content object if true
     * @deprecated
     */
    public function setContent($content, $save = false)
    {
        if (! $this->larabergContent) {
            $this->createContent();
        }

        $this->larabergContent->setContent($content);
        if ($save) {
            $this->larabergContent->save();
        }
        event(new ContentUpdated($this->larabergContent));
    }
}