{"id":21466581,"url":"https://github.com/permafrost-dev/laravel-helpers","last_synced_at":"2026-05-01T03:32:46.010Z","repository":{"id":57037881,"uuid":"282418828","full_name":"permafrost-dev/laravel-helpers","owner":"permafrost-dev","description":"Helpful helpers for Laravel","archived":false,"fork":false,"pushed_at":"2020-07-25T10:11:42.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T05:47:53.833Z","etag":null,"topics":["helper-functions","helpers","laravel","laravel-helpers","laravel-package"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/permafrost-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-25T10:10:50.000Z","updated_at":"2020-07-25T10:18:05.000Z","dependencies_parsed_at":"2022-08-24T06:41:02.516Z","dependency_job_id":null,"html_url":"https://github.com/permafrost-dev/laravel-helpers","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/permafrost-dev/laravel-helpers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permafrost-dev%2Flaravel-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permafrost-dev%2Flaravel-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permafrost-dev%2Flaravel-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permafrost-dev%2Flaravel-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/permafrost-dev","download_url":"https://codeload.github.com/permafrost-dev/laravel-helpers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permafrost-dev%2Flaravel-helpers/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259368027,"owners_count":22846827,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["helper-functions","helpers","laravel","laravel-helpers","laravel-package"],"created_at":"2024-11-23T08:14:38.625Z","updated_at":"2026-05-01T03:32:40.989Z","avatar_url":"https://github.com/permafrost-dev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Laravel Helpers\n\ndescription\n\n#### Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require permafrost-dev/laravel-helpers\n```\n\n#### Helper Classes\n\n- `\\Permafrost\\Helpers\\ModelHelper`\n\nExamples:\n\n- _Retrieve the first 10 models, and cache the results for 30 seconds. Repeated calls within 30 seconds will return the cached results instead of performing a new database query._\n```php\n$models = ModelHelper::create(MyClass::class)\n    -\u003ecached(30)\n    -\u003eorderBy('id')\n    -\u003elatest()\n    -\u003eget();\n```\n\n- _Retrieve all MyClass record id values and cache them for 60 seconds.  This can be used during database seeding to siginificantly speed up the process._\n```php\n// use the model helper class\n$ids = ModelHelper::create(MyClass::class)\n    -\u003ecached(60)\n    -\u003eids();\n\n// or use a helper function\n$ids = get_cached_model_ids(MyClass::class, 60);\n```\n \n---\n\n- `Permafrost\\Helpers\\RouteHelper`\n\nExamples:\n\nAssuming a route defined as `/products/{category}/{id}` and named `web.products.show`, return `/products/books/123`:\n```php\n    //class-based\n    RouteHelper::routename('web.products.show/books/123');\n    \n    //helper function\n    routename('web.products.show/books/123');\n```\n\n#### Helper Functions\n\n```php\n    //get all ids for a model and cache the results; returns cached results if they exist\n    function get_cached_model_ids(string $modelClass, int $ttlSeconds, int $recordLimit): array;\n    \n    //get all values of a column for a model and cache the results; returns cached results if they exist\n    function get_cached_model_columns(string $modelClass, string $column, int $ttlSeconds, int $recordLimit): array;\n\n    //get all values of a column for a model\n    function get_model_column($modelClass, string $column, int $recordLimit): array;\n\n    //get all ids for a model\n    function get_model_ids($modelClass, int $recordLimit): array;\n\n    //truncates text with an ellipsis, but doesn't return partially truncated words\n    function str_tease(string $string, int $length, string $moreTextIndicator = '...'): string;\n\n    //returns a relative url instead of a complete url\n    function relative_route(string $name, array $parameters): string;\n\n    //returns the value of a named route along with the provided parameters (see RouteHelper class)\n    function routepath(string $routepath): string;\n\n    //returns an array of the validated data\n    function validate($fields, $rules);\n    \n    //returns true if the data passes validation\n    function validated($fields, $rules);\n    \n    //creates a validator instance, accepting either array or string parameters\n    function validator_create($fields, $rules);\n```\n\n#### Testing\n\n``` bash\n./vendor/bin/phpunit --testdox\n```\n\n## License\n\nThe MIT License (MIT). Please see the [LICENSE File](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpermafrost-dev%2Flaravel-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpermafrost-dev%2Flaravel-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpermafrost-dev%2Flaravel-helpers/lists"}