Welcome Guest, Not a member yet? Register   Sign In
Relation entity
#1

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.
Reply


Messages In This Thread
Relation entity - by mcachile - 12-20-2019, 01:48 PM
RE: Relation entity - by MGatner - 12-21-2019, 05:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB