1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] Relationship with hasOne instead of belongsTo

Discussão em 'Outras Linguagens' iniciado por Stack, Setembro 11, 2024.

  1. Stack

    Stack Membro Participativo

    I have a database something like

    factories
    id
    gallery_id nullable
    ...

    galleries
    id
    ...


    I want to use hasOne because every factory has one gallery and not the other way around. Still I found that only belongsTo works in the Factory model:

    public function gallery(){
    return $this->belongsTo(Gallery::class);
    }


    Is there a way around this or I have to accept that Eloquent works this way?

    Continue reading...

Compartilhe esta Página