Вход Регистрация
Файл: system/src/Casts/Serialize.php
Строк: 37
<?php

/**
 * This file is part of JohnCMS Content Management System.
 *
 * @copyright JohnCMS Community
 * @license   https://opensource.org/licenses/GPL-3.0 GPL-3.0
 * @link      https://johncms.com JohnCMS Project
 */

declare(strict_types=1);

namespace 
JohncmsCasts;

use 
IlluminateContractsDatabaseEloquentCastsAttributes;
use 
IlluminateDatabaseEloquentModel;

class 
Serialize implements CastsAttributes
{
    
/**
     * Cast the given value.
     *
     * @param Model $model
     * @param string $key
     * @param mixed $value
     * @param array $attributes
     * @return array
     */
    
public function get($model$key$value$attributes): array
    {
        return ! empty(
$value) ? unserialize($value, ['allowed_classes' => false]) : [];
    }

    
/**
     * Prepare the given value for storage.
     *
     * @param Model $model
     * @param string $key
     * @param array $value
     * @param array $attributes
     * @return string
     */
    
public function set($model$key$value$attributes): string
    
{
        return 
serialize($value);
    }
}
Онлайн: 0
Реклама