<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Franz Nkemaka</title>
    <description>The latest articles on DEV Community by Franz Nkemaka (@franznkemaka).</description>
    <link>https://dev.to/franznkemaka</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F587879%2F55247d2b-7c5b-4cd7-bdd8-5386d151e76b.png</url>
      <title>DEV Community: Franz Nkemaka</title>
      <link>https://dev.to/franznkemaka</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/franznkemaka"/>
    <language>en</language>
    <item>
      <title>How to design your Laravel models fast in 2022 with Fluidbm</title>
      <dc:creator>Franz Nkemaka</dc:creator>
      <pubDate>Sat, 08 Jan 2022 16:09:08 +0000</pubDate>
      <link>https://dev.to/franznkemaka/how-to-design-your-laravel-models-fast-in-2022-with-fluidbm-55ip</link>
      <guid>https://dev.to/franznkemaka/how-to-design-your-laravel-models-fast-in-2022-with-fluidbm-55ip</guid>
      <description>&lt;p&gt;In this tutorial, I will show you how to design your Laravel Models fast using Fluidbm.&lt;/p&gt;

&lt;p&gt;👨‍💻 ⚡ 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.&lt;/p&gt;

&lt;p&gt;😊 Let's get started: &lt;br&gt;
This tutorial is splitted in two main parts: Designing the models and importing them to your Laravel project. &lt;/p&gt;
&lt;h2&gt;
  
  
  🎨 Design models with Fluidbm
&lt;/h2&gt;

&lt;p&gt;Foremost, you need to signup or login on Fluidbm: &lt;a href="https://fluidbm.com" rel="noopener noreferrer"&gt;https://fluidbm.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Press on &lt;strong&gt;Create new schema&lt;/strong&gt; to start a new project&lt;/p&gt;

&lt;p&gt;Using the editor, you can rename your Schema. In this case I will name mine "DemoBlog"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fei6jp5eorm5ghhl7mygi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fei6jp5eorm5ghhl7mygi.png" alt="New project on Fluidbm"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✍️ Creating models&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Press on &lt;strong&gt;Add Model&lt;/strong&gt; to create add a new model&lt;/p&gt;

&lt;p&gt;You can add as many models as you wish, as well as columns.&lt;/p&gt;

&lt;p&gt;To add columns to add Model, simply double-click the model.&lt;/p&gt;

&lt;p&gt;It should like this after: &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft4y5yv46n1iyfalyeg0t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft4y5yv46n1iyfalyeg0t.png" alt="Model showcase in Fluidbm"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using the Model Editor sidebar, one can add Laravel Database Factories, data dummies to fill up your models so you can use for testing.&lt;/p&gt;

&lt;p&gt;For our &lt;strong&gt;DemoBlog&lt;/strong&gt;, I will add another Model called &lt;strong&gt;Post&lt;/strong&gt;, with some additional factories, It looks as follows: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdf5x30modx3q8yxts2l0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdf5x30modx3q8yxts2l0.png" alt="Showcase models in Fluidbm"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔗 Adding relationships&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To link &lt;strong&gt;Users ** with **Posts&lt;/strong&gt;, click on the User model then drag the relation pin and drop on the model you want to connect. &lt;br&gt;
In our case &lt;strong&gt;User -&amp;gt; Post&lt;/strong&gt;. &lt;br&gt;
Then click on the connection line to define the type of Relationship. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8k7no4zkb4ubut1dkl66.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8k7no4zkb4ubut1dkl66.png" alt="Showcase Relationship in Fluidbm"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;😊 A code preview is also generated to give you some sense of the output later. &lt;/p&gt;
&lt;h2&gt;
  
  
  ⛏️ Importing to Laravel (in milliseconds)
&lt;/h2&gt;

&lt;p&gt;First create a new Laravel project, or open an existing one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer create-project laravel/laravel my-blog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;👨‍💻 ⚡ Fluidbm CLI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It interacts with the Fluidbm API to generate your Laravel schema schemas, factories and database seeder.&lt;/p&gt;

&lt;p&gt;The source code can be found here: &lt;a href="https://github.com/franznkemaka/fluidbm-cli" rel="noopener noreferrer"&gt;https://github.com/franznkemaka/fluidbm-cli&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use it directly with &lt;strong&gt;npx&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx fluidbm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or Install it via &lt;strong&gt;npm or yarn&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g fluidbm-cli

or 

yarn global add fluidbm-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this tutorial, we will use &lt;strong&gt;npx&lt;/strong&gt; as it requires no previous installation.&lt;/p&gt;

&lt;p&gt;🏗️ Authenticate with Fluidbm&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx fluidbm auth
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To link your Fluidbm project to your Laravel project, you have to clone it. Copy the url or the schema id only &lt;strong&gt;61d97a9185de6a5b30ab72e3&lt;/strong&gt; and paste it this way&lt;br&gt;
!make sure 61d97a9185de6a5b30ab72e3 to replace it with your own&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx fluidbm clone https://fluidbm.com/schema/61d97a9185de6a5b30ab72e3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's time to import all our code to Laravel with a single command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx fluidbm pull
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F822lhbndc1l6l8a9sz0u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F822lhbndc1l6l8a9sz0u.png" alt="After 140 milliseconds it is done"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All models and factories were successfully generated. A default seeder was also automatically implemented.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyp74bg6mr1o2dfw9nmmd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyp74bg6mr1o2dfw9nmmd.png" alt="Fludibm magic"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🎉After just 0.14s it is done ✅&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Go back to Fluidbm and perform changes, to resync, just hit &lt;code&gt;npx fluidbm pull&lt;/code&gt; and it is done 👍&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now let's migrate our DB and see the changes in a real DB&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generate mock data using the automatically generated seeder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan db:seed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpjpg489232rzx2fz1zbh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpjpg489232rzx2fz1zbh.png" alt="Generated Data in MySQL"&gt;&lt;/a&gt;&lt;br&gt;
✨ Boom! I think the result speaks for itself. &lt;/p&gt;

&lt;p&gt;To view DemoBlog on Fluidbm use this link, but you can't delete it instead you can &lt;strong&gt;Fork&lt;/strong&gt; it and create your own mutable copy: &lt;a href="https://fluidbm.com/s/zfy1opbnJdIW" rel="noopener noreferrer"&gt;https://fluidbm.com/s/zfy1opbnJdIW&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Give Fluidbm a try!

It’s free and available on https://fluidbm.com
Feedback is highly appreciated fluidbm@rigle.co
Cheers 🥂!
Franz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>laravel</category>
      <category>database</category>
      <category>schema</category>
      <category>cli</category>
    </item>
  </channel>
</rss>
