Permalink
Browse files

model - section for read from db

  • Loading branch information...
chemix committed Jun 14, 2014
1 parent 7fed0d0 commit fa96deed64d74de7ff0da782e2eb1d1e4080f9c4
Showing with 37 additions and 4 deletions.
  1. +1 −0 app/config/config.neon
  2. +33 −0 app/model/FacebookWallposts.php
  3. +3 −4 app/presenters/HomepagePresenter.php
View
@@ -25,3 +25,4 @@ services:
- App\Model\UserManager
- App\RouterFactory
router: @App\RouterFactory::createRouter
- App\Model\FacebookWallposts
@@ -0,0 +1,33 @@
<?php
/**
* @author Honza Cerny <hello@honzacerny.com>
*/
namespace App\Model;
use Nette\Database\Context;
use Nette\Object;
class FacebookWallposts extends Object
{
/**
* @var \Nette\Database\Context
*/
protected $database;
function __construct(Context $database)
{
$this->database = $database;
}
public function getLastPosts($count = 5)
{
return $this->database->table('facebook_wallposts')
->where('status', '1')
->order('created_time DESC')
->limit($count)
->fetchAll();
}
}
@@ -13,14 +13,13 @@ class HomepagePresenter extends BasePresenter
{
/**
* @var \Nette\Database\Context @inject
* @var \App\Model\FacebookWallposts @inject
*/
public $database;
public $wallposts;
public function renderDefault()
{
$facebookWallPosts = $this->database->table('facebook_wallposts')->where('status','1')->limit(5)->fetchAll();
$this->template->wallPosts = $facebookWallPosts;
$this->template->wallPosts = $this->wallposts->getLastPosts();
}
}

0 comments on commit fa96dee

Please sign in to comment.