Files
getgreen-backend/app/Models/PaymentSystemItem.php
2026-04-28 15:02:06 +05:00

79 lines
1.7 KiB
PHP
Executable File

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\Storage;
/**
* @package App\Models
* @property int $id
* @property int $payment_system_id
* @property array $title
* @property string $logo
* @property string $slug
* @property array $description
*
* @property PaymentSystemModel $paymentSystem
*
* @method getLogo(): string
*/
class PaymentSystemItem extends Model
{
use HasFactory;
protected $fillable = [
'payment_system_id',
'title',
'logo',
'slug',
'description'
];
protected $casts = [
'title' => 'array',
'description' => 'array'
];
protected $table = 'payment_system_items';
public function paymentSystem(): BelongsTo
{
return $this->belongsTo(PaymentSystemModel::class, 'payment_system_id', 'id');
}
public function getTitle(): string
{
if (App::isLocale('ru')) {
return (string) $this->title['ru'];
}
return (string) $this->title['uz'];
}
public function getDescription(): string
{
if ($this->description == null) {
return '';
}
if (App::isLocale('ru')) {
return (string) $this->description['ru'];
}
return (string) $this->description['uz'];
}
public function getLogo(): string
{
if (!empty($this->logo)) {
return Storage::url($this->logo);
}
return '/images/nophoto.jpg';
}
}