<?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: Adrián HM</title>
    <description>The latest articles on DEV Community by Adrián HM (@adrhem).</description>
    <link>https://dev.to/adrhem</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%2F3525291%2F2afcae82-7587-4d93-acc6-ded8a0a753d6.jpeg</url>
      <title>DEV Community: Adrián HM</title>
      <link>https://dev.to/adrhem</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adrhem"/>
    <language>en</language>
    <item>
      <title>Integrating MongoDB into Laravel with Filament</title>
      <dc:creator>Adrián HM</dc:creator>
      <pubDate>Wed, 24 Sep 2025 22:29:21 +0000</pubDate>
      <link>https://dev.to/adrhem/integrating-mongodb-into-laravel-with-filament-2593</link>
      <guid>https://dev.to/adrhem/integrating-mongodb-into-laravel-with-filament-2593</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Wall of text incoming...&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Skip to Getting Started if you want to go directly to the code&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://laravel.com/" rel="noopener noreferrer"&gt;Laravel&lt;/a&gt; is one of the best PHP frameworks I ever tried in my career which works very well with relational databases such &lt;a href="https://mariadb.org/" rel="noopener noreferrer"&gt;MariaDB&lt;/a&gt; or &lt;a href="https://www.postgresql.org/" rel="noopener noreferrer"&gt;PostgreSQL&lt;/a&gt;. However recently I had the opportunity to dig into NoSQL databases, specifically into &lt;a href="https://www.mongodb.com/" rel="noopener noreferrer"&gt;MongoDB&lt;/a&gt; that offers amazing features like TTL indexes or embedded documents (aka One to Few relationships).&lt;/p&gt;

&lt;p&gt;One of my hobbies is the homelab. I love to manage my own server and services. I have many of docker compose projects and everytime I want to test a new service it becomes a pain to manage the updates. Therefore I just started a new project trying to auto manage my docker applications in my personal server without using the CLI. I mean the CLI of docker-compose is amazing but I wanted to try out alternatives that are not so powerkill as &lt;a href="https://www.portainer.io/" rel="noopener noreferrer"&gt;portainer&lt;/a&gt; is. Saying that it came into my mind to work on a small application using &lt;a href="https://filamentphp.com/" rel="noopener noreferrer"&gt;Filament admin&lt;/a&gt; in order to avoid working on templates, scripts and all repetitive tasks that requires for a simple CRUD application. Filament offers a very nice admin panel that works out of the box and it is very easy to customize and integrate with Laravel.&lt;/p&gt;

&lt;p&gt;So I decided to work on &lt;a href="https://github.com/adrhem/lunash" rel="noopener noreferrer"&gt;Lunash&lt;/a&gt; and at the time I am writing this post I just released version 0.1 (All feedback is well received!). While I was working in Lunash I encountered many blockers integrating mongo with Laravel and Filament and this is the intention of this post. To you developers to avoid all the blockers I had and be able to create your own projects using these amazing technologies.&lt;/p&gt;
&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;Requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  PHP running and configured in your machine.&lt;/li&gt;
&lt;li&gt;  PECL. (If you have PHP installed probably you already have it).&lt;/li&gt;
&lt;li&gt;  Composer (&lt;a href="https://getcomposer.org/doc/00-intro.md" rel="noopener noreferrer"&gt;official documentation&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;  MongoDB running in your machine or a remote instance. (I used the community edition).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also I will assume you have basic knowledge of Laravel and MongoDB. If you don't, please check the official documentation of both technologies.&lt;/p&gt;

&lt;p&gt;For reference I published the code on my repo:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://github.com/adrhem/laravel-mongo-filament" rel="noopener noreferrer"&gt;https://github.com/adrhem/laravel-mongo-filament&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Laravel
&lt;/h3&gt;

&lt;p&gt;First of all we need to create a new laravel project. I used the &lt;a href="https://laravel.com/docs/12.x/installation#creating-a-laravel-project" rel="noopener noreferrer"&gt;Laravel Installer&lt;/a&gt; to create a new project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;laravel new &amp;lt;project&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I used the default configurations and I chose the &lt;strong&gt;no starter kit&lt;/strong&gt; option since filament covers all the needs of this project. If the CLI asks you for a specific database, pick any option since we will remove it in following steps.&lt;/p&gt;

&lt;h3&gt;
  
  
  MongoDB
&lt;/h3&gt;

&lt;p&gt;Now we need to configure MongoDB as our primary database. In the &lt;a href="https://laravel.com/docs/12.x/mongodb" rel="noopener noreferrer"&gt;official documentation of mongodb for laravel&lt;/a&gt; explains very well all the steps needed. But I will summarize them here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pecl install mongodb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://pecl.php.net/" rel="noopener noreferrer"&gt;PECL&lt;/a&gt; is a CLI that helps you to install PHP extensions easily and this command will install and configure the mongodb driver for your default PHP installation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require mongodb/laravel-mongodb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then using composer to manage our dependencies it will install the &lt;a href="https://www.mongodb.com/docs/drivers/php/laravel-mongodb/current/" rel="noopener noreferrer"&gt;official laravel mongodb package&lt;/a&gt; that will help us with all the driver integration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Laravel with Mongo
&lt;/h3&gt;

&lt;p&gt;Now that we have all the required dependencies we can go into specific configurations to make laravel compatible with mongodb.&lt;/p&gt;

&lt;h4&gt;
  
  
  Updating the &lt;code&gt;.env&lt;/code&gt; configuration
&lt;/h4&gt;

&lt;p&gt;I removed all the MariaDB (or any other relational database) configuration from the &lt;code&gt;.env&lt;/code&gt; file and added the following lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DB_CONNECTION=mongodb
MONGODB_DATABASE=db-name
MONGODB_URI="mongodb://localhost:27017/"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and make sure the connection &lt;code&gt;mongodb&lt;/code&gt; exists in the &lt;code&gt;config/database.php&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'connections' =&amp;gt; [
    ...
    'mongodb' =&amp;gt; [
        'driver' =&amp;gt; 'mongodb',
        'dsn' =&amp;gt; env('MONGODB_URI', 'mongodb://localhost:27017'),
        'database' =&amp;gt; env('MONGODB_DATABASE', 'db-name'),
    ],
],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Updating the migrations
&lt;/h4&gt;

&lt;p&gt;We need to update the database migrations to make them fully compatible with mongodb. Remember now we are working with collections and not tables. So we need to update the &lt;code&gt;use&lt;/code&gt; statement in the migration files as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;use MongoDB\Laravel\Schema\Blueprint;

Schema::create('users', function (Blueprint $collection) {
    $collection-&amp;gt;id();
    ... // other fields
    $collection-&amp;gt;timestamps();
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you plan to use the database session driver then update its migration as well:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Schema::create('sessions', function (Blueprint $collection) {
    $collection-&amp;gt;id();
    ... // other fields
    $collection-&amp;gt;expire('expires_at', config('session.lifetime'));
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where expire method will create a TTL index in the &lt;code&gt;expires_at&lt;/code&gt; field that will automatically remove the documents after the defined time.&lt;/p&gt;

&lt;p&gt;Now we can run the migration command and check everything ran correctly:&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;&lt;a href="https://media2.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%2Fz8ltzf8tpj5e36lcd6mi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fz8ltzf8tpj5e36lcd6mi.png" alt="Laravel migration" width="562" height="158"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Updating the User Model and other Models
&lt;/h4&gt;

&lt;p&gt;When we created the laravel application the model app/Models/User.php file auto generated. We need to update it to make it compatible with mongodb. We just need to update the &lt;code&gt;Authenticable&lt;/code&gt; dependency as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;use MongoDB\Laravel\Auth\User as Authenticatable;

class User extends Authenticatable
{
    ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All other traits and dependencies can remain the same.&lt;/p&gt;

&lt;p&gt;If you add more models remember to update the base model dependency with: &lt;code&gt;use MongoDB\Laravel\Eloquent\Model;&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Updating the Cache Store
&lt;/h4&gt;

&lt;p&gt;By default laravel uses the database store to write the cache hits. If you want to use mongodb as your cache provider you need to do the following updates:&lt;/p&gt;

&lt;p&gt;In the &lt;code&gt;config/cache.php&lt;/code&gt; update or create a new entry for mongodb:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'mongodb' =&amp;gt; [
    'driver' =&amp;gt; 'mongodb',
    'connection' =&amp;gt; 'mongodb',
    'collection' =&amp;gt; 'cache',
    'lock_connection' =&amp;gt; 'mongodb',
    'lock_collection' =&amp;gt; 'cache_locks',
    'lock_lottery' =&amp;gt; [2, 100],
    'lock_timeout' =&amp;gt; 86400,
],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update your &lt;code&gt;.env&lt;/code&gt; file to &lt;code&gt;CACHE_STORE=mongodb&lt;/code&gt; if needed.&lt;/p&gt;

&lt;p&gt;And finally update your migration that contains the creation of the cache table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php


use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Cache;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        /** @var MongoDB\Laravel\Cache\MongoStore */
        $store = Cache::store('mongodb');
        $store-&amp;gt;createTTLIndex();
        $store-&amp;gt;lock('')-&amp;gt;createTTLIndex();
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        /** @var MongoDB\Laravel\Cache\MongoStore */
        $store = Cache::store('mongodb');
        $store-&amp;gt;flush();
        /** @var MongoDB\Laravel\Cache\MongoLock */
        $store
            -&amp;gt;restoreLock('lunash', owner: 'app')
            -&amp;gt;forceRelease();
    }
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This migration will create and expire all documents saved in the cache collection automatically.&lt;/p&gt;

&lt;p&gt;Since we ran previously the &lt;code&gt;php artisan migrate&lt;/code&gt; you can run the command:&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:fresh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to drop all the collections and run all the migrations again.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Filament
&lt;/h3&gt;

&lt;p&gt;Now that we have all the required configuration with mongodb we can continue installing Filament admin. You can check &lt;a href="https://filamentphp.com/docs/4.x/getting-started" rel="noopener noreferrer"&gt;the official documentation&lt;/a&gt; for detailed instructions. But I know we just want the straightforward commands to make it work. So here we go:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require filament/filament:"^4.0"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will install the filament official package. The version 4 is the latest version for now.&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 filament:install --panels
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will create the default administration panels that allows you to navigate to &lt;code&gt;/admin&lt;/code&gt; or any other defined route administration.&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 make:filament-user
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And finally running this command will create an user to login into your app admin page:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fsdrb7pt0d7gkj2drw4v2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fsdrb7pt0d7gkj2drw4v2.png" alt="Filament default sign in page" width="560" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The admin page looks empty, right? Don't worry we will create a resource to manage users in the next section.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F1s0kne0ldiz38xenye8i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F1s0kne0ldiz38xenye8i.png" alt="Filament dashboard" width="800" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a Filament Resource
&lt;/h3&gt;

&lt;p&gt;Now that we have everything set up we can create a resource to manage users. Filament resources are very powerful and easy to create. You can check the &lt;a href="https://filamentphp.com/docs/4.x/resources/overview" rel="noopener noreferrer"&gt;official documentation&lt;/a&gt; for more information.&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 make:filament-resource User
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you will be able to see the user we created as admin with all the CRUD Operations available.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fiproyzpfnbu87ttc8aba.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fiproyzpfnbu87ttc8aba.png" alt="User resource for user resource" width="800" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And of course with &lt;code&gt;mongosh&lt;/code&gt; you will be able to see the document you created:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.users.find()
[
  {
    _id: ObjectId('68d2f89c9109cb649b081532'),
    name: 'Adrián HM',
    email: 'dev.foe555@slmail.me',
    password: '$2y$.....u',
    updated_at: ISODate('2025-09-23T19:50:46.440Z'),
    created_at: ISODate('2025-09-23T19:44:28.257Z')
  }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Adding a new One to Few relationship
&lt;/h3&gt;

&lt;p&gt;Now that we have everything working we can create a new model with a One to Few relationship. In MongoDB we can embed documents inside other documents. This is very useful when you have a relationship that doesn't require to be queried separately or it is not going to grow too much.&lt;/p&gt;

&lt;p&gt;For example a user can have many addresses but an address belongs to one user. So we can embed the addresses inside the user document.&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 make:model Address
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Do you remember that we are working with collections and not tables? So the migration is not needed. We just need to update the Address model as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Models;

use MongoDB\Laravel\Eloquent\Model;

class Address extends Model
{
    protected $fillable = [
        'street',
        'city',
        'state',
        'zip_code',
    ];
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we need to update the User model to add the new relationship:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;use MongoDB\Laravel\Relations\EmbedsMany;
...

protected $fillable = [
    ...
    'addresses',
];

public function addresses(): EmbedsMany
{
    return $this-&amp;gt;embedsMany(Address::class);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can update the &lt;code&gt;UserResource&lt;/code&gt; to add the addresses relationship. We need to update the &lt;code&gt;app/Filament/Resources/Users/Schemas/UserForm.php&lt;/code&gt; and add a new &lt;a href="https://filamentphp.com/docs/4.x/forms/repeater" rel="noopener noreferrer"&gt;Repeater&lt;/a&gt; field as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static function configure(Schema $schema): Schema
{
    return $schema
        -&amp;gt;components([
            ...
            Repeater::make('addresses')
                -&amp;gt;schema([
                    TextInput::make('street')-&amp;gt;required(),
                    TextInput::make('city')-&amp;gt;required(),
                    TextInput::make('state')-&amp;gt;required(),
                    TextInput::make('zip_code')-&amp;gt;required(),
                ])
                -&amp;gt;columnSpanFull()
                -&amp;gt;columns(2)
        ]);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see it is very easy to add a new embedded document with filament. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fq758v4ya97wy8fg2bgjl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fq758v4ya97wy8fg2bgjl.png" alt="Filament embedded addresses" width="701" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And checking with &lt;code&gt;mongosh&lt;/code&gt; we can see the new addresses embedded in the user document:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.users.find()

[
  {
    _id: ObjectId('68d4699ca2f00456ca042612'),
    name: 'Adrián HM',
    email: 'dev.foe555@slmail.me',
    password: "$2y$10$.....u",
    updated_at: ISODate('2025-09-24T22:14:49.202Z'),
    created_at: ISODate('2025-09-24T21:58:52.165Z'),
    addresses: [
      {
        street: 'En algún lugar de la mancha',
        city: 'De cuyo nombre',
        state: 'No quiero acordarme',
        zip_code: '12345'
      }
    ]
  }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;And that's it, you can easily integrate mongo with laravel and filament. Just a reminder that Filament doesn't officially support MongoDB so if you plan to use it in production please test all the features you plan to use. For more information visit the official documentation of all the technologies described in this post.&lt;/p&gt;

&lt;p&gt;Thanks for reading! And if you have any questions or feedback please let me know.&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>laravel</category>
      <category>php</category>
      <category>filament</category>
    </item>
  </channel>
</rss>
