First Commit
This commit is contained in:
+68
@@ -0,0 +1,68 @@
|
||||
<?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 Activity
|
||||
*
|
||||
* Model representing a global business activity or category.
|
||||
* Supports multi-language names stored in a JSON field.
|
||||
*
|
||||
* @package Modules\GlobalLists\Models
|
||||
* @property int $activities_id
|
||||
* @property array $activities_name JSON array of names in different locales
|
||||
* @property string $activities_slug URL-friendly slug
|
||||
* @property string $activities_type Type of activity (commercial, industrial, etc.)
|
||||
*/
|
||||
class Activity extends Model
|
||||
{
|
||||
protected $table = 'lists_activities';
|
||||
protected $primaryKey = 'activities_id';
|
||||
protected $fillable = [
|
||||
'activities_name',
|
||||
'activities_slug',
|
||||
'activities_type'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'activities_name' => 'array'
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the translated name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNameAttribute()
|
||||
{
|
||||
$names = $this->activities_name;
|
||||
if (is_array($names)) {
|
||||
$locale = \Kernel\Translator::getLocale() ?: 'pt_BR';
|
||||
return $names[$locale] ?? $names['pt_BR'] ?? array_shift($names);
|
||||
}
|
||||
return $names;
|
||||
}
|
||||
}
|
||||
Executable
+55
@@ -0,0 +1,55 @@
|
||||
<?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 City
|
||||
*
|
||||
* Model representing a city linked to a state.
|
||||
*
|
||||
* @package Modules\GlobalLists\Models
|
||||
* @property int $cities_id
|
||||
* @property int $cities_state_id
|
||||
* @property string $cities_name
|
||||
* @property string $cities_slug
|
||||
* @property string $cities_ibge_code
|
||||
*/
|
||||
class City extends Model
|
||||
{
|
||||
protected $table = 'lists_cities';
|
||||
protected $primaryKey = 'cities_id';
|
||||
protected $fillable = [
|
||||
'cities_state_id',
|
||||
'cities_name',
|
||||
'cities_slug',
|
||||
'cities_ibge_code'
|
||||
];
|
||||
|
||||
public function state()
|
||||
{
|
||||
return $this->belongsTo(State::class, 'cities_state_id', 'states_id');
|
||||
}
|
||||
}
|
||||
+74
@@ -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');
|
||||
}
|
||||
}
|
||||
Executable
+64
@@ -0,0 +1,64 @@
|
||||
<?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 State
|
||||
*
|
||||
* Model representing a state (federative unit) linked to a country.
|
||||
*
|
||||
* @package Modules\GlobalLists\Models
|
||||
* @property int $states_id
|
||||
* @property int $states_country_id
|
||||
* @property string $states_name
|
||||
* @property string $states_uf
|
||||
*/
|
||||
class State extends Model
|
||||
{
|
||||
protected $table = 'lists_states';
|
||||
protected $primaryKey = 'states_id';
|
||||
protected $fillable = [
|
||||
'states_country_id',
|
||||
'states_name',
|
||||
'states_uf'
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the country that owns the state.
|
||||
*/
|
||||
public function country()
|
||||
{
|
||||
return $this->belongsTo(Country::class, 'states_country_id', 'countries_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cities for the state.
|
||||
*/
|
||||
public function cities()
|
||||
{
|
||||
return $this->hasMany(City::class, 'cities_state_id', 'states_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user