ManagementSystem/BACKEND/Modules/Admin/app/Models/Setting.php

46 lines
1.0 KiB
PHP
Executable File

<?php
namespace Modules\Admin\app\Models;
use App\Traits\HasCacheModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Modules\Admin\Database\factories\SettingFactory;
class Setting extends Model
{
use HasFactory;
use HasCacheModel;
public function __construct()
{
$this->table = 'setting';
$this->guarded = [];
}
protected function _getKey()
{
$keyLength = strlen(env('APP_KEY'));
return substr(env('APP_KEY'), round($keyLength / 2), $keyLength);
}
// custom display get{file_name}Attribute()
public function getFaviconAttribute($value)
{
if ($value) {
return asset("/storage/$value?key=" . $this->_getKey());
} else {
return null;
}
}
// custom display get{file_name}Attribute()
public function getLogoAttribute($value)
{
if ($value) {
return asset("/storage/$value?key=" . $this->_getKey());
} else {
return null;
}
}
}