You can convert the related models into array using toArray() method, try something along these lines:
$post = Post::with('tags')->find($id);
$tags = $post->tags->toArray();
$impTags = implode(',',array_flatten($tags));
Not tested your solution usm4n but thanks anyway.. I did
$imptags = $post->tags->toArray();
$imptags = array_values( $imptags );
$strtags = '';
$count = count( $imptags );
for ( $x = 0 ; $x < $count; ++$x)
{
$strtags .= $imptags[$x]['tag'];
if ( $x < ( $count - 1 )) $strtags .= ', ';
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community