Hello! I am from Argentina. Sorry for my bad English.
I have a simple entity:
PHP Code:
<?php
namespace App\Entities;
class Usuario {
protected $id;
protected $nombre;
protected $apellido;
protected $fecha_nacimiento;
protected $dni;
protected $email;
protected $imagen;
protected $id_puesto;
protected $id_area;
protected $id_sector;
protected $session_id;
protected $is_su;
protected $limitar_cajas;
protected $habilitado;
protected $password;
protected $defecto;
protected $fecha_alta;
public function __set(string $key, $value = null) {
$method = 'set' . ucwords($key);
if (method_exists($this, $method)) {
$this->$method($value);
} else if (isset($this->$key)) {
$this->$key = $value;
}
}
public function __get(string $key) {
$method = 'get' . ucwords($key);
if (method_exists($this, $method)) {
return $this->$method();
} else if (isset($this->$key)) {
return $this->$key;
}
}
}
This entity is associated with a user model.
My question is: How do I communicate, for example, id_area with your table? The desired result would be:
$user->area->name or $user->area->id.
Thanks.