PHP code example of hoangphi / hwa-helpers

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

    

hoangphi / hwa-helpers example snippets


'providers' => array(
    // ...
    HoangPhi\HwaHelpers\Providers\HwaHelperServiceProvider::class,
);

app_name(); // Get website name, project name - Ex: Laravel

activate_status(); // Get status activate - Ex: 1 - activate

deactivate_status(); // Get status deactivate - Ex: 2 - deactivate

gender_male(); // Get gender male - Ex: 1 - male

gender_female(); // Get gender female - Ex: 1 - female

page_limit(); // Get page limit default in pagination - Ex: 12


current_day(); // Get current day - Ex: 01

current_month(); // Get current month - Ex: 07

current_year(); // Get current year - Ex: 2021

current_date(); // Get current - Ex: 2021-07-01 00:00:01

current_date('H:i:s d/m/Y'); // Get current date with format - Ex: 00:00:01 01/07/2021

custom_date('2021-07-01 00:00:01', 'H:i:s d/m/Y'); // Get customer date with format - Ex: 00:00:01 01/07/2021

custom_date('2021-07-01 00:00:01', 'H:i:s d/m/Y', 'en_EN'); // Get customer date with format and locale for diffForHumans - Ex: 00:00:01 01/07/2021 or 1 seconds or 1 minutes.


storage_folder_path('users'); // Check and create folder if not existed in storage.

storage_image_path('users', '1.jpg') // Check and get image from image storage path.

storage_image_url('users', '1.jpg') // Get public asset url image from storage.



get_user_agent(); // Get user agent

get_current_ip(); // Get current client ip

get_ip_info('127.0.0.1'); // Get info ip from http://api.ipstack.com

get_client_ip(); // Get client ip from https://ipinfo.io

code_to_country('EN'); // Convert country code to country name. Ex: EN to English

get_os(); // get OS client using

get_client_browser(); // get client browser using

get_device(); // get client device using


send_ok_response('Message.', ['name' => 'Phi Hoang', 'phone' => '0989324221']); // Response normal with param 1 is message, param 2 is object or array data.

send_ok_response('Message.', '<paginate_items_object>', true); // Response with param 1 is message, param 2 is data paginate 
shell
php artisan vendor:publish --provider="HoangPhi\HwaHelpers\Providers\HwaHelperServiceProvider" --tag=hwa_helpers
shell script
php artisan config:cache

# or

php artisan optimize:clear