Skip to main content
Version: 4.0

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​

OptionShort formDescription
--collection=-cFirestore collection name
--primaryKey=-pModel primary-key field
--force-fReplace 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'];