Hi guys,
I just want to ask you guys if what im doing is a good practice in coding, I'm referencing the $this->request as self::$hit on my basecontroller and using parent::$hit on my homecontroller so that i dont have to use $this->request everytime i get the value of fields in a form.
BaseController.php
class BaseController extends Controller
{
public static $hit;
public function initialize()
{
/* reference the request */
self::$hit = $this->request;
}
}
HomeController.php
class HomeController extends BaseController
{
private static $username, $fname, $lname, $email, $password;
public function initialize()
{
parent::initialize();
}
public function RFvalidationAction($form)
{
switch($form)
{
case ($form->isValid($_POST)):
$count_users = TblUser::find();
self::$fname = parent::$hit->getPost('fname', ['string', 'striptags', 'trim']);
self::$lname = parent::$hit->getPost('lname', ['string', 'striptags', 'trim']);
break;
deafult:
break;
}
}
}