Artisan Command
Generate a Firestore model with:
php artisan make:fmodel User
With the default configuration, this creates app/FModels/User.php in the App\FModels namespace.
Custom namespace
The generator uses class_namespace from config/firebase.php. See Configuration.
Options
| Option | Short form | Description |
|---|---|---|
--collection= | -c | Firestore collection name |
--primaryKey= | -p | Model primary-key field |
--force | -f | Replace an existing generated model |
Artisan Command Examples
Generate a new model
php artisan make:fmodel User
php artisan make:fmodel User --collection=users
php artisan make:fmodel User --primaryKey=uid
php artisan make:fmodel User --collection=users --primaryKey=uid
The generated model contains $collection, $primaryKey, $fillable, $required, $default, and $fieldTypes. Add writable fields to $fillable before calling create() or update().
protected $fillable = ['uid', 'email', 'name'];
protected $required = ['email'];
protected $fieldTypes = ['email' => 'string'];