setwise / laravel-helpers
Setwise's generic package containing helpful Laravel tools
Requires
- php: ^5.6|^7.0
- illuminate/auth: ~5|~6|~7|~8
- illuminate/config: ~5|~6|~7|~8
- illuminate/database: ~5|~6|~7|~8
- illuminate/hashing: ~5|~6|~7|~8
- illuminate/support: ~5|~6|~7|~8
Requires (Dev)
- illuminate/testing: ~5|~6|~7|~8
- orchestra/testbench: ~3|~4|~5|~6
- phpunit/phpunit: ~8|~9
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2024-11-15 07:53:10 UTC
README
Setwise's generic package containing helpful Laravel tools
Installation
Install via the command
composer require setwise/laravel-helpers
Configuration
To publish this package's config file use the command
php artisan vendor:publish --tag=setwise-helpers-config
Usage
Commands
php artisan email:check-verified [email] [email2] [email...]
Use this command to check if given email(s) are verifiedphp artisan email:verify-all
Use this command to verify all emails in the databasephp artisan email:unverify [email] [email2] [email...]
Use this command to unverify given email(s)php artisan email:verify [email] [email2] [email...]
Use this command to verify given email(s)php artisan db:initialize
This command will initialize your active database connection with all the proper extensions and requirements for Setwisephp artisan setwise:logseed
Use this command to insert testing log entries
Controller Traits
ControllerHasUploads
Desc: This trait adds two methods to any controller action, uploadFile()
and deleteFile()
to allow for easy file uploads and storage
Configuration: In your controller's __construct()
function, define these parameters
// Prefix folder to prepend to your uploaded file
protected $uploadBucket = '';
// Class the file is being uploaded for, typically a model
protected $uploadClass = '';
// Authorize string resulting from a $this->can($uploadClass, $uploadAuthorize) to authorize the upload
protected $uploadAuthorize = '';
// Validation rules applied ot the upload
protected $uploadRules = 'required|file|image|max:2048';
And add these two routes to web.php
Route::post('<URL>', '<Controller>@uploadFile')->name('<Name>');
Route::post('<URL>', '<Controller>@deleteFile')->name('<Name>');
Database Macros
Macro 1
Macro 2
Macro 3
Macro 4
Macro 5
Eloquent Traits
SoftDeletesRouteBinding
Desc: Soft deleted entries cannot be recovered when passed in the url for restoration by default,
so this trait allows for the usage of route parameters even on restore routes with deleted models.
For this method to work, you MUST have restore
within your route url
Helpers
humanize()
Humanize takes in an underscore cased string and coverts it to a human readable sentence
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.