Created
January 20, 2020 05:46
-
-
Save cwicaksono/1025d3c22520a687fb0eb2cb6553b5f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
class Welcome extends CI_Controller { | |
function __construct() { | |
parent::__construct(); | |
$this->load->model('blogpost_model'); | |
$this->load->model('categories_model'); | |
} | |
public function index() | |
{ | |
$data = array( | |
'posts' => $this->blogpost_model->getHome(), | |
'categories' => $this->categories_model->getAll() | |
); | |
$this->load->view('blog', $data); | |
} | |
public function view($id) | |
{ | |
$this->db->join('users', 'users.id = blogpost.id_author'); | |
$detail = $this->db->get_where('blogpost', array('blogpost.id' => $id))->result(); | |
$data = array( | |
'detail' => $detail, | |
'categories' => $this->categories_model->getAll() | |
); | |
$this->load->view('detail', $data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment