PHP code example of marcogmonteiro / ci-admin-controller

1. Go to this page and download the library: Download marcogmonteiro/ci-admin-controller library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

marcogmonteiro / ci-admin-controller example snippets

 namespace App\Controllers\Admin;

    use App\Models\ArticleModel;

    class Articles extends AdminController
    {

        public function __construct()
        {
            $this->article = model('App\Models\ArticleModel');
            $this->model_class = 'article';
        }

        /**
         * List Articles
         */
        public function index()
        {
            $this->data['articles'] = $this->article->findAll();
        }

        /**
         * Create Article
         */
        public function create()
        {
            return $this->adminCreate($this->request->getPost());
        }

        /**
         * Update a Article
         * @param int $id The article id
         */
        public function update($id)
        {
            return $this->adminUpdate($id, $this->request->getPost());
        }

        /**
         * Delete Article
         * @param int $id The article id
         */
        public function delete($id = null)
        {
            return $this->adminDelete($id);
        }

    }


## Usage

### Manual Instalation

Drag the **AdminController.php** file into your _app/Controllers/Admin/_ folder. This way, you have a distinct difference bettwen your backend and front-end. All your controller inside this folder should extend to adminController and your controllers outside this folder should extend to baseController. This way, only your backend controllers will have access to your CRUD functions.

### Composer install

This way you should run the following command in your terminal.

    composer order to specify where in your layout you'd like to output the view, the rendered view will be stored in a `$yield` variable:

    <h1>Header</h1>

    <div id="page">
         echo $this->renderSection('yield') 
 echo $this->extend($layout); 
 echo $this->section('yield') 
 echo $this->endSection() 
 echo $this->renderSection('yield') 
 echo $this->renderSection('yield')