PHP code example of kolyayurev / voyager

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

    

kolyayurev / voyager example snippets

bash
php artisan voyager:install
bash
php artisan voyager:install --with-dummy
bash
php artisan voyager:admin [email protected]
bash
php artisan voyager:admin [email protected] --create


public function adminFields():array{
    
     return [
      'meta_1' => [
          "name" => "meta_1",
          "type" => "varchar",
          "null" => "YES",
          "field" => "timestamp",
          "key" => null,
          // OTHERS
          "default" => null,
          "notnull" => false,
          "length" => 0,
          "precision" => 10,
          "scale" => 0,
          "fixed" => false,
          "unsigned" => false,
          "autoincrement" => false,
          "columnDefinition" => null,
          "comment" => null,
          "oldName" => "timestamp",
          "extra" => "",
          "composite" => false,
          "indexes" => [],
      ],
     ];
    }

    public function setOptionsAttribute($value)
    {
        $this->attributes['options'] = json_encode($value);
    }

    public function getOptionsAttribute($value)
    {
        return json_decode(!empty($value) ? $value : '{}');
    }

    public function setMeta1Attribute($value)
    {
        $this->attributes['options'] = collect($this->options)->merge(['meta_1' => $value]);
    }
    public function getMeta1Attribute()
    {
        return $this->options->meta_1 ?? null;
    }


public static function boot(){
    parent::boot();
    static::creating(function ($model) {
        $model->type = 'client';
    });
    static::addGlobalScope('client', function($builder){
        $builder->where('type', 'client');
    });
}


php artisan db:seed --class=VoyagerBreadFeedbacksSeeder