You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
959 B
PHTML

<?php
namespace App\Models;
1 year ago
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Concerns\HasUlids;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Setting extends Model
{
use HasFactory, SoftDeletes, HasUlids;
const PAYMENT_MANUAL = 'MANUAL';
const PAYMENT_MIDTRANS = 'MIDTRANS';
const PAYMENT_PAYLATER = 'PAYLATER';
protected $fillable = [
'key',
'value',
'type',
];
1 year ago
protected $appends = [
'url',
];
protected function url(): Attribute
{
return Attribute::make(get: function () {
if ($this->type == 'image') {
return asset($this->value);
}
return '';
});
}
public static function getByKey($key)
{
return Setting::where('key', $key)->value('value');
}
}