MOON
Server: Apache
System: Linux server1.studioinfinity.com.br 2.6.32-954.3.5.lve1.4.90.el6.x86_64 #1 SMP Tue Feb 21 12:26:30 UTC 2023 x86_64
User: artinside (517)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //home/artinside/www/lhh/source/Models/Address.php
<?php
/**
 * Created by PhpStorm.
 * User: sergiohidalgojunior
 * Date: 2019-09-16
 * Time: 18:22
 */

namespace Source\Models;

use Source\Core\Model;

class Address extends Model
{

    /**
     * Address constructor.
     */
    public function __construct()
    {
        parent::__construct("address", ["id"], ["user_id", "zipcode", "street", "number", "city", "state"]);
    }

    /**
     * @return bool
     */
    public function save(): bool
    {
        if (!$this->required()) {
            $this->message->warning("Campos com * são de preenchimento obrigatório");
            return false;
        }

        return parent::save();
    }

    public function findByUser(int $user_id): ? Address
    {
        $find = $this->find("user_id = :uid", "uid={$user_id}");
        return $find->fetch();
    }

}