PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Question By
Solved

ScopeCurrentUser on add new item to table

Solved
cassiolacerda

Jun 21st, 2022 07:46 PM

Hello, I'm using the ScopeCurrentUser function, so the system only shows me my groups. But when creating a new post, I can create this post in another user's group. How can I fix this?

Foto Wave.png

When I'm going to create a new post, I want to show only my groups in the relationship dropbox.

bobbyiliev

Jun 22nd, 2022 02:20 AM

Best Answer

Hi there,

You will need to scope the relationship too. You can do that by following the steps from the docs here:

Voyager Scoping relationships

Besically you have to first add the local scope in the foreign model and then specify it in the relation, eg.:

{
    "scope": "currentUser"
}

I've just tested it and can verify that it is working as expected.

Hope that this helps!

Best,

Bobby