Welcome Guest, Not a member yet? Register   Sign In
my controller fails to find helper function
#6

PHP Code:
<?php
namespace App\Controllers;
use 
CodeIgniter\Controller;
use 
CodeIgniter\HTTP\CLIRequest;
use 
CodeIgniter\HTTP\IncomingRequest;
use 
CodeIgniter\HTTP\RequestInterface;
use 
CodeIgniter\HTTP\ResponseInterface;
use 
Psr\Log\LoggerInterface;
/**
* Class BaseController
*
* BaseController provides a convenient place for loading components
* and performing functions that are needed by all your controllers.
* Extend this class in any new controllers:
*    class Home extends BaseController
*
* For security be sure to declare any new methods as protected or private.
*/
abstract class BaseController extends Controller
{
    /**
    * Instance of the main Request object.
    *
    * @var CLIRequest|IncomingRequest
    */
    protected $request;
    /**
    * An array of helpers to be loaded automatically upon
    * class instantiation. These helpers will be available
    * to all other controllers that extend BaseController.
    *
    * @var list<string>
    */
    protected $helpers = ['url''form''functions''time''myvalidate''debug'];
    /**
    * Be sure to declare properties for any property fetch you initialized.
    * The creation of dynamic property is deprecated in PHP 8.2.
    */
    protected $session;
protected 
$db;
protected 
$smail;
protected 
$ajax;
protected 
$template;
protected 
$get;
protected 
$make;
protected 
$delete;
    /**
    * @return void
    */
    public function initController(RequestInterface $requestResponseInterface $responseLoggerInterface $logger)
    {
        // Do Not Edit This Line
        parent::initController($request$response$logger);
        // Preload any models, libraries, etc, here.
        $this->session = \Config\Services::session();
$this->db = \Config\Database::connect();
$this->smail = new \App\Libraries\Smail();
$this->ajax = new \App\Libraries\Ajax();
$this->template = new \App\Libraries\Template();
$this->get = new \App\Libraries\Get();
$this->make = new \App\Libraries\Make();
$this->delete = new \App\Libraries\Delete();
    }
}

ls -l ci460/app/Helpers
total 40
-rw-r----- 1 paul www-data  2710 May  7 09:08 debug_helper.php
-rw-r----- 1 paul www-data 20140 May  7 09:37 functions_helper.php
-rw-r----- 1 paul www-data  2363 May  7 09:23 myvalidate_helper.php
-rw-r----- 1 paul www-data  3599 Apr  7 18:53 pagination_helper.php
-rw-r----- 1 paul www-data  1402 Apr  7 18:54 tag_helper.php
-rw-r----- 1 paul www-data  2742 Apr  7 18:54 time_helper.php

<?php

namespace App\Helpers;

// ------------------------------------------------------------------------
if (!function_exists('is_valid_reference')) {
    function is_valid_reference($reference$split ',')
    {
        //Validate reference
        $parts explode($split$reference2);
        $col = @(int) $parts[0];
        $row = @(int) $parts[1];

        return !(
            !is_numeric($col) || strpos($col'.') !== false || $col || $col 1000
        
||
        !is_numeric($row) || strpos($row'.') !== false || $row || $row 1000
        
);
    }
}

// ------------------------------------------------------------------------
if (!function_exists('is_valid_level')) {
    function is_valid_level($input)
    {

        //Validate level
        $separator strpos($input'-') !== false '-' '_';
        list($col$row) = explode($separator$input);

        return !(
            !is_numeric($col) || strpos($col'.') !== false || $col || $col 5
        
||
        !is_numeric($row) || strpos($row'.') !== false || $row || $row 5
        
);
    }
}

// ------------------------------------------------------------------------
if (!function_exists('is_valid_colour')) {
    function is_valid_colour($input)
    {
$input ltrim($input'#');
return 
ctype_xdigit($input);
    }
}

// ------------------------------------------------------------------------
if (!function_exists('valid_twitter_username')) {
    function valid_twitter_username($input)
    {
        return preg_match('/^(\@)?[A-Za-z0-9_]+$/'$input);
    }
}

// ------------------------------------------------------------------------
if (!function_exists('valid_facebook_url')) {
    function valid_facebook_url($input)
    {
        return preg_match('/^(http\:\/\/|https\:\/\/)?(?:www\.)?facebook\.com\/(?:(?:\w\.)*#!\/)?(?:pages\/)?(?:[\w\-\.]*\/)*([\w\-\.]*)/'$input);
    }
}

// ------------------------------------------------------------------------
if (!function_exists('field_class')) {
    function field_class($input)
    {
        //Get Errors
        $errors $this->template->input_errors;

        //If error
        if (isset($errors[$input])) {
            return 'has-error';
        } elseif ($this->request->getPost()) {
            return 'has-success';
        } else {
            return '';
        }
    }

Reply


Messages In This Thread
RE: my controller fails to find helper function - by PaulC - Yesterday, 01:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB