I'm new to this questions thing so please bear with me.

I'm using Eloquent as my PHP database library. So I created a class that extends from `Illuminate\Database\Eloquent\Model` and tried to query one single record. When I print the results I know it is fetching the information, as you can see by the protected *attributes*, but somehow the public attributes of the record are NULL.

Am I missing some previous configuration, or is there another reason for that?

Here's my structure:

The Model, `Plantilla.php`

```php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Plantilla extends Model
{
    /**
     * @var string
     */
    protected $primaryKey = 'cod_plantilla';
    /**
     * @var string
     */
    protected $table = 'plantilla';
    protected $connection = 'mysql';

    public function __construct()
    {
        #attributes
        parent::__construct();
        Database2::init();
    }
}

```

`Database.php`

```php
<?php

namespace App\Models;

use Illuminate\Database\Capsule\Manager as Capsule;

class Database2
{
    private static $db;

    static public function init()
    {
        if (is_null(self::$db)) {
            $capsule = new Capsule;

            $capsule->addConnection([
                'driver' => 'mysql',
                'host' => getenv('DB_HOST'),
                'database' => getenv('DB_NAME'),
                'username' => getenv('DB_USER'),
                'password' => getenv('DB_PASS'),
                'charset' => 'utf8',
                'collation' => 'utf8_unicode_ci',
                'prefix' => '',
            ], 'mysql');

            // Make this Capsule instance available globally via static methods... (optional)
            $capsule->setAsGlobal();

            // Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
            $capsule->bootEloquent();
        }
    }
}

```

index.php

```php
$p = Plantilla::where('cod_plantilla', 35)->first();
var_dump($p);

```

Result

```
object(App\Models\Plantilla)[251]
  protected 'primaryKey' => string 'cod_plantilla' (length=13)
  protected 'table' => string 'plantilla' (length=9)
  protected 'connection' => string 'mysql' (length=5)

  # Values I need
  public 'cod_area_interna' => null
  public 'cod_tipo_plantilla' => null
  public 'nombre' => null
  public 'detalle' => null
  public 'personalizada' => null
  public 'fecha' => null
  # Values I need

  protected 'keyType' => string 'int' (length=3)
  public 'incrementing' => boolean true
  protected 'with' => 
    array (size=0)
      empty
  protected 'withCount' => 
    array (size=0)
      empty
  protected 'perPage' => int 15
  public 'exists' => boolean true
  public 'wasRecentlyCreated' => boolean false

  # Same values I need but they're protected
  protected 'attributes' => 
    array (size=7)
      'cod_plantilla' => int 35
      'cod_area_interna' => int 2
      'cod_tipo_plantilla' => int 1
      'nombre' => string 'Some' (length=32)
      'detalle' => string 'Some' (length=142)
      'personalizada' => null
      'fecha' => string '2020-06-25 12:15:13' (length=19)
  protected 'original' => 
    array (size=7)
      'cod_plantilla' => int 35
      'cod_area_interna' => int 2
      'cod_tipo_plantilla' => int 1
      'nombre' => string 'Some' (length=32)
      'detalle' => string 'Some' (length=142)
      'personalizada' => null
      'fecha' => string '2020-06-25 12:15:13' (length=19)
  protected 'changes' => 
...

```

As the documentation states, you can do something like this

```php
<?php

$flights = App\Models\Flight::all();

foreach ($flights as $flight) {
    echo $flight->name;
}

```

So you can access the attributes aka table columns values.

In my case those are:

* cod\_plantilla
* cod\_area\_interna
* cod\_tipo\_plantilla
* nombre
* detalle
* personalizada
* fecha