This repository has been archived on 2025-05-12. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
hack13-blog/app/Models/BlogModel.php
2020-08-01 23:52:45 -04:00

30 lines
No EOL
642 B
PHP

<?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->orderBy('id', 'DESC')
->findAll();
}
return $this->asArray()
->where(['slug' => $slug])
->first();
}
public function getBlogs($limit = false, $offset = 0)
{
return $this->orderBy('id', 'DESC')
->findAll($limit, $offset);
}
}