Blog and Pages are now database driven, woo!

This commit is contained in:
Timothy Rogers 2020-08-01 23:52:45 -04:00
parent 34fe54c20c
commit 1f1cf3b71b
20 changed files with 137 additions and 24 deletions

0
app/Models/.gitkeep Normal file
View file

View file

@ -1,16 +1,19 @@
<?php namespace App\Models;
use CodeIgniter\Model;
use CodeIgniter\Services;
class BlogModel extends Model
{
protected $table = 'blog';
protected $primaryKey = 'id';
public function getBlog($slug = false)
{
if ($slug === false)
{
return $this->findAll();
return $this->orderBy('id', 'DESC')
->findAll();
}
return $this->asArray()
@ -18,4 +21,10 @@ class BlogModel extends Model
->first();
}
public function getBlogs($limit = false, $offset = 0)
{
return $this->orderBy('id', 'DESC')
->findAll($limit, $offset);
}
}

21
app/Models/PagesModel.php Normal file
View file

@ -0,0 +1,21 @@
<?php namespace App\Models;
use CodeIgniter\Model;
class PagesModel extends Model
{
protected $table = 'pages';
public function getPage($slug = false)
{
if ($slug === false)
{
return $this->findAll();
}
return $this->asArray()
->where(['slug' => $slug])
->first();
}
}