{"id":19455932,"url":"https://github.com/teguh02/filament-db-sync","last_synced_at":"2025-07-03T16:37:32.594Z","repository":{"id":255436958,"uuid":"849887537","full_name":"teguh02/filament-db-sync","owner":"teguh02","description":"This package allow sync two different laravel filament app db","archived":false,"fork":false,"pushed_at":"2024-10-25T10:01:36.000Z","size":344,"stargazers_count":11,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-18T04:49:09.855Z","etag":null,"topics":["filament","laravel","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/teguh02.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"teguh02"}},"created_at":"2024-08-30T13:00:36.000Z","updated_at":"2025-03-28T08:06:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"bd7c93c6-cf9d-4805-9b3f-0f8a8c99fbd4","html_url":"https://github.com/teguh02/filament-db-sync","commit_stats":null,"previous_names":["teguh02/filament-db-sync"],"tags_count":3,"template":false,"template_full_name":"filamentphp/plugin-skeleton","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teguh02%2Ffilament-db-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teguh02%2Ffilament-db-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teguh02%2Ffilament-db-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teguh02%2Ffilament-db-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teguh02","download_url":"https://codeload.github.com/teguh02/filament-db-sync/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250760648,"owners_count":21482843,"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":["filament","laravel","php"],"created_at":"2024-11-10T17:15:28.140Z","updated_at":"2025-04-25T05:30:56.799Z","avatar_url":"https://github.com/teguh02.png","language":"PHP","funding_links":["https://github.com/sponsors/teguh02"],"categories":[],"sub_categories":[],"readme":"![Background](assets/images/background.png)\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/teguh02/filament-db-sync.svg?style=flat-square)](https://packagist.org/packages/teguh02/filament-db-sync)\n[![Total Downloads](https://img.shields.io/packagist/dt/teguh02/filament-db-sync.svg?style=flat-square)](https://packagist.org/packages/teguh02/filament-db-sync)\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require teguh02/filament-db-sync\n```\n\n### Panel Configuration\nInstall the library in your panel service provider\n```php\n\u003c?php\nuse Teguh02\\FilamentDbSync\\FilamentDbSync;\n\npublic function panel(Panel $panel): Panel\n{\n    return $panel\n    // ... another filament configuration\n        -\u003eplugins([\n            FilamentDbSync::make(),\n        ]);\n}\n```\n### Configuration File and Migrations\n\nPublish the configuration and migrations\n\n```bash\nphp artisan vendor:publish --provider=\"Teguh02\\FilamentDbSync\\FilamentDbSyncServiceProvider\"\nphp artisan migrate\n```\n\n## Usage\n\n### Model configuration\nIn your model class, add the \u003ccode\u003efillable\u003c/code\u003e and the \u003ccode\u003ecasts\u003c/code\u003e attribute. For example if we have a model with name is Items, the model configuration should will be below\n```php\n\u003c?php\n\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Items extends Model\n{\n    use HasFactory;\n\n    // Define the fillable property to \n    // allow mass assignment on the model\n    // and the database sync process\n    protected $fillable = [\n        'name',\n        'description',\n        'price',\n        'stock',\n        'expired_at',\n    ];\n\n    // Define the casts property to\n    // automatically cast the data type\n    // of the model attributes\n    protected $casts = [\n        'stock' =\u003e 'integer',\n        'price' =\u003e 'integer',\n        'expired_at' =\u003e 'date',\n    ];\n}\n```\n\n### db_sync.php config\nFor the plugins config, you can adjust manually as you needs.\n```php\n\u003c?php\n\n// config for Teguh02/FilamentDbSync\nreturn [\n\n    /**\n     * The host where the data will be synced\n     */\n    'sync_host' =\u003e env('SYNC_HOST', 'http://localhost'),\n\n    /**\n     * The token to be used for authentication\n     */\n    'auth_token' =\u003e env('SYNC_TOKEN', 'default_token'),\n\n    /**\n     * Models configuration\n     */\n    'models' =\u003e [\n        /**\n         * If set to true, the package will\n         * automatically scan all models in the app/Models directory\n         */\n        'auto_scan' =\u003e env('AUTO_SCAN_MODELS', true),\n\n        /**\n         * If auto_scan is set to true,\n         * this configuration will be used to exclude models\n         * which will not be synced\n         */\n        'excluded' =\u003e [\n            // App\\Models\\User::class,\n        ],\n\n        /**\n         * When auto_scan is set to false,\n         * this configuration will be used to include models\n         */\n        'included' =\u003e [\n            // App\\Models\\User::class,\n        ],\n\n        /**\n         * The column to be used as the key\n         * when syncing data\n         */\n        'column_as_key' =\u003e [\n            // class =\u003e column\n            App\\Models\\User::class =\u003e 'email',\n\n            // or you can use the table name\n            // table_name =\u003e column\n            // 'users' =\u003e 'email',\n        ],\n    ],\n\n    /**\n     * Sync configuration\n     */\n    'sync' =\u003e [\n        /**\n         * The action to be taken when there is duplicate data\n         *\n         * Available options:\n         * - update : update the existing data\n         * - duplicate : create a new data with the same data\n         */\n        'duplicate_data_action' =\u003e env('DUPLICATE_DATA_ACTION', 'update'),\n    ],\n];\n```\n\n### Sync Env Configuration\nPlease set your env configuration following below, for example we have 2 different server below. Server 1 app domain is server1.com and then server 2 domain is server2.com\n\nOn the Server 1 : \n```bash\nSYNC_TOKEN=FUswndOCKEm5rAKzgqFDsXZ5euWhA535tOzgE00n9tuP4IsofFslPM5VgtrT\nSYNC_HOST=http://server2.com\n```\n\nOn the Server 2 :\n```bash\nSYNC_TOKEN=FUswndOCKEm5rAKzgqFDsXZ5euWhA535tOzgE00n9tuP4IsofFslPM5VgtrT\nSYNC_HOST=http://server1.com\n```\n\n### Queue configuration\nBecause this plugin use a jobs function to execute huge data, please set your queue driver according your needs\n```bash\n#QUEUE_CONNECTION=sync\nQUEUE_CONNECTION=database\n```\n\n## Screenshoot\n![Screenshot](https://github.com/user-attachments/assets/7c0add30-0f0f-4b1c-baa8-cccf59f61444)\n\n\n## Contributing\n\nPlease see [CONTRIBUTING](.github/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- [Teguh Rijanandi](https://github.com/teguh02)\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%2Fteguh02%2Ffilament-db-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteguh02%2Ffilament-db-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteguh02%2Ffilament-db-sync/lists"}