Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Hala's avatar
Level 3

Nova disable attach on Belongs to Many

Hello , i have rescorce having many to many with another model how could i disable editing on it just view relation with out attach or detach it

0 likes
7 replies
Hala's avatar
Level 3

i define the polices and the relation but nothing change i try to non display view icon and it's work but the attach did not work

bobbybouwmann's avatar

How do you hide the attach action? Show your policy. How can I help you with little information?

Hala's avatar
Level 3

@bobbybouwmann

well i have Order model and Theme model they are many to many

this is Order policy

public function attachTheme(Order $order, Theme $theme)
{
    return false;
}

and this is Theme policy

public function attachOrder(Order $order,Theme $theme) 
{
    return false;
}

and this is the relation in Order model

public function Themes()
{
    return $this->belongsToMany(Theme::class);
}
Hala's avatar
Level 3

@bobbybouwmann

Thank you , yes it works , one of these policies was having before method with override these things

Please or to participate in this conversation.