PHP code example of icehouse-ventures / laravel-mermaid
1. Go to this page and download the library: Download icehouse-ventures/laravel-mermaid library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
icehouse-ventures / laravel-mermaid example snippets
// In your controller
public function index()
{
$data =
'graph LR;
A[Label 1];
A-->B;
A-->C;
B[Label 2];
B-->D;
C[Label 3];
C-->D;
D[Label 4];';
return view('your-view', compact('data'));
}
// Your page blade file
<x-mermaid::component :data="$data" />
// In your controller
use IcehouseVentures\LaravelMermaid\Facades\Mermaid;
public function index()
{
$data = [
'A-->B',
'A-->C',
'B-->D',
'C-->D'
];
Mermaid::build()->generateDiagramFromArray($data);
return view('your-view', compact('data'));
}
// Your page blade file
<x-mermaid::component :data="$data" />
// In your controller
use IcehouseVentures\LaravelMermaid\Facades\Mermaid;
public function index()
{
$collection = User::with('posts')->get();
$data = Mermaid::build()->generateDiagramFromCollection($collection);
return view('your-view', compact('data'));
}
// Your page blade file
<x-mermaid::component :data="$data" />