Skip to content

Commit 508577f

Browse files
committed
Update readme.md
1 parent e5d9345 commit 508577f

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

readme.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,48 @@ This command will generate a Livewire page for the User model with CRUD function
105105
## Prevent Automatic Route Generation (as of `v0.35.2`)
106106
Starting from version `0.35.2`, MaryGen prevents automatic route generation feature. By default, when you generate a new component without using --no-route option with the `marygen:make` command, a corresponding route is automatically added to your `routes/web.php` file.
107107

108+
## New in Version 0.36.1: Multi-Database Connection Support
109+
110+
As of version 0.36.1, MaryGen now supports models that use different database connections. This feature allows you to generate components and pages for models that are associated with databases other than your default connection.
111+
112+
### How it works
113+
114+
MaryGen now respects the `$connection` property of your Eloquent models. When generating components and pages, it will use the specified connection to:
115+
116+
1. Retrieve the correct table schema
117+
2. Generate appropriate form fields
118+
3. Create table columns
119+
4. Set up sorting and filtering
120+
121+
### Usage
122+
123+
No additional configuration is required. Simply ensure that your model specifies the correct connection:
124+
125+
```php
126+
class User extends Model
127+
{
128+
protected $connection = 'secondary_db';
129+
130+
// ... rest of your model
131+
}
132+
```
133+
134+
When you run the `marygen:make` command for this model, MaryGen will automatically use the 'secondary_db' connection for all database operations.
135+
136+
### Example
137+
138+
```bash
139+
php artisan marygen:make --model=User
140+
```
141+
142+
If the User model specifies a different connection, MaryGen will use that connection to generate the component and page.
143+
144+
### Notes
145+
146+
- Ensure that all specified connections are properly configured in your `config/database.php` file.
147+
- If a model doesn't specify a connection, MaryGen will use the default database connection.
148+
- This feature is particularly useful for applications that interact with multiple databases or use database sharding.
149+
108150
## Customization
109151

110152
You can customize the generated components by modifying the following methods in the `MaryGenCommand` class:

0 commit comments

Comments
 (0)