Getters and Setters are automatically generated by Eloquent when we use relies / laravel to generate the Modules?

0

I have an already functional application. I'm moving on to laravel 5.4. Since the database already exists and with real data, my choice is not to use Migrations. One option would be to use the Query Builder to access the data in the database. But I did not want to leave behind some conveniences offered by the Eloquent. So I decided to import the database model into ORM using reliese / laravel , and at the end of the process the Templates are created in folder app / Models / MyTab.php .

Since I am a beginner in Laravel I do not know which methods are automatically created when we generate the Models. It struck me that no getters and setters were created automatically for each field or atributuo of each table. In Sinfony there is a Doctrine function, which after creating Entities (equivalent to Eloquent Templates), this function generates getters and setters for each field in the table.

This is a sample of the auto-generated code for the Template of the Country table:

<?php

/**
 * Created by Reliese Model.
 * Date: Mon, 06 Mar 2017 02:14:38 +0000.
 */

namespace App\Models;

use Reliese\Database\Eloquent\Model as Eloquent;

/**
 * Class Country
 * 
 * @property int $id
 * @property string $name
 * @property string $iso3_code
 * @property string $iso2_code
 * @property string $geocodeBr
 * @property float $lat
 * @property float $long
 * 
 * @property \Illuminate\Database\Eloquent\Collection $provinces
 *
 * @package App\Models
 */
class Country extends Eloquent
{
    protected $table = 'country';
    public $timestamps = false;

    protected $casts = [
        'lat' => 'float',
        'long' => 'float'
    ];

    protected $fillable = [
        'name',
        'iso3_code',
        'iso2_code',
        'geocodeBr',
        'lat',
        'long'
    ];

    public function provinces()
    {
        return $this->hasMany(\App\Models\Province::class, 'fk_country');
    }
}

As you can see, practically nothing was created, I would have to create the setters and getters and put delete, etc, for each field of each table.

When we have a database with 200 tables, that's boring.

So my question is whether getters and setters are automatically generated by some Eloquent command or do I have to automatically create each one of them? If so, which command would that be?

    
asked by anonymous 06.03.2017 / 15:46

0 answers