Skip to content

Commit 7adc598

Browse files
committed
doc: update README.md for install and usage package
1 parent 2067620 commit 7adc598

File tree

1 file changed

+64
-2
lines changed

1 file changed

+64
-2
lines changed

README.md

+64-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,70 @@
11
# Metabase Laravel
2-
2+
**First [Metabase](https://www.metabase.com/ "Metabase") should be installed . You can get more info [Here](https://www.metabase.com/docs/latest/).**
33

44
# Installation
55

66
## Step 1 - Install the package
77

8-
You can install ehsan9/laravel-metabase with Composer directly in your project:
8+
You can install ehsan9/metabase-laravel with Composer directly in your project:
9+
10+
```sh
11+
$ composer require ehsan9/metabase-laravel
12+
```
13+
## Step 2 - Publish
14+
15+
Run this command in your project directory:
16+
```sh
17+
php artisan vendor:publish --provider="Ehsan9\MetabaseLaravel\MetabaseServiceProvider"
18+
```
19+
20+
## Step 3 - Set config
21+
22+
Now you must define your [Metabase Url, Username and Password](https://www.metabase.com/learn/administration/metabase-api) to project. for this head to **config/metabase-api.php** then put your metabase info in the code:
23+
```php
24+
return [
25+
'url' => 'https://yoursmetabase.com',
26+
'username' => 'your_metabase_username',
27+
'password' => 'your_metabase_pass'
28+
];
29+
```
30+
31+
# Usage
32+
33+
You can use the package where ever you want.
34+
- **Method 1**:
35+
36+
- First use the class:
37+
```php
38+
use Ehsan9\MetabaseLaravel\MetabaseApi;
39+
```
40+
- Then use this pattern to connect Metabase api:
41+
```php
42+
$metabaseApi = new \Ehsan9\MetabaseLaravel\MetabaseApi(
43+
config('metabase-api.url'), config('metabase-api.username'), config('metabase-api.password')
44+
);
45+
$parameters = [
46+
[
47+
"type" => "category",
48+
"value" => "YOUR_VALUE",
49+
"target" => [
50+
"variable",
51+
[
52+
"template-tag",
53+
"member_id"
54+
]
55+
]
56+
]
57+
];
58+
59+
$result = $metabaseApi->getQuestion('questionId', 'json', $parameters);
60+
```
61+
62+
- **Method 2**:
63+
- use MetabaseApi Facade in ServiceProvider
64+
```php
65+
use Ehsan9\MetabaseLaravel\Facades\MetabaseApi;
66+
```
67+
- then use this pattern
68+
```php
69+
MetabaseApi::getQuestion('questionId');
70+
```

0 commit comments

Comments
 (0)