This if kind of a finicky problem, and the title may be a bit confusing, so I'll try and explain as best as I can.

Basically, I am creating a Recipe application, where users can create lists and add recipes to them.

I want the lists to only be able to have one instance of each recipe, so for example, if I add Recipe 10 to List number 1, I don't want the user to be able to add Recipe 10 any more to List 1.

Right now I've only used validation for checking if the meal\_id (the id for the recipe) already exists in the recipes table, but with this I am only able to add each recipe to one list.

```
$this->validate($request, [
            'name' => 'required',
            'meal_id' => 'required|unique:recipes,meal_id',
            'list_id' => 'required'
        ]);

```

My relations are simply that a Recipe hasOne RecipeList, and a RecipeList hasMany Recipes, but I'm fairly certain changing that up wont be the fix.

Recipe model

```
 class Recipe extends Model

    {
        use HasFactory;

        protected $fillable = [
            'name',
            'meal_id',
            'list_id'
        ];

        public function lists()
        {
            return $this->hasOne(RecipeList::class);
        }
}

```

RecipeList model

```
class RecipeList extends Model
{
    use HasFactory;

    protected $fillable = [
        'name',
        'user_id'
    ];

    public function user() 
    {
        return $this->belongsTo(User::class);
    }

    public function recipes()
    {
        return $this->hasMany(Recipe::class);
    }
}

```

Recipes table

```
  public function up()
    {
        Schema::create('recipes', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('meal_id');
            $table->unsignedBigInteger('list_id');
            $table->timestamps();
        });
    }

```

However maybe I need to set up some form of pivot table?

Does anyone have any ideas on some smart way of achieving what I want through the validation, or any other ideas?