I try to use scaffold from table of relational-object database using infyom
but i can't manipulate object like in POO because the models generated contains only the id of the other object! there is a way to manipulate object correctly?
model generated is like:
<?php
namespace App\Models;
use Eloquent as Model;
/**
* Class Facture
* @package App\Models
* @version July 17, 2018, 6:08 pm UTC
*
* @property \Illuminate\Database\Eloquent\Collection Consomme
* @property \Illuminate\Database\Eloquent\Collection contient
* @property \Illuminate\Database\Eloquent\Collection EstFactureBst
* @property \App\Models\EstFacture estFacture
* @property string num_facture
* @property date date_facture
* @property string etat_facture
* @property integer num_releve
*/
class personnel extends Model
{
public $table = 'personnel';
public $timestamps = false;
public $sousPersonnel;
protected $primaryKey = 'id_pers';
public $fillable = [
'id_pers',
'lib_pers'
];
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts = [
'lib_pers' => 'string'
];
/**
* Validation rules
*
* @var array
*/
public static $rules = [
];
public function SousPersonnel(){
return $this->hasMany(\App\Models\TypePersonne::class);
}
}
there is a relation between my class personnel and TypePErsonne
but when I want to write like $personnel->typePersonne
and make dd I have it null I use Eloquent ORM
it seems like they can't find typePersonne
for my object $personnel
You have defined relation within the method named SousPersonnel()
so to read it you should use SousPersonnel
attribute like this:
$personnel->SousPersonnel