PHP code example of sanwarul / organogram

1. Go to this page and download the library: Download sanwarul/organogram 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/ */

    

sanwarul / organogram example snippets


use Sanwarul\Organogram\Models\Organization;

$ministry = Organization::create([
    'name' => 'Ministry of Public Administration',
    'code' => 'MOPA',
    'type' => 'ministry',
    'metadata' => json_encode([
                'address' => 'Bangladesh Secretariat, Dhaka',
                'phone' => '02-12345678',
                'email' => '[email protected]'
    ]),
]);

// Add Bangla translation
$ministry->setTranslation('name', 'bn', 'জনপ্রশাসন মন্ত্রণালয়');
$ministry->save();

$division = Organization::create([
    'name' => 'Public Administration Division',
    'code' => 'PAD',
    'type' => 'division',
    'parent_id' => $ministry->id,
    'metadata' => json_encode([
                'address' => 'Bangladesh Secretariat, Dhaka',
                'phone' => '02-12345678',
                'email' => '[email protected]'
    ]),
]);

$tree = Organization::with('children')->whereNull('parent_id')->get();
bash
php artisan organogram:install