Support the ongoing development of Laravel.io →
Eloquent
Last updated 3 weeks ago.
0

I think that I was thinking about it the wrong way.

I think something like this should work in my EloquentFormRepository:


    public function addField($field, $label, $is_required)
    {
        $field = $this->field->where('name', $field)->first();

        return $this->form->fields()->attach($field->id);

        // TODO: Add pivot data $label and $is_required
    }

    public function deleteField($field)
    {
        $field = $this->field->where('name', $field)->first();

        return $this->form->fields()->detach($field->id);
    }

Last updated 3 weeks ago.
0

Sign in to participate in this thread!

Cloudways

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 Laravel.io - All rights reserved.