{"id":27639307,"url":"https://github.com/bored-programmers/laragrid","last_synced_at":"2025-04-23T22:15:08.456Z","repository":{"id":197437690,"uuid":"691147815","full_name":"Bored-Programmers/laragrid","owner":"Bored-Programmers","description":"LaraGrid is a powerful and customizable grid system package for Laravel. It provides an easy way to create sortable, filterable tables with pagination. The package is designed to be highly customizable, allowing developers to define columns, apply filters, and sort data with ease.","archived":false,"fork":false,"pushed_at":"2023-12-30T11:36:48.000Z","size":497,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-04-23T22:14:58.751Z","etag":null,"topics":["grid","grid-system","laragrid","laravel","laravel-framework","laravel-grid","laravel-laragrid","livewire"],"latest_commit_sha":null,"homepage":"https://boredprogrammers.gitbook.io/laragrid/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bored-Programmers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-13T15:38:20.000Z","updated_at":"2023-12-30T11:42:35.000Z","dependencies_parsed_at":"2023-11-28T12:26:12.224Z","dependency_job_id":"b4a49874-d069-4cce-a850-b6b61f87a05d","html_url":"https://github.com/Bored-Programmers/laragrid","commit_stats":null,"previous_names":["bored-programmers/laragrid"],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bored-Programmers%2Flaragrid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bored-Programmers%2Flaragrid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bored-Programmers%2Flaragrid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bored-Programmers%2Flaragrid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bored-Programmers","download_url":"https://codeload.github.com/Bored-Programmers/laragrid/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250522299,"owners_count":21444512,"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":["grid","grid-system","laragrid","laravel","laravel-framework","laravel-grid","laravel-laragrid","livewire"],"created_at":"2025-04-23T22:15:07.663Z","updated_at":"2025-04-23T22:15:08.443Z","avatar_url":"https://github.com/Bored-Programmers.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LaraGrid\n\n🚧 **This package is in development, and is not ready for use in production yet.** 🚧\n\n\u003cimg src=\"./resources/assets/img/logo.png\" alt=\"LaraGrid Logo\" height=\"500\" width=\"750\"\u003e\n\n[![Latest Stable Version](https://poser.pugx.org/bored-programmers/laragrid/v)](//packagist.org/packages/bored-programmers/laragrid)\n[![Total Downloads](https://poser.pugx.org/bored-programmers/laragrid/downloads)](//packagist.org/packages/bored-programmers/laragrid)\n[![License](https://poser.pugx.org/bored-programmers/laragrid/license)](//packagist.org/packages/bored-programmers/laragrid)\n\nLaraGrid is a Laravel package that provides a powerful and customizable grid system. It allows you to easily create\nsortable, filterable tables with pagination.\n\n## Table of Contents\n\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Publishable Assets](#publishable)\n- **[Documentation](https://boredprogrammers.gitbook.io/laragrid)**\n- [Usage](#base-usage) \n    - [Creating a Grid](#creating-a-grid)\n    - [Displaying the Grid](#displaying-the-grid)\n    - [Customizing the Theme](#customizing-the-theme)\n- [Contribution Guidelines](#contribution-guidelines)\n- [Changelog](#changelog)\n- [License](#license)\n- [Contact Information](#contact-information)\n- [Acknowledgments](#acknowledgments)\n\n## Requirements\n\n- PHP 8.1 or higher\n- Laravel 10.0 or higher\n\n## Installation\n\nTo install LaraGrid, you need to run the following command:\n\n```bash\ncomposer require bored-programmers/laragrid\n```\n\n## Publishable\n\nYou can publish the package's configuration, language files, and views using the following commands:\n\n**_required_**\n\n```bash\nphp artisan vendor:publish --tag=laragrid-assets\n```\n\n**_optional_**\n\n```bash\nphp artisan vendor:publish --tag=laragrid-config\nphp artisan vendor:publish --tag=laragrid-lang\nphp artisan vendor:publish --tag=laragrid-views\n```\n\n## TODO List\n\n1. [ ] Write tests for all functionality\n\n## Base Usage\n\n### Creating a Grid\n\nTo create a grid, you need to extend the `BaseLaraGrid` class and implement\nthe `getColumns`, and `getDataSource` methods.\n\n```php\nuse BoredProgrammers\\LaraGrid\\Components\\ColumnComponents\\Column;\nuse BoredProgrammers\\LaraGrid\\Livewire\\BaseLaraGrid;\nuse Illuminate\\Database\\Eloquent\\Builder;\nuse BoredProgrammers\\LaraGrid\\Filters\\FilterResetButton;\n\nclass MyGrid extends BaseLaraGrid\n{\n\n    protected function getColumns(): array\n    {\n        return [\n            Column::make('id', 'ID'),\n            Column::make('name', 'Name'),\n            // Add more columns as needed\n        ];\n    }\n\n    protected function getDataSource(): Builder\n    {\n        return MyModel::query();\n    }\n\n}\n```\n\nIn the `getColumns` method, you define the columns that will be displayed in the grid. The `Column::make` method takes\ntwo arguments: the model field and the label.\n\nThe `getDataSource` method should return an instance of `Illuminate\\Database\\Eloquent\\Builder` for the model you want to\ndisplay in the grid.\n\n### Displaying the Grid\n\nTo display the grid in a Blade view, you can use the `@livewire` or `\u003clivewire\u003e` directive:\n\n```blade\n@livewire('my-grid')\n```\n\n```blade\n\u003clivewire:my-grid/\u003e\n```\n\n_Replace `'my-grid'` with the actual name of your Livewire component._\n\n### Customizing the Theme\n\nYou can customize the appearance of the grid by extending the `BaseLaraGridTheme` class and setting the desired CSS.\n\n```php\nuse BoredProgrammers\\LaraGrid\\Theme\\BaseLaraGridTheme;\nuse BoredProgrammers\\LaraGrid\\Theme\\FilterTheme;\nuse BoredProgrammers\\LaraGrid\\Theme\\TBodyTheme;\nuse BoredProgrammers\\LaraGrid\\Theme\\THeadTheme;\n\nclass MyTheme extends BaseLaraGridTheme\n{\n\n    public static function make(): static\n    {\n        $theme = new static();\n\n        $theme-\u003esetTableClass('min-w-full table-auto');\n\n        $theme-\u003esetTheadTheme(\n            THeadTheme::make()\n                -\u003esetTheadClass('pb-4')\n                -\u003esetThClass('pb-3 px-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap')\n        );\n\n        $theme-\u003esetTbodyTheme(\n            TBodyTheme::make()\n                -\u003esetEmptyMessageClass('text-white')\n                -\u003esetTdClass('whitespace-nowrap p-3 text-sm text-gray-500')\n                -\u003esetGroupTdClass('whitespace-nowrap flex items-center p-3 text-sm text-gray-500')\n\n                -\u003esetRecordTrClass(fn($record) =\u003e $record-\u003erole === 'admin' ? 'bg-red-500' : 'bg-white'); // you can also set a closure for record tr class. Pass a closure that returns a string class.\n                -\u003esetRecordTrClass('bg-white odd:bg-gray-100'); // If you don't want to set a closure, you can just pass a string class.\n        );\n\n        $theme-\u003esetFilterTheme(\n            FilterTheme::make()\n                -\u003esetFilterTextClass('bg-white w-full rounded-xl border border-gray-300')\n                -\u003esetFilterSelectClass('bg-white w-full rounded-xl border border-gray-300')\n                -\u003esetFilterDateClass('bg-white w-full rounded-xl border border-gray-300')\n        );\n        \n        // those are not all methods, you can find all of them in BaseLaraGridTheme, THeadTheme, TBodyTheme and FilterTheme classes\n\n        return $theme;\n    }\n    \n}\n\n```\n\nThen, in your grid class, you need to override the `getTheme` method and return an instance of your theme class.\n\n```php\n    protected function getTheme(): BaseLaraGridTheme\n    {\n        return MyTheme::make();\n    }\n```\n\nBy default, there is a theme called `TailwindTheme`. \n\n## Show filtering and sorting in url\n\nIf you want to show filtering and sorting in url, you need to rewrite default LaraGrid properties. You can do it like\nthis:\n\n```php\nabstract class MyBaseGrid extends BaseLaraGrid\n{\n\n    #[Url]\n    public array $filter = [];\n\n    #[Url(except: 'id')]\n    public string $sortColumn = 'id';\n\n    #[Url]\n    public string $sortDirection = 'desc';\n\n    protected function getFilterResetButton(): FilterResetButton\n    {\n        return FilterResetButton::make();\n    }\n\n    protected function getTheme(): BaseLaraGridTheme\n    {\n        return MyTheme::make();\n    }\n\n}\n```\n\nThose Url params are default from livewire, so you can customize them as you want by\nfollowing [livewire docs](https://livewire.laravel.com/docs/url#initializing-properties-from-the-url).\n\n## Contribution Guidelines\n\nWe welcome contributions to LaraGrid. If you'd like to contribute, please fork the repository, make your changes, and\nsubmit a pull request. We have a few requirements for contributions:\n\n- Follow the PSR-2 coding standard.\n- Write tests for new features and bug fixes.\n- Only use pull requests for contributions.\n\n## Changelog\n\nFor a detailed history of changes, see [releases](https://github.com/Bored-Programmers/laragrid/releases) on GitHub.\n\n## License\n\nThis project is licensed under the [MIT license](https://github.com/Bored-Programmers/laragrid/blob/main/LICENSE.md).\n\n## Contact Information\n\nFor any questions or concerns, please feel free to create\na [discussion](https://github.com/Bored-Programmers/laragrid/discussions) on GitHub.\n\n## Credits\n\nCreated by [Matěj Černý](https://github.com/LeMatosDeFuk)\nfrom [Bored Programmers](https://github.com/Bored-Programmers).\n\n## Acknowledgments\n\nWe would like to thank all the contributors who have helped to make LaraGrid a better package.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbored-programmers%2Flaragrid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbored-programmers%2Flaragrid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbored-programmers%2Flaragrid/lists"}