aheer.me

Building a Gym Management App with Laravel, Filament, Herd, and Blueprint

Hello friends,

I recently took on the challenge of building a gym management application. Using Laravel along with some fantastic tools like Filament, Herd, and Blueprint, I was able to create a robust app in no time. If you find documentation hard to follow or just want a more guided experience, this post is for you. I’ll walk you through everything step-by-step. Let’s dive in!

Setting Up Your Environment with Herd

First things first, let’s get our development environment ready with Herd. Herd makes setting up Laravel projects a breeze, so you can get to coding faster.

  1. Download and Install Herd: Head over to Herd’s official site and follow the instructions to install it.
  2. Create a New Laravel Project: Open your terminal and run:
    laravel new project-name

Replace project-name with your desired project name.

Installing Filament

Filament is an awesome admin panel for Laravel applications. It gives you a beautiful, easy-to-use interface to manage your app’s data.

  1. Navigate to Your Project Directory:
    cd project-name
  2. Install Filament: Run the following command to install Filament:
    composer require filament/filament:"^3.2" -W
  3. Set Up Filament: After installation, set it up with:
    php artisan filament:install --panels
  4. Start the Development Server:
    php artisan serve

Now, you can access the admin panel at http://localhost/admin.

  1. Create an Admin User:
    php artisan make:filament-user

Follow the prompts to set up a username and password.

Accelerating Development with Blueprint

Blueprint lets you define your application’s models, controllers, and more using simple YAML files. This can save you a ton of time.

  1. Install Blueprint:
    composer require -W --dev laravel-shift/blueprint
  2. Create a New Blueprint Draft:
    php artisan blueprint:new

Here’s an example draft.yaml file for our gym management application:

models:
  Member:
    id: id
    name: string:255
    email: string:255 unique
    phone: string:20
    address: string:255
    membership_start_date: date
    membership_end_date: nullable date
    membership_type_id: foreignId:constrained:cascade
    relationships:
      belongsTo: membership_type
      hasMany: payments, invoices

  MembershipType:
    id: id
    name: string:255
    description: text
    price: decimal:8,2
    duration_months: integer
    relationships:
      hasMany: members

  Payment:
    id: id
    member_id: foreignId:constrained:cascade
    amount: decimal:8,2
    payment_date: date
    payment_method: string:50
    relationships:
      belongsTo: member

  Invoice:
    id: id
    member_id: foreignId:constrained:cascade
    amount: decimal:8,2
    due_date: date
    paid: boolean
    relationships:
      belongsTo: member
JSON

Build Your Application:
php artisan blueprint:build

    This command will generate the necessary models, migrations, and more based on your draft.yaml.

    Run the Migrations:
    php artisan migrate

      Creating Filament Resources

      Filament makes it super easy to generate resource management interfaces. Let’s create resources for our models.

      Generate Resources:

        
        php artisan make:filament-resource MemberResource --generate 
        php artisan make:filament-resource PaymentResource --generate 
        php artisan make:filament-resource InvoiceResource --generate
        Bash

        Wrapping Up

        And there you have it! Using Herd, Filament, and Blueprint, I was able to quickly build a functional gym management application. These tools made the process smooth and enjoyable, turning what could have been a tedious task into a fun project.

        Recent Posts

        Leave a Comment

        Your email address will not be published. Required fields are marked *