Laravel Metabox : Easy creation of custom fields for Laravel

If you have worked with WordPress, WordPress has a feature called custom metabox. The work of metabox in WordPress is that you create fields, you don’t need to create a database table related to its field. So the metabox itself has a special table that stores the received field data in key and value. Well, we brought this feature of WordPress metabox to Laravel. Installs Install Package: composer require rayiumir/laravel-metabox After Publish Files: php artisan vendor:publish --provider="Rayiumir\\LaravelMetabox\\ServiceProvider\\MetaboxServiceProvider" And Migration Database: php artisan migrate How to use Calling HasMetaboxes in Models Post.php: use Rayiumir\LaravelMetabox\Traits\HasMetaboxes; use HasMetaboxes; To delete post metabox data, place the following function in Post.php: protected static function boot(): void { parent::boot(); static::deleting(function ($post) { $post->metaboxes()->delete(); }); } Read the following documentation to work with fields: Text Field Image Upload Field GitHub

Mar 23, 2025 - 01:32
 0
Laravel Metabox : Easy creation of custom fields for Laravel

If you have worked with WordPress, WordPress has a feature called custom metabox. The work of metabox in WordPress is that you create fields, you don’t need to create a database table related to its field. So the metabox itself has a special table that stores the received field data in key and value.

Well, we brought this feature of WordPress metabox to Laravel.

Installs

Install Package:

composer require rayiumir/laravel-metabox

After Publish Files:

php artisan vendor:publish --provider="Rayiumir\\LaravelMetabox\\ServiceProvider\\MetaboxServiceProvider"

And Migration Database:

php artisan migrate

How to use

Calling HasMetaboxes in Models Post.php:

use Rayiumir\LaravelMetabox\Traits\HasMetaboxes;

use HasMetaboxes;

To delete post metabox data, place the following function in Post.php:

protected static function boot(): void
{
    parent::boot();

    static::deleting(function ($post) {
        $post->metaboxes()->delete();
    });
}

Read the following documentation to work with fields:

Text Field

Image Upload Field

GitHub