PHP code example of ci4-cms-erp / ext_module_generator
1. Go to this page and download the library: Download ci4-cms-erp/ext_module_generator 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/ */
ci4-cms-erp / ext_module_generator example snippets
namespace Modules\Blog\Controllers;
class Blog extends \Modules\Backend\Controllers\BaseController {
public function index() {
return view('Modules\Blog\Views\list', $this->defData);
}
public function create() {
if ($this->request->is('post')) {
$vdata = [
''=>['label'=>'', 'rules'=>''],
];
$valData = ($vdata);
if ($this->validate($valData) == false) return redirect()->back()->withInput()->with('errors', $this->validator->getErrors());
}
return view('Modules\Blog\Views\create', $this->defData);
}
public function update(int $id) {
if ($this->request->is('post')) {
$vdata = [
''=>['label'=>'', 'rules'=>''],
];
$valData = ($vdata);
if ($this->validate($valData) == false) return redirect()->back()->withInput()->with('errors', $this->validator->getErrors());
}
return view('Modules\Blog\Views\update', $this->defData);
}
public function delete(int $id)
{
$infos=$this->commonModel->selectOne('your_table',['id'=>$id]);
if($this->commonModel->remove('your_table',['id'=>$id]))
return $this->redirect()->back()->with('success',$infos->attr.' deleted.');
return $this->redirect()->back()->with('error','Can not deleted.');
}
}