{"id":23266804,"url":"https://github.com/snoeren-development/laravel-currency-casting","last_synced_at":"2025-08-20T22:32:56.850Z","repository":{"id":52377810,"uuid":"258117303","full_name":"snoeren-development/laravel-currency-casting","owner":"snoeren-development","description":"Cast currency attributes stored as integer to floats automatically.","archived":false,"fork":false,"pushed_at":"2024-03-25T07:40:19.000Z","size":156,"stargazers_count":5,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-01T09:47:18.263Z","etag":null,"topics":["cast","composer","currency","laravel","laravel-package","php"],"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/snoeren-development.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://bunq.me/SnoerenDevelopment"]}},"created_at":"2020-04-23T06:40:56.000Z","updated_at":"2024-03-02T20:02:42.000Z","dependencies_parsed_at":"2024-03-25T08:46:03.050Z","dependency_job_id":"876820b3-40da-4b38-b186-e40bc3ad6780","html_url":"https://github.com/snoeren-development/laravel-currency-casting","commit_stats":{"total_commits":50,"total_committers":4,"mean_commits":12.5,"dds":0.07999999999999996,"last_synced_commit":"84e64c36bd0b39dfac9dceb62b3846d51277449a"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snoeren-development%2Flaravel-currency-casting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snoeren-development%2Flaravel-currency-casting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snoeren-development%2Flaravel-currency-casting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snoeren-development%2Flaravel-currency-casting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snoeren-development","download_url":"https://codeload.github.com/snoeren-development/laravel-currency-casting/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230463010,"owners_count":18229878,"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":["cast","composer","currency","laravel","laravel-package","php"],"created_at":"2024-12-19T16:21:54.911Z","updated_at":"2024-12-19T16:21:55.429Z","avatar_url":"https://github.com/snoeren-development.png","language":"PHP","funding_links":["https://bunq.me/SnoerenDevelopment"],"categories":[],"sub_categories":[],"readme":"# Laravel Currency Casting\n[![Latest version on Packagist](https://img.shields.io/packagist/v/snoeren-development/laravel-currency-casting.svg?style=flat-square)](https://packagist.org/packages/snoeren-development/laravel-currency-casting)\n[![Software License](https://img.shields.io/github/license/snoeren-development/laravel-currency-casting?style=flat-square)](LICENSE)\n[![Build status](https://img.shields.io/github/actions/workflow/status/snoeren-development/laravel-currency-casting/php.yml?style=flat-square)](https://github.com/snoeren-development/laravel-currency-casting/actions)\n[![Downloads](https://img.shields.io/packagist/dt/snoeren-development/laravel-currency-casting?style=flat-square)](https://packagist.org/packages/snoeren-development/laravel-currency-casting)\n\nThis package adds a Laravel model cast. This way you can cast any attribute that stores a currency, with an integer value in the database, to a float automatically!\n\n## Installation\nYou can install the package using Composer:\n```bash\ncomposer require snoeren-development/laravel-currency-casting\n```\n\n### Requirements\nThis package requires **at least** PHP 8.2 and Laravel 10.\n\n### Usage\nStore your currency as an integer value in the database. This is more accurate than storing it as a float.\nAdd the attributes you'd like to see cast to the `casts` array and assign the `Currency` class to it. If you need more than the default 2 digits currency usually has, you can append the number of digits you need after the currency class like in the example below. Just make sure your database column can handle the larger integer it produces.\n```php\n\u003c?php\nuse Illuminate\\Database\\Eloquent\\Model;\nuse SnoerenDevelopment\\CurrencyCasting\\Currency;\n\nclass Plan extends Model\n{\n    //\n\n    /**\n     * The attributes that should be cast.\n     *\n     * @var array\n     */\n    protected $casts = [\n        'price' =\u003e Currency::class,\n        'price_with_digits' =\u003e Currency::class . ':4',\n    ];\n\n    //\n}\n```\n\n## Testing\n```bash\n$ composer test\n```\n\n## Credits\n- [Michael Snoeren](https://github.com/MSnoeren)\n- [All Contributors](https://github.com/snoeren-development/laravel-currency-casting/graphs/contributors)\n\n## License\nThe MIT license. See [LICENSE](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnoeren-development%2Flaravel-currency-casting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnoeren-development%2Flaravel-currency-casting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnoeren-development%2Flaravel-currency-casting/lists"}