PHP code example of monamoxie / vocab-mapper

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

    

monamoxie / vocab-mapper example snippets


php artisan vendor:publish --tag=vocab-mapper-config

php artisan vendor:publish --tag=vocab-mapper-migration

php artisan migrate

php artisan tenants:migrate



use App\Models\MyModel;

(new MyModel)->createVocab(name: 'Vocab Name');



use App\Models\MyModel;

(new MyModel)->mapVocabTo($entity, $customName);



use App\Models\MyModel;

(new MyModel)->getVocabFor($entity);



use App\Models\MyModel;
use Monamoxie\VocabMapper\Facades\VocabCollector;

public function index()
{
    $entity = Tenant::where('id', auth()->user()->id)->first();

    return view('academy.foo.bar', [
        'vocab' => VocabCollector::getFor($entity, MyModel::class),
        'data' => 'some random data',
        'data2' => 'some other random data'
    ]);
}