Laravel Voyager Database – Database manager for Voyager

Laravel Voyager provides a robust database management interface that allows you to easily create, manage, and interact with your application’s database tables directly from the admin panel.

Accessing the Database Manager

  1. Log in to Voyager: First, ensure you’re logged into the Voyager admin panel at http://your-app-url/admin.
  2. Navigate to Database: From the sidebar, click on Tools, then select Database. This will bring you to the database management interface.

Key Features of the Database Manager

  1. View Tables: You can see a list of all the tables in your database. Clicking on a table will show you its structure and allow you to manage it.
  2. Create New Tables:
    • Click the Add Table button.
    • Fill out the form to define the table name and other settings.
    • After creating the table, you can define its columns.
  3. Manage Columns:
    • For any table, you can view, edit, or delete columns.
    • To add a new column, click the Add Column button, and specify the column name, type, and other attributes (like nullable, unique, default values).
  4. BREAD Management:
    • Once you have a table, you can set up BREAD (Browse, Read, Edit, Add, Delete) for that table.
    • Click on BREAD next to the table name to start configuring it. You can customize which fields are visible in each action and set validation rules.

Configuring BREAD

When you set up BREAD, you’ll have several options:

  • Display Name: Set a user-friendly name for the resource.
  • Columns: Choose which columns to display in the list view and detail view.
  • Validation: Define validation rules for each field to ensure data integrity.
  • Relationships: Set up relationships with other tables (e.g., one-to-many, many-to-many).

Advanced Features

  1. Relationships: Voyager supports defining relationships between tables. You can set foreign keys in the column configuration and link them to related tables.
  2. Indexes: You can create indexes on columns to improve query performance. This is especially useful for columns that will be searched frequently.
  3. Database Backup: Voyager has built-in options for database backups. You can manage your database backups through the Tools > Backup section.
  4. Migrations: While Voyager allows you to manage tables directly, it’s a good practice to use migrations for version control. You can create migrations using:
    bash

    After creating the migration, run it with:

    bash

Viewing Data

  • Click on any table name in the Database manager to view the data within that table.
  • You can add new records, edit existing ones, or delete them directly from the Voyager interface.

Conclusion

The Database manager in Laravel Voyager makes managing your application’s database straightforward and intuitive. By leveraging its features, you can easily create and manage your tables and their relationships, as well as set up BREAD functionality without writing extensive code. This not only speeds up development but also provides a user-friendly interface for managing your database.

Leave a Comment

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

Scroll to Top