Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter 4 - $ sign is not accepted in placeholder
#1

(This post was last modified: 08-31-2021, 11:59 PM by c4nn.)

Hi everyone, I have a problem. I have following in codeigniter 4

PHP Code:
<?php 
namespace App\Controllers\Backend;

use 
App\Controllers\BaseController;
use 
App\Models\PullData;


class 
Datass extends BaseController
{

public  function edit($id)
{



$pullData = new PullData();
$data['pullData'] = $pullData->find($id);
return 
view('backend/edit'$data);
}






PHP Code:
$routes->group('admin', function($routes){
    $routes->match(['get','post'],'login''Backend/AdminAuth::login');
    $routes->match(['get','post'],'signup''Backend/AdminAuth::signup');
    $routes->get('dashboard''Backend/Dashboard::index');
    $routes->get('logout''Backend/AdminAuth::logout');
    $routes->group('dashboard', function($routes){
        $routes->match(['get','post'],'profile''Backend/AdminAuth::profile');
        $routes->match(['get''post'], 'datas''Backend/Datass::index');
        $routes->match(['get''post'], 'createdata''Backend/Datass::create');
        $routes->match(['get''post'], 'save-data''Backend/Datass::savedata');
        $routes->get('edit/(:any)''Backend/Datass::edit/$1');    <----
    
    
});
}); 
Code:
http://localhost/admin/dashboard/edit/1
gives me 404 error. However if I remove $ sign as follow it works
PHP Code:
$routes->get('edit/(:any)''Backend/Datass::edit/$1'); 
But this time it's only showing the values of 1.
Reply
#2

Your missing the route group function closing bracket }.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

Use backslash in class namespace
Backend/Datass:: <- bad
Backend\Datass:: <- good
Reply




Theme © iAndrew 2016 - Forum software by © MyBB