- This package provides helpful and neccessary helper functions which can be useful in your Laravel projects.
Requires PHP 8.0+ | Laravel 8.0+
Require Laravel Utils using Composer:
composer require --dev vcian/laravel-utils
You can access different helper functions mentioned below.
use Vcian\LaravelUtils\LaravelUtils;
- Grab the application name
LaravelUtils::appName()
- Get logged in user
LaravelUtils::loggedInUser()
- Check login status
LaravelUtils::checkAuth()
- Encrypt given value
LaravelUtils::encryption($string)
- Decrypt given value
LaravelUtils::decryption($string)
- Get server user agent
LaravelUtils::getUserAgent()
- Check database connection
LaravelUtils::checkDbConnection()
- Print query
LaravelUtils::printQuery($string)
- Select query
LaravelUtils::selectQuery($table, $columns, $conditions, $orderBy, $limit)
- Insert record
LaravelUtils::insertQuery($table, $data)
- Update record
LaravelUtils::updateQuery($table, $data, $conditions)
- Delete record
LaravelUtils::deleteQuery($table, $conditions)
- Filter query with condition
LaravelUtils::filterQuery($table, $column, $operator, $value)
- Get records in specific order
LaravelUtils::orderResults($table, $column, $direction)
- Count number of records in table
LaravelUtils::countResults($table)
- Join query for tables
LaravelUtils::joinTables($table1, $table2, $column1, $column2)
- Get paginate results
LaravelUtils::getPaginatedResults($query, $perPage)
- Searches sub-directories
LaravelUtils::includeRouteFiles($folder)
- Get route URL
LaravelUtils::getRouteUrl($url, $urlType, $separator)
- Generate API token
LaravelUtils::generateApiToken()
- CURL request
LaravelUtils::callAPI($url, $method, $data, $headers)
- Get Json Response from API
LaravelUtils::jsonResponseFromAPI($data, $statusCode)
- Get css and js path
LaravelUtils::customAsset($path)
- Get active menu
LaravelUtils::activeMenu($route, $page)
- Generate random color
LaravelUtils::getRandomColor()
- Search in array
LaravelUtils::arrayPartialSearch($array, $keyword)
- Convert object to array
LaravelUtils::objectToArray($collection)
- Get Json to array
LaravelUtils::jsonToArray($names)
- CSV to ARRAY (Convert file CSV to array)
LaravelUtils::csvToArray($filename)
- Array to CSV file
LaravelUtils::arrayToCsv($data, $fileName)
- Get current timestamp in the specified timezone
LaravelUtils::getCurrentTimestamp($timezone)
- Get current year
LaravelUtils::getCurrentYear()
- Get current month
LaravelUtils::getCurrentMonth()
- Get current date
LaravelUtils::getCurrentDate()
- Get sum of time
LaravelUtils::timeSumCalculation($times)
- Get hours difference
LaravelUtils::getHoursDifference($createdDate)
- Get days difference
LaravelUtils::getDaysDiff($date1, $date2)
- Get date range
LaravelUtils::getDateRange($startDate, $endDate, $format)
- Convert timestamp into date
LaravelUtils::convertTimeStampIntoDate($timestamp, $format)
- Convert local time to UTC
LaravelUtils::convertLocalToUTC($currentTimeZone, $date)
- Convert UTC to local
LaravelUtils::convertUTCtoLocal($currentTimeZone, $date)
- Time percentage calculation
LaravelUtils::timePercentageCal($totalTime, $usedTime)
- Divide time
LaravelUtils::divideTime($time, $count)
- Convert time to seconds
LaravelUtils::timeToSec($time)
- Convert time to minute
LaravelUtils::timeToMin($time)
- Get hours between two dates
LaravelUtils::checkHoursBetweenTwoDates($startDate, $endDate)
- Convert timestamp to min
LaravelUtils::timestampToMin($time)
- Calculate Age (Date Format should be 'd-m-y')
LaravelUtils::calculateAge($dateOfBirth)
- Get user location
LaravelUtils::getUserLocation()
- Get latitute and logitute based on zip code
LaravelUtils::zipCodeBaseGetLatLong($zipCode)
- Calculate Distance
LaravelUtils::calculateDistance($lat1, $lon1, $lat2, $lon2, $unit)
- Print a character
LaravelUtils::printChar($string)
- Convert a string to title case
LaravelUtils::toTitleCase($string)
- Check if the specified string starts with the given prefix
LaravelUtils::startsWith($string, $prefix)
- Check if the specified string ends with the given suffix
LaravelUtils::endsWith($string, $suffix)
- Explode a string into an array
LaravelUtils::explodeData($delimiter, $string)
- Implode a array into a string
LaravelUtils::implodeData($delimiter, $array)
- Search a string for a specific pattern
LaravelUtils::pregMatch($pattern, $string)
- Replace a pattern in a string
LaravelUtils::pregReplace($replaceWord, $replaceWith, $string)
- Remove space between words
LaravelUtils::pregRemoveSpace($string)
- Truncate text from given text and put the suffix in the text
LaravelUtils::truncateText($text, $length, $suffix)
- Get a string between specific characters
LaravelUtils::getBetweenString($string, $start, $end)
- Format phone number
LaravelUtils::formatPhoneNumber($phoneNumber)
- Get error response
LaravelUtils::errorResponse($message, $statusCode)
- Link Formating
LaravelUtils::linkFormatting($link)
- Upload Image
LaravelUtils::uploadImage($request, $inputName, $uploadPath, $oldFileName)
- Upload multiple images
LaravelUtils::uploadMultipleImage($request, $inputName, $uploadPath, $oldFileName)
- Upload file to local storage
LaravelUtils::uploadFileToLocalTemp($request)
- Copy file to another path
LaravelUtils::copyFileToAnotherPath($from, $to)
- Delete file from given location
LaravelUtils::deleteFile($destinationPath, $oldFileName)
- Delete file by path
LaravelUtils::deleteFileByPath($path)
- Convert image into Base64
LaravelUtils::imageToBase64($imagePath)
- Compress Image
LaravelUtils::compressImage($sourcePath, $destinationPath, $quality)
- Resize Image
LaravelUtils::resizeImage($sourcePath, $destinationPath, $width, $height)
- Crop Image
LaravelUtils::cropImage($sourcePath, $destinationPath, $width, $height, $x, $y)
- Generate a unique file name
LaravelUtils::generateUniqueFileName($extension)
- Get File
LaravelUtils::getFile($fileName, $basePath)
- Get the extension of the specified file
LaravelUtils::getFileExtension($fileName)
- Generate URL for an uploaded file
LaravelUtils::getUploadedFileUrl($path)
- Print XML in readable format
LaravelUtils::readXMLFile($file)
- Create Folder
LaravelUtils::createFolder($destinationPath)
- Delete Folder
LaravelUtils::deleteFolder($destinationPath, $folderName)
- Convert value in integer
LaravelUtils::convertValueInteger($value)
- Convert float value to round value
LaravelUtils::convertToRound($value, $precision)
- Convert foot/inches to centimeter
LaravelUtils::convertToCM($feet, $inches)
- Convert centimeter to inches
LaravelUtils::convertToInches($cm)
- Convert pounds to kilogram
LaravelUtils::convertToKG($pounds)
- Convert kilogram to pounds
LaravelUtils::convertToPounds($kg)
- Calculate vat on price
LaravelUtils::calculateVatOnPrice($priceExcludingVat, $vat)
- Discount on price
LaravelUtils::discountOnPrice($price, $discount)
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
We believe in
👇
ACT NOW
PERFECT IT LATER
CORRECT IT ON THE WAY.
If you discover any security-related issues, please email ruchit.patel@viitor.cloud instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.