Д

Size: a a a
Д
Д
SS
контроллер
//...
$tags = Tag::all();
$postTags = $post->tags->pluck('id');
return view('...', compact('tags', 'postTags'));
@foreach( $tags as $tag )
<option value="{{ $tag->id }}" @if ($postTags->contains($tag->id)) selected="selected" @endif>
{{ $tag->name }}
</option>
@endforeach
MR
MR
AH
Д
Д
Д
AH
return view('backend.pages.singlePost')
->with(compact('post', 'tags));
AH
$tags = Tag::get();Но не обязательно.
all
- это алиас get
с той разницей что в случае использования условий выборки all
будет нелогичным, но код лучше привести к одному виду, т.е. getД
SS
Д
Д
Д
Д
AH
->with('post', $post)
->with('tags', $tags)
->with([
'post' => $post,
'tags' => $tags
])
->with(compact('post', 'tags'))
->withPost($post)
->withTags($tags)