ryne / laravel-starter
Laravel helper methods
Requires
- laravel/framework: 9.*.* || 10.*.*
- dev-master
- 1.3.17
- 1.3.16
- 1.3.15
- 1.3.14
- 1.3.13
- 1.3.12
- 1.3.11
- 1.3.10
- 1.3.9
- 1.3.8
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-laravel-9-10-compatibility
- dev-develop
- dev-laravel-less-9-compatibility
This package is auto-updated.
Last update: 2024-12-18 14:56:06 UTC
README
Version 1.0
Laravel starter comes with helpful methods in making laravel projects
Installation
download the package via composer
composer require ryne/laravel-starter
Files, Classes and Methods
Files
- DBHelper.php - Database migration helper class
- Helpers.php - Global methods
- L0g.php - Custom message logs, uses the original laravel logging class \Log::class, this only helps the logging error to be arrange with second parameter as array
Classes
- DBHelper::class
- L0g::class
to use must call or use the class full path itself by:
\Ryne\LaravelStarter\DBHelper
\Ryne\LaravelStarter\L0g
or register the class in the app.php configuration in the aliases section to easily access its methods
'aliases' => Facade::defaultAliases()->merge([
'DBHelper' => Ryne\LaravelStarter\DBHelper,
'L0g' => Ryne\LaravelStarter\L0g,
])->toArray(),
Methods
***DBHelper::class
- keyDelete (DBHelper::keyDelete) - static method, use to delete foreign keys in the migration whenever rolling back some migration or simply removing existing foreign keys.
Parameters:
- String $tableName (required) - table of the foreign keys to be deleted
- String $key (required) - key name to be deleted
Return: void
Sample usage:
DBHelper::keyDelete('user_numbers', 'user_numbers_use_id_foreign');
***L0g::class
- info (L0g::info) - static method, use to make an information log in the storage folder, it uses the laravel \Log::class to output its log while this customize its output message
Parameter:
- String $message - message to be log
- ...$params - will accept arrays and string as its value as an additional information about the log
Return: void
Sample usage:
\L0g::info('test log', ['data' => 'additional data']);
- error (L0g::info) - static method, use to make an error log in the storage folder, it uses the laravel \Log::class to output its log while this customize its output message
Parameter:
- String $message - message to be log
- ...$params - will accept arrays and string as its value as an additional information about the log
Return: void
Sample usage:
\L0g::error('test log', ['data' => 'additional data']);
Sample output:
[2022-04-10 03:01:21] local.ERROR: ***XController.php@xmethod:11***
Message: "test log"
| data: additional data
File trace:
file:
/var/www/dc/vendor/ryne/laravel-starter/src/L0g.php@39 Function: error()
/var/www/dc/app/Http/Controllers/XController.php@11 Function: xmethod()
/var/www/dc/vendor/laravel/framework/src/Illuminate/Routing/Controller.php@54 Function: callAction()
__________________________________________________________________________________________________
***Helpers.php file
- _vers - use in blade files to import css/js/fonts/images or any other medias within the application that puts a version at end of its url. Version string will contain the modified timestamp of the file
Parameters:
- String $urlFile - file url of the resource within the application public or storage folder
- Bool $onlyVersion - output the version only instead of the whole url + version, default is false
Return: String
Sample usage:
_vers('/images/logo.png');
Sample output:
https://localhost/images/logo.png?v=22343423
- _trim - use to limit the number of characters of a string then puts a string at the end. If there is more than characters than the max limit then it will concatenate a string suffix that is given in the parameter
Parameters:
- String $string - string/text to be trimmed
- Int $limit - number of characters to cut, default is 50 characters
- String $withSuffix - suffix to be given if string exceed the limit
Return: String
Sample usage:
_trim('hello world', 7, '...')
Sample output:
"hello w..."
- _trimText - the same as the _trim() method, but will remove any html tags that is within the string
Parameters:
- String $string - string/text to be trimmed
- Int $limit - number of characters to cut, default is 50 characters
- String $withSuffix - suffix to be given if string exceed the limit
Return: Boolean true/false
Sample usage:
_trim('hello world', 7, '...')
Sample output:
"hello w..."
- _isRoute - use to check the current route of the page
Parameters:
- String $routeName - the route name to be check
Return: Bool/String false/"active"
Sample usage:
_isRoute('user.index')
License
this package is free, open source, and GPL friendly. You can use it for commercial projects, open source projects, or really almost whatever you want.
- Code — MIT License