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... :)
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. :)
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...
Hmm ... Sorry for my english :) I need to bring the latest news viewed by the user (id) :) Thank you :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community