php - How to make routes in group correctly? (CodeIgniter 4)
one text
I have a routes group like this. When i tried to run 'detail_datapegawai' page, it said "404 - File Not FoundController is not found".
this is my routes code:
$routes->group('admin', function ($routes) {
$routes->add('admin', 'Admin\datapegawai::datapegawai');
$routes->add('admin/(:segment)', 'Admin\datapegawai::detail_pegawai/$1');
});
my controller folder is 'Admin' and the file name is 'Datapegawai.php' while the file views name is 'detail_datapegawai.php'
this routes $routes->add('admin', 'Admin\datapegawai::datapegawai');
works perfectly.
while this one $routes->add('admin/(:segment)', 'Admin\datapegawai::detail_pegawai/$1');
have an 404 error as i said before.
controller:
public function detail_pegawai($slug)
{
$data = [
'title' => 'Admin | Detail Pegawai',
'profilpegawai' => $this->profilpegawaiModel->getProfilpegawai($slug)
];
return view('user_admin/detail_datapegawai', $data);
}
button detail to go to 'detail_datapegawai' page:
<a href="/admin/<?= $profil['slug']; ?>" class="btn btn-sm btn-primary">
<i class="fa fa-sm fa-eye" style="color: white;"></i>
</a>
hope you guys can understand what i said, please help if you can. thankyou so much.
Source