Support the ongoing development of Laravel.io →
Input Session Blade
Last updated 2 years ago.
0

Hi,

Can you perhaps try to describe you problem a little bit more... I mean, from where do you take your news, a MySQL database? In this case, how do your tables look like? Can you also say where do you want to display the news... From which controller?

Otherwise it will be a little bit difficult to help you... :)

0

Thanks :) Uses a database MySQL. The tables are of the form:

$ table-> increments ('id'); $ table-> string ('name'); $ table-> text ('desc); $ table-> timestamps ();

I need output to news page / product. :)

Last updated 9 years ago.
0

Well,

You have a table news that contains the following columns: id, name, desc, updated_at and created_at.

If it isn't already done, create a model that has the same name as your table. For example, if the name of your table is "news" create a file named "News.php" in app/models and put the following code in it:

class News extends Eloquent {

    protected $table = 'news';

}

Then, in your controller, use this code

// Select the latest 10 news
$news = News::select('name', 'desc', 'updated_at')->take(10)->orderBy('updated_at', 'desc')->get();

foreach($news as $item)
{
// Display the news using $item->name ...
}

Hope it helps...

0

Hmm ... Sorry for my english :) I need to bring the latest news viewed by the user (id) :) Thank you :)

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Jacklar1 jacklar1 Joined 19 Dec 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.