rin4ik

issue related with pivot tables

Posted 9 months ago by rin4ik

Hey folks really need your professional help with pivot table in my create view

<div class="form-group">
              <label>Теги</label>
              <select class="form-control select2" multiple="multiple" data-placeholder="Выберите теги" name="tags[]">
                    
                        @if ($tags->count())
                    
                            @foreach($tags as $tag)
                                <option value="{{ $tag->id }}">{{ $tag->title }}</option>    
                            @endforeach
                        @endif
                    
                    </select>
            </div>

I am passing tags array . after in my controller I've added method for adding other fields add method

     
        request()->validate([
            'title' => 'required',
            'content' => 'required',
            'date' => 'required',
            'image' => 'nullable|image'
        ]);
        $post->add($request->all());
        $post->setTags($request->input('tags'));

I am passing request all which has tags fields on board it gives me error I know actual problem error because of I don't have field in my table tags but don't know to solve this issue. how to exclude tags being passed with request->all()?

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.