Search
 
SCRIPT & CODE EXAMPLE
 

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;
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: php get last date of month 
Php :: get data in two columns in div in loop php 
Php :: php composer copy library to public vendor folder 
Php :: php substring last 4 characters to censure credit card 
Php :: doctrine remove element from arraycollection 
Php :: laravel capitalize first letter 
Php :: laravel list unique indexes 
Php :: install php 5.5 ubuntu 20.05 
Php :: send notification php to PC 
Php :: php ord deprecated 
Php :: Add laravel sail build as alias 
Php :: PDF Library Persian Language UTF-8 Support mPDF Lib 
Php :: laravel 9 remove public from url 
Php :: vagrant no pg_hba.conf entry for host 
Php :: htmlentities (PHP 4, PHP 5, PHP 7, PHP 8) htmlentities — Convert all applicable characters to HTML entities 
Php :: add variables to line in laravel notification 
Php :: php clear echo messages 
Php :: Laravel: Session message exist while click on browser back button 
Php :: composer install error 
Php :: relationship on the base of condition in laravel 
Php :: same name selection in phpstorm mac 
Php :: php array cartesian product 
Php :: learndash logo link 
Php :: Laravel-permission update name 
Php :: PHP OOP - Traits 
Php :: Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query laravel 
Php :: symfony user online 
Php :: execute query and use die in php 
Php :: Same Taxonomy Add Multiple Post Type 
Php :: copy(/Users/admin/Library/Caches/composer/files/fakerphp/faker 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =