php - Access a column in a database Eloquent Laravel4 -


I should be able to access all the data in one of the columns in my table. My initial approach was to do something like this. I am trying to enter my database, the column is called 'tag'

  // Get all posts $ post = Post :: get (); // Get All Post Tags $ post_tags = $ post ['tags'];  

But this return is empty. I know that there will be an extremely easy way to do this, I am not seeing it!

Edit

The reason for this is that I am doing a tagging system in place when something is posted You can add 3 tags That are related to the post when I'm clicking on a tag, then I can filter all the posts with that set tag.

The way it tags, when a tag is clicked, the user will be redirected, so for this URL

  // test-site.com/ Posts / tags / {tag}  

So Ill can query using that tag Databases for results I have managed to mislead myself into a task which I thought That would be very simple!

If your tags are stored in the same table, the problem may be that you can set the full result Getting:

  Posted: Meetings ();  

When you should only get one line:

  post: first ();  

Then this one can do the trick in this case:

  $ post = Post :: first (); $ Post_tags = $ post- & gt; Tag;  

If you use post: meet () or post: all () , then you have to trough The result is set to receive your information:

  foreach (post: all () as $ post) {echo $ post- & gt; Tag; }  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -