Converted code from CI into FuelPHP