In this tutorial, I will show you how to design your Laravel Models fast using Fluidbm.
👨💻 ⚡ Fluidbm is a free Laravel schema designer that syncs your online model designs to your project using a cli. No download and copy-pasting files anymore. Just run "fluidbm pull" and the job is done.
😊 Let's get started:
This tutorial is splitted in two main parts: Designing the models and importing them to your Laravel project.
🎨 Design models with Fluidbm
Foremost, you need to signup or login on Fluidbm: https://fluidbm.com
Press on Create new schema to start a new project
Using the editor, you can rename your Schema. In this case I will name mine "DemoBlog"
✍️ Creating models
Press on Add Model to create add a new model
You can add as many models as you wish, as well as columns.
To add columns to add Model, simply double-click the model.
Using the Model Editor sidebar, one can add Laravel Database Factories, data dummies to fill up your models so you can use for testing.
For our DemoBlog, I will add another Model called Post, with some additional factories, It looks as follows:
🔗 Adding relationships
To link Users ** with **Posts, click on the User model then drag the relation pin and drop on the model you want to connect.
In our case User -> Post.
Then click on the connection line to define the type of Relationship.
😊 A code preview is also generated to give you some sense of the output later.
⛏️ Importing to Laravel (in milliseconds)
First create a new Laravel project, or open an existing one:
composer create-project laravel/laravel my-blog
👨💻 ⚡ Fluidbm CLI
It interacts with the Fluidbm API to generate your Laravel schema schemas, factories and database seeder.
The source code can be found here: https://github.com/franznkemaka/fluidbm-cli
Use it directly with npx
npx fluidbm
or Install it via npm or yarn
npm install -g fluidbm-cli
or
yarn global add fluidbm-cli
In this tutorial, we will use npx as it requires no previous installation.
🏗️ Authenticate with Fluidbm
npx fluidbm auth
To link your Fluidbm project to your Laravel project, you have to clone it. Copy the url or the schema id only 61d97a9185de6a5b30ab72e3 and paste it this way
!make sure 61d97a9185de6a5b30ab72e3 to replace it with your own
npx fluidbm clone https://fluidbm.com/schema/61d97a9185de6a5b30ab72e3
It's time to import all our code to Laravel with a single command:
npx fluidbm pull
All models and factories were successfully generated. A default seeder was also automatically implemented.
🎉After just 0.14s it is done ✅
Go back to Fluidbm and perform changes, to resync, just hit npx fluidbm pull
and it is done 👍
Now let's migrate our DB and see the changes in a real DB
php artisan migrate
Generate mock data using the automatically generated seeder:
php artisan db:seed
✨ Boom! I think the result speaks for itself.
To view DemoBlog on Fluidbm use this link, but you can't delete it instead you can Fork it and create your own mutable copy: https://fluidbm.com/s/zfy1opbnJdIW
Give Fluidbm a try!
It’s free and available on https://fluidbm.com
Feedback is highly appreciated fluidbm@rigle.co
Cheers 🥂!
Franz
Top comments (4)
Looking forward to trying this tool.
One important feature. Is it able to import from an existing database? I don't want to recreate all my tables from scratch. Already have a DB and just starting to move to Laravel. Can't find an easy DB designer tool. Everything is cumbersome.
This is a great tool! Thanks @franznkemaka
For me, it does exactly what it should and I'll use in my development workflow.
I'm gonna give it it a try to this tool, seems amazing! Thank you for sharing :)
Hi Jérémie, glad to hear that. Did you give a try already? Let me know what you think about and how it could be improved :D