You talk, guys? Next, to head with the seed of my BD in laravel, I believe that anyone with more experience with the framework knows how to solve.
I have the model Person with relationship One to Many for other two (Professional and Client). At the time of the migration, it turns out that the registered people end up being professionals and clients at the same time, because they take the same ids, as I determine, for example, 10 registration of id 1 to 5 will be clients and id 6 to 10 Are they professional?
class Pessoa extends Model {
public function cliente()
{
return $this->hasOne('App\Cliente');
}
public function profissional()
{
return $this->hasOne('App\Profissional');
}
}
Professional Model
class Profissional extends Model
{
public function pessoa(){
return $this->belongsTo('App\Pessoa');
}
Model Client
class Cliente extends Model
{
public function pessoa(){
return $this->belongsTo('App\Cliente');
}
}
My seed (Here is the error >: p)
factory(App\Pessoa::class, 10)->create()->each(function ($u) {
$u->cliente()->
save(factory(App\Cliente::class)->make());
$u->profissional()->
save(factory(App\Profissional::class)->make());
});