Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel Join columns of Day, Month , Year to calculate age

class Patients extends Model
{
    protected $appends = ['age'];

    /**
     * Get the patients's age.
     *
     * @param  string  $value
     * @return string
     */
    public function getAgeAttribute($value)
    {
        $age = (time() - strtotime($this->dobDay.' '.$this->dobMonth.' '. $this->dobYear)) / (60 * 60 * 24 * 365);
        $age = floor($age);

        return $age;
    }
}
 
PREVIOUS NEXT
Tagged: #laravel #Join #columns #Month #Year #calculate #age
ADD COMMENT
Topic
Name
6+2 =