You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,6 +105,48 @@ This command will generate a Livewire page for the User model with CRUD function
105
105
## Prevent Automatic Route Generation (as of `v0.35.2`)
106
106
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.
107
107
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
+
108
150
## Customization
109
151
110
152
You can customize the generated components by modifying the following methods in the `MaryGenCommand` class:
0 commit comments