Support the ongoing development of Laravel.io →
Database Eloquent Views
Last updated 2 years ago.
0
Solution

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));
Last updated 2 years ago.
0

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 .= ', ';
                }
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

soyraro soyraro Joined 15 Mar 2014

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.