Salut,
Lucrez la un blog in CodeIgniter. Am adaugat un controller pentru posturi cu metoda “create”.
Problema e ca atunci cand incerc sa intru pe /blog/create primesc eroarea asta:
Controllerul arata asa:
<?php namespace App\Controllers;
use App\Models\BlogModel;
class Blog extends BaseController {
function post($slug) {
echo view('templates/header');
echo view('blog/post');
echo view('templates/footer');
}
function create() {
helper('form');
$model = new BlogModel();
if(! $this->validate([
'title' => 'required | min_length[3] | max_length[255]',
'body' => 'required'
])) {
echo view('templates/header');
echo view('blog/post');
echo view('templates/footer');
} else {
$model->save(
[
'title' => $this->request->getVar('title'),
'body' => $this->request->getVar('body'),
'slug' => url_title($this->request->getVar('title'))
]
);
return redirect()->to('/');
}
}
//--------------------------------------------------------------------
}
Controllerul l-am scris dupa un tutorial in care la el vad ca merge…aveti vreo idee ce ar insemna eroarea respectiva?