Download the PHP package muzammal/syncmodelfillable without Composer
On this page you can find all versions of the php package muzammal/syncmodelfillable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download muzammal/syncmodelfillable
More information about muzammal/syncmodelfillable
Files in muzammal/syncmodelfillable
Package syncmodelfillable
Short Description A Laravel package to synchronize model fillable fields with migration columns using commands
License MIT
Informations about the package syncmodelfillable
SyncModelFillable
SyncModelFillable is a Laravel package designed to help automatically sync a model's $fillable
fields with its database migration columns. π With just a simple Artisan command, you can keep your model properties up-to-date with your migration files effortlessly.
β¨ Features
- π οΈ Syncs model
$fillable
properties with migration columns. - π¦ Supports Laravel versions 8, 9, 10, and 11.
- βοΈ Customizable to exclude specific columns, like timestamps.
π Installation
-
Install the package via Composer:
-
(Optional) Publish the configuration file:
If you'd like to customize which columns are excluded from the
$fillable
fields, publish the configuration file:This will create a
config/syncfillable.php
file where you can specify columns to exclude (such ascreated_at
,updated_at
,deleted_at
etc.).
π Usage
This package provides an Artisan command sync:fillable
that lets you sync a model's $fillable
fields with its migration columns.
Sync a Specific Model's $fillable
Fields
To sync the $fillable
fields of a specific model, use the command with the model name. For example, if you have a model named Post
:
This will:
- Look for the
Post
model in theapp/Models
directory. - Find the migration file associated with the modelβs database table.
- Update the
$fillable
property in the model with the columns from the migration file.
Sync All Models in app/Models
To sync all models in the app/Models
directory, use all
as the parameter:
This will:
- Look for all models in the
app/Models
directory. - Match each model with its migration file.
- Update the
$fillable
property for each model.
βοΈ Configuration
The configuration file syncfillable.php
allows you to specify which columns to exclude from the $fillable
fields. By default, common timestamp columns (created_at
, updated_at
, deleted_at
) are excluded.
Example configuration:
Add any column names here that you want to exclude from the $fillable
fields.
π Example
Suppose you have a Post
model with a migration that defines columns such as name
, slug
, and content
. Running the following command:
Would automatically set the $fillable
fields in Post.php
as follows:
π License
This package is open-source software licensed under the MIT license.
All versions of syncmodelfillable with dependencies
illuminate/support Version ^8.0|^9.0|^10.0|^11.0
illuminate/console Version ^8.0|^9.0|^10.0|^11.0
illuminate/filesystem Version ^8.0|^9.0|^10.0|^11.0