Downloads
Stars
Version
Default Laravel library for Axstarzy Dot Com that includes the most used libraries, plugins, helper classes, and migrations
Note that this package is in constant development and update. Please do voice out if you have any suggestions for improvement on this package.
This package is meant for Laravel Framework 5.5 LTS and above.
composer require tommyys/laravel_library
providers
array of config/app.php
:'providers' => [
// ...
Collective\Html\HtmlServiceProvider::class,
Intervention\Image\ImageServiceProvider::class,
// ...
],
aliases
array of config/app.php
:'aliases' => [
// ...
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
'Image' => Intervention\Image\Facades\Image::class,
// ...
],
composer.json
."extra": {
...
"include_files": [
"vendor/tommyys/laravel_library/src/Helper.php"
]
},
Run composer dumpautoload
Run php artisan migrate
to migrate the required tables
To use the included classes, include the namespace on top of your controller/command.
...
use Axstarzy\LaravelLibrary\ActionLog;
use Axstarzy\LaravelLibrary\ErrorLog;
use Axstarzy\LaravelLibrary\Telegram;
...
Below are the classes that are available:
Then you may use it normally like a helper class in your controller/commands.
//create new action log
$log = ActionLog::createRecord($request, $user); //$user is optional, if variable not passed it will use auth()->user() by default
//check time gap between last request
$gap = ActionLog::check30sGap($request);
To setup Telegram, add these variables to your .env
file
TELEGRAM_NOTI_GROUP=-123123123
TELEGRAM_BOT_ID=botid
class TestController extends Controller
{
public function foo(){
sqlLog(ActionLog::where('user_id', 1));
}
}
This package includes an updated trans
function, you must have added vendor/tommyys/laravel_library/src/Helper.php
to composer.json
to have it working.
Example:
<span class="m-menu__link-text">
{{trans('string.Stock')}}
</span>
Output:
<span class="m-menu__link-text">
Stock
</span>
This function will run echo
and Log::info
together.
Accepts model/eloquent object as input. This helper function will form a full sql query including parameters to ease troubleshooting in MYSQL.
Example:
$userID = 123;
sqlLog(ActionLog::where('user_id', $userID));
Output:
select * from `action_log` where `user_id` = "123"
This helper function works like number_format. except that it does not round up the decimals.
Example:
echo roundDownDecimal(200.1779, 2); #returns 200.17
echo roundDownDecimal(200.175,2); #returns 200.17
echo roundDownDecimal(200.172,2); #returns 200.17