{"id":19689135,"url":"https://github.com/onursimsek/laravel-extended","last_synced_at":"2025-12-27T01:55:59.050Z","repository":{"id":256031231,"uuid":"851227533","full_name":"onursimsek/laravel-extended","owner":"onursimsek","description":"Extend your Laravel project 🪄","archived":false,"fork":false,"pushed_at":"2025-01-27T01:42:54.000Z","size":53,"stargazers_count":26,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-27T02:31:26.299Z","etag":null,"topics":["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/onursimsek.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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":{"github":"onursimsek"}},"created_at":"2024-09-02T17:09:27.000Z","updated_at":"2025-01-27T01:42:52.000Z","dependencies_parsed_at":"2024-11-11T18:44:07.535Z","dependency_job_id":"c4033d13-453a-48d9-8b6b-6ca282057c9a","html_url":"https://github.com/onursimsek/laravel-extended","commit_stats":null,"previous_names":["onursimsek/laravel-extended"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onursimsek%2Flaravel-extended","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onursimsek%2Flaravel-extended/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onursimsek%2Flaravel-extended/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onursimsek%2Flaravel-extended/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onursimsek","download_url":"https://codeload.github.com/onursimsek/laravel-extended/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251465272,"owners_count":21593852,"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":["laravel-package"],"created_at":"2024-11-11T18:42:54.279Z","updated_at":"2025-12-27T01:55:59.022Z","avatar_url":"https://github.com/onursimsek.png","language":"PHP","funding_links":["https://github.com/sponsors/onursimsek"],"categories":["PHP"],"sub_categories":[],"readme":"\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://banners.beyondco.de/Laravel%20Extended.png?theme=dark\u0026packageManager=composer+require\u0026packageName=onursimsek%2Flaravel-extended\u0026pattern=topography\u0026style=style_1\u0026description=Extend+your+Laravel+project+with+mixins+and+mores\u0026md=1\u0026showWatermark=0\u0026fontSize=100px\u0026images=arrows-expand\"\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://banners.beyondco.de/Laravel%20Extended.png?theme=light\u0026packageManager=composer+require\u0026packageName=onursimsek%2Flaravel-extended\u0026pattern=topography\u0026style=style_1\u0026description=Extend+your+Laravel+project+with+mixins+and+mores\u0026md=1\u0026showWatermark=0\u0026fontSize=100px\u0026images=arrows-expand\"\u003e\n  \u003cimg alt=\"Package Image\" src=\"https://banners.beyondco.de/Precondition.png?theme=dark\u0026packageManager=composer+require\u0026packageName=onursimsek%2Fprecondition\u0026pattern=topography\u0026style=style_2\u0026description=HTTP+Precondition+for+Laravel\u0026md=1\u0026showWatermark=1\u0026fontSize=125px\u0026images=https%3A%2F%2Flaravel.com%2Fimg%2Flogomark.min.svg\"\u003e\n\u003c/picture\u003e\n\n# Extend your Laravel project with mixins and mores\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/onursimsek/laravel-extended.svg?style=flat-square)](https://packagist.org/packages/onursimsek/laravel-extended)\n[![MIT Licensed](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/onursimsek/laravel-extended/fix-php-code-style-issues.yml?branch=main\u0026label=code%20style\u0026style=flat-square)](https://github.com/onursimsek/laravel-extended/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Tests](https://github.com/onursimsek/laravel-extended/actions/workflows/run-tests.yml/badge.svg)](https://github.com/onursimsek/laravel-extended/actions)\n[![Total Downloads](https://img.shields.io/packagist/dt/onursimsek/laravel-extended.svg?style=flat-square)](https://packagist.org/packages/onursimsek/)\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require onursimsek/laravel-extended\n```\n\n## Contents\n\n- [Illuminate\\Database\\Query\\Builder](#extended-illuminatedatabasequerybuilder)\n- [Illuminate\\Support\\Str](#extended-illuminatesupportstr)\n- [Illuminate\\Support\\Stringable](#extended-illuminatesupportstringable)\n- [Useful Traits](#useful-traits)\n  - [InteractsWithDatabase](#interactswithdatabase)\n    - [beginTransaction](#begintransactionstring-connections-void)\n    - [commit](#commitstring-connections-void)\n    - [commitAll](#commitall-void)\n    - [rollBack](#rollbackstring-connections-void)\n    - [rollBack](#rollbackall-void)\n    - [Example](#interactswithdatabase-example)\n  - [HasName](#hasname)\n    - [names](#names)\n  - [HasValue](#hasvalue)\n    - [value](#values-and-names)\n\n## Usage\n\n### Extended Illuminate\\Database\\Query\\Builder\n\n```php\nProduct::whereGreaterThan('price', 500)-\u003eget();\n// select * from products where price \u003e 500\nProduct::whereGreaterThanOrEqual('price', 500)-\u003eget();\n// select * from products where price \u003e= 500\n\nProduct::whereLessThan('price', 500)-\u003eget();\n// select * from products where price \u003c 500\nProduct::whereLessThanOrEqual('price', 500)-\u003eget();\n// select * from products where price \u003c= 500\n\nProduct::whereColumnGreaterThan('price', 'amount')-\u003eget();\n// select * from products where price \u003e amount\nProduct::whereColumnGreaterThanOrEqual('price', 'amount')-\u003eget();\n// select * from products where price \u003e= amount\n\nProduct::whereColumnLessThan('price', 'amount')-\u003eget();\n// select * from products where price \u003c amount\nProduct::whereColumnLessThanOrEqual('price', 'amount')-\u003eget();\n// select * from products where price \u003c= amount\n\nProduct::whenWhere(false, 'is_active')-\u003eget();\n// select * from products\nProduct::whenWhere(true, 'is_active')-\u003eget();\n// select * from products where is_active = 1\n```\n\n### Extended Illuminate\\Support\\Str\n\n```php\nuse Illuminate\\Support\\Str;\n\nStr::squishBetween(\"I\\twill kiss\\t\\nyou!\", 'kiss', 'you');\n// I       will kiss you!\nStr::replaceBetween('I will kiss you!', 'will', 'you', 'miss');\n// I will miss you!\nStr::replaceBetweenMatch('I will kiss you!', 'will', 'you', '/k(.*)s/', 'hug');\n// I will hug you!\n```\n\n### Extended Illuminate\\Support\\Stringable\n\n```php\nuse Illuminate\\Support\\Str;\n\nStr::of(\"I\\twill kiss\\t\\nyou!\")-\u003esquishBetween('kiss', 'you');\n// I       will kiss you!\nStr::of('I will kiss you!')-\u003ereplaceBetween('will', 'you', 'miss');\n// I will miss you!\nStr::of('I will kiss you!')-\u003ereplaceBetweenMatch('will', 'you', '/k(.*)s/', 'hug');\n// I will hug you!\n```\n\n## Useful Traits\n\n### InteractsWithDatabase\n\nThis trait provides an easy way to manage database transactions across multiple connections. It allows you to **begin**,\n**commit**, and **roll back** transactions.\n\n#### beginTransaction(string ...$connections): void\n\nThis method starts a transaction on the specified database connections. If no connections are provided, the default\ndatabase connection specified in your Laravel configuration will be used.\n\n```php\n$this-\u003ebeginTransaction(); // Starts transaction on default connection\n$this-\u003ebeginTransaction('mysql', 'sqlite'); // Starts transactions on the 'mysql' and 'sqlite' connections\n```\n\n#### commit(string ...$connections): void\n\nThis method commits a transaction on the specified connections. If no connections are specified, nothing will happen.\n\n```php\n$this-\u003ecommit(); // No action taken (no specific connection provided)\n$this-\u003ecommit('mysql', 'sqlite'); // Commits the transactions on the 'mysql' and 'sqlite' connections\n```\n\n#### commitAll(): void\nThis method commits transactions on all connections that have begun a transaction during the lifetime of the object.\n\n```php\n$this-\u003ecommitAll(); // Commits all active transactions\n```\n\n#### rollBack(string ...$connections): void\nThis method rolls back a transaction on the specified connections.\n\n```php\n$this-\u003erollBack(); // Rolls back on the default connection\n$this-\u003erollBack('mysql', 'sqlite'); // Rolls back on the 'mysql' and 'sqlite' connections\n```\n\n#### rollBackAll(): void\nThis method rolls back transactions on all connections that have begun a transaction during the lifetime of the object.\n\n```php\n$this-\u003erollBackAll(); // Rolls back all active transactions\n```\n\n#### InteractsWithDatabase Example\n\n```php\nnamespace App\\Http\\Controllers\\Controller;\n\nuse OnurSimsek\\LaravelExtended\\Support\\InteractsWithDatabase;\n\nclass Controller\n{\n    use InteractsWithDatabase;\n    \n    public function store()\n    {\n        $this-\u003ebeginTransaction('mysql', 'pgsql');\n\n        try {\n            // Your data processing logic\n\n            $this-\u003ecommitAll(); // Commit the transactions if everything goes well\n        } catch (\\Exception $e) {\n            $this-\u003erollBackAll(); // Roll back if an error occurs\n            throw $e;\n        }\n    }\n}\n```\n\n### HasName\n\nThis trait converts the **names** of _UnitEnum_ into an array.\n\n#### names()\n\n```php\nenum Status \n{\n    use HasName;\n\n    case Active;\n    case Inactive;\n}\n\nStatus::names(); // ['Active', 'Inactive']\n```\n\n### HasValue\n\n#### values() and names()\n\nThis trait converts the **names** and **values** of _BackedEnum_ into an array\n\n```php\nenum Status: string\n{\n    use HasValue;\n\n    case Active = 'active';\n    case Inactive = 'inactive';\n}\n\nStatus::names();  // ['Active', 'Inactive']\nStatus::values(); // ['active', 'inactive']\n```\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Onur Şimşek](https://github.com/onursimsek)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonursimsek%2Flaravel-extended","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonursimsek%2Flaravel-extended","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonursimsek%2Flaravel-extended/lists"}