PHP code example of optimuscms / meta

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

    

optimuscms / meta example snippets


    class MyModel extends Model
    {
        use Optix\Meta\HasMeta;
    

    protected static function boot()
    {
        parent::boot();
    
        static::saved(function ($model) {
            /** @var HasMeta $model */
            $model->saveMeta(request('meta'));
        });
    }
    

   public function toArray()
   {
       return [
           ...other properties,
           'meta' => $this->meta,
       ];
   }
    

$media = $myModel->meta->getOgImage();
bash
php artisan migrate