PHP code example of bigsinoos / j-eloquent

1. Go to this page and download the library: Download bigsinoos/j-eloquent library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bigsinoos / j-eloquent example snippets




class Role extends \Eloquent {
    use \Bigsinoos\JEloquent\PersianDateTrait;
    protected $table = 'roles';
}

    $userPremiumRole = Auth::user()->roles()->where('type', 'premium');
    $userPremiumRole->create_at; // 2014/12/30 22:12:34
    $userPremiumRole->jalali_created_at; // 93/09/08


class Role extends \Eloquent {

    use \Bigsinoos\JEloquent\PersianDateTrait;

    protected $jalaliDateFormat = 'l j F Y H:i';
}

# or

class Role extends \Eloquent {
    
    use \Bigsinoos\JEloquent\PersianDateTrait;
    
    public function setJalaliFormat($format){
        // do custom things here
        $this->jalaliDateFormat = $format; return $this;
    }
    
    protected function getJalaliFormat()
    {
        // return any format you want
        return 'l j F Y H:i';
    }

}



Class Role extends \Eloquent {
    
    use \Bigsinoos\JEloquent\PersianDateTrait;
    
    /**
    * Add this method to customize your date attributes
    *
    * @return array
    */
    protected function getDates()
    {
        return ['created_at', 'updated_at', 'expired_at'];
    }
    
}


$user = Auth::user();
$user->convertToPersian('created_at', 'y/m/d'); // 93/09/08