Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use I..
Decoded Output download
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* @property string $key
* @property mixed $value
*
* @method static self find(string $key)
*/
class Setting extends Model
{
use HasFactory;
protected $primaryKey = 'key';
protected $keyType = 'string';
public $timestamps = false;
protected $guarded = [];
protected $casts = ['value' => 'json'];
public static function get(string $key): mixed
{
return self::find($key)?->value;
}
/**
* Set a setting (no pun) value.
*
* @param array|string $key the key of the setting, or an associative array of settings,
* in which case $value will be discarded
*/
public static function set(array|string $key, $value = ''): void
{
if (is_array($key)) {
foreach ($key as $k => $v) {
self::set($k, $v);
}
return;
}
self::query()->updateOrCreate(compact('key'), compact('value'));
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* @property string $key
* @property mixed $value
*
* @method static self find(string $key)
*/
class Setting extends Model
{
use HasFactory;
protected $primaryKey = 'key';
protected $keyType = 'string';
public $timestamps = false;
protected $guarded = [];
protected $casts = ['value' => 'json'];
public static function get(string $key): mixed
{
return self::find($key)?->value;
}
/**
* Set a setting (no pun) value.
*
* @param array|string $key the key of the setting, or an associative array of settings,
* in which case $value will be discarded
*/
public static function set(array|string $key, $value = ''): void
{
if (is_array($key)) {
foreach ($key as $k => $v) {
self::set($k, $v);
}
return;
}
self::query()->updateOrCreate(compact('key'), compact('value'));
}
}
Function Calls
| None |
Stats
| MD5 | c7f97c5b0d0027e15e999bc37bfc7465 |
| Eval Count | 0 |
| Decode Time | 87 ms |