An open API service indexing awesome lists of open source software.

https://github.com/devatreides/metavel

A simple package to integrate Metabase dashboards and questions to Laravel
https://github.com/devatreides/metavel

data-visualization integration laravel metabase php

Last synced: 4 months ago
JSON representation

A simple package to integrate Metabase dashboards and questions to Laravel

Awesome Lists containing this project

README

          


Total Downloads
Issues Open
Total Downloads
Latest Version
License

---

Metabase is an open source business intelligence platform where you can create charts/grids (known as questions) or a collection of questions (known as dashboards) as a custom visualization for your data. One of Metabase's features is embedding. Therefore, this package provides blade components that abstract the platform integration, allowing you to easily embed your question/dashboard in a Laravel application.

![image](https://user-images.githubusercontent.com/18440704/226209981-defde2b1-5fb3-42da-8d6f-f9088f68e10f.png)

## REQUIREMENTS
> **[PHP 8.1+](https://www.php.net/releases/)**
>
> **[Laravel 10](https://github.com/laravel/laravel)**

## HOW TO INSTALL

To install the package, just use [composer](https://getcomposer.org):

```bash
composer require tombenevides/metavel
```

## HOW TO USE

### Configuring Metabase credentials

After installing, publish your config file using:

```bash
php artisan vendor:publish --tag=metavel-config
```

This will create a `metavel.php` file in your config folder. There, you'll see the environment variables to set the Metabase's base url and secret key.

```env
METAVEL_BASE_URL #Metabase base url
METAVEL_SECRET_KEY #Metabase secret key
```

You will also find in the config file a *expiration_time* option. Since the communication between Laravel and Metabase works with JWT, using this option you can set an exp date for you generated token. The value is in seconds using NumericDate format.

### Call the component

After setting the platform credentials, you just need to call the match component in your blade file. There's two components, one for questions and other for dahsboards:

```blade



```

The components have some properties that you can set to customize the embbeding. Most of them are optional, except for **resource**, which is the ID of the element on Metabase (question or dashboard). Besides that, you can also set:

| Property | Type | default value | Description |
|-----------|---------|---------------|--------------------------------------------------|
| params | array | [ ] | if your question/dashboard have implicit filters |
| bordered | boolean | true | to load (or not) borders in the element |
| titled | boolean | true | to load (or not) the element original title |
| darkTheme | boolean | false | to load (or not) the element with dark theme |
| width | int | 1366 | set the width of the element |
| height | int | 768 | set the height of the element |

### Styling

As a blade component, you can add HTML attributes as classes for styling, for example. The Metabase element is loaded in an iframe but it's encapsulated by a div that receives the attributes, as shown below::

```php

```

This will generate:

```html



```

## LICENSE

**Metavel** is a software under the [MIT License](LICENSE)

## UPDATES

👋 Follow the author [@devatreides](https://twitter.com/devatreides) on Twitter to know more about the last updates and other projects. Say Hi!