PHP code example of xmo / mine-helpers

1. Go to this page and download the library: Download xmo/mine-helpers 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/ */

    

xmo / mine-helpers example snippets


use Hyperf\Database\Model\Builder;

use Mine\Helper\FastBuilderWhere as BaseBuilder;

// old 
class oldDao {
    public function handleSearch(Builder $builder,array $params) {
        if (!empty($params['username'])){
            $builder->where('username',$params['username']);
        }
        if (!empty($params['user_created_at'])){
            list($startDate,$endDate) = $params['user_created_at'];
            $builder->whereBetween('created_at',[
            \Carbon\Carbon::createFromFormat('Y-m-d',$startDate)->startOfDay()->format('Y-m-d'),
            \Carbon\Carbon::createFromFormat('Y-m-d',$endDate)->startOfDay()->format('Y-m-d')
            ]);
        }
        if (!empty($params['sign_timestamp_at'])){
            list($startDate,$endDate) = $params['created_at'];
            $builder->whereBetween('created_at',[
            \Carbon\Carbon::createFromFormat('Y-m-d',$startDate)->startOfDay()->timestamp,
            \Carbon\Carbon::createFromFormat('Y-m-d',$endDate)->startOfDay()->timestamp
            ]);
        }
        return $builder;
    }
}

// new dao
class newDao {
    public function handleSearch(BaseBuilder $builder,array $params) {
        $builder->eq('username')
                ->dateRange('created_at','user_created_at')
                ->timestampsRange('created_at','sign_timestamp_at');
        return $builder;
    }
}