Hello Phalconers!!!! I'm trying save relationed models N:N, but i'm already searched everywhere, and nothing works..
class PainelPerfil extends BaseModel {
public function initialize()
{
$this->hasManyToMany('id', PainelPerfilAction::class, 'painel_perfil_usuario_id', 'painel_action_id', PainelAction::class, 'id', ['alias' => 'PainelAction']);
}
}
class PainelPerfilAction extends BaseModel {
public function initialize()
{
$this->belongsTo('painel_perfil_id', PainelPerfil::class, 'id', ['alias' => 'PainelPerfil']);
$this->belongsTo('painel_action_id', PainelAction::class, 'id', ['alias' => 'PainelAction']);
}
}
class PainelAction extends BaseModel {
public function initialize()
{
$this->hasManyToMany('id', PainelPerfilAction::class, 'painel_action_id', 'painel_perfil_usuario_id', PainelPerfil::class, 'id', ['alias' => 'PainelPerfil']);
}
}
if i use
$perfil->painelAction();
works fine to get related objects, but i can't insert or update this relationship
variable $actions has an collection of PainelAction.
$perfil->painelAction = $actions;
$perfil->save();
but not save relations :(
Anyone has any idea to save it? Thx!