Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 18,588
» Latest member: ngochoang
» Forum threads: 71,791
» Forum posts: 368,332

Full Statistics

Latest Threads
Multi search - Create fli...
Forum: General Help
Less than 1 minute ago
» Replies: 1   » Views: 5
how to retrive data from ...
Forum: CodeIgniter 4 Support
22 minutes ago
» Replies: 3   » Views: 24
Transaction in controller...
Forum: CodeIgniter 4 Support
1 hour ago
» Replies: 1   » Views: 11
Undefined index: expires_...
Forum: CodeIgniter 3.x
2 hours ago
» Replies: 0   » Views: 8
Calender in Codeigniter 4
Forum: CodeIgniter 4 Support
3 hours ago
» Replies: 4   » Views: 55
How to continue a Code Ig...
Forum: General Help
4 hours ago
» Replies: 1   » Views: 31
CSRF with fetch API
Forum: CodeIgniter 4 Support
9 hours ago
» Replies: 3   » Views: 118
Simple chat facility - if...
Forum: General Help
10 hours ago
» Replies: 16   » Views: 399
setTranslateURIDashes Not...
Forum: CodeIgniter 4 Support
Yesterday, 11:32 AM
» Replies: 0   » Views: 20
What is the better soluti...
Forum: CodeIgniter 4 Support
Yesterday, 10:21 AM
» Replies: 1   » Views: 110

 
Question Toolbar and performence information
Posted by: Michal_PB1 - 07-05-2020, 12:11 PM - Forum: CodeIgniter 4 Support - Replies (1)

Hi,



Maybe someone knows if there is a way to more accurately check the performance of individual elements/methods? As you can see in the photo below 'Controller' takes about 3.5s, but without more information, it is difficult to check which function is so slow.


[Image: attachment.php?aid=1815]



Attached Files Thumbnail(s)
   

  Live search with ajax
Posted by: mohs3n - 07-05-2020, 04:10 AM - Forum: CodeIgniter 4 Support - Replies (5)

Hi

I've been looking for a tutorial on how to make a live user search with CI4 but I haven't found anything useful on the net.
I am creating a backend with CI4 and on the user management page I have a search input which I want to be a live search with ajax where I can start typing a name and it shows me suggestions.

Has anybody done this with CI4?
I'd appreciate if anybody could share their ideas or some code snippets. Smile


  My template library
Posted by: cvlancvlan - 07-04-2020, 10:47 PM - Forum: CodeIgniter 4 Support - Replies (1)

I'm beginner in codeigniter 4. Recently i created this Template Library for my project. If someone have suggestions please put here.

I inspired from this project: https://github.com/lonnieezell/myth-forums


app/Libraries/TemplateLibrary.php

PHP Code:
<?php namespace App\Libraries;
use 
CodeIgniter\View\View;
use 
Config\Services;

class 
TemplateLibrary {

    private 
$renderer;
    
    private 
$template;
    
    public function 
__construct() {
        
        
$this->template = [];
        
        
/* Theme */
        
        
$this->template['theme'] = 'default';
        
        
/* Headline */
        
        
$this->template['headline'] = '';
        
        
/* Breadcrumb */
        
        
$this->template['breadcrumb'] = '';
        
        
/* Canonical */
        
        
$this->template['canonical'] = '';
        
        
/* Meta */
        
        
$this->template['meta'] = [
            
'title' => '',
            
'description' => '',
            
'keywords' => '',
            
'robots' => 'INDEX, FOLLOW'
        
];
        
        
/* Css files */
        
        
$this->template['css_files'] = [];
        
        
/* Js files */
        
        
$this->template['js_files'] = [];
    
    }
    
    public function 
setTheme(string $theme) {
        
        
$this->template['theme'] = $theme;
        
    }
    
    public function 
setHeadline(string $headline) {
        
        
$this->template['headline'] = $headline;
        
    }
    
    public function 
setBreadcrumb(array $breadcrumb) {
        
        
$this->template['breadcrumb'] = $breadcrumb;
        
    }
    
    public function 
setCanonical(string $canonical) {
        
        
$this->template['canonical'] = $canonical;
        
    }
    
    public function 
setMeta(string $key$value) {
        
        if ( 
array_key_exists($key$this->template['meta']) ) {
            
            
$this->template['meta'][$key] = (string) $value;
            
        }
        
    }
    
    public function 
addCssFile(string $keystring $pathint $priority) {
        
        if ( 
strpos($path'https://') === false ) {
            
            
$path href('themes/' strtolower($this->template['theme']) . '/' $path);
            
        }
        
        
$this->template['css_files'][$key]['path'] = $path;
        
$this->template['css_files'][$key]['priority'] = $priority;
        
        
usort($this->template['css_files'], function($a$b) {
            return 
$a['priority'] - $b['priority'];
        });
        
    }
    
    public function 
addJsFile(string $keystring $pathint $priority) {
    
        if ( 
strpos($path'https://') === false ) {
            
            
$path href('themes/' strtolower($this->template['theme']) . '/' $path);
            
        }
        
        
$this->template['js_files'][$key]['path'] = $path;
        
$this->template['js_files'][$key]['priority'] = $priority;
        
        
usort($this->template['js_files'], function($a$b) {
            return 
$a['priority'] - $b['priority'];
        });
        
    }
    
    public function 
getTemplate() {
        
        return 
$this->template;
        
    }
    
    public function 
getTheme() {
        
        return 
$this->template['theme'];
        
    }
    
    public function 
getHeadline() {
        
        return 
$this->template['headline'];
        
    }
    
    public function 
getBreadcrumb() {
        
        return 
$this->template['breadcrumb'];
        
    }
    
    public function 
getCanonical() {
        
        return 
$this->template['canonical'];
        
    }
    
    public function 
getMeta(string $key) {
        
        if ( 
array_key_exists($key$this->template['meta']) ) {
            
            return 
$this->template['meta'][$key];
            
        } return 
NULL;
        
    }
    
    public function 
getCssFiles() {
        
        return 
$this->template['css_files'];
        
    }
    
    public function 
getJsFiles() {
        
        return 
$this->template['js_files'];
        
        
    }
    
    
/*
    public function renderView(string $name, array $data = [], array $options = []) {
        
        return view('MyApp\Views\\' . ucfirst($this->template['theme']) . '\\' . $name, $data, $options);
        
    }
    
    public function render(string $name, array $data = [], array $options = []) {

        $data['template'] = $this;
        
        return $this->renderView($name, $data, ['saveData' => true]);
        
    }
    */
    
    
private function getRenderer() {
        
        
if ( $this->renderer !== NULL ) {
            
            return $this->renderer;
            
        }

        $path ROOTPATH 'myapp/Views/' ucfirst($this->template['theme']);

        $this->renderer Services::renderer($pathnullfalse);

        return $this->renderer;
        
    }
    
    public function 
renderView(string $name, array $data = [], array $options = []) {
    
        
$renderer $this->getRenderer();

        
$saveData null;
        if (
array_key_exists('saveData'$options)) {
            
$saveData = (bool) $options['saveData'];
            unset(
$options['saveData']);
        }

        return 
$renderer->setData($data'raw')
                        ->
render($name$options$saveData);
                        
    }
    
    public function 
render(string $name, array $data = []) {
        
        $data
['template'] = $this->template;

        return $this->renderView($name$data, ['saveData' => true]);
        
    }
    


  my model does not work as expected
Posted by: Ahmad Ali - 07-04-2020, 09:14 PM - Forum: Model-View-Controller - Replies (1)

Hi, I have a users table in the database the problem is when I want to update a selected row in the table using save or update function it does not update.
I don't know why but I'm sure that the code is fine.
Below is the function that updates the selected row.

PHP Code:
public function edit_profile()
    {
        if ($this->request->getPost()) {
            $email $this->request->getPost('email');
            $username $this->request->getPost('username');
            $model = new UserModel();
            $site_session = new site_session();
            $id session()->get($site_session->userid());

            echo $id ' '$email ' ' $username;
            $model->save([
                'id' => $id,
                'email' => $email,
                'username' => $username
            
]);
        }
        //    return  redirect()->to('profile');
    
My model 
PHP Code:
<?php

namespace App\Models;

use 
CodeIgniter\Model;
use 
site_session;

class 
UserModel extends Model
{

    protected $table      'users';
    protected $primaryKey 'id';

    protected $returnType     'array';
    protected $useSoftDeletes true;

    protected $allowedFields = ['email''username''password'];

    protected $useTimestamps true;
    protected $createdField  'created_at';
    protected $updatedField  'updated_at';
    protected $deletedField  'deleted_at';

    protected $validationRules    = [
        'email' => 'required|valid_email',
        'username' => 'required|min_length[2]|max_length[10]|is_unique[users.username]',
        'password' => 'required|min_length[8]|max_length[20]'
    ];
    protected $validationMessages = [
        'email' => [
            'required' => 'This field is required',
            'valid_email' => 'email is not valid make sure you wrote it right'
        ],
        'username' => [
            'required' => 'This field is required',
            'min_length' => 'the min username is 2',
            'is_unique' => 'this username is takken',
            'max_length' => 'the max username is 10'
        ],
        'password' => [
            'required' => 'This field is required',
            'min_length' => 'the min pasword is 8',
            'max_length' => 'the max pasword is 20'
        ]
    ];
    // protected $skipValidation     = false;

    protected $beforeInsert = ['hashPassword'];
    protected $beforeUpdate = ['hashPassword'];

    protected function hashPassword(array $data)
    {
        if (!isset($data['data']['password']))
         return $data;

        $password $data['data']['password'];
        $data['data']['password'] = password_hash($passwordPASSWORD_DEFAULT);
        
    
        
return $data;
    }

    public function validateUser($data $password){
        if(password_verify($password $data)){
            return true;
        }
        if(password_verify($data $password)){
            return true;
        }
        return false;
    }


Star Show email errors
Posted by: Ceo - 07-04-2020, 03:16 PM - Forum: CodeIgniter 4 Support - Replies (1)

How do I view the particular error when trying to send an email.

The email->send() only returns boolean and thus I cannot catch an exception

Any help?


  Table Custom
Posted by: gra - 07-04-2020, 10:56 AM - Forum: CodeIgniter 4 Support - Replies (4)

I would like to create a dynamic table with the edit and delete buttons.

PHP Code:
        $this->table->setheading(   'Product',
                                    'Description',
                                    'Number',
                                    'Actions'
                                    );

        foreach ($param as $key_TB => $value) {
    
    //second Buttons Delete
            $LAY_BT_Delete '<form action="FormDelete" method="POST">
                                    <input type="text" hidden name="id" value="'
.$value["id"].'">
                                    <button class="btn btn-danger" type="submit">
                                        Delete
                                    </button>
                                    </frorm>'
;
    
    // Close first button Change FormChange
            $LAY_BT_Change ='<button class="btn btn-primary" type="submit" >
                                                Change
                                            </button>
                                            </frorm>'
;
    
    //Data for form change                                        
            $this->table->addRow(   '<form action="FormChange" method="POST">'
                                    .'<input type="text"  class="form-control" maxlength="50" required name="name" value="'.$value["name"].'">'
                                    '<input type="text" class="form-control" maxlength="50" name="description" value="'.$value["description"].'">',
                                    $Number,
                                    $LAY_BT_Change.$LAY_BT_Delete);

        }
        return  $this->table->generate(); 
When he sees the first form open he closes it.
But without understanding the data to be sent.
And it doesn't allow me to generate the second submission form.

what solution can i use?

Thanks


  Filter arguments - howto?
Posted by: tgix - 07-04-2020, 01:31 AM - Forum: CodeIgniter 4 Support - No Replies

Creating my RESTful API and I'd like to use the filter arguments as described in the docs:
http://codeigniter.com/user_guide/incomi...ng-filters

However, the FilterInterface signatures for after() and before() doesn't allow me to access the arguments passed (even though they are passed from \CodeIgniter\Filters::run). As I cannot create my own implementations of after() and before() that includes the argument without breaking \CodeIgniter\Filters\FilterInterface I'm at a loss here.

Realizing that a patch for this would break all code implementing \CodeIgniter\Filters\FilterInterface I don't find that to be a good solution, but still I'm working on a patch.

Or, maybe I am missing something completely?


  Problem with redirect-> to
Posted by: hugoafr - 07-03-2020, 11:20 PM - Forum: CodeIgniter 4 Support - Replies (2)

Hello,
sorry for my English,
I have a strange problem, redirection works fine when I call it from a method, but when I call it from a function it doesn't work.

Example:

PHP Code:
   //Example function to redirect
    public function _redirect_user(){
        return redirect()->to(site_url('proyecto/index'));
    }
    
    
//This does not work, it does not throw an error, it is just as if the process ended.
    public function my_method_a()    
    
{
        $this->_redirect_user();
    }
    
    
//This works fine.
    public function my_method_b()    
    
{
        return redirect()->to(site_url('proyecto/index'));
    


  How to return $data to modal btn form (for Edit function)
Posted by: Maxel - 07-03-2020, 06:45 PM - Forum: General Help - Replies (1)

Hi, i'm new with php and i wonder anybody here can help me with how to return data to a modal button.
when calling the edit button a page, it is quite easy as you just have to load the $data array in the controller that leads the view.
But with the modal button, there is no loading view, then where are loading the $data.

Please need help i'm stuck with my project work


  Started a brand new youtube channel and my first series will be about Codeigniter
Posted by: marcogmonteiro - 07-03-2020, 01:01 PM - Forum: CodeIgniter 4 Discussion - No Replies

Hi guys, so I started this new youtube channel mostly to help out on creating content for our beloved framework. In my opinion the more content we put out there about the framework the more people will use it and help out with it.

Here's the link for my first video. Inputs on how to get better at this would be appreciated.

How to install and setup Codeigniter 4 - https://www.youtube.com/watch?v=tSdbT0GMEqU
Learning Codeigniter 4 folder structure - https://www.youtube.com/watch?v=pCpIuGSGSsk


I'm planing on doing this first series on small episodes until we have a small blog application running with both front-end and backend.



  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.