feat: add City10 platform with Laravel 13, AI agents, 3D viewer, and LGPD compliance

Initial commit of the complete City10 virtual city simulation platform.

Backend (Laravel 13):
- REST API with Sanctum tokens and session-based web authentication
- Role-based access control (admin/user) with middleware protection
- AI agent CRUD with OpenRouter.ai integration restricted to free models
- Store management with 3D coordinates and AI shopkeeper assignment
- Versioned legal documents (Terms, Privacy, Cookies) with LGPD audit trail
- Math CAPTCHA on public forms and multi-language support (pt_BR, en, es)

Frontend:
- Responsive Blade templates with Tailwind CSS v4
- Three.js 3D city viewer with SSE chat streaming to AI agents
- Admin panel for store and user administration

Infrastructure:
- MariaDB/MySQL database with comprehensive migrations
- Database seeders for demo content and test accounts
- PHPUnit test suite and Laravel Pint code styling
- Vite build configuration with hot reload
This commit is contained in:
2026-10-17 20:46:15 -03:00
commit 79d12fa2f4
128 changed files with 17053 additions and 0 deletions
+113
View File
@@ -0,0 +1,113 @@
<?php
namespace App\Models;
use Database\Factories\UserFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Hidden;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
/**
* Application user entity.
*
* Supports role based access control (admin/user) and records the
* acceptance of versioned legal documents (Terms, Privacy, Cookies)
* required by the Brazilian LGPD.
*/
#[Fillable(['name', 'email', 'password', 'role', 'locale', 'is_active'])]
#[Hidden(['password', 'remember_token'])]
class User extends Authenticatable
{
/** @use HasFactory<UserFactory> */
use HasApiTokens, HasFactory, Notifiable;
/**
* Role granted to platform administrators.
*
* @var string
*/
public const ROLE_ADMIN = 'admin';
/**
* Role granted to regular citizens of the virtual city.
*
* @var string
*/
public const ROLE_USER = 'user';
/**
* Stores owned by this user.
*
* @return HasMany<Store, $this>
*/
public function stores(): HasMany
{
return $this->hasMany(Store::class, 'owner_id');
}
/**
* Legal consents recorded for this user.
*
* @return HasMany<UserConsent, $this>
*/
public function consents(): HasMany
{
return $this->hasMany(UserConsent::class);
}
/**
* Legal documents this user has accepted.
*
* @return BelongsToMany<LegalDocument, $this>
*/
public function acceptedDocuments(): BelongsToMany
{
return $this->belongsToMany(LegalDocument::class, 'user_consents')
->withPivot(['accepted_at', 'ip_address', 'user_agent', 'source'])
->withTimestamps();
}
/**
* Determine whether the user holds administrator privileges.
*/
public function isAdmin(): bool
{
return $this->role === self::ROLE_ADMIN;
}
/**
* Check whether the user accepted every current legal document version.
*/
public function hasAcceptedCurrentTerms(): bool
{
$currentIds = LegalDocument::query()->where('is_current', true)->pluck('id');
if ($currentIds->isEmpty()) {
return true;
}
$acceptedIds = $this->consents()->pluck('legal_document_id');
return $currentIds->diff($acceptedIds)->isEmpty();
}
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'last_login_at' => 'datetime',
'password' => 'hashed',
'is_active' => 'boolean',
];
}
}