i have two controllers PrivacypolicyController and OtpController in OtpController one method generateotp is there i want use it in PrivacyPolicyController, i am using trait but i am getting error. this is my code.
class PrivacyPolicyController extends Controller {
use OtpController;
public function getCheck($phno,$app_type)
{
$authentication = authentication::select('pp_version','toc_version')
->where('phone_no',$phno and 'application_type',$app_type);
if ( !$authentication->count() )
{
$this->generateotp($phno,$app_type);
}
}
and my otpController is like this
class OtpController extends Controller {
trait OtpController{
public function generateotp($number,$length)
{
for ($c = 0; $c < $length - 1; $c++)
{
array_push($rand, mt_rand(0, 9));
shuffle($rand);
}
return implode('', $rand);
}
}
and the error is syntax error, unexpected 'trait' (T_TRAIT), expecting function (T_FUNCTION)
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire