First Commit

This commit is contained in:
marco
2026-09-01 10:46:29 -03:00
commit bf96b77e9c
10000 changed files with 3508600 additions and 0 deletions
+74
View File
@@ -0,0 +1,74 @@
<?php
/**
* SysCMS - Content Management System
*
* Copyright (c) 2026 Marco Costa
* All rights reserved.
*
* Author: Marco Costa
* Email: contato@syspanel.com.br
* Project: SysCMS
*
* This software is licensed, not sold.
* Permission is granted to use this software
* subject to the terms of the SysCMS Commercial License.
*
* Redistribution, sublicensing, resale, or
* disclosure of this software, in whole or in part,
* is strictly prohibited without prior written permission.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
*/
namespace Modules\GlobalLists\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Class Country
*
* Model representing a country with multi-language name support.
*
* @package Modules\GlobalLists\Models
* @property int $countries_id
* @property array $countries_name JSON array of names in different locales
* @property string $countries_iso_code ISO country code
*/
class Country extends Model
{
protected $table = 'lists_countries';
protected $primaryKey = 'countries_id';
protected $fillable = [
'countries_name',
'countries_iso_code'
];
protected $casts = [
'countries_name' => 'array'
];
/**
* Get the translated name.
*
* @return string
*/
public function getNameAttribute()
{
$names = $this->countries_name;
if (is_array($names)) {
$locale = \Kernel\Translator::getLocale() ?: 'pt_BR';
return $names[$locale] ?? $names['pt_BR'] ?? array_shift($names);
}
return $names;
}
/**
* Get the states for the country.
*/
public function states()
{
return $this->hasMany(State::class, 'states_country_id', 'countries_id');
}
}